]> git.ipfire.org Git - thirdparty/sarg.git/blob - report.c
Replaced the ifdef FOPEN64 by a single call to MY_FOPEN for code clarity.
[thirdparty/sarg.git] / report.c
1 /*
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
3 * 1998, 2008
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
5 *
6 * SARG donations:
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
23 *
24 */
25
26 #include "include/conf.h"
27 #include "include/defs.h"
28
29 static void maketmp(const char *user, const char *dirname, int debug, int indexonly);
30 static void maketmp_hour(const char *user, const char *dirname, int indexonly);
31 static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly);
32 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);
33 static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly);
34 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);
35 static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart);
36
37 void gerarel(void)
38 {
39
40 FILE *fp_in;
41
42 char accdia[11], acchora[9], accuser[MAXLEN], accip[MAXLEN], accurl[MAXLEN], accbytes[12], accelap[10];
43 char oldaccdia[11], oldacchora[9], oldaccip[MAXLEN], wdir[MAXLEN], per1[MAXLEN];
44 char wdirname[MAXLEN], oldurl[MAXLEN], oldaccuser[MAXLEN];
45 char olduser[MAXLEN], oldmsg[50], acccode[50], oldaccelap[10], oldacccode[50], user[MAXLEN];
46 char ipantes[MAXLEN], nameantes[MAXLEN];
47 char accsmart[MAXLEN];
48 char wcrc[50];
49 char crc2[50];
50 long long int nbytes=0;
51 long long int nelap=0;
52 long long int nacc=0;
53 long long int rtotal=0;
54 long long int incache=0;
55 long long int oucache=0;
56 char *s;
57 DIR *dirp;
58 struct dirent *direntp;
59 const char logext[]=".log";
60 int dlen;
61
62 ipantes[0]='\0';
63 nameantes[0]='\0';
64 smartfilter=0;
65
66 sprintf(dirname, "%s%s", outdir, period);
67 sprintf(wdir, "%s%s", outdir, period);
68 strcpy(per1,period);
69 vrfydir(wdir, per1, addr, site, us, email);
70
71 if(debugz){
72 debugaz("dirname",dirname);
73 debugaz("wdir",wdir);
74 }
75
76 strcpy(wdirname,dirname);
77 gperiod();
78
79 if(strlen(UserAgentLog) > 0 && email[0] == '\0') useragent();
80
81 olduser[0]='\0';
82 strncat(tmp,"/sarg",5);
83
84 dirp = opendir(tmp);
85 while ((direntp = readdir( dirp )) != NULL ) {
86 dlen=strlen(direntp->d_name)-(sizeof(logext)-1);
87 if (dlen<0) continue;
88 if((strcmp(direntp->d_name+dlen,logext) != 0) ||
89 (strncmp(direntp->d_name,"download.log",12) == 0) ||
90 (strncmp(direntp->d_name,"denied.log",10) == 0) ||
91 (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0))
92 continue;
93 if (snprintf(tmp3,sizeof(tmp3),"%s/%s",tmp,direntp->d_name)>=sizeof(tmp3)) {
94 fprintf(stderr, "SARG: (report) directory entry too long: %s/%s\n",tmp,direntp->d_name);
95 exit(1);
96 }
97 if((fp_in=fopen(tmp3,"r"))==NULL){
98 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],tmp);
99 exit(1);
100 }
101
102 if (dlen>0) {
103 if (dlen>=sizeof(user)) continue;
104 strncpy(user,direntp->d_name,dlen);
105 user[dlen]=0;
106 } else {
107 user[0]='\0';
108 }
109
110 strcpy(wdirname,dirname);
111 maketmp(user,tmp,debug,indexonly);
112 maketmp_hour(user,tmp,indexonly);
113
114 strcpy(u2,user);
115 if(strcmp(Ip2Name,"yes") == 0)
116 ip2name(u2,sizeof(u2));
117 get_usertab_name(u2,name,sizeof(name));
118
119 if(dotinuser && strstr(name,"_")) {
120 str2=(char *)subs(name,"_",".");
121 strcpy(name,str2);
122 }
123
124 ttopen=0;
125 bzero(html_old, MAXLEN);
126
127 while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
128 if (getword(accdia,sizeof(accdia),buf,' ')<0 || getword(acchora,sizeof(acchora),buf,' ')<0 ||
129 getword(accuser,sizeof(accuser),buf,' ')<0 || getword(accip,sizeof(accip),buf,' ')<0 ||
130 getword(accurl,sizeof(accurl),buf,' ')<0 || getword(accbytes,sizeof(accbytes),buf,' ')<0 ||
131 getword(acccode,sizeof(acccode),buf,' ')<0) {
132 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3);
133 exit(1);
134 }
135 if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
136 if (getword(accelap,sizeof(accelap),buf,' ')<0 || getword(accsmart,sizeof(accsmart),buf,' ')<0 ||
137 getword(accsmart,sizeof(accsmart),buf,'"')<0) {
138 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3);
139 exit(1);
140 }
141
142 if(strlen(accsmart) > 0) {
143 smartfilter++;
144 strcpy(wdirname,dirname);
145 grava_SmartFilter(wdirname,accuser,accip,accdia,acchora,accurl,accsmart);
146 }
147
148 if(strcmp(Ip2Name,"yes") == 0) {
149 if(strcmp(accip,ipantes) != 0) {
150 strcpy(ipantes,accip);
151 ip2name(accip,sizeof(accip));
152 strcpy(nameantes,accip);
153 } else strcpy(accip,nameantes);
154 }
155
156 strcpy(wdirname,dirname);
157 gravatmp_hora(wdirname,accuser,accdia,acchora,accelap,accbytes,indexonly);
158
159 if(iprel){
160 strcpy(wdirname,dirname);
161 gravaporuser(accuser,wdirname,accurl,accip,accdia,acchora,accbytes,accelap,indexonly);
162 }
163
164 if(!rtotal){
165 strcpy(oldurl,accurl);
166 strcpy(oldacccode,acccode);
167 strcpy(oldaccelap,accelap);
168 strcpy(oldaccuser,accuser);
169 strcpy(oldaccip,accip);
170 strcpy(oldaccdia,accdia);
171 strcpy(oldacchora,acchora);
172 rtotal++;
173 }
174
175 if(site[0] != '\0') {
176 if(strcmp(oldaccuser,accuser) != 0){
177 strcpy(oldmsg,"OK");
178 if(strstr(oldacccode,"DENIED") != 0)
179 sprintf(oldmsg,"%s",text[46]);
180 gravatmp(oldaccuser,wdirname,oldurl,nacc,nbytes,oldmsg,nelap,indexonly,incache,oucache);
181 gravager(wdirname,oldaccuser,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,
182 incache,oucache);
183 nacc=0;
184 nbytes=0;
185 nelap=0;
186 incache=0;
187 oucache=0;
188 }
189 } else {
190 if(strcmp(oldurl,accurl) != 0 || strcmp(oldaccuser,accuser) != 0){
191 strcpy(oldmsg,"OK");
192 if(strstr(oldacccode,"DENIED") != 0)
193 sprintf(oldmsg,"%s",text[46]);
194 strcpy(wdirname,dirname);
195 gravatmp(oldaccuser,wdirname,oldurl,nacc,nbytes,oldmsg,nelap,indexonly,incache,oucache);
196 strcpy(wdirname,dirname);
197 gravager(wdirname,oldaccuser,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
198 nacc=0;
199 nbytes=0;
200 nelap=0;
201 incache=0;
202 oucache=0;
203 if(strcmp(oldaccuser,accuser) != 0)
204 ind2=0;
205 }
206 }
207 nacc++;
208 nbytes+=my_atoll(accbytes);
209 nelap+=my_atoll(accelap);
210
211 if(strstr(ReportType,"site_user_time_date") != 0) {
212 if(!ttopen) {
213 ind2++;
214 strcpy(siteind,accurl);
215 str=siteind;
216 for(z1=0; str[z1]; z1++) {
217 if(str[z1]=='?' || str[z1]=='-' || str[z1]=='.' || str[z1]==':' || str[z1]=='/' || str[z1]=='\\' || str[z1]=='*' ||
218 str[z1]=='\'' || str[z1]=='\"' || str[z1]=='$')
219 str[z1]='_';
220 }
221 sprintf(arqtt,"%s/%s",dirname,accuser);
222 if(access(arqtt, R_OK) != 0)
223 my_mkdir(arqtt);
224 sprintf(arqtt,"%s/%s/tt%s-%s.html",dirname,accuser,accuser,siteind);
225 if(strlen(arqtt) > 255) {
226 strncpy(val7,arqtt,255);
227 bzero(arqtt,MAXLEN);
228 strcpy(arqtt,val7);
229 }
230 if ((fp_tt = fopen(arqtt, "w")) == 0) {
231 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],arqtt);
232 exit(1);
233 }
234 ttopen=1;
235
236 if(strcmp(Privacy,"yes") == 0)
237 sprintf(httplink,"<font size=%s color=%s><href=http://%s>%s", \
238 FontSize,PrivacyStringColor,PrivacyString,PrivacyString);
239 else
240 sprintf(httplink,"<font size=%s><a href=http://%s>%s</A>",FontSize,accurl,accurl);
241
242 sprintf(ltext110,"%s",text[110]);
243 for(s=ltext110; *s; ++s)
244 *s=tolower(*s);
245
246 fprintf(fp_tt, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
247 css(fp_tt);
248 fputs("</head>\n",fp_tt);
249 fprintf(fp_tt,"<body bgcolor=%s text=%s background='%s'>\n",BgColor,TxColor,BgImage);
250 if(strlen(LogoImage) > 0) fprintf(fp_tt, "<center><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"logo\"><img src='%s' border=0 align=absmiddle width=%s height=%s>&nbsp;%s</th></tr>\n<tr><td height=\"5\"></td></tr>\n</table>\n",LogoImage,Width,Height,LogoText);
251
252 if(strcmp(IndexTree,"date") == 0)
253 show_sarg(fp_tt, "../../../..");
254 else
255 show_sarg(fp_tt, "../..");
256
257 fputs("<center><table cellpadding=0 cellspacing=0>\n",fp_tt);
258 fprintf(fp_tt,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\n",Title);
259
260 fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[89],period);
261 fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",text[90],name);
262 fprintf(fp_tt,"<tr><td class=\"header\" colspan=\"2\">%s:&nbsp;%s, %s</td></tr>\n",text[104],UserSortField,UserSortOrder);
263 fprintf(fp_tt,"<tr><th class=\"header3\" colspan=2>%s</th></tr>\n",text[32]);
264
265 fputs("</table></center>\n",fp_tt);
266 fputs("<center><table cellpadding=\"0\" cellspacing=\"2\">\n",fp_tt);
267 fputs("<tr><td></td><td></td></tr>",fp_tt);
268 bzero(tmp4, MAXLEN);
269 strncpy(tmp4,text[110],4);
270 fprintf(fp_tt,"<tr><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text[91],tmp4,text[110]+5);
271 }
272
273 sprintf(html,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accurl,accdia,acchora);
274
275 if(strcmp(html,html_old) != 0)
276 fputs(html,fp_tt);
277 strcpy(html_old, html);
278 } else bzero(ltext110, 50);
279
280 strcpy(wcrc,acccode);
281 if (getword(crc2,sizeof(crc2),wcrc,'/')<0) {
282 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp3);
283 exit(1);
284 }
285
286 if(strstr(crc2,"MISS") != 0)
287 oucache+=my_atoll(accbytes);
288 else incache+=my_atoll(accbytes);
289
290 strcpy(oldurl,accurl);
291
292 if(strcmp(accuser,oldaccuser) != 0) {
293 strcpy(wdirname,dirname);
294 day_totalize(tmp,oldaccuser,indexonly);
295 }
296
297 strcpy(oldaccuser,accuser);
298 strcpy(oldacccode,acccode);
299 strcpy(oldaccelap,accelap);
300 strcpy(oldaccip,accip);
301 strcpy(oldaccdia,accdia);
302 strcpy(oldacchora,acchora);
303
304 }
305 bzero(user,MAXLEN);
306 fclose(fp_in);
307 unlink(tmp3);
308 }
309
310 strcpy(oldmsg,"OK");
311 if(strstr(oldacccode,"DENIED") != 0)
312 sprintf(oldmsg,"%s",text[46]);
313 strcpy(wdirname,dirname);
314 if(strlen(oldaccuser) == 0)
315 strcpy(oldaccuser,accuser);
316 gravatmpf(oldaccuser,wdirname,oldurl,nacc,nbytes,oldmsg,nelap,indexonly,incache,oucache);
317 strcpy(wdirname,dirname);
318 gravager(wdirname,oldaccuser,nacc,oldurl,nbytes,oldaccip,oldacchora,oldaccdia,nelap,incache,oucache);
319 strcpy(wdirname,dirname);
320 day_totalize(tmp,oldaccuser,indexonly);
321
322 tmpsort();
323
324 strcpy(wdirname,dirname);
325 totalger(wdirname, debug, outdir);
326
327 if(strlen(email) == 0) {
328 if(strstr(ReportType,"downloads") != 0) download_report();
329
330 if(strlen(DansGuardianConf) > 0) {
331 strcpy(wdirname,dirname);
332 dansguardian_log();
333 }
334
335 strcpy(wdirname,dirname);
336 squidguard_log();
337
338 strcpy(wdirname,dirname);
339 topuser();
340
341 if(strstr(ReportType,"topsites") != 0) topsites();
342
343 if(strstr(ReportType,"sites_users") != 0) siteuser();
344 gen_denied_report();
345
346 strcpy(wdirname,dirname);
347 authfail_report();
348
349 if(smartfilter) smartfilter_report();
350
351 if(strlen(DansGuardianConf) > 0) dansguardian_report();
352
353 squidguard_report();
354
355 if(strstr(ReportType,"users_sites") != 0) htmlrel();
356
357 make_index();
358
359 if(strncmp(SuccessfulMsg,"yes",3) == 0) fprintf(stderr, "SARG: %s %s\n",text[47],dirname);
360 } else {
361 strcpy(wdirname,dirname);
362 geramail(wdirname, debug, outdir, userip, email, TempDir);
363
364 if((strcmp(email,"stdout") != 0) && (strncmp(SuccessfulMsg,"yes",3) == 0))
365 fprintf(stderr, "SARG: %s %s\n",text[48],email);
366 }
367
368 if(indexonly) {
369 strcpy(wdirname,dirname);
370 index_only(wdirname, debug);
371 }
372
373 if(strlen(email) < 0)
374 removetmp(dirname);
375
376 return;
377 }
378
379 static void maketmp(const char *user, const char *dirname, int debug, int indexonly)
380 {
381
382 FILE *fp_ou;
383
384 char wdirname[MAXLEN];
385
386 if(indexonly) return;
387 if(strstr(ReportType,"users_sites") == 0) return;
388
389 strcpy(wdirname,tmp);
390 strcat(wdirname,"/");
391 strcat(wdirname,user);
392
393 if(debug){
394 sprintf(msg,"%s: %s",text[49],wdirname);
395 debuga(msg);
396 }
397
398 strcat(wdirname,".utmp");
399 if((fp_ou=fopen(wdirname,"w"))==NULL){
400 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
401 exit(1);
402 }
403
404 fclose(fp_ou);
405 return;
406 }
407
408
409 static void maketmp_hour(const char *user, const char *dirname, int indexonly)
410 {
411
412 FILE *fp_ou;
413
414 char wdirname[MAXLEN];
415
416 if(indexonly) return;
417 if(strstr(ReportType,"users_sites") == 0) return;
418
419 strcpy(wdirname,tmp);
420 strcat(wdirname,"/");
421 strcat(wdirname,user);
422
423 strcat(wdirname,".htmp");
424 if((fp_ou=fopen(wdirname,"w"))==NULL){
425 fprintf(stderr, "SARG: (report-1) %s: %s - %s\n",text[45],wdirname,strerror(errno));
426 exit(1);
427 }
428
429 fclose(fp_ou);
430 return;
431 }
432
433
434 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)
435 {
436
437 FILE *fp_ou;
438
439 char wdirname[MAXLEN];
440
441 if(indexonly) return;
442 if(strstr(ReportType,"users_sites") == 0) return;
443
444 strcpy(wdirname,tmp);
445 strcat(wdirname,"/");
446 strcat(wdirname,oldaccuser);
447 strcat(wdirname,".utmp");
448
449 if((fp_ou=fopen(wdirname,"a"))==NULL){
450 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
451 exit(1);
452 }
453
454 my_lltoa(nacc,val1,15);
455 my_lltoa(nbytes,val2,15);
456 my_lltoa(nelap,val3,15);
457 my_lltoa(incache,val4,15);
458 my_lltoa(oucache,val5,15);
459 fprintf(fp_ou,"%s %s %s %s %s %s %s\n",val1,val2,oldurl,oldmsg,val3,val4,val5);
460
461 fclose(fp_ou);
462 ttopen=0;
463
464 if(fp_tt) {
465 fputs("</table>\n",fp_tt);
466 fputs("</body>\n</html>\n",fp_tt);
467 fclose(fp_tt);
468 }
469
470 return;
471
472 }
473
474
475 static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly)
476 {
477
478 FILE *fp_ou;
479
480 char wdirname[MAXLEN];
481
482 if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
483
484 strcpy(wdirname,tmp);
485 strcat(wdirname,"/");
486 strcat(wdirname,user);
487 strcat(wdirname,".htmp");
488
489 if((fp_ou=fopen(wdirname,"a"))==NULL){
490 fprintf(stderr, "SARG: (report-2) %s: %s - %s\n",text[45],wdirname,strerror(errno));
491 exit(1);
492 }
493
494 if(strcmp(datetimeby,"bytes") == 0) fprintf(fp_ou,"%s %s %s\n",data,hora,bytes);
495 else fprintf(fp_ou,"%s %s %s\n",data,hora,elap);
496
497 fclose(fp_ou);
498
499 return;
500 }
501
502
503 static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly)
504 {
505
506 FILE *fp_ou;
507
508 char wdirname[MAXLEN];
509
510 if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
511
512 strcpy(wdirname,tmp);
513 strcat(wdirname,"/");
514 strcat(wdirname,user);
515 strcat(wdirname,".ip");
516
517 if((fp_ou=fopen(wdirname,"a"))==NULL){
518 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
519 exit(1);
520 }
521
522 fprintf(fp_ou,"%s %s %s %s %s %s\n",ip,url,data,hora,tam,elap);
523
524 fclose(fp_ou);
525
526 return;
527
528 }
529
530
531 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)
532 {
533
534 FILE *fp_ou;
535
536 char wdirname[MAXLEN];
537
538 if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
539
540 strcpy(wdirname,tmp);
541 strcat(wdirname,"/");
542 strcat(wdirname,oldaccuser);
543 strcat(wdirname,".utmp");
544
545 if((fp_ou=fopen(wdirname,"a"))==NULL){
546 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
547 exit(1);
548 }
549
550 my_lltoa(nacc,val1,15);
551 my_lltoa(nbytes,val2,15);
552 my_lltoa(nelap,val3,15);
553 my_lltoa(incache,val4,15);
554 my_lltoa(oucache,val5,15);
555 fprintf(fp_ou,"%s %s %s %s %s %s %s\n",val1,val2,oldurl,oldmsg,val3,val4,val5);
556
557 fclose(fp_ou);
558 ttopen=0;
559 ind2=0;
560
561 if(fp_tt) {
562 fputs("</table>\n",fp_tt);
563 fputs("</html>\n",fp_tt);
564 fclose(fp_tt);
565 }
566
567 return;
568
569 }
570
571
572 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)
573 {
574
575 FILE *fp_ou;
576
577 strcat(dirname,"/");
578 strcat(dirname,"sarg-general");
579
580 if((fp_ou=fopen(dirname,"a"))==NULL){
581 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],dirname);
582 exit(1);
583 }
584
585 my_lltoa(nacc,val1,15);
586 my_lltoa(nbytes,val2,15);
587 my_lltoa(nelap,val3,15);
588 my_lltoa(incache,val4,15);
589 my_lltoa(oucache,val5,15);
590 fprintf(fp_ou,"%s %s %s %s %s %s %s %s %s %s\n",user,val1,val2,url,ip,hora,dia,val3,val4,val5);
591
592 fclose(fp_ou);
593 return;
594
595 }
596
597 static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart)
598 {
599
600 FILE *fp_ou;
601
602 char wdirname[MAXLEN];
603
604 sprintf(wdirname,"%s/smartfilter.unsort",dirname);
605
606 if((fp_ou=fopen(wdirname,"a"))==NULL){
607 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
608 exit(1);
609 }
610
611 fprintf(fp_ou,"%s %s %s %s %s %s\n",user,data,hora,ip,url,smart);
612 fputs("</body>\n</html>\n",fp_tt);
613
614 fclose(fp_ou);
615
616 return;
617
618 }