2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 #include "include/conf.h"
28 #include "include/defs.h"
30 static FILE *fp_tt
=NULL
;
32 static void maketmp(const char *user
, const char *dirname
, int debug
, int indexonly
);
33 static void maketmp_hour(const char *user
, const char *dirname
, int indexonly
);
34 static void gravatmp_hora(const char *dirname
, const struct userinfostruct
*uinfo
, const char *data
, const char *hora
, long long int elap
, long long int accbytes
, int indexonly
);
35 static void gravatmpf(const struct userinfostruct
*uinfo
, 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
);
36 static void gravaporuser(const struct userinfostruct
*uinfo
, const char *dirname
, const char *url
, const char *ip
, const char *data
, const char *hora
, long long int tam
, long long int elap
, int indexonly
);
37 static void gravager(FILE *fp_gen
, const struct userinfostruct
*uinfo
, long long int nacc
, const char *url
, long long int nbytes
, const char *ip
, const char *hora
, const char *dia
, long long int nelap
, long long int incache
, long long int oucache
);
38 static void grava_SmartFilter(const char *dirname
, const char *user
, const char *ip
, const char *data
, const char *hora
, const char *url
, const char *smart
);
47 char accdia
[11], acchora
[9], accip
[MAXLEN
], *accurl
;
48 char oldaccdia
[11], oldacchora
[9], oldaccip
[MAXLEN
];
49 char wdirname
[MAXLEN
];
51 char oldmsg
[50], acccode
[MAXLEN
/2 - 1], oldacccode
[MAXLEN
/2 - 1], user
[MAX_USER_LEN
];
52 char ipantes
[MAXLEN
], nameantes
[MAXLEN
];
53 char accsmart
[MAXLEN
];
54 char crc2
[MAXLEN
/2 -1];
55 char siteind
[MAX_TRUNCATED_URL
];
58 char oldaccdiatt
[11],oldacchoratt
[9];
61 char u2
[MAX_USER_LEN
];
62 long long int nbytes
=0;
63 long long int nelap
=0;
65 long long int rtotal
=0;
66 long long int incache
=0;
67 long long int oucache
=0;
68 long long int accbytes
, accelap
;
71 struct dirent
*direntp
;
72 const char logext
[]=".log";
79 struct getwordstruct gwarea
;
81 struct userinfostruct
*uinfo
,*puinfo
;
86 if (vrfydir(&period
, addr
, site
, us
, email
)<0) {
87 debuga(_("Cannot create the output directory name containing the period as part of the name\n"));
92 debugaz("outdirname",outdirname
);
95 if(UserAgentLog
[0] != '\0' && email
[0] == '\0') useragent();
97 snprintf(wdirname
,sizeof(wdirname
),"%s/sarg-general",outdirname
);
98 if((fp_gen
=MY_FOPEN(wdirname
,"w"))==NULL
){
99 debuga(_("(report) Cannot open file %s\n"),wdirname
);
104 strncat(tmp
,"/sarg",5);
107 if ((dirp
= opendir(tmp
)) == NULL
) {
108 debuga(_("Failed to open directory %s - %s\n"),tmp
,strerror(errno
));
111 while ((direntp
= readdir( dirp
)) != NULL
) {
112 dlen
=strlen(direntp
->d_name
)-(sizeof(logext
)-1);
113 if (dlen
<0) continue;
114 if((strcmp(direntp
->d_name
+dlen
,logext
) != 0) ||
115 (strncmp(direntp
->d_name
,"download.log",12) == 0) ||
116 (strncmp(direntp
->d_name
,"denied.log",10) == 0) ||
117 (strncmp(direntp
->d_name
,"authfail.log.unsort",19) == 0))
119 if (snprintf(tmp3
,sizeof(tmp3
),"%s/%s",tmp
,direntp
->d_name
)>=sizeof(tmp3
)) {
120 debuga(_("(report) directory entry too long: %s/%s\n"),tmp
,direntp
->d_name
);
123 if((fp_in
=MY_FOPEN(tmp3
,"r"))==NULL
){
124 debuga(_("(report) Cannot open file %s\n"),tmp
);
129 if (dlen
>=sizeof(user
)) continue;
130 strncpy(user
,direntp
->d_name
,dlen
);
136 uinfo
=userinfo_find_from_file(user
);
138 debuga(_("Ignoring unknown user file %s\n"),user
);
141 strcpy(u2
,uinfo
->id
);
142 if(Ip2Name
&& uinfo
->id_is_ip
) {
144 ip2name(u2
,sizeof(u2
));
145 strcpy(nameantes
,u2
);
147 user_find(uinfo
->label
,MAX_USER_LEN
, u2
);
149 maketmp(user
,tmp
,debug
,indexonly
);
150 maketmp_hour(user
,tmp
,indexonly
);
155 memset(oldaccdiatt
,0,sizeof(oldaccdiatt
));
156 memset(oldacchoratt
,0,sizeof(oldacchoratt
));
159 if ((line
=longline_create())==NULL
) {
160 debuga(_("Not enough memory to read the downloaded files\n"));
164 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
165 getword_start(&gwarea
,buf
);
166 if (getword(accdia
,sizeof(accdia
),&gwarea
,'\t')<0 || getword(acchora
,sizeof(acchora
),&gwarea
,'\t')<0 ||
167 getword(accip
,sizeof(accip
),&gwarea
,'\t')<0 ||
168 getword_ptr(buf
,&accurl
,&gwarea
,'\t')<0 || getword_atoll(&accbytes
,&gwarea
,'\t')<0 ||
169 getword(acccode
,sizeof(acccode
),&gwarea
,'\t')<0) {
170 debuga(_("There is a broken record or garbage in file %s\n"),tmp3
);
173 if(strncmp(acccode
,"TCP_DENIED/407",14) == 0) continue;
174 if (getword_atoll(&accelap
,&gwarea
,'\t')<0) {
175 debuga(_("There is a broken elapsed time in file %s\n"),tmp3
);
178 if (getword_skip(20000,&gwarea
,'"')<0 || getword(accsmart
,sizeof(accsmart
),&gwarea
,'"')<0) {
179 debuga(_("There is a broken smart info in file %s\n"),tmp3
);
183 if(accsmart
[0] != '\0') {
185 grava_SmartFilter(outdirname
,uinfo
->id
,accip
,accdia
,acchora
,accurl
,accsmart
);
189 if(strcmp(accip
,ipantes
) != 0) {
190 strcpy(ipantes
,accip
);
191 ip2name(accip
,sizeof(accip
));
192 strcpy(nameantes
,accip
);
193 } else strcpy(accip
,nameantes
);
196 gravatmp_hora(outdirname
,uinfo
,accdia
,acchora
,accelap
,accbytes
,indexonly
);
199 gravaporuser(uinfo
,outdirname
,accurl
,accip
,accdia
,acchora
,accbytes
,accelap
,indexonly
);
203 url_len
=strlen(accurl
);
204 if (!oldurl
|| url_len
>=ourl_size
) {
206 oldurl
=realloc(oldurl
,ourl_size
);
208 debuga(_("Not enough memory to store the url\n"));
212 strcpy(oldurl
,accurl
);
213 strcpy(oldacccode
,acccode
);
215 strcpy(oldaccip
,accip
);
216 strcpy(oldaccdia
,accdia
);
217 strcpy(oldacchora
,acchora
);
221 same_url
=(strcmp(oldurl
,accurl
) == 0);
223 if(site
[0] != '\0') {
225 if(strstr(oldacccode
,"DENIED") != 0)
226 strcpy(oldmsg
,"DENIED");
229 gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
230 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
238 if(!same_url
|| new_user
){
239 if(strstr(oldacccode
,"DENIED") != 0)
240 strcpy(oldmsg
,"DENIED");
243 gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
244 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
256 if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0 &&
257 (!oldurltt
|| strcmp(oldurltt
,accurl
) || strcmp(oldaccdiatt
,accdia
) || strcmp(oldacchoratt
,acchora
))) {
260 snprintf(arqtt
,sizeof(arqtt
),"%s/%s",outdirname
,uinfo
->filename
);
261 if(access(arqtt
, R_OK
) != 0)
263 url_to_file(accurl
,siteind
,sizeof(siteind
));
264 snprintf(arqtt
,sizeof(arqtt
),"%s/%s/tt%s-%s.html",outdirname
,uinfo
->filename
,uinfo
->filename
,siteind
);
265 if ((fp_tt
= fopen(arqtt
, "w")) == 0) {
266 debuga(_("(report) Cannot open file %s\n"),arqtt
);
273 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
274 FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
276 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
279 write_html_header(fp_tt
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("Site access report"));
280 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
281 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
282 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s, %s</td></tr>\n",_("Sort"),UserSortField
,UserSortOrder
);
283 fprintf(fp_tt
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
284 close_html_header(fp_tt
);
286 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt
);
287 strncpy(tmp4
,_("DATE/TIME"),4);
289 fprintf(fp_tt
,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("ACCESSED SITE"),tmp4
,_("DATE/TIME")+5);
292 fputs("<tr><td class=\"data\">",fp_tt
);
293 output_html_string(fp_tt
,accurl
,100);
294 fprintf(fp_tt
,"</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia
,acchora
);
296 url_len
=strlen(accurl
);
297 if (!oldurltt
|| url_len
>=ourltt_size
) {
298 ourltt_size
=url_len
+1;
299 oldurltt
=realloc(oldurltt
,ourltt_size
);
301 debuga(_("Not enough memory to store the url\n"));
305 strcpy(oldurltt
,accurl
);
306 strcpy(oldaccdiatt
,accdia
);
307 strcpy(oldacchoratt
,acchora
);
310 strcpy(crc2
,acccode
);
311 str
=strchr(crc2
,'/');
313 if(strstr(crc2
,"MISS") != 0)
315 else incache
+=accbytes
;
319 day_totalize(tmp
,puinfo
,indexonly
);
323 strcpy(oldacccode
,acccode
);
324 strcpy(oldaccip
,accip
);
326 url_len
=strlen(accurl
);
327 if (url_len
>=ourl_size
) {
329 oldurl
=realloc(oldurl
,ourl_size
);
331 debuga(_("Not enough memory to store the url\n"));
335 strcpy(oldurl
,accurl
);
337 strcpy(oldaccdia
,accdia
);
338 strcpy(oldacchora
,acchora
);
342 longline_destroy(&line
);
343 if (oldurltt
) free(oldurltt
);
349 if(strstr(oldacccode
,"DENIED") != 0)
350 strcpy(oldmsg
,"DENIED");
353 gravatmpf(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
354 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
358 if (puinfo
) day_totalize(tmp
,puinfo
,indexonly
);
362 totalger(outdirname
, debug
, outdir
);
364 if(email
[0] == '\0') {
365 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0) download_report();
367 if(DansGuardianConf
[0] != '\0') {
375 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0) topsites();
377 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0) siteuser();
382 if(smartfilter
) smartfilter_report();
384 if(DansGuardianConf
[0] != '\0') dansguardian_report();
388 if((ReportType
& REPORT_TYPE_USERS_SITES
) != 0) htmlrel();
392 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
394 geramail(outdirname
, debug
, outdir
, email
, TempDir
);
396 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
397 debuga(_("Successful report generated and sent to %s\n"),email
);
401 index_only(outdirname
, debug
);
404 removetmp(outdirname
);
408 static void maketmp(const char *user
, const char *dirname
, int debug
, int indexonly
)
413 char wdirname
[MAXLEN
];
415 if(indexonly
) return;
416 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
418 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
419 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
420 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,user
);
424 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
425 debuga(_("(report) Cannot open file %s\n"),wdirname
);
434 static void maketmp_hour(const char *user
, const char *dirname
, int indexonly
)
439 char wdirname
[MAXLEN
];
441 if(indexonly
) return;
442 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
443 if(datetimeby
==0) return;
445 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,user
)>=sizeof(wdirname
)) {
446 debuga(_("Temporary file name too long: %s/%s.htmp\n"),tmp
,user
);
450 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
451 debuga(_("(report-1) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
460 void gravatmp(const struct userinfostruct
*uinfo
, 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
)
463 char wdirname
[MAXLEN
];
465 if(indexonly
) return;
466 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
468 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
469 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,uinfo
->filename
);
473 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
474 debuga(_("(report) Cannot open file %s\n"),wdirname
);
479 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
480 to print a long long int unless it is exactly 64-bits long.
482 fprintf(fp_ou
,"%"PRIu64
"\t%"PRIu64
"\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\n",(uint64_t)nacc
,(uint64_t)nbytes
,oldurl
,oldmsg
,(uint64_t)nelap
,(uint64_t)incache
,(uint64_t)oucache
);
488 fputs("</table>\n</div>\n",fp_tt
);
489 fputs("</body>\n</html>\n",fp_tt
);
497 static void gravatmpf(const struct userinfostruct
*uinfo
,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
)
500 char wdirname
[MAXLEN
];
502 if(indexonly
|| (ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
504 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
505 debuga(_("Path too long %s/%s.utmp\n"),tmp
,uinfo
->filename
);
509 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
510 debuga(_("(report) Cannot open file %s\n"),wdirname
);
515 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
516 to print a long long int unless it is exactly 64-bits long.
518 fprintf(fp_ou
,"%"PRIu64
"\t%"PRIu64
"\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\n",(uint64_t)nacc
,(uint64_t)nbytes
,oldurl
,oldmsg
,(uint64_t)nelap
,(uint64_t)incache
,(uint64_t)oucache
);
520 if (fclose(fp_ou
)==EOF
) {
521 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
527 fputs("</table>\n",fp_tt
);
528 fputs("</body>\n</html>\n",fp_tt
);
537 static void gravatmp_hora(const char *dirname
, const struct userinfostruct
*uinfo
, const char *data
, const char *hora
, long long int elap
, long long int bytes
, int indexonly
)
541 char wdirname
[MAXLEN
];
544 if(indexonly
|| ((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) || datetimeby
==0) return;
546 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
547 debuga(_("Path too long %s/%s.htmp\n"),tmp
,uinfo
->filename
);
551 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
552 debuga(_("(report-2) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
557 fprintf(fp_ou
,"%s\t%d",data
,hour
);
558 if((datetimeby
& DATETIME_BYTE
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)bytes
);
559 if((datetimeby
& DATETIME_ELAP
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)elap
);
562 if (fclose(fp_ou
)==EOF
) {
563 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
571 static void gravaporuser(const struct userinfostruct
*uinfo
, const char *dirname
, const char *url
, const char *ip
, const char *data
, const char *hora
, long long int tam
, long long int elap
, int indexonly
)
575 char wdirname
[MAXLEN
];
577 if(indexonly
|| ((ReportType
& REPORT_TYPE_USERS_SITES
) == 0)) return;
579 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
580 debuga(_("Path too long %s/%s.ip\n"),tmp
,uinfo
->filename
);
584 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
585 debuga(_("(report) Cannot open file %s\n"),wdirname
);
590 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
591 to print a long long int unless it is exactly 64-bits long.
593 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\n",ip
,url
,data
,hora
,(uint64_t)tam
,(uint64_t)elap
);
602 static void gravager(FILE *fp_gen
, const struct userinfostruct
*uinfo
, long long int nacc
, const char *url
, long long int nbytes
, const char *ip
, const char *hora
, const char *dia
, long long int nelap
, long long int incache
, long long int oucache
)
605 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
606 to print a long long int unless it is exactly 64-bits long.
608 fprintf(fp_gen
,"%s\t%"PRIu64
"\t%"PRIu64
"\t%s\t%s\t%s\t%s\t%"PRIu64
"\t%"PRIu64
"\t%"PRIu64
"\n",uinfo
->id
,(uint64_t)nacc
,(uint64_t)nbytes
,url
,ip
,hora
,dia
,(uint64_t)nelap
,(uint64_t)incache
,(uint64_t)oucache
);
612 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
616 long long int number
;
618 if (strncmp(buffer
,"TOTAL\t",6)==0) {
623 if (*buffer
== '-') {
626 } else if (*buffer
== '+') {
630 while (isdigit(*buffer
))
631 number
=(number
* 10) + (*buffer
++)-'0';
633 debuga(_("Invalid total number of accesses in %s\n"),filename
);
637 item
->nacc
=number
*sign
;
640 if (*buffer
== '-') {
643 } else if (*buffer
== '+') {
647 while (isdigit(*buffer
))
648 number
=(number
* 10) + (*buffer
++)-'0';
650 debuga(_("Invalid total size in %s\n"),filename
);
654 item
->nbytes
=number
*sign
;
657 if (*buffer
== '-') {
660 } else if (*buffer
== '+') {
664 while (isdigit(*buffer
))
665 number
=(number
* 10) + (*buffer
++)-'0';
667 debuga(_("Invalid total elapsed time in %s\n"),filename
);
671 item
->nelap
=number
*sign
;
674 if (*buffer
== '-') {
677 } else if (*buffer
== '+') {
681 while (isdigit(*buffer
))
682 number
=(number
* 10) + (*buffer
++)-'0';
684 debuga(_("Invalid total cache hit in %s\n"),filename
);
688 item
->incache
=number
*sign
;
691 if (*buffer
== '-') {
694 } else if (*buffer
== '+') {
698 while (isdigit(*buffer
))
699 number
=(number
* 10) + (*buffer
++)-'0';
701 debuga(_("Invalid total cache miss in %s\n"),filename
);
704 item
->oucache
=number
*sign
;
709 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
711 debuga(_("User name too long or invalid in %s\n"),filename
);
717 if (*buffer
== '-') {
720 } else if (*buffer
== '+') {
724 while (isdigit(*buffer
))
725 number
=(number
* 10) + (*buffer
++)-'0';
727 debuga(_("Invalid number of accesses in %s\n"),filename
);
731 item
->nacc
=number
*sign
;
734 if (*buffer
== '-') {
737 } else if (*buffer
== '+') {
741 while (isdigit(*buffer
))
742 number
=(number
* 10) + (*buffer
++)-'0';
744 debuga(_("Invalid number of bytes in %s\n"),filename
);
748 item
->nbytes
=number
*sign
;
751 while ((unsigned char)*buffer
>=' ') buffer
++;
753 debuga(_("URL too long or invalid in %s\n"),filename
);
759 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
761 debuga(_("IP address too long or invalid in %s\n"),filename
);
767 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
769 debuga(_("Time too long or invalid in %s\n"),filename
);
775 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
777 debuga(_("Date too long or invalid in %s\n"),filename
);
783 if (*buffer
== '-') {
786 } else if (*buffer
== '+') {
790 while (isdigit(*buffer
))
791 number
=(number
* 10) + (*buffer
++)-'0';
793 debuga(_("Invalid elapsed time in %s\n"),filename
);
797 item
->nelap
=number
*sign
;
800 if (*buffer
== '-') {
803 } else if (*buffer
== '+') {
807 while (isdigit(*buffer
))
808 number
=(number
* 10) + (*buffer
++)-'0';
810 debuga(_("Invalid cache hit size in %s\n"),filename
);
814 item
->incache
=number
*sign
;
817 if (*buffer
== '-') {
820 } else if (*buffer
== '+') {
824 while (isdigit(*buffer
))
825 number
=(number
* 10) + (*buffer
++)-'0';
827 debuga(_("Invalid cache miss size in %s\n"),filename
);
830 item
->oucache
=number
*sign
;
835 static void grava_SmartFilter(const char *dirname
, const char *user
, const char *ip
, const char *data
, const char *hora
, const char *url
, const char *smart
)
839 char wdirname
[MAXLEN
];
841 sprintf(wdirname
,"%s/smartfilter.unsort",dirname
);
843 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
844 debuga(_("(report) Cannot open file %s\n"),wdirname
);
848 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
849 fputs("</body>\n</html>\n",fp_tt
);