]> git.ipfire.org Git - thirdparty/sarg.git/blob - topuser.c
5a441c9d2dbb069790f5843f904d795e3a4a09cf
[thirdparty/sarg.git] / topuser.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 void topuser(void)
31 {
32
33 FILE *fp_in = NULL, *fp_ou = NULL, *fp_top1 = NULL, *fp_top2 = NULL, *fp_top3 = NULL;
34 long long int ttnbytes=0, ttnacc=0, tnacc=0;
35 long long int tnbytes=0, ttnelap=0, tnelap=0;
36 long long int tnincache=0, tnoucache=0, ttnincache=0, ttnoucache=0;
37 long long int nbytes;
38 long long int nacc;
39 long long int elap, incac, oucac;
40 double perc=0.00;
41 double perc2=0.00;
42 double inperc=0.00, ouperc=0.00;
43 int posicao=0;
44 char olduser[MAXLEN], csort[MAXLEN], period[MAXLEN], arqper[MAXLEN];
45 char wger[MAXLEN], top1[MAXLEN], top2[MAXLEN], top3[MAXLEN];
46 char user[MAXLEN], tusr[MAXLEN];
47 char ip[MAXLEN], time[30], date[30];
48 char ipantes[MAXLEN], nameantes[MAXLEN];
49 char sfield[10]="2,2";
50 char order[255]="-r";
51 int totuser=0;
52 int topcount=0;
53 char *s;
54 int cstatus;
55 char warea[MAXLEN];
56 char user2[MAXLEN];
57 char name[MAXLEN];
58 struct getwordstruct gwarea;
59
60 ipantes[0]='\0';
61 nameantes[0]='\0';
62
63 /*
64 * get period
65 */
66 strcpy(arqper,dirname);
67 strcat(arqper,"/sarg-period");
68 if ((fp_in = fopen(arqper, "r")) == 0) {
69 fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],arqper);
70 exit(1);
71 }
72 if (!fgets(period,sizeof(period),fp_in)) {
73 fprintf(stderr,"SARG: (topuser) Read error in %s\n",arqper);
74 exit(1);
75 }
76 fclose(fp_in);
77
78 strcpy(wger,dirname);
79 strcpy(top1,dirname);
80 strcpy(top2,dirname);
81 strcpy(top3,dirname);
82 strcpy(tusr,dirname);
83 strcat(wger,"/sarg-general");
84 strcat(top1,"/top");
85 strcat(top2,"/top.tmp");
86 strcat(tusr,"/sarg-users");
87 strcat(top3,"/index.html");
88
89 ntopuser = 0;
90 if((fp_in=fopen(wger,"r"))==NULL) {
91 fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],wger);
92 exit(1);
93 }
94
95 if((fp_top2=fopen(top2,"w"))==NULL) {
96 fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],top2);
97 exit(1);
98 }
99
100 olduser[0]='\0';
101 totuser=0;
102
103 while(fgets(warea,sizeof(warea),fp_in)) {
104 getword_start(&gwarea,warea);
105 if (getword(user,sizeof(user),&gwarea,'\t')<0) {
106 printf("SARG: Maybe you have a broken user in your %s file.\n",wger);
107 exit(1);
108 }
109 if(strcmp(user,"TOTAL") == 0) {
110 continue;
111 }
112 if (getword_atoll(&nacc,&gwarea,'\t')<0) {
113 printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger);
114 exit(1);
115 }
116 if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
117 printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger);
118 exit(1);
119 }
120 if (getword(url,sizeof(url),&gwarea,'\t')<0) {
121 printf("SARG: Maybe you have a broken url in your %s file.\n",wger);
122 exit(1);
123 }
124 if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
125 printf("SARG: Maybe you have a broken user's IP in your %s file.\n",wger);
126 exit(1);
127 }
128 if (getword(time,sizeof(time),&gwarea,'\t')<0) {
129 printf("SARG: Maybe you have a broken time in your %s file.\n",wger);
130 exit(1);
131 }
132 if (getword(date,sizeof(date),&gwarea,'\t')<0) {
133 printf("SARG: Maybe you have a broken date in your %s file.\n",wger);
134 exit(1);
135 }
136 if (getword_atoll(&elap,&gwarea,'\t')<0) {
137 printf("SARG: Maybe you have a broken download duration in your %s file.\n",wger);
138 exit(1);
139 }
140 if (getword_atoll(&incac,&gwarea,'\t')<0) {
141 printf("SARG: Maybe you have a broken in cache download in your %s file.\n",wger);
142 exit(1);
143 }
144 if (getword_atoll(&oucac,&gwarea,'\n')<0) {
145 printf("SARG: Maybe you have a broken not in cache download in your %s file.\n",wger);
146 exit(1);
147 }
148 if(strcmp(olduser,user) != 0) {
149 totuser++;
150
151 if (olduser[0] != '\0') {
152 my_lltoa(tnbytes,val1,15);
153 my_lltoa(tnacc,val2,15);
154 my_lltoa(tnelap,val3,15);
155 my_lltoa(tnincache,val4,15);
156 my_lltoa(tnoucache,val5,15);
157 fprintf(fp_top2,"%s\t%s\t%s\t%s\t%s\t%s\n",olduser,val1,val2,val3,val4,val5);
158
159 ttnbytes+=tnbytes;
160 ttnacc+=tnacc;
161 ttnelap+=tnelap;
162 ttnincache+=tnincache;
163 ttnoucache+=tnoucache;
164 }
165 strcpy(olduser,user);
166 tnbytes=0;
167 tnacc=0;
168 tnelap=0;
169 tnincache=0;
170 tnoucache=0;
171 }
172
173 tnbytes+=nbytes;
174 tnacc+=nacc;
175 tnelap+=elap;
176 tnincache+=incac;
177 tnoucache+=oucac;
178 }
179 fclose(fp_in);
180
181 if (olduser[0] != '\0') {
182 my_lltoa(tnbytes,val1,15);
183 my_lltoa(tnacc,val2,15);
184 my_lltoa(tnelap,val3,15);
185 my_lltoa(tnincache,val4,15);
186 my_lltoa(tnoucache,val5,15);
187 fprintf(fp_top2,"%s\t%s\t%s\t%s\t%s\t%s\n",olduser,val1,val2,val3,val4,val5);
188
189 ttnbytes+=tnbytes;
190 ttnacc+=tnacc;
191 ttnelap+=tnelap;
192 ttnincache+=tnincache;
193 ttnoucache+=tnoucache;
194 }
195 fclose(fp_top2);
196
197 strup(TopuserSortField);
198 strlow(TopuserSortOrder);
199
200 if(strcmp(TopuserSortField,"USER") == 0)
201 strcpy(sfield,"1,1");
202
203 if(strcmp(TopuserSortField,"CONNECT") == 0)
204 strcpy(sfield,"3,3");
205
206 if(strcmp(TopuserSortField,"TIME") == 0)
207 strcpy(sfield,"4,4");
208
209 if(strcmp(TopuserSortOrder,"normal") == 0)
210 order[0]='\0';
211
212 sprintf(csort,"sort -n -T \"%s\" %s -k %s -o \"%s\" \"%s\"", TempDir, order, sfield, top1, top2);
213 cstatus=system(csort);
214 if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
215 fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
216 fprintf(stderr, "SARG: sort command: %s\n",csort);
217 exit(1);
218 }
219
220 if((fp_top1=fopen(top1,"r"))==NULL) {
221 fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],top1);
222 exit(1);
223 }
224
225 unlink(top2);
226
227 if((fp_top3=fopen(top3,"w"))==NULL) {
228 fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],top3);
229 exit(1);
230 }
231
232 fprintf(fp_top3, "<!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);
233 css(fp_top3);
234 fputs("</head>\n<body class=\"body\">",fp_top3);
235 write_logo_image(fp_top3);
236
237 if(IndexTree == INDEX_TREE_DATE)
238 show_sarg(fp_top3, "../../..");
239 else
240 show_sarg(fp_top3, "..");
241 fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_top3);
242 fprintf(fp_top3,"<tr><th align=\"center\" class=\"title\">%s</th></tr>\n",Title);
243 fprintf(fp_top3,"<tr><td class=\"header3\">%s: %s</td></tr>\n",text[89],period);
244 fprintf(fp_top3,"<tr><td class=\"header3\">%s: %s, %s</td></tr>\n",text[104],TopuserSortField,TopuserSortOrder);
245 fprintf(fp_top3,"<tr><th class=\"header3\">%s</th></tr>\n",text[137]);
246 fputs("</table></div>\n",fp_top3);
247
248 fputs("<div align=\"center\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
249 fputs("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n",fp_top3);
250
251 if((ReportType & REPORT_TYPE_TOPSITES) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"topsites.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[119]);
252 if((ReportType & REPORT_TYPE_SITES_USERS) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"siteuser.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[85]);
253 if(dansguardian_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"dansguardian.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[128]);
254 if(squidguard_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=11><a href=\"squidguard.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[122]);
255 if ((ReportType & REPORT_TYPE_DOWNLOADS) != 0 && download_count && !Privacy && ndownload) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"download.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[125]);
256 if ((ReportType & REPORT_TYPE_DENIED) != 0 && denied_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"denied.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[118]);
257 if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0 && authfail_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"authfail.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[117]);
258 if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"11\"><a href=\"smartfilter.html\"><font class=\"link\">%s</font></a><font class=\"text\"></font></td></tr>\n",text[116]);
259 fputs("<tr><td></td></tr>\n",fp_top3);
260
261 if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
262 fputs("</body>\n</html>\n",fp_top3);
263 fclose (fp_top3);
264 return;
265 }
266
267 fputs("<tr>",fp_top3);
268
269 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
270 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[100]);
271 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0)
272 fputs("<th class=\"header\"></th>",fp_top3);
273 if((TopUserFields & TOPUSERFIELDS_USERID) != 0)
274 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[98]);
275 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
276 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[92]);
277 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
278 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[93]);
279 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
280 fprintf(fp_top3,"<th class=\"header\">%%%s</th>",text[93]);
281 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
282 fprintf(fp_top3,"<th class=\"header3\" colspan=\"2\">%s-%s-%s</th>",text[113],text[114],text[112]);
283 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
284 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[94]);
285 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
286 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[95]);
287 if((TopUserFields & TOPUSERFIELDS_PTIME) != 0)
288 fprintf(fp_top3,"<th class=\"header\">%%%s</th>",text[99]);
289
290 fputs("</tr>\n",fp_top3);
291
292 ntopuser = 0;
293
294 while(fgets(warea,sizeof(warea),fp_top1)) {
295 getword_start(&gwarea,warea);
296 if (getword(user,sizeof(user),&gwarea,'\t')<0) {
297 printf("SARG: Maybe you have a broken user in your %s file.\n",top1);
298 exit(1);
299 }
300 if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
301 printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",top1);
302 exit(1);
303 }
304 if (getword_atoll(&nacc,&gwarea,'\t')<0) {
305 printf("SARG: Maybe you have a broken number of access in your %s file.\n",top1);
306 exit(1);
307 }
308 if (getword_atoll(&elap,&gwarea,'\t')<0) {
309 printf("SARG: Maybe you have a broken elpased time in your %s file.\n",top1);
310 exit(1);
311 }
312 if (getword_atoll(&incac,&gwarea,'\t')<0) {
313 printf("SARG: Maybe you have a broken in-cache size in your %s file.\n",top1);
314 exit(1);
315 }
316 if (getword_atoll(&oucac,&gwarea,'\n')<0) {
317 printf("SARG: Maybe you have a broken out-of-cache size in your %s file.\n",top1);
318 exit(1);
319 }
320 if(nacc < 1)
321 continue;
322 ntopuser = 1;
323 if(TopUsersNum > 0 && topcount >= TopUsersNum) goto final;
324 tnbytes=nbytes;
325 tnelap=elap;
326
327 strcpy(user2,user);
328 if(userip) {
329 fixip(user2);
330 if(Ip2Name) {
331 if(strcmp(user2,ipantes) != 0) {
332 strcpy(ipantes,user2);
333 ip2name(user2,sizeof(user2));
334 strcpy(nameantes,user2);
335 } else strcpy(user2,nameantes);
336 }
337 }
338
339 fputs("<tr>",fp_top3);
340
341 posicao++;
342 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
343 fprintf(fp_top3,"<td class=\"data\">%d</td>",posicao);
344
345 user_find(name, sizeof(name), user2);
346 if(Ip2Name &&
347 ((str=(char *) strstr(name, ".")) != (char *) NULL) &&
348 ((str=(char *) strstr(str+1, ".")) != (char *) NULL))
349 ip2name(name,sizeof(name));
350 if(dotinuser && strchr(name,'_')) {
351 subs(name,sizeof(name),"_",".");
352 }
353
354 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) {
355 sprintf(ltext110,"%s",text[110]);
356 for(s=ltext110; *s; ++s)
357 *s=tolower(*s);
358 fputs("<td class=\"data2\">",fp_top3);
359 #ifdef HAVE_GD
360 if(Graphs) {
361 fprintf(fp_top3,"<a href=\"%s/graph_day.png\"><img src=\"%s/graph.png\" border=\"0\" title=\"%s\" alt=\"G\"></a>&nbsp;",user,ImageFile,text[126]);
362 }
363 #endif
364 fprintf(fp_top3,"<a href=\"%s/d%s.html\"><img src=\"%s/datetime.png\" border=\"0\" title=\"%s",user,user,ImageFile,ltext110);
365 #ifdef HAVE_GD
366 fprintf(fp_top3," %s",text[55]);
367 #endif
368 fputs("\" alt=\"T\"></a></td>",fp_top3);
369 } else {
370 sprintf(val1,"%s/d%s.html",dirname,user);
371 unlink(val1);
372 }
373 if((TopUserFields & TOPUSERFIELDS_USERID) != 0) {
374 if((ReportType & REPORT_TYPE_USERS_SITES) == 0)
375 fprintf(fp_top3,"<td class=\"data2\">%s</td>",name);
376 else
377 fprintf(fp_top3,"<td class=\"data2\"><a href=\"%s/%s.html\">%s</a></td>",user,user,name);
378 }
379 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
380 fprintf(fp_top3,"<td class=\"data\">%s</td>",fixnum(nacc,1));
381 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
382 fprintf(fp_top3,"<td class=\"data\">%s</td>",fixnum(tnbytes,1));
383 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0) {
384 perc=(ttnbytes) ? tnbytes * 100. / ttnbytes : 0.;
385 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td>",perc);
386 }
387 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0) {
388 inperc=(tnbytes) ? incac * 100. / tnbytes : 0.;
389 ouperc=(tnbytes) ? oucac * 100. / tnbytes : 0.;
390 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",inperc,ouperc);
391 }
392 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
393 fprintf(fp_top3,"<td class=\"data\">%s</td>",buildtime(tnelap));
394 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
395 fprintf(fp_top3,"<td class=\"data\">%s</td>",fixnum2(tnelap,1));
396 if((TopUserFields & TOPUSERFIELDS_PTIME) != 0) {
397 perc2=(ttnelap) ? elap * 100. / ttnelap : 0.;
398 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td>",perc2);
399 }
400
401 fputs("</tr>\n",fp_top3);
402
403 topcount++;
404 }
405
406 if((TopUserFields & TOPUSERFIELDS_TOTAL) != 0) {
407
408 fputs("<tr>",fp_top3);
409 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
410 fputs("<td></td>",fp_top3);
411 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0)
412 fputs("<td></td>",fp_top3);
413 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[107]);
414
415 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
416 fprintf(fp_top3,"<th class=\"header2\">%s</th>",fixnum(ttnacc,1));
417 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
418 fprintf(fp_top3,"<th class=\"header2\">%15s</th>",fixnum(ttnbytes,1));
419 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
420 fputs("<td></td>",fp_top3);
421 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
422 {
423 inperc=(ttnbytes) ? ttnincache * 100. / ttnbytes : 0.;
424 ouperc=(ttnbytes) ? ttnoucache *100. / ttnbytes : 0.;
425 fprintf(fp_top3,"<th class=\"header2\">%3.2lf%%</th><th class=\"header2\">%3.2lf%%</th>",inperc,ouperc);
426 }
427 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
428 fprintf(fp_top3,"<th class=\"header2\">%s</th>",buildtime(ttnelap));
429 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
430 fprintf(fp_top3,"<th class=\"header2\">%s</th>",fixnum2(ttnelap,1));
431
432 fputs("</tr>\n",fp_top3);
433 }
434
435 if(ntopuser && (TopUserFields & TOPUSERFIELDS_AVERAGE) != 0) {
436 fputs("<tr>",fp_top3);
437 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
438 fputs("<td></td>",fp_top3);
439 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0)
440 fputs("<td></td>",fp_top3);
441 fprintf(fp_top3,"<th class=\"header\">%s</th>",text[96]);
442
443 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
444 fprintf(fp_top3,"<th class=\"header2\">%s</th>",fixnum(ttnacc/totuser,1));
445 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0) {
446 tnbytes=(totuser) ? ttnbytes / totuser : 0;
447 fprintf(fp_top3,"<th class=\"header2\">%15s</th>",fixnum(tnbytes,1));
448 }
449 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
450 fputs("<td></td>",fp_top3);
451 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
452 fputs("<td></td><td></td>",fp_top3);
453 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
454 fprintf(fp_top3,"<th class=\"header2\">%s</th>",buildtime(ttnelap/totuser));
455 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
456 fprintf(fp_top3,"<th class=\"header2\">%s</th>",fixnum2(ttnelap/totuser,1));
457 fputs("</tr>\n",fp_top3);
458 }
459
460 if(UserAgentLog[0] != '\0') {
461 fputs("<tr><td></td></tr>\n",fp_top3);
462 fputs("<tr><td></td></tr>\n",fp_top3);
463 fputs("<td align=\"left\" colspan=\"8\"><font size=-1><a href=\"useragent.html\">Useragent</a> Report</td>\n",fp_top3);
464 }
465
466 fputs("</table></div>",fp_top3);
467
468 show_info(fp_top3);
469
470 final:
471 fclose(fp_top1);
472 unlink(top1);
473
474 if((fp_ou=fopen(tusr,"w"))==NULL) {
475 fprintf(stderr, "SARG: (topuser) %s: %s\n",text[45],tusr);
476 exit(1);
477 }
478
479 fprintf(fp_ou,"%d\n",totuser);
480
481 fputs("</body>\n</html>\n",fp_top3);
482 fclose(fp_top3);
483 fclose(fp_ou);
484
485 return;
486 }