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