#include "include/conf.h"
#include "include/defs.h"
-void convlog(const char *arq, char *df, int dfrom, int duntil)
+void convlog(const char *arq, char df, int dfrom, int duntil)
{
FILE *fp_in;
char *buf;
continue;
}
- if(df[0]=='e')
+ if (df=='e')
strftime(dia, sizeof(dia), "%d/%m/%Y", t);
- else
+ else if (df=='u')
strftime(dia, sizeof(dia), "%m/%d/%Y", t);
+ else //if (df=='w')
+ strftime(dia, sizeof(dia), "%Y.%U", t);
printf("%s %02d:%02d:%02d %s\n",dia,t->tm_hour,t->tm_min,t->tm_sec,gwarea.current);
}
strcpy(user,ip);
bzero(date, 15);
- if(strncmp(df,"u",1) != 0) {
+ if (df!='u') {
strncpy(date,date2+6,2);
strcat(date,"/");
strncat(date,date2+4,2);
debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
exit(EXIT_FAILURE);
}
- strncpy(DateFormat,gwarea.current,1);
- fixnone(DateFormat);
+ DateFormat=gwarea.current[0];
return;
}
t = time(NULL);
local = localtime(&t);
- if(DateFormat[0]=='u')
+ if (df=='u')
strftime(ftime, sizeof(ftime), "%b/%d/%Y %H:%M", local);
- if(DateFormat[0]=='e')
+ if (df=='e')
strftime(ftime, sizeof(ftime), "%d/%b/%Y-%H:%M", local);
x=ImgXSize*5/12;
char arqtt[MAXLEN];
char html[MAXLEN];
char ConfigFile[MAXLEN];
-char df[20];
+char df;
int LastLog;
bool RemoveTempFiles;
char ReplaceIndex[256];
char module[255];
char ExcludeHosts[255];
char ExcludeUsers[255];
-char DateFormat[2];
+char DateFormat;
char PerUserLimitFile[255];
int PerUserLimit;
bool UserIp;
void ccharset(char *CharSet);
// convlog.c
-void convlog(const char *arq, char *df, int dfrom, int duntil);
+void convlog(const char* arq, char df, int dfrom, int duntil);
// css.c
void css_content(FILE *fp_css);
void sort_labels(const char **label,const char **order);
// splitlog.c
-void splitlog(const char *arq, const char *df, int dfrom, int duntil, int convert, const char *splitprefix);
+void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, const char *splitprefix);
// topsites.c
void topsites(void);
void getperiod_fromrange(struct periodstruct *period,int dfrom,int duntil);
int getperiod_buildtext(struct periodstruct *period);
void removetmp(const char *outdir);
-void zdate(char *ftime,int ftimesize, const char *DateFormat);
+void zdate(char *ftime,int ftimesize, char DateFormat);
char *get_param_value(const char *param,char *line);
int compar( const void *, const void * );
void unlinkdir(const char *dir,bool contentonly);
debuga(_("not enough memory to sort the index\n"));
exit(EXIT_FAILURE);
}
- if(strcmp(df,"u") == 0) {
+ if (df=='u') {
item->year=atoi(direntp->d_name);
item->month=conv_month(direntp->d_name+4);
item->day=atoi(direntp->d_name+7);
d1=0;
d2=0;
i=0;
- if(strcmp(df,"u") == 0) {
+ if (df=='u') {
for (j=0 ; entry[i] && isdigit(entry[i]) ; j++)
y1=y1*10+(entry[i++]-'0');
if (j!=4) return;
for (j=0 ; entry[i] && isdigit(entry[i]) ; j++)
d2=d2*10+(entry[i++]-'0');
if (j!=2) return;
- } else if(strcmp(df,"e") == 0) {
+ } else if (df=='e') {
for (j=0 ; entry[i] && isdigit(entry[i]) ; j++)
d1=d1*10+(entry[i++]-'0');
if (j!=2) return;
continue;
}
- if(strcmp(df,"u") == 0) sprintf(newdir,"%s%04d%s%02d-%04d%s%02d",outdir,y1,sm1,d1,y1,sm2,d2);
- else if(strcmp(df,"e") == 0) sprintf(newdir,"%s%02d%s%04d-%02d%s%04d",outdir,d1,sm1,y1,d2,sm2,y1);
+ if (df=='u') sprintf(newdir,"%s%04d%s%02d-%04d%s%02d",outdir,y1,sm1,d1,y1,sm2,d2);
+ else if (df=='e') sprintf(newdir,"%s%02d%s%04d-%02d%s%04d",outdir,d1,sm1,y1,d2,sm2,y1);
else continue;
sprintf(olddir,"%s%04d/%s/%s",outdir,y1,direntp2->d_name,direntp3->d_name);
if(rename(olddir,newdir)) {
strcpy(OutputDir,"/var/www/html/squid-reports");
AnonymousOutputFiles=false;
Ip2Name=false;
- strcpy(DateFormat,"u");
+ DateFormat='u';
OverwriteReport=false;
RemoveTempFiles=true;
strcpy(ReplaceIndex,"index.html");
tmp[0]='\0';
us[0]='\0';
ReadFilter.DateRange[0]='\0';
- df[0]='\0';
+ df='\0';
uagent[0]='\0';
hexclude[0]='\0';
addr[0]='\0';
safe_strcpy(ConfigFile,optarg,sizeof(ConfigFile));
break;
case 'g':
- safe_strcpy(df,optarg,sizeof(df));
+ df=*optarg;
break;
case 'h':
usage(argv[0]);
if(DataFile[0] != '\0')
dataonly++;
- if(df[0] == '\0') strcpy(df,DateFormat);
- else strcpy(DateFormat,df);
-
- if(df[0] == '\0') {
- strcpy(df,"u");
- strcpy(DateFormat,"u");
- }
- if (df[0]=='w')
+ if (df=='\0') df=DateFormat;
+ if (df=='\0') df='u';
+ if (df=='w')
IndexTree=INDEX_TREE_FILE;
if(NAccessLog == 0) {
debuga(_(" Date from-until (-d) = %s\n"),ReadFilter.DateRange);
debuga(_(" Email address to send reports (-e) = %s\n"),email);
debuga(_(" Config file (-f) = %s\n"),ConfigFile);
- if(strcmp(df,"e") == 0)
+ if (df=='e')
debuga(_(" Date format (-g) = Europe (dd/mm/yyyy)\n"));
- if(strcmp(df,"u") == 0)
+ else if (df=='u')
debuga(_(" Date format (-g) = USA (mm/dd/yyyy)\n"));
- if(strcmp(df,"w") == 0)
+ else if (df=='w')
debuga(_(" Date format (-g) = Sites & Users (yyyy/ww)\n"));
debuga(_(" IP report (-i) = %s\n"),(iprel) ? _("Yes") : _("No"));
debuga(_(" Keep temporary files (-k) = %s\n"),(KeepTempLog) ? _("Yes") : _("No"));
printf(_(" Date from-until (-d) = %s\n"),ReadFilter.DateRange);
printf(_(" Email address to send reports (-e) = %s\n"),email);
printf(_(" Config file (-f) = %s\n"),ConfigFile);
- if(strcmp(df,"e") == 0)
+ if (df=='e')
printf(_(" Date format (-g) = Europe (dd/mm/yyyy)\n"));
- if(strcmp(df,"u") == 0)
+ else if (df=='u')
printf(_(" Date format (-g) = USA (mm/dd/yyyy)\n"));
- if(strcmp(df,"w") == 0)
+ else if (df=='w')
printf(_(" Date format (-g) = Sites & Users (yyyy/ww)\n"));
printf(_(" IP report (-i) = %s\n"),(iprel) ? _("Yes") : _("No"));
printf(_(" Keep temporary files (-k) = %s\n"),(KeepTempLog) ? _("Yes") : _("No"));
id_is_ip=true;
} else {
id_is_ip=false;
- if(strcmp(log_entry.User,"-") == 0 || strcmp(log_entry.User," ") == 0 || strcmp(log_entry.User,"") == 0) {
+ if ((log_entry.User[0]=='\0') || (log_entry.User[1]=='\0' && (log_entry.User[0]=='-' || log_entry.User[0]==' '))) {
if(RecordsWithoutUser == RECORDWITHOUTUSER_IP) {
log_entry.User=log_entry.Ip;
id_is_ip=true;
tt=(time_t)dat;
t=localtime(&tt);
- if(DateFormat[0]=='u')
+ if (df=='u')
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M", t);
- else if(DateFormat[0]=='e')
+ else if (df=='e')
strftime(tbuf, sizeof(tbuf), "%d-%m-%Y %H:%M", t);
printf("<tr><td class=\"data\">%s</td><td class=\"data3\">%s</td><td class=\"data3\">%s</td><td class=\"data3\">%s</td><td class=\"data2\"><a href=\"http://%s\">%s</td></tr>\n",tbuf,ip,name,typ,url,url);
id_is_ip=true;
} else {
id_is_ip=false;
- if(strcmp(user,"-") == 0 || strcmp(user," ") == 0 || strcmp(user,"") == 0) {
+ if (user[0]=='\0' || (user[1]=='\0' && (user[0]=='-' || user[0]==' '))) {
if(RecordsWithoutUser == RECORDWITHOUTUSER_IP) {
strcpy(user,ip);
id_is_ip=true;
fuser=0;
fputs("</table>\n",fp_user);
if(ShowSargInfo) {
- zdate(ftime, sizeof(ftime), DateFormat);
+ zdate(ftime, sizeof(ftime), df);
fprintf(fp_user,"<br><br><div align=\"center\"><font size=\"-2\">%s <a href=\"%s\">%s-%s</a> %s %s</font></div>\n",_("Generated by"),URL,PGM,VERSION,_("on"),ftime);
}
fputs("</body>\n</html>\n",fp_user);
fputs("</table>\n",fp_ou);
if(ShowSargInfo) {
- zdate(ftime, sizeof(ftime), DateFormat);
+ zdate(ftime, sizeof(ftime), df);
fprintf(fp_ou,"<br><br><div align=\"center\"><font size=\"-2\">%s <a href=\"%s\">%s-%s</a> %s %s</font></div>\n",_("Generated by"),URL,PGM,VERSION,_("on"),ftime);
}
if(fp_user) {
fputs("</table>\n",fp_user);
if(ShowSargInfo) {
- zdate(ftime, sizeof(ftime), DateFormat);
+ zdate(ftime, sizeof(ftime), df);
fprintf(fp_user,"<br><br><div align=\"center\"><font size=\"-2\">%s <a href=\"%s\">%s-%s</a> %s %s</font></div>\n",_("Generated by"),URL,PGM,VERSION,_("on"),ftime);
}
fputs("</body>\n</html>\n",fp_user);
\param splitprefix If not empty, the output file is written in separate files (one for each day) and
the files are named after the day they contain prefixed with the string contained in this variable.
*/
-void splitlog(const char *arq, const char *df, int dfrom, int duntil, int convert, const char *splitprefix)
+void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, const char *splitprefix)
{
FILE *fp_in;
FILE *fp_ou=NULL;
if(!convert) {
fprintf(fp_ou,"%s %s\n",data,gwarea.current);
} else {
- if(df[0]=='e')
+ if (df=='e')
strftime(dia, sizeof(dia), "%d/%m/%Y", t);
else
strftime(dia, sizeof(dia), "%m/%d/%Y", t);
int range;
char text1[40], text2[40];
- if(df[0]=='u') {
+ if (df=='u') {
i=strftime(text1, sizeof(text1), "%Y %b %d", &period->start);
- }else if(df[0]=='e') {
+ } else if(df=='e') {
i=strftime(text1, sizeof(text1), "%d %b %Y", &period->start);
- } else /*if(df[0]=='w')*/ {
+ } else /*if (df=='w')*/ {
IndexTree=INDEX_TREE_FILE;
i=strftime(text1, sizeof(text1), "%Y.%U", &period->start);
}
period->start.tm_mon!=period->end.tm_mon ||
period->start.tm_mday!=period->end.tm_mday);
if (range) {
- if(df[0]=='u') {
+ if (df=='u') {
i=strftime(text2, sizeof(text2)-i, "%Y %b %d", &period->end);
- } else if(df[0]=='e') {
+ } else if (df=='e') {
i=strftime(text2, sizeof(text2)-i, "%d %b %Y", &period->end);
} else {
i=strftime(text2, sizeof(text2)-i, "%Y.%U", &period->end);
wlen+=sprintf(wdir+wlen,"/%02d",d1);
if(d1!=d2) wlen+=sprintf(wdir+wlen,"-%02d",d2);
} else {
- if(df[0] == 'u') {
+ if (df == 'u') {
wlen=snprintf(wdir+wlen,sizeof(wdir)-wlen,"%04d%s%02d-%04d%s%02d",y1,
conv_month_name(m1),d1,y2,conv_month_name(m2),d2);
- } else if(df[0] == 'e') {
+ } else if (df == 'e') {
wlen=snprintf(wdir+wlen,sizeof(wdir)-wlen,"%02d%s%04d-%02d%s%04d",d1,
conv_month_name(m1),y1,d2,conv_month_name(m2),y2);
- } else if(df[0] == 'w') {
+ } else if (df == 'w') {
wlen2=strftime(wdir+wlen, sizeof(wdir)-wlen, "%Y.%U", &per1->start);
if (wlen2==0) return(-1);
wlen+=wlen2;
return;
}
-void zdate(char *ftime,int ftimesize, const char *DateFormat)
+void zdate(char *ftime,int ftimesize, char DateFormat)
{
time_t t;
struct tm *local;
t = time(NULL);
local = localtime(&t);
- if(strcmp(DateFormat,"u") == 0)
+ if (DateFormat=='u')
strftime(ftime, ftimesize, "%b/%d/%Y %H:%M", local);
- if(strcmp(DateFormat,"e") == 0)
+ else if (DateFormat=='e')
strftime(ftime, ftimesize, "%d/%b/%Y-%H:%M", local);
- if(strcmp(DateFormat,"w") == 0)
+ else if (DateFormat=='w')
strftime(ftime, ftimesize, "%W-%H-%M", local);
return;
}
char ftime[127];
if(!ShowSargInfo) return;
- zdate(ftime, sizeof(ftime), DateFormat);
+ zdate(ftime, sizeof(ftime), df);
fprintf(fp_ou,"<div class=\"info\">%s <a href='%s'>%s-%s</a> %s %s</div>\n",_("Generated by"),URL,PGM,VERSION,_("on"),ftime);
}