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
);
106 if ((dirp
= opendir(tmp
)) == NULL
) {
107 debuga(_("Failed to open directory %s - %s\n"),tmp
,strerror(errno
));
110 while ((direntp
= readdir( dirp
)) != NULL
) {
111 dlen
=strlen(direntp
->d_name
)-(sizeof(logext
)-1);
112 if (dlen
<0) continue;
113 if((strcmp(direntp
->d_name
+dlen
,logext
) != 0) ||
114 (strncmp(direntp
->d_name
,"download.log",12) == 0) ||
115 (strncmp(direntp
->d_name
,"denied.log",10) == 0) ||
116 (strncmp(direntp
->d_name
,"authfail.log.unsort",19) == 0))
118 if (snprintf(tmp3
,sizeof(tmp3
),"%s/%s",tmp
,direntp
->d_name
)>=sizeof(tmp3
)) {
119 debuga(_("(report) directory entry too long: %s/%s\n"),tmp
,direntp
->d_name
);
122 if((fp_in
=MY_FOPEN(tmp3
,"r"))==NULL
){
123 debuga(_("(report) Cannot open file %s\n"),tmp
);
128 if (dlen
>=sizeof(user
)) continue;
129 strncpy(user
,direntp
->d_name
,dlen
);
135 uinfo
=userinfo_find_from_file(user
);
137 debuga(_("Ignoring unknown user file %s\n"),user
);
140 strcpy(u2
,uinfo
->id
);
141 if(Ip2Name
&& uinfo
->id_is_ip
) {
143 ip2name(u2
,sizeof(u2
));
144 strcpy(nameantes
,u2
);
146 user_find(uinfo
->label
,MAX_USER_LEN
, u2
);
148 maketmp(user
,tmp
,debug
,indexonly
);
149 maketmp_hour(user
,tmp
,indexonly
);
154 memset(oldaccdiatt
,0,sizeof(oldaccdiatt
));
155 memset(oldacchoratt
,0,sizeof(oldacchoratt
));
158 if ((line
=longline_create())==NULL
) {
159 debuga(_("Not enough memory to read the downloaded files\n"));
163 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
164 getword_start(&gwarea
,buf
);
165 if (getword(accdia
,sizeof(accdia
),&gwarea
,'\t')<0 || getword(acchora
,sizeof(acchora
),&gwarea
,'\t')<0 ||
166 getword(accip
,sizeof(accip
),&gwarea
,'\t')<0 ||
167 getword_ptr(buf
,&accurl
,&gwarea
,'\t')<0 || getword_atoll(&accbytes
,&gwarea
,'\t')<0 ||
168 getword(acccode
,sizeof(acccode
),&gwarea
,'\t')<0) {
169 debuga(_("There is a broken record or garbage in file %s\n"),tmp3
);
172 if(strncmp(acccode
,"TCP_DENIED/407",14) == 0) continue;
173 if (getword_atoll(&accelap
,&gwarea
,'\t')<0) {
174 debuga(_("There is a broken elapsed time in file %s\n"),tmp3
);
177 if (getword_skip(20000,&gwarea
,'"')<0 || getword(accsmart
,sizeof(accsmart
),&gwarea
,'"')<0) {
178 debuga(_("There is a broken smart info in file %s\n"),tmp3
);
182 if(accsmart
[0] != '\0') {
184 grava_SmartFilter(outdirname
,uinfo
->id
,accip
,accdia
,acchora
,accurl
,accsmart
);
188 if(strcmp(accip
,ipantes
) != 0) {
189 strcpy(ipantes
,accip
);
190 ip2name(accip
,sizeof(accip
));
191 strcpy(nameantes
,accip
);
192 } else strcpy(accip
,nameantes
);
195 gravatmp_hora(outdirname
,uinfo
,accdia
,acchora
,accelap
,accbytes
,indexonly
);
198 gravaporuser(uinfo
,outdirname
,accurl
,accip
,accdia
,acchora
,accbytes
,accelap
,indexonly
);
202 url_len
=strlen(accurl
);
203 if (!oldurl
|| url_len
>=ourl_size
) {
205 oldurl
=realloc(oldurl
,ourl_size
);
207 debuga(_("Not enough memory to store the url\n"));
211 strcpy(oldurl
,accurl
);
212 strcpy(oldacccode
,acccode
);
214 strcpy(oldaccip
,accip
);
215 strcpy(oldaccdia
,accdia
);
216 strcpy(oldacchora
,acchora
);
220 same_url
=(strcmp(oldurl
,accurl
) == 0);
222 if(site
[0] != '\0') {
224 if(strstr(oldacccode
,"DENIED") != 0)
225 strcpy(oldmsg
,"DENIED");
228 gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
229 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
237 if(!same_url
|| new_user
){
238 if(strstr(oldacccode
,"DENIED") != 0)
239 strcpy(oldmsg
,"DENIED");
242 gravatmp(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
243 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
255 if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0 &&
256 (!oldurltt
|| strcmp(oldurltt
,accurl
) || strcmp(oldaccdiatt
,accdia
) || strcmp(oldacchoratt
,acchora
))) {
259 snprintf(arqtt
,sizeof(arqtt
),"%s/%s",outdirname
,uinfo
->filename
);
260 if(access(arqtt
, R_OK
) != 0)
262 url_to_file(accurl
,siteind
,sizeof(siteind
));
263 snprintf(arqtt
,sizeof(arqtt
),"%s/%s/tt%s-%s.html",outdirname
,uinfo
->filename
,uinfo
->filename
,siteind
);
264 if ((fp_tt
= fopen(arqtt
, "w")) == 0) {
265 debuga(_("(report) Cannot open file %s\n"),arqtt
);
272 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
273 FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
275 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
278 write_html_header(fp_tt
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("Site access report"));
279 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
280 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
281 fprintf(fp_tt
,"<tr><td class=\"header_c\">%s: %s, %s</td></tr>\n",_("Sort"),UserSortField
,UserSortOrder
);
282 fprintf(fp_tt
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
283 close_html_header(fp_tt
);
285 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt
);
286 strncpy(tmp4
,_("DATE/TIME"),4);
288 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);
291 fputs("<tr><td class=\"data\">",fp_tt
);
292 output_html_string(fp_tt
,accurl
,100);
293 fprintf(fp_tt
,"</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia
,acchora
);
295 url_len
=strlen(accurl
);
296 if (!oldurltt
|| url_len
>=ourltt_size
) {
297 ourltt_size
=url_len
+1;
298 oldurltt
=realloc(oldurltt
,ourltt_size
);
300 debuga(_("Not enough memory to store the url\n"));
304 strcpy(oldurltt
,accurl
);
305 strcpy(oldaccdiatt
,accdia
);
306 strcpy(oldacchoratt
,acchora
);
309 strcpy(crc2
,acccode
);
310 str
=strchr(crc2
,'/');
312 if(strstr(crc2
,"MISS") != 0)
314 else incache
+=accbytes
;
318 day_totalize(tmp
,puinfo
,indexonly
);
322 strcpy(oldacccode
,acccode
);
323 strcpy(oldaccip
,accip
);
325 url_len
=strlen(accurl
);
326 if (url_len
>=ourl_size
) {
328 oldurl
=realloc(oldurl
,ourl_size
);
330 debuga(_("Not enough memory to store the url\n"));
334 strcpy(oldurl
,accurl
);
336 strcpy(oldaccdia
,accdia
);
337 strcpy(oldacchora
,acchora
);
341 longline_destroy(&line
);
342 if (oldurltt
) free(oldurltt
);
348 if(strstr(oldacccode
,"DENIED") != 0)
349 strcpy(oldmsg
,"DENIED");
352 gravatmpf(puinfo
,oldurl
,nacc
,nbytes
,oldmsg
,nelap
,indexonly
,incache
,oucache
);
353 gravager(fp_gen
,puinfo
,nacc
,oldurl
,nbytes
,oldaccip
,oldacchora
,oldaccdia
,nelap
,incache
,oucache
);
357 if (puinfo
) day_totalize(tmp
,puinfo
,indexonly
);
361 totalger(outdirname
, debug
, outdir
);
363 if(email
[0] == '\0') {
364 if((ReportType
& REPORT_TYPE_DOWNLOADS
) != 0) download_report();
366 if(DansGuardianConf
[0] != '\0') {
374 if((ReportType
& REPORT_TYPE_TOPSITES
) != 0) topsites();
376 if((ReportType
& REPORT_TYPE_SITES_USERS
) != 0) siteuser();
381 if(smartfilter
) smartfilter_report();
383 if(DansGuardianConf
[0] != '\0') dansguardian_report();
387 if((ReportType
& REPORT_TYPE_USERS_SITES
) != 0) htmlrel();
391 if(SuccessfulMsg
) debuga(_("Successful report generated on %s\n"),outdirname
);
393 geramail(outdirname
, debug
, outdir
, email
, tmp
);
395 if((strcmp(email
,"stdout") != 0) && SuccessfulMsg
)
396 debuga(_("Successful report generated and sent to %s\n"),email
);
400 index_only(outdirname
, debug
);
403 removetmp(outdirname
);
407 static void maketmp(const char *user
, const char *dirname
, int debug
, int indexonly
)
412 char wdirname
[MAXLEN
];
414 if(indexonly
) return;
415 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
417 if(debug
) debuga(_("Making file: %s/%s\n"),tmp
,user
);
418 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,user
)>=sizeof(wdirname
)) {
419 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,user
);
423 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
424 debuga(_("(report) Cannot open file %s\n"),wdirname
);
433 static void maketmp_hour(const char *user
, const char *dirname
, int indexonly
)
438 char wdirname
[MAXLEN
];
440 if(indexonly
) return;
441 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
442 if(datetimeby
==0) return;
444 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,user
)>=sizeof(wdirname
)) {
445 debuga(_("Temporary file name too long: %s/%s.htmp\n"),tmp
,user
);
449 if((fp_ou
=fopen(wdirname
,"w"))==NULL
){
450 debuga(_("(report-1) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
459 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
)
462 char wdirname
[MAXLEN
];
464 if(indexonly
) return;
465 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
467 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
468 debuga(_("Temporary file name too long: %s/%s.utmp\n"),tmp
,uinfo
->filename
);
472 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
473 debuga(_("(report) Cannot open file %s\n"),wdirname
);
478 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
479 to print a long long int unless it is exactly 64-bits long.
481 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
);
487 fputs("</table>\n</div>\n",fp_tt
);
488 fputs("</body>\n</html>\n",fp_tt
);
496 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
)
499 char wdirname
[MAXLEN
];
501 if(indexonly
|| (ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
503 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.utmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
504 debuga(_("Path too long %s/%s.utmp\n"),tmp
,uinfo
->filename
);
508 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
509 debuga(_("(report) Cannot open file %s\n"),wdirname
);
514 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
515 to print a long long int unless it is exactly 64-bits long.
517 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
);
519 if (fclose(fp_ou
)==EOF
) {
520 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
526 fputs("</table>\n",fp_tt
);
527 fputs("</body>\n</html>\n",fp_tt
);
536 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
)
540 char wdirname
[MAXLEN
];
543 if(indexonly
|| ((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) || datetimeby
==0) return;
545 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.htmp",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
546 debuga(_("Path too long %s/%s.htmp\n"),tmp
,uinfo
->filename
);
550 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
551 debuga(_("(report-2) Cannot open file %s - %s\n"),wdirname
,strerror(errno
));
556 fprintf(fp_ou
,"%s\t%d",data
,hour
);
557 if((datetimeby
& DATETIME_BYTE
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)bytes
);
558 if((datetimeby
& DATETIME_ELAP
)!=0) fprintf(fp_ou
,"\t%"PRIu64
,(uint64_t)elap
);
561 if (fclose(fp_ou
)==EOF
) {
562 debuga(_("Failed to close file %s - %s\n"),wdirname
,strerror(errno
));
570 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
)
574 char wdirname
[MAXLEN
];
576 if(indexonly
|| ((ReportType
& REPORT_TYPE_USERS_SITES
) == 0)) return;
578 if (snprintf(wdirname
,sizeof(wdirname
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(wdirname
)) {
579 debuga(_("Path too long %s/%s.ip\n"),tmp
,uinfo
->filename
);
583 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
584 debuga(_("(report) Cannot open file %s\n"),wdirname
);
589 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
590 to print a long long int unless it is exactly 64-bits long.
592 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
);
601 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
)
604 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
605 to print a long long int unless it is exactly 64-bits long.
607 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
);
611 int ger_read(char *buffer
,struct generalitemstruct
*item
,const char *filename
)
615 long long int number
;
617 if (strncmp(buffer
,"TOTAL\t",6)==0) {
622 if (*buffer
== '-') {
625 } else if (*buffer
== '+') {
629 while (isdigit(*buffer
))
630 number
=(number
* 10) + (*buffer
++)-'0';
632 debuga(_("Invalid total number of accesses in %s\n"),filename
);
636 item
->nacc
=number
*sign
;
639 if (*buffer
== '-') {
642 } else if (*buffer
== '+') {
646 while (isdigit(*buffer
))
647 number
=(number
* 10) + (*buffer
++)-'0';
649 debuga(_("Invalid total size in %s\n"),filename
);
653 item
->nbytes
=number
*sign
;
656 if (*buffer
== '-') {
659 } else if (*buffer
== '+') {
663 while (isdigit(*buffer
))
664 number
=(number
* 10) + (*buffer
++)-'0';
666 debuga(_("Invalid total elapsed time in %s\n"),filename
);
670 item
->nelap
=number
*sign
;
673 if (*buffer
== '-') {
676 } else if (*buffer
== '+') {
680 while (isdigit(*buffer
))
681 number
=(number
* 10) + (*buffer
++)-'0';
683 debuga(_("Invalid total cache hit in %s\n"),filename
);
687 item
->incache
=number
*sign
;
690 if (*buffer
== '-') {
693 } else if (*buffer
== '+') {
697 while (isdigit(*buffer
))
698 number
=(number
* 10) + (*buffer
++)-'0';
700 debuga(_("Invalid total cache miss in %s\n"),filename
);
703 item
->oucache
=number
*sign
;
708 for (i
=0 ; i
<MAX_USER_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
710 debuga(_("User name too long or invalid in %s\n"),filename
);
716 if (*buffer
== '-') {
719 } else if (*buffer
== '+') {
723 while (isdigit(*buffer
))
724 number
=(number
* 10) + (*buffer
++)-'0';
726 debuga(_("Invalid number of accesses in %s\n"),filename
);
730 item
->nacc
=number
*sign
;
733 if (*buffer
== '-') {
736 } else if (*buffer
== '+') {
740 while (isdigit(*buffer
))
741 number
=(number
* 10) + (*buffer
++)-'0';
743 debuga(_("Invalid number of bytes in %s\n"),filename
);
747 item
->nbytes
=number
*sign
;
750 while ((unsigned char)*buffer
>=' ') buffer
++;
752 debuga(_("URL too long or invalid in %s\n"),filename
);
758 for (i
=0 ; i
<MAX_IP_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
760 debuga(_("IP address too long or invalid in %s\n"),filename
);
766 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
768 debuga(_("Time too long or invalid in %s\n"),filename
);
774 for (i
=0 ; i
<MAX_DATETIME_LEN
-1 && (unsigned char)*buffer
>=' ' ; i
++) buffer
++;
776 debuga(_("Date too long or invalid in %s\n"),filename
);
782 if (*buffer
== '-') {
785 } else if (*buffer
== '+') {
789 while (isdigit(*buffer
))
790 number
=(number
* 10) + (*buffer
++)-'0';
792 debuga(_("Invalid elapsed time in %s\n"),filename
);
796 item
->nelap
=number
*sign
;
799 if (*buffer
== '-') {
802 } else if (*buffer
== '+') {
806 while (isdigit(*buffer
))
807 number
=(number
* 10) + (*buffer
++)-'0';
809 debuga(_("Invalid cache hit size in %s\n"),filename
);
813 item
->incache
=number
*sign
;
816 if (*buffer
== '-') {
819 } else if (*buffer
== '+') {
823 while (isdigit(*buffer
))
824 number
=(number
* 10) + (*buffer
++)-'0';
826 debuga(_("Invalid cache miss size in %s\n"),filename
);
829 item
->oucache
=number
*sign
;
834 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
)
838 char wdirname
[MAXLEN
];
840 sprintf(wdirname
,"%s/smartfilter.unsort",dirname
);
842 if((fp_ou
=MY_FOPEN(wdirname
,"a"))==NULL
){
843 debuga(_("(report) Cannot open file %s\n"),wdirname
);
847 fprintf(fp_ou
,"%s\t%s\t%s\t%s\t%s\t%s\n",user
,data
,hora
,ip
,url
,smart
);
848 fputs("</body>\n</html>\n",fp_tt
);