]> git.ipfire.org Git - thirdparty/sarg.git/blob - report.c
Trivial changes made while ensuring the reports are complete and accurate
[thirdparty/sarg.git] / report.c
1 /*
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
3 * 1998, 2010
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
10 *
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.
15 *
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.
20 *
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.
24 *
25 */
26
27 #include "include/conf.h"
28 #include "include/defs.h"
29
30 static FILE *fp_tt=NULL;
31
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 char *user, const char *data, const char *hora, long long int elap, long long int accbytes, int indexonly);
35 static void gravatmpf(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);
36 static void gravaporuser(const char *user, 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 char *user, 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);
39
40 void gerarel(void)
41 {
42
43 FILE *fp_in;
44 FILE *fp_gen;
45
46 char *buf;
47 char accdia[11], acchora[9], accuser[MAXLEN], accip[MAXLEN], *accurl;
48 char oldaccdia[11], oldacchora[9], oldaccip[MAXLEN];
49 char wdirname[MAXLEN], oldaccuser[MAXLEN];
50 char *oldurl=NULL;
51 char olduser[MAXLEN], oldmsg[50], acccode[MAXLEN/2 - 1], oldacccode[MAXLEN/2 - 1], user[MAXLEN];
52 char ipantes[MAXLEN], nameantes[MAXLEN];
53 char accsmart[MAXLEN];
54 char crc2[MAXLEN/2 -1];
55 char siteind[MAX_TRUNCATED_URL];
56 char arqtt[256];
57 char *oldurltt=NULL;
58 char oldaccdiatt[11],oldacchoratt[9];
59 long long int nbytes=0;
60 long long int nelap=0;
61 long long int nacc=0;
62 long long int rtotal=0;
63 long long int incache=0;
64 long long int oucache=0;
65 long long int accbytes, accelap;
66 char *str;
67 DIR *dirp;
68 struct dirent *direntp;
69 const char logext[]=".log";
70 int dlen;
71 int url_len;
72 int ourl_size=0;
73 int ourltt_size=0;
74 int same_url;
75 struct getwordstruct gwarea;
76 struct longlinestruct line;
77
78 ipantes[0]='\0';
79 nameantes[0]='\0';
80 smartfilter=0;
81
82 sprintf(dirname, "%s%s", outdir, period);
83 vrfydir(period, addr, site, us, email);
84
85 if(debugz){
86 debugaz("dirname",dirname);
87 }
88
89 gperiod(dirname,period);
90
91 if(UserAgentLog[0] != '\0' && email[0] == '\0') useragent();
92
93 sprintf(wdirname,"%s/sarg-general",dirname);
94 if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){
95 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
96 exit(1);
97 }
98
99 olduser[0]='\0';
100 strncat(tmp,"/sarg",5);
101 fp_tt=NULL;
102
103 dirp = opendir(tmp);
104 while ((direntp = readdir( dirp )) != NULL ) {
105 dlen=strlen(direntp->d_name)-(sizeof(logext)-1);
106 if (dlen<0) continue;
107 if((strcmp(direntp->d_name+dlen,logext) != 0) ||
108 (strncmp(direntp->d_name,"download.log",12) == 0) ||
109 (strncmp(direntp->d_name,"denied.log",10) == 0) ||
110 (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0))
111 continue;
112 if (snprintf(tmp3,sizeof(tmp3),"%s/%s",tmp,direntp->d_name)>=sizeof(tmp3)) {
113 fprintf(stderr, "SARG: (report) directory entry too long: %s/%s\n",tmp,direntp->d_name);
114 exit(1);
115 }
116 if((fp_in=MY_FOPEN(tmp3,"r"))==NULL){
117 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],tmp);
118 exit(1);
119 }
120
121 if (dlen>0) {
122 if (dlen>=sizeof(user)) continue;
123 strncpy(user,direntp->d_name,dlen);
124 user[dlen]=0;
125 } else {
126 user[0]='\0';
127 }
128
129 strcpy(wdirname,dirname);
130 maketmp(user,tmp,debug,indexonly);
131 maketmp_hour(user,tmp,indexonly);
132
133 strcpy(u2,user);
134 if(Ip2Name)
135 ip2name(u2,sizeof(u2));
136 user_find(name,sizeof(name), u2);
137
138 if(dotinuser && strchr(name,'_')) {
139 subs(name,sizeof(name),"_",".");
140 }
141
142 ttopen=0;
143 oldurltt=NULL;
144 ourltt_size=0;
145 memset(oldaccdiatt,0,sizeof(oldaccdiatt));
146 memset(oldacchoratt,0,sizeof(oldacchoratt));
147
148 if (longline_prepare(&line)<0) {
149 debuga(_("Not enough memory to read the downloaded files"));
150 exit(1);
151 }
152
153 while((buf=longline_read(fp_in,&line))!=NULL) {
154 getword_start(&gwarea,buf);
155 if (getword(accdia,sizeof(accdia),&gwarea,'\t')<0 || getword(acchora,sizeof(acchora),&gwarea,'\t')<0 ||
156 getword(accuser,sizeof(accuser),&gwarea,'\t')<0 || getword(accip,sizeof(accip),&gwarea,'\t')<0 ||
157 getword_ptr(buf,&accurl,&gwarea,'\t')<0 || getword_atoll(&accbytes,&gwarea,'\t')<0 ||
158 getword(acccode,sizeof(acccode),&gwarea,'\t')<0) {
159 debuga(_("Maybe you have a broken record or garbage in your %s file (%d)"),tmp3,__LINE__);
160 exit(1);
161 }
162 if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
163 if (getword_atoll(&accelap,&gwarea,'\t')<0 || getword_skip(20000,&gwarea,'\t')<0) {
164 printf("SARG: Maybe you have a broken elapsed time in your %s file (%d).\n",tmp3,__LINE__);
165 exit(1);
166 }
167 if (getword(accsmart,sizeof(accsmart),&gwarea,'"')<0) {
168 printf("SARG: Maybe you have a broken smart info in your %s file (%d).\n",tmp3,__LINE__);
169 exit(1);
170 }
171
172 if(accsmart[0] != '\0') {
173 smartfilter++;
174 strcpy(wdirname,dirname);
175 grava_SmartFilter(wdirname,accuser,accip,accdia,acchora,accurl,accsmart);
176 }
177
178 if(Ip2Name) {
179 if(strcmp(accip,ipantes) != 0) {
180 strcpy(ipantes,accip);
181 ip2name(accip,sizeof(accip));
182 strcpy(nameantes,accip);
183 } else strcpy(accip,nameantes);
184 }
185
186 strcpy(wdirname,dirname);
187 gravatmp_hora(wdirname,accuser,accdia,acchora,accelap,accbytes,indexonly);
188
189 if(iprel){
190 strcpy(wdirname,dirname);
191 gravaporuser(accuser,wdirname,accurl,accip,accdia,acchora,accbytes,accelap,indexonly);
192 }
193
194 if(!rtotal){
195 url_len=strlen(accurl);
196 if (!oldurl || url_len>=ourl_size) {
197 ourl_size=url_len+1;
198 oldurl=realloc(oldurl,ourl_size);
199 if (!oldurl) {
200 debuga(_("Not enough memory to store the url"));
201 exit(1);
202 }
203 }
204 strcpy(oldurl,accurl);
205 strcpy(oldacccode,acccode);
206 strcpy(oldaccuser,accuser);
207 strcpy(oldaccip,accip);
208 strcpy(oldaccdia,accdia);
209 strcpy(oldacchora,acchora);
210 rtotal++;
211 }
212 same_url=(strcmp(oldurl,accurl) == 0);
213
214 if(site[0] != '\0') {
215 if(strcmp(oldaccuser,accuser) != 0){
216 strcpy(oldmsg,"OK");
217 if(strstr(oldacccode,"DENIED") != 0)
218 sprintf(oldmsg,"%s",text[46]);
219 gravatmp(oldaccuser,oldurl,nacc,nbytes,oldmsg,nelap,indexonly,incache,oucache);
220 gravager(fp_gen,oldaccuser,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
221 nacc=0;
222 nbytes=0;
223 nelap=0;
224 incache=0;
225 oucache=0;
226 }
227 } else {
228 if(!same_url || strcmp(oldaccuser,accuser) != 0){
229 if(strstr(oldacccode,"DENIED") != 0)
230 strcpy(oldmsg,text[46]);
231 else
232 strcpy(oldmsg,"OK");
233 gravatmp(oldaccuser,oldurl,nacc,nbytes,oldmsg,nelap,indexonly,incache,oucache);
234 gravager(fp_gen,oldaccuser,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
235 nacc=0;
236 nbytes=0;
237 nelap=0;
238 incache=0;
239 oucache=0;
240 if(strcmp(oldaccuser,accuser) != 0)
241 ind2=0;
242 }
243 }
244 nacc++;
245 nbytes+=accbytes;
246 nelap+=accelap;
247
248 if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0 &&
249 (!oldurltt || strcmp(oldurltt,accurl) || strcmp(oldaccdiatt,accdia) || strcmp(oldacchoratt,acchora))) {
250
251 if(!ttopen) {
252 ind2++;
253 url_to_file(accurl,siteind,sizeof(siteind));
254 snprintf(arqtt,sizeof(arqtt),"%s/%s",dirname,accuser);
255 if(access(arqtt, R_OK) != 0)
256 my_mkdir(arqtt);
257 snprintf(arqtt,sizeof(arqtt),"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind);
258 if ((fp_tt = fopen(arqtt, "w")) == 0) {
259 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt);
260 exit(1);
261 }
262 ttopen=1;
263
264 /*
265 if(Privacy)
266 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
267 FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
268 else
269 sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
270 */
271
272 write_html_header(fp_tt,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Site access report"));
273 fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",text[89],period);
274 fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",text[90],name);
275 fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
276 fprintf(fp_tt,"<tr><th class=\"header_c\">%s</th></tr>\n",text[32]);
277 close_html_header(fp_tt);
278
279 fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
280 fputs("<tr><td></td><td></td></tr>",fp_tt);
281 bzero(tmp4, MAXLEN);
282 strncpy(tmp4,text[110],4);
283 fprintf(fp_tt,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",text[91],tmp4,text[110]+5);
284 }
285
286 fputs("<tr><td class=\"data\">",fp_tt);
287 output_html_string(fp_tt,accurl,100);
288 fprintf(fp_tt,"</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accdia,acchora);
289
290 url_len=strlen(accurl);
291 if (!oldurltt || url_len>=ourltt_size) {
292 ourltt_size=url_len+1;
293 oldurltt=realloc(oldurltt,ourltt_size);
294 if (!oldurltt) {
295 debuga(_("Not enough memory to store the url"));
296 exit(1);
297 }
298 }
299 strcpy(oldurltt,accurl);
300 strcpy(oldaccdiatt,accdia);
301 strcpy(oldacchoratt,acchora);
302 }
303
304 strcpy(crc2,acccode);
305 str=strchr(crc2,'/');
306 if (str) *str='\0';
307 if(strstr(crc2,"MISS") != 0)
308 oucache+=accbytes;
309 else incache+=accbytes;
310
311 if(strcmp(accuser,oldaccuser) != 0) {
312 strcpy(wdirname,dirname);
313 day_totalize(tmp,oldaccuser,indexonly);
314 strcpy(oldaccuser,accuser);
315 }
316
317 strcpy(oldacccode,acccode);
318 strcpy(oldaccip,accip);
319 if (!same_url) {
320 url_len=strlen(accurl);
321 if (url_len>=ourl_size) {
322 ourl_size=url_len+1;
323 oldurl=realloc(oldurl,ourl_size);
324 if (!oldurl) {
325 debuga(_("Not enough memory to store the url"));
326 exit(1);
327 }
328 }
329 strcpy(oldurl,accurl);
330 }
331 strcpy(oldaccdia,accdia);
332 strcpy(oldacchora,acchora);
333
334 }
335 fclose(fp_in);
336 longline_free(&line);
337 if (oldurltt) free(oldurltt);
338 unlink(tmp3);
339 bzero(user,sizeof(user));
340 }
341 closedir(dirp);
342
343 if (oldurl) {
344 if(strstr(oldacccode,"DENIED") != 0)
345 strcpy(oldmsg,text[46]);
346 else
347 strcpy(oldmsg,"OK");
348 strcpy(wdirname,dirname);
349 if(oldaccuser[0] == '\0')
350 strcpy(oldaccuser,accuser);
351 gravatmpf(oldaccuser,wdirname,oldurl,nacc,nbytes,oldmsg,nelap,indexonly,incache,oucache);
352 strcpy(wdirname,dirname);
353 gravager(fp_gen,oldaccuser,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
354 free(oldurl);
355 }
356 fclose(fp_gen);
357 day_totalize(tmp,oldaccuser,indexonly);
358
359 tmpsort();
360
361 strcpy(wdirname,dirname);
362 totalger(wdirname, debug, outdir);
363
364 if(email[0] == '\0') {
365 if((ReportType & REPORT_TYPE_DOWNLOADS) != 0) download_report();
366
367 if(DansGuardianConf[0] != '\0') {
368 strcpy(wdirname,dirname);
369 dansguardian_log();
370 }
371
372 strcpy(wdirname,dirname);
373 squidguard_log();
374
375 strcpy(wdirname,dirname);
376 topuser();
377
378 if((ReportType & REPORT_TYPE_TOPSITES) != 0) topsites();
379
380 if((ReportType & REPORT_TYPE_SITES_USERS) != 0) siteuser();
381 gen_denied_report();
382
383 strcpy(wdirname,dirname);
384 authfail_report();
385
386 if(smartfilter) smartfilter_report();
387
388 if(DansGuardianConf[0] != '\0') dansguardian_report();
389
390 squidguard_report();
391
392 if((ReportType & REPORT_TYPE_USERS_SITES) != 0) htmlrel();
393
394 make_index();
395
396 if(SuccessfulMsg) fprintf(stderr, "SARG: %s %s\n",text[47],dirname);
397 } else {
398 strcpy(wdirname,dirname);
399 geramail(wdirname, debug, outdir, userip, email, TempDir);
400
401 if((strcmp(email,"stdout") != 0) && SuccessfulMsg)
402 fprintf(stderr, "SARG: %s %s\n",text[48],email);
403 }
404
405 if(indexonly) {
406 strcpy(wdirname,dirname);
407 index_only(wdirname, debug);
408 }
409
410 /*
411 2009-10-13(Frederic) This piece of code is never called so it is commented out for good.
412 if(strlen(email) < 0)
413 removetmp(dirname);
414 */
415
416 return;
417 }
418
419 static void maketmp(const char *user, const char *dirname, int debug, int indexonly)
420 {
421
422 FILE *fp_ou;
423
424 char wdirname[MAXLEN];
425
426 if(indexonly) return;
427 if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
428
429 strcpy(wdirname,tmp);
430 strcat(wdirname,"/");
431 strcat(wdirname,user);
432
433 if(debug){
434 debuga("%s: %s",text[49],wdirname);
435 }
436
437 strcat(wdirname,".utmp");
438 if((fp_ou=fopen(wdirname,"w"))==NULL){
439 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
440 exit(1);
441 }
442
443 fclose(fp_ou);
444 return;
445 }
446
447
448 static void maketmp_hour(const char *user, const char *dirname, int indexonly)
449 {
450
451 FILE *fp_ou;
452
453 char wdirname[MAXLEN];
454
455 if(indexonly) return;
456 if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
457
458 strcpy(wdirname,tmp);
459 strcat(wdirname,"/");
460 strcat(wdirname,user);
461
462 strcat(wdirname,".htmp");
463 if((fp_ou=fopen(wdirname,"w"))==NULL){
464 fprintf(stderr, "SARG: (report-1) %s: %s - %s\n",text[45],wdirname,strerror(errno));
465 exit(1);
466 }
467
468 fclose(fp_ou);
469 return;
470 }
471
472
473 void gravatmp(const char *oldaccuser, 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)
474 {
475
476 FILE *fp_ou;
477 char wdirname[MAXLEN];
478
479 if(indexonly) return;
480 if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
481
482 if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,oldaccuser)>=sizeof(wdirname)) {
483 debuga(_("Path too long %s/%s.utmp"),tmp,oldaccuser);
484 exit(1);
485 }
486
487 if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
488 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
489 exit(1);
490 }
491
492 fprintf(fp_ou,"%lld\t%lld\t%s\t%s\t%lld\t%lld\t%lld\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
493
494 fclose(fp_ou);
495 ttopen=0;
496
497 if(fp_tt) {
498 fputs("</table>\n</div>\n",fp_tt);
499 fputs("</body>\n</html>\n",fp_tt);
500 fclose(fp_tt);
501 fp_tt=NULL;
502 }
503
504 return;
505
506 }
507
508
509 static void gravatmp_hora(const char *dirname, const char *user, const char *data, const char *hora, long long int elap, long long int bytes, int indexonly)
510 {
511
512 FILE *fp_ou;
513 char wdirname[MAXLEN];
514
515 if(indexonly || ((ReportType & REPORT_TYPE_USERS_SITES) == 0)) return;
516
517 if (snprintf(wdirname,sizeof(wdirname),"%s/%s.htmp",tmp,user)>=sizeof(wdirname)) {
518 fprintf(stderr,"SARG: Path too long %s/%s.htmp\n",tmp,user);
519 exit(1);
520 }
521
522 if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
523 fprintf(stderr, "SARG: (report-2) %s: %s - %s\n",text[45],wdirname,strerror(errno));
524 exit(1);
525 }
526
527 if(strcmp(datetimeby,"bytes") == 0) fprintf(fp_ou,"%s\t%s\t%lld\n",data,hora,bytes);
528 else fprintf(fp_ou,"%s\t%s\t%lld\n",data,hora,elap);
529
530 fclose(fp_ou);
531
532 return;
533 }
534
535
536 static void gravaporuser(const char *user, 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)
537 {
538
539 FILE *fp_ou;
540 char wdirname[MAXLEN];
541
542 if(indexonly || ((ReportType & REPORT_TYPE_USERS_SITES) == 0)) return;
543
544 if (snprintf(wdirname,sizeof(wdirname),"%s/%s.ip",tmp,user)>=sizeof(wdirname)) {
545 fprintf(stderr,"SARG: Path too long %s/%s.ip\n",tmp,user);
546 exit(1);
547 }
548
549 if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
550 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
551 exit(1);
552 }
553
554 fprintf(fp_ou,"%s\t%s\t%s\t%s\t%lld\t%lld\n",ip,url,data,hora,tam,elap);
555
556 fclose(fp_ou);
557
558 return;
559
560 }
561
562
563 static void gravatmpf(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)
564 {
565
566 FILE *fp_ou;
567 char wdirname[MAXLEN];
568
569 if(indexonly || ((ReportType & REPORT_TYPE_USERS_SITES) == 0)) return;
570
571 if (snprintf(wdirname,sizeof(wdirname),"%s/%s.utmp",tmp,oldaccuser)>=sizeof(wdirname)) {
572 fprintf(stderr,"SARG: Path too long %s/%s.utmp\n",tmp,oldaccuser);
573 exit(1);
574 }
575
576 if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
577 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
578 exit(1);
579 }
580
581 fprintf(fp_ou,"%lld\t%lld\t%s\t%s\t%lld\t%lld\t%lld\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
582
583 fclose(fp_ou);
584 ttopen=0;
585 ind2=0;
586
587 if(fp_tt) {
588 fputs("</table>\n",fp_tt);
589 fputs("</body>\n</html>\n",fp_tt);
590 fclose(fp_tt);
591 fp_tt=NULL;
592 }
593
594 return;
595
596 }
597
598
599 static void gravager(FILE *fp_gen, const char *user, 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)
600 {
601 fprintf(fp_gen,"%s\t%lld\t%lld\t%s\t%s\t%s\t%s\t%lld\t%lld\t%lld\n",user,nacc,nbytes,url,ip,hora,dia,nelap,incache,oucache);
602 return;
603 }
604
605 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)
606 {
607
608 FILE *fp_ou;
609 char wdirname[MAXLEN];
610
611 sprintf(wdirname,"%s/smartfilter.unsort",dirname);
612
613 if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){
614 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
615 exit(1);
616 }
617
618 fprintf(fp_ou,"%s\t%s\t%s\t%s\t%s\t%s\n",user,data,hora,ip,url,smart);
619 fputs("</body>\n</html>\n",fp_tt);
620
621 fclose(fp_ou);
622
623 return;
624
625 }