]> git.ipfire.org Git - thirdparty/sarg.git/blame - report.c
Moved local variables declared at the global scope to the function that use them.
[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
5f3cfd1d
FM
29static void maketmp(const char *user, const char *dirname, int debug, int indexonly);
30static void maketmp_hour(const char *user, const char *dirname, int indexonly);
31static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *accbytes, int indexonly);
32static 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);
33static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly);
34static 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);
35static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart);
36
32e71fa4 37void gerarel(void)
25697a35
GS
38{
39
d6e703cc 40 FILE *fp_in;
25697a35
GS
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];
623c04aa 45 char olduser[MAXLEN], oldmsg[50], acccode[MAXLEN/2 - 1], oldaccelap[10], oldacccode[MAXLEN/2 - 1], user[MAXLEN];
8db846b0 46 char ipantes[MAXLEN], nameantes[MAXLEN];
25697a35 47 char accsmart[MAXLEN];
623c04aa
FM
48 char wcrc[MAXLEN/2 -1];
49 char crc2[MAXLEN/2 -1];
25697a35
GS
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;
8db846b0
FM
59 const char logext[]=".log";
60 int dlen;
25697a35
GS
61
62 ipantes[0]='\0';
63 nameantes[0]='\0';
64 smartfilter=0;
65
d6e703cc
FM
66 sprintf(dirname, "%s%s", outdir, period);
67 sprintf(wdir, "%s%s", outdir, period);
68 strcpy(per1,period);
25697a35
GS
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);
d6e703cc 77 gperiod();
25697a35 78
d6e703cc 79 if(strlen(UserAgentLog) > 0 && email[0] == '\0') useragent();
25697a35
GS
80
81 olduser[0]='\0';
82 strncat(tmp,"/sarg",5);
83
84 dirp = opendir(tmp);
85 while ((direntp = readdir( dirp )) != NULL ) {
8db846b0
FM
86 dlen=strlen(direntp->d_name)-(sizeof(logext)-1);
87 if (dlen<0) continue;
88 if((strcmp(direntp->d_name+dlen,logext) != 0) ||
d6e703cc
FM
89 (strncmp(direntp->d_name,"download.log",12) == 0) ||
90 (strncmp(direntp->d_name,"denied.log",10) == 0) ||
5f3cfd1d 91 (strncmp(direntp->d_name,"authfail.log.unsort",19) == 0))
25697a35 92 continue;
8db846b0
FM
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);
25697a35
GS
95 exit(1);
96 }
8db846b0
FM
97 if((fp_in=fopen(tmp3,"r"))==NULL){
98 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],tmp);
4bcb77cf
FM
99 exit(1);
100 }
8db846b0
FM
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';
25697a35
GS
108 }
109
110 strcpy(wdirname,dirname);
111 maketmp(user,tmp,debug,indexonly);
112 maketmp_hour(user,tmp,indexonly);
113
936c9905
FM
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
25697a35
GS
124 ttopen=0;
125 bzero(html_old, MAXLEN);
126
127 while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
4bcb77cf
FM
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 }
d6e703cc 135 if(strncmp(acccode,"TCP_DENIED/407",14) == 0) continue;
4bcb77cf
FM
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 }
25697a35
GS
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);
a1c55d8c 151 ip2name(accip,sizeof(accip));
25697a35
GS
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 }
5f3cfd1d 189 } else {
25697a35
GS
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;
5f3cfd1d
FM
203 if(strcmp(oldaccuser,accuser) != 0)
204 ind2=0;
32e71fa4 205 }
5f3cfd1d
FM
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
5f3cfd1d
FM
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);
94ff9470
GS
271 }
272
5f3cfd1d 273 sprintf(html,"<tr><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td></tr>\n",accurl,accdia,acchora);
25697a35 274
5f3cfd1d
FM
275 if(strcmp(html,html_old) != 0)
276 fputs(html,fp_tt);
277 strcpy(html_old, html);
278 } else bzero(ltext110, 50);
25697a35 279
5f3cfd1d
FM
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 }
25697a35 285
5f3cfd1d
FM
286 if(strstr(crc2,"MISS") != 0)
287 oucache+=my_atoll(accbytes);
288 else incache+=my_atoll(accbytes);
25697a35 289
5f3cfd1d
FM
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);
25697a35 303
5f3cfd1d
FM
304 }
305 bzero(user,MAXLEN);
306 fclose(fp_in);
307 unlink(tmp3);
25697a35 308 }
25697a35
GS
309
310 strcpy(oldmsg,"OK");
311 if(strstr(oldacccode,"DENIED") != 0)
312 sprintf(oldmsg,"%s",text[46]);
313 strcpy(wdirname,dirname);
d6e703cc
FM
314 if(strlen(oldaccuser) == 0)
315 strcpy(oldaccuser,accuser);
25697a35
GS
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);
d6e703cc 320 day_totalize(tmp,oldaccuser,indexonly);
25697a35
GS
321
322 tmpsort();
323
324 strcpy(wdirname,dirname);
325 totalger(wdirname, debug, outdir);
326
327 if(strlen(email) == 0) {
d6e703cc 328 if(strstr(ReportType,"downloads") != 0) download_report();
25697a35
GS
329
330 if(strlen(DansGuardianConf) > 0) {
331 strcpy(wdirname,dirname);
332 dansguardian_log();
333 }
334
491b862f
GS
335 strcpy(wdirname,dirname);
336 squidguard_log();
25697a35
GS
337
338 strcpy(wdirname,dirname);
339 topuser();
340
d6e703cc 341 if(strstr(ReportType,"topsites") != 0) topsites();
25697a35 342
d6e703cc 343 if(strstr(ReportType,"sites_users") != 0) siteuser();
25697a35
GS
344 gen_denied_report();
345
346 strcpy(wdirname,dirname);
347 authfail_report();
348
d6e703cc 349 if(smartfilter) smartfilter_report();
25697a35 350
d6e703cc 351 if(strlen(DansGuardianConf) > 0) dansguardian_report();
25697a35 352
491b862f 353 squidguard_report();
25697a35 354
d6e703cc 355 if(strstr(ReportType,"users_sites") != 0) htmlrel();
25697a35 356
491b862f 357 make_index();
25697a35 358
d6e703cc 359 if(strncmp(SuccessfulMsg,"yes",3) == 0) fprintf(stderr, "SARG: %s %s\n",text[47],dirname);
25697a35
GS
360 } else {
361 strcpy(wdirname,dirname);
362 geramail(wdirname, debug, outdir, userip, email, TempDir);
363
d6e703cc 364 if((strcmp(email,"stdout") != 0) && (strncmp(SuccessfulMsg,"yes",3) == 0))
25697a35 365 fprintf(stderr, "SARG: %s %s\n",text[48],email);
25697a35
GS
366 }
367
368 if(indexonly) {
369 strcpy(wdirname,dirname);
370 index_only(wdirname, debug);
371 }
372
d6e703cc
FM
373 if(strlen(email) < 0)
374 removetmp(dirname);
25697a35
GS
375
376 return;
377}
378
5f3cfd1d 379static void maketmp(const char *user, const char *dirname, int debug, int indexonly)
25697a35
GS
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){
d2fe0c32 394 debuga("%s: %s",text[49],wdirname);
25697a35
GS
395 }
396
397 strcat(wdirname,".utmp");
398 if((fp_ou=fopen(wdirname,"w"))==NULL){
399 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
400 exit(1);
401 }
402
403 fclose(fp_ou);
404 return;
405}
406
407
5f3cfd1d 408static void maketmp_hour(const char *user, const char *dirname, int indexonly)
25697a35
GS
409{
410
411 FILE *fp_ou;
412
413 char wdirname[MAXLEN];
414
415 if(indexonly) return;
416 if(strstr(ReportType,"users_sites") == 0) return;
417
418 strcpy(wdirname,tmp);
419 strcat(wdirname,"/");
420 strcat(wdirname,user);
421
422 strcat(wdirname,".htmp");
423 if((fp_ou=fopen(wdirname,"w"))==NULL){
424 fprintf(stderr, "SARG: (report-1) %s: %s - %s\n",text[45],wdirname,strerror(errno));
425 exit(1);
426 }
427
428 fclose(fp_ou);
429 return;
430}
431
432
433void 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)
434{
435
436 FILE *fp_ou;
437
25697a35
GS
438 char wdirname[MAXLEN];
439
440 if(indexonly) return;
441 if(strstr(ReportType,"users_sites") == 0) return;
442
443 strcpy(wdirname,tmp);
444 strcat(wdirname,"/");
445 strcat(wdirname,oldaccuser);
446 strcat(wdirname,".utmp");
447
448 if((fp_ou=fopen(wdirname,"a"))==NULL){
449 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
450 exit(1);
451 }
452
453 my_lltoa(nacc,val1,15);
454 my_lltoa(nbytes,val2,15);
455 my_lltoa(nelap,val3,15);
456 my_lltoa(incache,val4,15);
457 my_lltoa(oucache,val5,15);
d6e703cc 458 fprintf(fp_ou,"%s %s %s %s %s %s %s\n",val1,val2,oldurl,oldmsg,val3,val4,val5);
25697a35
GS
459
460 fclose(fp_ou);
461 ttopen=0;
462
463 if(fp_tt) {
464 fputs("</table>\n",fp_tt);
465 fputs("</body>\n</html>\n",fp_tt);
466 fclose(fp_tt);
467 }
468
469 return;
470
471}
472
473
5f3cfd1d 474static void gravatmp_hora(char *dirname, char *user, char *data, char *hora, char *elap, char *bytes, int indexonly)
25697a35
GS
475{
476
477 FILE *fp_ou;
478
25697a35
GS
479 char wdirname[MAXLEN];
480
d6e703cc 481 if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
25697a35
GS
482
483 strcpy(wdirname,tmp);
484 strcat(wdirname,"/");
485 strcat(wdirname,user);
486 strcat(wdirname,".htmp");
487
488 if((fp_ou=fopen(wdirname,"a"))==NULL){
489 fprintf(stderr, "SARG: (report-2) %s: %s - %s\n",text[45],wdirname,strerror(errno));
490 exit(1);
491 }
492
d6e703cc
FM
493 if(strcmp(datetimeby,"bytes") == 0) fprintf(fp_ou,"%s %s %s\n",data,hora,bytes);
494 else fprintf(fp_ou,"%s %s %s\n",data,hora,elap);
25697a35
GS
495
496 fclose(fp_ou);
497
498 return;
499}
500
501
5f3cfd1d 502static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly)
25697a35
GS
503{
504
505 FILE *fp_ou;
506
25697a35
GS
507 char wdirname[MAXLEN];
508
d6e703cc 509 if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
25697a35
GS
510
511 strcpy(wdirname,tmp);
512 strcat(wdirname,"/");
513 strcat(wdirname,user);
514 strcat(wdirname,".ip");
515
516 if((fp_ou=fopen(wdirname,"a"))==NULL){
517 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
518 exit(1);
519 }
520
d6e703cc 521 fprintf(fp_ou,"%s %s %s %s %s %s\n",ip,url,data,hora,tam,elap);
25697a35
GS
522
523 fclose(fp_ou);
524
525 return;
526
527}
528
529
5f3cfd1d 530static 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)
25697a35
GS
531{
532
533 FILE *fp_ou;
534
25697a35
GS
535 char wdirname[MAXLEN];
536
d6e703cc 537 if(indexonly || (strstr(ReportType,"users_sites") == 0)) return;
25697a35
GS
538
539 strcpy(wdirname,tmp);
540 strcat(wdirname,"/");
541 strcat(wdirname,oldaccuser);
542 strcat(wdirname,".utmp");
543
544 if((fp_ou=fopen(wdirname,"a"))==NULL){
545 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
546 exit(1);
547 }
548
549 my_lltoa(nacc,val1,15);
550 my_lltoa(nbytes,val2,15);
551 my_lltoa(nelap,val3,15);
552 my_lltoa(incache,val4,15);
553 my_lltoa(oucache,val5,15);
d6e703cc 554 fprintf(fp_ou,"%s %s %s %s %s %s %s\n",val1,val2,oldurl,oldmsg,val3,val4,val5);
25697a35
GS
555
556 fclose(fp_ou);
557 ttopen=0;
558 ind2=0;
559
560 if(fp_tt) {
561 fputs("</table>\n",fp_tt);
562 fputs("</html>\n",fp_tt);
563 fclose(fp_tt);
564 }
565
566 return;
567
568}
569
570
5f3cfd1d 571static 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)
25697a35
GS
572{
573
574 FILE *fp_ou;
25697a35
GS
575
576 strcat(dirname,"/");
d6e703cc 577 strcat(dirname,"sarg-general");
25697a35
GS
578
579 if((fp_ou=fopen(dirname,"a"))==NULL){
580 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],dirname);
581 exit(1);
582 }
583
584 my_lltoa(nacc,val1,15);
585 my_lltoa(nbytes,val2,15);
586 my_lltoa(nelap,val3,15);
587 my_lltoa(incache,val4,15);
588 my_lltoa(oucache,val5,15);
d6e703cc 589 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
590
591 fclose(fp_ou);
592 return;
593
594}
595
5f3cfd1d 596static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart)
25697a35
GS
597{
598
599 FILE *fp_ou;
600
25697a35
GS
601 char wdirname[MAXLEN];
602
603 sprintf(wdirname,"%s/smartfilter.unsort",dirname);
604
605 if((fp_ou=fopen(wdirname,"a"))==NULL){
606 fprintf(stderr, "SARG: (report) %s: %s\n",text[45],wdirname);
607 exit(1);
608 }
609
d6e703cc 610 fprintf(fp_ou,"%s %s %s %s %s %s\n",user,data,hora,ip,url,smart);
25697a35
GS
611 fputs("</body>\n</html>\n",fp_tt);
612
613 fclose(fp_ou);
614
615 return;
616
617}