{
FILE *fp_in = NULL, *fp_ou = NULL;
-
+
char url[MAXLEN];
char report_in[MAXLEN];
char wdirname[MAXLEN];
int i;
ouser[0]='\0';
+ ouser2[0]='\0';
sprintf(report_in,"%s/sarg/download.log",TempDir);
if(access(report_in, R_OK) != 0)
fixip(user);
}
- if(strcmp(Ip2Name,"yes") == 0)
+ if(strcmp(Ip2Name,"yes") == 0)
ip2name(ip,sizeof(ip));
if(!z) {
user[0]='\0';
if(user[0] != '\0')
strcpy(ouser,user);
- if(strcmp(oip,ip) == 0)
+ if(strcmp(oip,ip) == 0)
ip[0]='\0';
if(ip[0] != '\0')
strcpy(oip,ip);
if(DownloadReportLimit) {
if(strcmp(ouser2,name) == 0) {
- count++;
+ count++;
} else {
count=1;
strcpy(ouser2,name);
long long int totelap=0, totelap2=0, nnelap=0, unelap=0, tnelap=0;
long long int incache=0, oucache=0, tnincache=0, tnoucache=0, twork=0, twork2=0;
char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN];
- char nacc[20], nbytes[20], url[1024], tmsg[50], nelap[20], csort[MAXLEN];
+ char nacc[20], nbytes[20], url[MAXLEN], tmsg[50], nelap[20], csort[MAXLEN];
char period[MAXLEN], usuario[MAXLEN], wusuario[MAXLEN], u2[MAXLEN], duser[MAXLEN];
char userbytes[20], userelap[20], userurl[1024], userhora[9], userdia[9];
char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN], incac[20], oucac[20];
const char txtext[]=".txt";
int dlen;
char href2[MAXLEN];
+ char urly[MAXLEN];
+ char siteind[MAXLEN];
if(strstr(ReportType,"users_sites") == 0) return;
strcpy(duser,arqin);
strcat(duser,"denied_");
strcat(arqin,direntp->d_name);
-
+
if((str=(char *) strstr(denied_report, "_")) != (char *) NULL ) {
if((str=(char *) strstr(str+1, "_")) != (char *) NULL )
fixip(denied_report);
fputs("</table></div>\n",fp_ou);
fputs("<div align=\"center\"><table cellpadding=\"2\" cellspacing=\"1\">\n",fp_ou);
- if(strlen(denied_report) > 0) {
+ if(denied_report[0]!='\0') {
fprintf(fp_ou,"<tr><td class=\"header\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a> %s</td></tr>\n",denied_report,text[116],text[55]);
}
debuga("%s: %s",text[61],usuario);
}
- fscanf(fp_in,"%s",nacc);
- fscanf(fp_in,"%s",nbytes);
- fscanf(fp_in,"%s",url);
- fscanf(fp_in,"%s",tmsg);
- fscanf(fp_in,"%s",nelap);
- fscanf(fp_in,"%s",incac);
- fscanf(fp_in,"%s",oucac);
+ while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
+ if (getword(nacc,sizeof(nacc),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken number of access in your %s file.\n",arqin);
+ exit(1);
+ }
+ if (getword(nbytes,sizeof(nbytes),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",arqin);
+ exit(1);
+ }
+ if (getword(url,sizeof(url),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken url in your %s file.\n",arqin);
+ exit(1);
+ }
+ if (getword(tmsg,sizeof(tmsg),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken status in your %s file.\n",arqin);
+ exit(1);
+ }
+ if (getword(nelap,sizeof(nelap),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",arqin);
+ exit(1);
+ }
+ if (getword(incac,sizeof(incac),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken in cache column in your %s file.\n",arqin);
+ exit(1);
+ }
+ if (getword(oucac,sizeof(oucac),buf,' ')<0) {
+ printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",arqin);
+ exit(1);
+ }
- while(!feof(fp_in)) {
if(strncmp(tmsg,"OK",2) != 0)
sprintf(tmsg,"<td class=\"data\">%s</td>",text[46]);
else bzero(tmsg, 50);
perc2=nnelap * 100;
perc2=perc2 / tnelap;
} else perc2=0;
-
+
if(incache) {
inperc=incache * 100;
inperc=inperc / nnbytes;
strcpy(wwork3,fixnum2(nnelap,1));
if(strcmp(LongUrl,"yes") != 0) {
- if (getword(warea,sizeof(warea),url,'/')<0) {
- printf("SARG: Maybe you have a broken record or garbage in the url of the %s file.\n",arqin);
- exit(1);
- }
- sprintf(url,"%s",warea);
+ char *endofhost=strchr(url,'/');
+ if (endofhost) *endofhost='\0';
strcpy(urly,url);
} else {
strcpy(urly,url);
} else {
bzero(href2, MAXLEN);
bzero(ltext110, 50);
- }
+ }
sprintf(val2,"%s",href2);
sprintf(val3,"%3.2f%%",perc);
if(strncmp(tmsg," ",1) == 0)
bzero(hbc9, 30);
-
+
if(UserReportLimit<=0 || count<=UserReportLimit) {
fprintf(fp_ou,"<tr><td class=\"data\">%s</td><td class=\"data2\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td>%s</tr>\n",val2,httplink,wwork1,wwork2,val3,val4,val5,val6,wwork3,val7,tmsg);
count++;
unbytes=0;
unelap=0;
- fscanf(fp_in,"%s",nacc);
- fscanf(fp_in,"%s",nbytes);
- fscanf(fp_in,"%s",url);
- fscanf(fp_in,"%s",tmsg);
- fscanf(fp_in,"%s",nelap);
- fscanf(fp_in,"%s",incac);
- fscanf(fp_in,"%s",oucac);
-// fscanf(fp_in,"%s",datestimes);
-
}
if(iprel)
}
fclose(fp_in);
-
+
if(atoi(PerUserLimit) > 0) {
if(tnbytes > (atoi(PerUserLimit)*1000000)) {
limit_flag=0;
strcpy(wwork3,fixnum2(totelap2,1));
sprintf(val6,"%s",buildtime(totelap2));
- sprintf(val7,"%3.2f%%",perc2);
+ sprintf(val7,"%3.2f%%",perc2);
strcpy(hbc1,"class=\"header2\"");
strcpy(hbc2,"class=\"header2\"");
bzero(wwork3, 255);
bzero(hbc3, 30);
}
- if(strstr(UserReportFields,"USED_TIME") == 0) {
+ if(strstr(UserReportFields,"USED_TIME") == 0) {
bzero(val6, 255);
bzero(hbc4, 30);
}
bzero(val7, 255);
bzero(hbc5, 30);
}
-
+
if(strstr(UserReportFields,"AVERAGE") != 0) {
fprintf(fp_ou,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th></th><th></th><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc6,text[96],hbc1,wwork1,hbc2,wwork2,hbc4,val6,hbc3,wwork3,hbc5,val7);
}
char mask[MAXLEN];
char httplink[MAXLEN];
char html_old[MAXLEN];
-char siteind[MAXLEN];
char site[MAXLEN];
char us[50];
char email[MAXLEN];
void report_day(const char *user);
// report.c
-void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
+void gravatmp(const char *oldaccuser, const char *dirname, const char *oldurl, long long int nacc, long long int nbytes, const char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
void gerarel(void);
// siteuser.c
strcpy(warea,direntp2->d_name);
if(strstr(warea,"-") != 0) {
if (getword_multisep(m1,sizeof(m1),warea,'-')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",val2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",val2);
exit(1);
}
strcpy(m2,warea);
strcpy(warea,direntp3->d_name);
if(strstr(warea,"-") != 0) {
if (getword_multisep(d1,sizeof(d1),warea,'-')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",val2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s directory.\n",val2);
exit(1);
}
strcpy(d2,warea);
obttotal(outdir,direntp->d_name,tbytes,tuser,media);
strcpy(html,data);
if (getword_multisep(mon,sizeof(mon),html,' ')<0) {
- printf("SARG: Maybe you have a broken week day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken week day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
if (getword_multisep(mon,sizeof(mon),html,' ')<0) {
- printf("SARG: Maybe you have a broken month in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken month in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
if (getword_multisep(day,sizeof(day),html,' ')<0) {
- printf("SARG: Maybe you have a broken day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
if (getword_multisep(hour,sizeof(hour),html,' ')<0) {
- printf("SARG: Maybe you have a broken time in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken time in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
if (getword_multisep(year,sizeof(year),html,' ')<0) {
- printf("SARG: Maybe you have a broken year in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken year in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
strcpy(html,hour);
if (getword_multisep(h,sizeof(h),html,':')<0) {
- printf("SARG: Maybe you have a broken hour in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken hour in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
if (getword_multisep(m,sizeof(m),html,':')<0) {
- printf("SARG: Maybe you have a broken minute in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken minute in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
if (getword_multisep(s,sizeof(s),html,0)<0) {
- printf("SARG: Maybe you have a broken second in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ printf("SARG: Maybe you have a broken second in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
exit(1);
}
buildymd(day,mon,year,ftime);
}
write_html_header(fp_ou, ".");
fprintf(fp_ou,"<tr><th %s>%s</th><th %s>%s</th></tr>\n",hbc1,text[130],hbc1,text[132]);
- while(fgets(wwork1,MAXLEN,fp_tmp)!=NULL) {
+ while(fgets(wwork1,sizeof(wwork1),fp_tmp)!=NULL) {
if (getword_multisep(tmp4,sizeof(tmp4),wwork1,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
fprintf(fp_ou,"<tr><td class=\"data2\"><a href=\"%s\">%s</a></td><td class=\"data2\">%s</td></tr>\n",tmp4,tmp4,wwork1);
write_html_header(fp_ou2,"..");
fprintf(fp_ou2,"<tr><th %s>%s/%s</th></tr>\n",hbc1,text[130],text[131]);
while(fgets(wwork1,MAXLEN,fp_tmp2)!=NULL) {
- wwork1[strlen(wwork1)-1]='\0';
+ wwork1[strlen(wwork1)-1]='\0';
strcpy(tmp5,wwork1);
if(strstr(tmp5,"-") != 0) {
if (getword_multisep(warea,sizeof(warea),tmp5,'-')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp3);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp3);
exit(1);
}
name_month(warea,sizeof(warea));
name_month(nmonth,sizeof(nmonth));
}
fprintf(fp_ou2,"<tr><td class=\"data2\"><a href=\"%s\">%s %s</a></td></tr>\n",wwork1,tmp4,nmonth);
-
+
sprintf(val1,"%s%s/%s",outdir,tmp4,wwork1);
sprintf(tmp5,"%s%s/%s/index.unsort",outdir,tmp4,wwork1);
if((fp_ou3=fopen(tmp5,"w"))==NULL) {
fprintf(fp_ou,"<tr><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc1,text[101],hbc1,text[102],hbc1,text[103],hbc1,text[93],hbc1,text[96]);
while(fgets(buf,MAXLEN,fp_tmp2)!=NULL) {
if (getword_multisep(period,sizeof(period),buf,';')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
if (getword_multisep(period,sizeof(period),buf,';')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
if (getword_multisep(data,sizeof(data),buf,';')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
if (getword_multisep(tuser,sizeof(tuser),buf,';')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
if (getword_multisep(tbytes,sizeof(tbytes),buf,';')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
if (getword_multisep(media,sizeof(media),buf,';')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
+ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wdir_tmp2);
exit(1);
}
fprintf(fp_ou,"<tr><td class=\"data2\"><a href='%s/%s'>%s</a></td><td class=\"data2\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",period,ReplaceIndex,period,data,tuser,tbytes,media);
if(fp_tmp2) fclose(fp_tmp2);
unlink(wdir_tmp2);
}
-
+
write_html_trailer(fp_ou);
if(fp_ou) fclose(fp_ou);
}
}
if(strcmp(LongUrl,"no") == 0) {
- if (getword_multisep(w,sizeof(w),url,'/')<0){
- printf("SARG: Maybe you have a broken url in your %s file.\n",arq);
- exit(1);
- }
- strcpy(url,w);
- if(strlen(url) > 512 && strchr(url,'%') != NULL) {
- if (getword_multisep(w,sizeof(w),url,'%')<0){
- printf("SARG: Maybe you have a broken url in your %s file.\n",arq);
- exit(1);
- }
- strcpy(url,w);
+ char *endofhost=strchr(url,'/');
+ if (endofhost)
+ *endofhost='\0';
+ if(strlen(url) > 512 && (endofhost=strchr(url,'%')) != NULL) {
+ *endofhost='\0';
}
}
sort_users_log(tmp, debug);
- if(strlen(DataFile) > 0)
+ if(DataFile[0] != '\0')
data_file(tmp);
else
gerarel();
static void maketmp(const char *user, const char *dirname, int debug, int indexonly);
static void maketmp_hour(const char *user, const char *dirname, int indexonly);
-static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly);
+static void gravatmp_hora(const char *dirname, const char *user, const char *data, const char *hora, const char *elap, const char *accbytes, int indexonly);
static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache);
static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly);
static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache);
char oldaccdia[11], oldacchora[9], oldaccip[MAXLEN], wdir[MAXLEN], per1[MAXLEN];
char wdirname[MAXLEN], oldurl[MAXLEN], oldaccuser[MAXLEN];
char olduser[MAXLEN], oldmsg[50], acccode[MAXLEN/2 - 1], oldaccelap[10], oldacccode[MAXLEN/2 - 1], user[MAXLEN];
- char ipantes[MAXLEN], nameantes[MAXLEN];
+ char ipantes[MAXLEN], nameantes[MAXLEN];
char accsmart[MAXLEN];
char wcrc[MAXLEN/2 -1];
char crc2[MAXLEN/2 -1];
- long long int nbytes=0;
- long long int nelap=0;
+ long long int nbytes=0;
+ long long int nelap=0;
long long int nacc=0;
long long int rtotal=0;
long long int incache=0;
struct dirent *direntp;
const char logext[]=".log";
int dlen;
+ char siteind[MAXLEN];
ipantes[0]='\0';
nameantes[0]='\0';
gperiod(dirname,period);
- if(strlen(UserAgentLog) > 0 && email[0] == '\0') useragent();
+ if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent();
olduser[0]='\0';
strncat(tmp,"/sarg",5);
exit(1);
}
- if(strlen(accsmart) > 0) {
+ if(accsmart[0] != '\0') {
smartfilter++;
strcpy(wdirname,dirname);
grava_SmartFilter(wdirname,accuser,accip,accdia,acchora,accurl,accsmart);
if(!ttopen) {
ind2++;
strcpy(siteind,accurl);
- str=siteind;
- for(z1=0; str[z1]; z1++) {
- if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' ||
- str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$')
- str[z1]='_';
+ for(str=siteind; *str; str++) {
+ if(*str=='?' || *str=='-' || *str=='.' || *str==':' || *str=='/' || *str=='\\' || *str=='*' ||
+ *str=='\'' || *str=='\"' || *str=='$')
+ *str='_';
}
sprintf(arqtt,"%s/%s",dirname,accuser);
if(access(arqtt, R_OK) != 0)
sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
else
- sprintf(httplink,"<font size=%s><a href=http://%s>%s</A>",FontSize,accurl,accurl);
+ sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
sprintf(ltext110,"%s",text[110]);
for(s=ltext110; *s; ++s)
fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text[89],period);
fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text[90],name);
fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s: %s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
- fprintf(fp_tt,"<tr><th class=\"header3\" colspan=2>%s</th></tr>\n",text[32]);
+ fprintf(fp_tt,"<tr><th class=\"header3\" colspan=\"2\">%s</th></tr>\n",text[32]);
fputs("</table></div>\n",fp_tt);
fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
}
-void gravatmp(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache)
+void gravatmp(const char *oldaccuser, const char *dirname, const char *oldurl, long long int nacc, long long int nbytes, const char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache)
{
FILE *fp_ou;
+ char val1[16];
+ char val2[16];
+ char val3[16];
+ char val4[16];
+ char val5[16];
char wdirname[MAXLEN];
if((fp_ou=fopen(wdirname,"a"))==NULL){
fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
exit(1);
- }
+ }
my_lltoa(nacc,val1,15);
my_lltoa(nbytes,val2,15);
}
-static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly)
+static void gravatmp_hora(const char *dirname, const char *user, const char *data, const char *hora, const char *elap, const char *bytes, int indexonly)
{
FILE *fp_ou;
-
char wdirname[MAXLEN];
if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
if((fp_ou=fopen(wdirname,"a"))==NULL){
fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
exit(1);
- }
+ }
fprintf(fp_ou,"%s %s %s %s %s %s\n",ip,url,data,hora,tam,elap);
}
return;
-
+
}
strcat(dirname,"/");
strcat(dirname,"sarg-general");
-
+
if((fp_ou=fopen(dirname,"a"))==NULL){
fprintf(stderr, "SARG: (report) %s: %s\n",text[45],dirname);
exit(1);
int topcount=0;
char *s;
int cstatus;
- char warea[1500];
+ char warea[MAXLEN];
char user2[MAXLEN];
char name[MAXLEN];
char href1[MAXLEN];
//fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,time,date,elap,incac,oucac);
fgets(warea,sizeof(warea),fp_in);
if (getword(user,sizeof(user),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken user in your %s file.\n",wger);
exit(1);
}
while(!feof(fp_in)) {
if (getword(nacc,sizeof(nacc),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger);
exit(1);
}
if (getword(nbytes,sizeof(nbytes),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger);
exit(1);
}
if (getword(url,sizeof(url),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken url in your %s file.\n",wger);
exit(1);
}
if (getword(ip,sizeof(ip),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken user's IP in your %s file.\n",wger);
exit(1);
}
if (getword(time,sizeof(time),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken time in your %s file.\n",wger);
exit(1);
}
if (getword(date,sizeof(date),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken date in your %s file.\n",wger);
exit(1);
}
if (getword(elap,sizeof(elap),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken download duration in your %s file.\n",wger);
exit(1);
}
if (getword(incac,sizeof(incac),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken in cache download in your %s file.\n",wger);
exit(1);
}
if (getword(oucac,sizeof(oucac),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken not in cache download in your %s file.\n",wger);
exit(1);
}
if(strcmp(olduser,user) != 0) {
ttnoucache+=tnoucache;
tnbytes=0;
tnacc=0;
- tnelap=0;
+ tnelap=0;
tnincache=0;
tnoucache=0;
}
sprintf(val8,"%%%s",text[99]);
strcpy(val9,"colspan=2");
bzero(val10, 255);
-
+
strcpy(hbc1,"class=\"header\"");
strcpy(hbc2,"class=\"header\"");
strcpy(hbc3,"class=\"header\"");
bzero(val6, 255);
bzero(hbc6, 30);
}
- if(strstr(TopUserFields,"MILISEC") == 0) {
+ if(strstr(TopUserFields,"MILISEC") == 0) {
bzero(val7, 255);
bzero(hbc7, 30);
}
unlink(val1);
}
-// if(UserTabFile[0] != '\0' && strstr(user2,".") != 0) {
- if(strcmp(user2,"TOTAL") != 0)
+ if(strcmp(user2,"TOTAL") != 0) {
get_usertab_name(user2,name,sizeof(name));
- if((strcmp(Ip2Name,"yes") == 0) &&
- ((str=(char *) strstr(name, ".")) != (char *) NULL) &&
- ((str=(char *) strstr(str+1, ".")) != (char *) NULL))
- ip2name(name,sizeof(name));
+ if((strcmp(Ip2Name,"yes") == 0) &&
+ ((str=(char *) strstr(name, ".")) != (char *) NULL) &&
+ ((str=(char *) strstr(str+1, ".")) != (char *) NULL))
+ ip2name(name,sizeof(name));
+ } else {
+ name[0]='\0';
+ }
twork=my_atoll(nacc);
my_lltoa(twork,nacc,0);
bzero(wwork1, 255);
bzero(hbc3, 30);
}
- if(strstr(TopUserFields,"BYTES") == 0) {
+ if(strstr(TopUserFields,"BYTES") == 0) {
bzero(wwork2, 255);
bzero(hbc4, 30);
}
strcpy(hbc3,"class=\"header2\"");
strcpy(hbc4,"class=\"header2\"");
strcpy(hbc5,"class=\"header2\"");
- strcpy(hbc6,"class=\"header2\"");
+ strcpy(hbc6,"class=\"header2\"");
strcpy(hbc7,"class=\"header2\"");
strcpy(hbc8,"class=\"header2\"");
strcpy(hbc9,"class=\"header2\"");
}
if(ntopuser) {
- if((strstr(ReportType,"date_time") != 0 && strstr(TopUserFields,"AVERAGE") != 0)) fprintf(fp_top3,"<tr><td></td><th></th><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[96],hbc1,wwork1,hbc2,wwork2,hbc3,buildtime(ttnelap/totuser),hbc4,wwork3);
- else if(strstr(TopUserFields,"AVERAGE") != 0) fprintf(fp_top3,"<tr><td></td><th></th><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[96],hbc1,wwork1,hbc2,wwork2,hbc3,buildtime(ttnelap/totuser),hbc4,wwork3);
+ if((strstr(ReportType,"date_time") != 0 && strstr(TopUserFields,"AVERAGE") != 0))
+ fprintf(fp_top3,"<tr><td></td><th></th><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[96],hbc1,wwork1,hbc2,wwork2,hbc3,buildtime(ttnelap/totuser),hbc4,wwork3);
+ else if(strstr(TopUserFields,"AVERAGE") != 0)
+ fprintf(fp_top3,"<tr><td></td><th></th><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr>\n",hbc10,text[96],hbc1,wwork1,hbc2,wwork2,hbc3,buildtime(ttnelap/totuser),hbc4,wwork3);
}
- if(strlen(UserAgentLog) > 0) {
+ if(UserAgentLog[0] != '\0') {
fputs("<tr><td></td></tr>\n",fp_top3);
fputs("<tr><td></td></tr>\n",fp_top3);
fputs("<td align=\"left\" colspan=\"8\"><font size=-1><a href='useragent.html'>Useragent</a> Report</td>\n",fp_top3);
long long int tnbytes=0;
long long int telap=0;
long long int tincache=0, toucache=0;
- char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[2048];
+ char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[MAXLEN];
char ip[MAXLEN], hora[9], data[11], elap[16];
char incac[16], oucac[16];
- char warea[1500];
+ char warea[MAXLEN];
strcpy(wger,dirname);
strcat(wger,"/sarg-general");
exit(1);
}
- //fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
- fgets(warea,sizeof(warea),fp_in);
-
- while(!feof(fp_in))
+ while(fgets(warea,sizeof(warea),fp_in))
{
+ //printf("%s\n",warea);
if (getword(user,sizeof(user),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken user in your %s file.\n",wger);
exit(1);
}
if (getword(nacc,sizeof(nacc),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger);
exit(1);
}
if (getword(nbytes,sizeof(nbytes),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger);
exit(1);
}
if (getword(url,sizeof(url),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken url in your %s file.\n",wger);
exit(1);
}
if (getword(ip,sizeof(ip),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken source IP address in your %s file.\n",wger);
exit(1);
}
if (getword(hora,sizeof(hora),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken time in your %s file.\n",wger);
exit(1);
}
if (getword(data,sizeof(data),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken date in your %s file.\n",wger);
exit(1);
}
if (getword(elap,sizeof(elap),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",wger);
exit(1);
}
if (getword(incac,sizeof(incac),warea,' ')<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken in cache column in your %s file.\n",wger);
exit(1);
}
if (getword(oucac,sizeof(oucac),warea,0)<0) {
- printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",wger);
+ printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",wger);
exit(1);
}
tnacc+=my_atoll(nacc);
telap+=my_atoll(elap);
tincache+=my_atoll(incac);
toucache+=my_atoll(oucac);
-
- //fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
- fgets(warea,sizeof(warea),fp_in);
}
fclose(fp_in);
if(url[x] == '/' || y>=sizeof(w)-1) break;
w[y++]=url[x];
}
+ if (x<0) {
+ w2[0]='\0';
+ return;
+ }
x=0;
for(y=y-1; y>=0; y--) {
w2[x++]=w[y];
}
- w2[x]=0;
+ w2[x]='\0';
}