]> git.ipfire.org Git - thirdparty/sarg.git/blob - html.c
Fix more messages to translate
[thirdparty/sarg.git] / html.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 htmlrel(void)
31 {
32 DIR *dirp;
33 FILE *fp_in, *fp_ou, *fp_ip, *fp_ip2, *fp_usr;
34
35 struct dirent *direntp;
36 long long int nnbytes=0, unbytes=0, tnbytes=0, totbytes=0, totbytes2=0;
37 long long int totelap=0, totelap2=0, nnelap=0, unelap=0, tnelap=0;
38 long long int incache=0, oucache=0, tnincache=0, tnoucache=0, twork=0;
39 long long int ltemp;
40 long long int ntotuser;
41 long long int userbytes, userelap;
42 char *buf;
43 char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN];
44 char *url, tmsg[50], csort[MAXLEN];
45 char period[MAXLEN], user[MAXLEN], duser[MAXLEN];
46 char userhora[9], userdia[9];
47 char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN];
48 char denied_report[255];
49 char *str;
50 char warea[MAXLEN];
51 char totuser[8];
52 char ltext110[100];
53 char tmp6[MAXLEN];
54 long long int tnacc=0, ttnacc=0, unacc=0;
55 double perc=0, perc2=0, ouperc=0, inperc=0;
56 char *s;
57 int count;
58 int cstatus;
59 const char txtext[]=".txt";
60 int dlen;
61 char siteind[MAX_TRUNCATED_URL];
62 struct getwordstruct gwarea;
63 struct longlinestruct line,line1;
64 struct generalitemstruct item;
65 const struct userinfostruct *uinfo;
66
67 if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
68
69 strcpy(tmp2,TempDir);
70 strcat(tmp2,"/sargtmp.unsort");
71
72 strcpy(tmp3,TempDir);
73 strcat(tmp3,"/sargtmp.log");
74
75 snprintf(arqper,sizeof(arqper),"%s/sarg-period",outdirname);
76 if ((fp_in = fopen(arqper, "r")) == 0){
77 debuga(_("(html1) Cannot open file %s\n"),arqper);
78 exit(1);
79 }
80 if (!fgets(period,sizeof(period),fp_in)) {
81 debuga(_("(html1) read error in %s\n"),arqper);
82 exit(1);
83 }
84 fclose(fp_in);
85
86 snprintf(arqper,sizeof(arqper),"%s/sarg-general",outdirname);
87 if ((fp_in = fopen(arqper, "r")) == 0){
88 debuga(_("(html2) Cannot open file %s\n"),arqper);
89 exit(1);
90 }
91 if (longline_prepare(&line)<0) {
92 debuga(_("Not enough memory to read file %s\n"),arqper);
93 exit(1);
94 }
95 ttnacc=0;
96 totbytes=0;
97 totelap=0;
98 while((buf=longline_read(fp_in,&line))!=NULL) {
99 ger_read(buf,&item,arqper);
100 if(item.total) {
101 ttnacc+=item.nacc;
102 totbytes+=item.nbytes;
103 totelap+=item.nelap;
104 }
105 }
106 fclose(fp_in);
107 longline_free(&line);
108
109 snprintf(arqper,sizeof(arqper),"%s/sarg-users",outdirname);
110 if ((fp_in = fopen(arqper, "r")) == 0){
111 debuga(_("(html11) Cannot open file %s\n"),arqper);
112 exit(1);
113 }
114 if (!fgets(totuser,sizeof(totuser),fp_in)) {
115 debuga(_("(html11) read error in %s\n"),arqper);
116 exit(1);
117 }
118 fclose(fp_in);
119 ntotuser=my_atoll(totuser);
120 if (ntotuser<=0) ntotuser=1;
121
122 dirp = opendir(tmp);
123 while ( (direntp = readdir( dirp )) != NULL ) {
124 dlen=strlen(direntp->d_name)-(sizeof(txtext)-1);
125 if (dlen<0) continue;
126 if(strcmp(direntp->d_name+dlen,txtext) != 0)
127 continue;
128
129 count=1;
130 if (dlen>0) {
131 if (dlen>=sizeof(user)) continue;
132 strncpy(user,direntp->d_name,dlen);
133 user[dlen]=0;
134 } else {
135 user[0]=0;
136 }
137
138 uinfo=userinfo_find_from_file(user);
139 if (!uinfo) {
140 debuga(_("Unknown user ID %s in directory %s\n"),user,tmp);
141 exit(1);
142 }
143 str=strrchr(user,'.');
144 if (str)
145 strcpy(denied_report,str+1);
146 else
147 strcpy(denied_report,user);
148
149 if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,user)>=sizeof(warea)) {
150 debuga(_("Destination directory too long: %s/%s\n"),outdirname,user);
151 exit(1);
152 }
153 mkdir(warea,0755);
154
155 report_day(uinfo);
156 greport_day(uinfo);
157
158 if (snprintf(arqin,sizeof(arqin),"%s/%s",tmp,direntp->d_name)>=sizeof(arqin)) {
159 debuga(_("Input file name too long: %s/%s\n"),tmp,direntp->d_name);
160 exit(1);
161 }
162 if (snprintf(arqou,sizeof(arqou),"%s/%s/%s.html",outdirname,uinfo->filename,uinfo->filename)>=sizeof(arqou)) {
163 debuga(_("Output file name too long: %s/%s/%s.html\n"),outdirname,uinfo->filename,uinfo->filename);
164 exit(1);
165 }
166 if (snprintf(duser,sizeof(duser),"%s/%s/denied_%s.html",tmp,direntp->d_name,denied_report)>=sizeof(duser)) {
167 debuga(_("File name too long: %s/%s/denied_%s.html\n"),tmp,direntp->d_name,denied_report);
168 exit(1);
169 }
170 if(access(duser, R_OK) != 0)
171 denied_report[0]='\0';
172
173 if ((fp_in = fopen(arqin, "r")) == 0){
174 debuga(_("(html3) Cannot open file %s\n"),arqin);
175 exit(1);
176 }
177
178 if (longline_prepare(&line)<0) {
179 debuga(_("Not enough memory to read file %s\n"),arqin);
180 exit(1);
181 }
182
183 tnacc=0;
184 tnbytes=0;
185 tnelap=0;
186 tnincache=0;
187 tnoucache=0;
188 while((buf=longline_read(fp_in,&line))!=NULL) {
189 getword_start(&gwarea,buf);
190 if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
191 debuga(_("There is a broken number of access in file %s\n"),arqin);
192 exit(1);
193 }
194 tnacc+=ltemp;
195 if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
196 debuga(_("There is a broken downloaded size in file %s\n"),arqin);
197 exit(1);
198 }
199 tnbytes+=ltemp;
200 if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
201 debuga(_("There is a broken url in file %s\n"),arqin);
202 exit(1);
203 }
204 if (getword_skip(MAXLEN,&gwarea,'\t')<0) {
205 debuga(_("There is a broken access code in file %s\n"),arqin);
206 exit(1);
207 }
208 if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
209 debuga(_("There is a broken elapsed time in file %s\n"),arqin);
210 exit(1);
211 }
212 tnelap+=ltemp;
213 if (getword_atoll(&ltemp,&gwarea,'\t')<0) {
214 debuga(_("There is a broken in-cache volume in file %s\n"),arqin);
215 exit(1);
216 }
217 tnincache+=ltemp;
218 if (getword_atoll(&ltemp,&gwarea,'\n')<0) {
219 debuga(_("There is a broken out-cache volume in file %s\n"),arqin);
220 exit(1);
221 }
222 tnoucache+=ltemp;
223 }
224
225 rewind(fp_in);
226
227 if ((fp_ou = fopen(arqou, "w")) == 0){
228 debuga(_("(html5) Cannot open file %s\n"),arqou);
229 exit(1);
230 }
231
232 write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("User report"));
233 fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("Period"),period);
234 fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("User"),uinfo->label);
235 fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s, %s</td></tr>\n",_("Sort"),UserSortField,UserSortOrder);
236 fprintf(fp_ou,"<tr><td class=\"header_c\">%s %s</td></tr>\n",_("User"),_("Report"));
237 //fputs("<tr><td></td></tr>\n",fp_ou);
238 close_html_header(fp_ou);
239
240 fputs("<div class=\"report\"><table cellpadding=\"2\" cellspacing=\"1\">\n",fp_ou);
241
242 if(denied_report[0]!='\0') {
243 fprintf(fp_ou,"<tr><td class=\"header_l\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a> %s</td></tr>\n",denied_report,_("SmartFilter"),_("Report"));
244 }
245
246 fprintf(fp_ou,"<tr><th></th><th class=\"header_l\">%s</th>",_("ACCESSED SITE"));
247
248 if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
249 fprintf(fp_ou,"<th class=\"header_l\">%s</th>",_("CONNECT"));
250 if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
251 fprintf(fp_ou,"<th class=\"header_l\">%s</th>",_("BYTES"));
252 if((UserReportFields & USERREPORTFIELDS_SETYB) != 0)
253 fprintf(fp_ou,"<th class=\"header_l\">%%%s</th>",_("BYTES"));
254 if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0)
255 fprintf(fp_ou,"<th class=\"header_c\" colspan=\"2\">%s-%s-%s</th>",_("IN"),_("CACHE"),_("OUT"));
256 if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
257 fprintf(fp_ou,"<th class=\"header_l\">%s</th>",_("ELAPSED TIME"));
258 if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
259 fprintf(fp_ou,"<th class=\"header_l\">%s</th>",_("MILISEC"));
260 if((UserReportFields & USERREPORTFIELDS_PTIME) != 0)
261 fprintf(fp_ou,"<th class=\"header_l\">%%%s</th>",_("TIME"));
262
263 fputs("</tr>\n",fp_ou);
264
265 if(debug) {
266 debuga(_("Making report: %s\n"),uinfo->id);
267 }
268
269 while((buf=longline_read(fp_in,&line))!=NULL) {
270 getword_start(&gwarea,buf);
271 if (getword_atoll(&twork,&gwarea,'\t')<0) {
272 debuga(_("Maybe you have a broken number of access in your %s file\n"),arqin);
273 exit(1);
274 }
275 if (getword_atoll(&nnbytes,&gwarea,'\t')<0) {
276 debuga(_("Maybe you have a broken number of bytes in your %s file\n"),arqin);
277 exit(1);
278 }
279 if (getword_ptr(buf,&url,&gwarea,'\t')<0) {
280 debuga(_("Maybe you have a broken url in your %s file\n"),arqin);
281 exit(1);
282 }
283 if (getword(tmsg,sizeof(tmsg),&gwarea,'\t')<0) {
284 debuga(_("Maybe you have a broken status in your %s file\n"),arqin);
285 exit(1);
286 }
287 if (getword_atoll(&nnelap,&gwarea,'\t')<0) {
288 debuga(_("Maybe you have a broken elapsed time in your %s file\n"),arqin);
289 exit(1);
290 }
291 if (getword_atoll(&incache,&gwarea,'\t')<0) {
292 debuga(_("Maybe you have a broken in cache column in your %s file\n"),arqin);
293 exit(1);
294 }
295 if (getword_atoll(&oucache,&gwarea,'\n')<0) {
296 debuga(_("Maybe you have a broken not in cache column in your %s file (%d)\n"),arqin,__LINE__);
297 exit(1);
298 }
299
300 if(UserReportLimit<=0 || count<=UserReportLimit) {
301 fputs("<tr>",fp_ou);
302
303 if(IndexTree == INDEX_TREE_DATE)
304 sprintf(tmp6,"../%s",ImageFile);
305 else
306 strcpy(tmp6,"../../images");
307
308 if((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) {
309 s=_("DATE/TIME");
310 for(z1=0 ; z1<sizeof(ltext110)-1 && s[z1] ; z1++)
311 ltext110[z1]=tolower(s[z1]);
312 ltext110[z1]='\0';
313 url_to_file(url,siteind,sizeof(siteind));
314 fprintf(fp_ou,"<td class=\"data\"><a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" title=\"%s %s\" alt=\"T\"></a></td>",uinfo->filename,siteind,tmp6,ltext110,_("Report"));
315 } else {
316 fprintf(fp_ou,"<td class=\"data\"></td>");
317 }
318
319 if(Privacy)
320 fprintf(fp_ou,"<td class=\"data2\"><span style=\"color:%s;\">%s</span></td>",PrivacyStringColor,PrivacyString);
321 else {
322 fputs("<td class=\"data2\">",fp_ou);
323 if(BlockIt[0]!='\0') {
324 fprintf(fp_ou,"<a href=\"%s%s?url=",wwwDocumentRoot,BlockIt);
325 output_html_url(fp_ou,url);
326 fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a>&nbsp;",tmp6);
327 }
328 fputs("<a href=\"http://",fp_ou);
329 output_html_url(fp_ou,url);
330 fputs("\">",fp_ou);
331 output_html_string(fp_ou,url,100);
332 fputs("</a></td>",fp_ou);
333 }
334
335 if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
336 fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum(twork,1));
337 if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
338 fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum(nnbytes,1));
339 if((UserReportFields & USERREPORTFIELDS_SETYB) != 0) {
340 perc=(tnbytes) ? nnbytes * 100. / tnbytes : 0.;
341 fprintf(fp_ou,"<td class=\"data\">%3.2lf%%</td>",perc);
342 }
343 if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0) {
344 inperc=(nnbytes) ? incache * 100. / nnbytes : 0.;
345 ouperc=(nnbytes) ? oucache * 100. / nnbytes : 0.;
346 fprintf(fp_ou,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",inperc,ouperc);
347 }
348 if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
349 fprintf(fp_ou,"<td class=\"data\">%s</td>",buildtime(nnelap));
350 if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
351 fprintf(fp_ou,"<td class=\"data\">%s</td>",fixnum2(nnelap,1));
352 if((UserReportFields & USERREPORTFIELDS_PTIME) != 0) {
353 perc2=(tnelap) ? nnelap * 100. / tnelap : 0.;
354 fprintf(fp_ou,"<td class=\"data\">%3.2lf%%</td>",perc2);
355 }
356
357 if(strncmp(tmsg,"OK",2) != 0)
358 fprintf(fp_ou,"<td class=\"data\">%s</td>",_("DENIED"));
359
360 fputs("</tr>\n",fp_ou);
361 count++;
362 }
363
364 if(iprel) {
365 if (snprintf(arqip,sizeof(arqip),"%s/%s.ip",tmp,uinfo->filename)>=sizeof(arqip)) {
366 debuga(_("File name too long: %s/%s.ip\n"),tmp,uinfo->filename);
367 exit(1);
368 }
369
370 if ((fp_ip = fopen(arqip, "r")) == 0){
371 debuga(_("(html6) Cannot open file %s\n"),arqip);
372 exit(1);
373 }
374
375 if ((fp_ip2 = MY_FOPEN(tmp2, "a")) == 0){
376 debuga(_("(html7) Cannot open file %s\n"),tmp2);
377 exit(1);
378 }
379
380 if (longline_prepare(&line1)<0) {
381 debuga(_("Not enough memory to read file %s\n"),arqip);
382 exit(1);
383 }
384 while((buf=longline_read(fp_ip,&line1))!=NULL) {
385 if(strstr(buf,url) != 0)
386 fputs(buf,fp_ip2);
387 }
388 longline_free(&line1);
389
390 fclose(fp_ip);
391 fclose(fp_ip2);
392
393 sprintf(csort,"sort -n -T \"%s\" -k 1,1 -k 5,5 -o \"%s\" \"%s\"",TempDir,tmp3,tmp2);
394 cstatus=system(csort);
395 if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
396 debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
397 debuga(_("sort command: %s\n"),csort);
398 exit(1);
399 }
400
401 if ((fp_ip = MY_FOPEN(tmp3, "r")) == 0) {
402 debuga(_("(html8) Cannot open file %s\n"),tmp3);
403 exit(1);
404 }
405
406 olduserip[0]='\0';
407
408 if (longline_prepare(&line1)<0) {
409 debuga(_("Not enough memory to read file %s\n"),arqip);
410 exit(1);
411 }
412 while((buf=longline_read(fp_ip,&line1))!=NULL) {
413 getword_start(&gwarea,buf);
414 if (getword(user_ip,sizeof(user_ip),&gwarea,'\t')<0) {
415 debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3);
416 exit(1);
417 }
418 if (getword_ptr(NULL,NULL,&gwarea,'\t')<0) {
419 debuga(_("Maybe you have a broken user url in your %s file\n"),tmp3);
420 exit(1);
421 }
422 if (getword(userdia,sizeof(userdia),&gwarea,'\t')<0) {
423 debuga(_("Maybe you have a broken day in your %s file\n"),tmp3);
424 exit(1);
425 }
426 if (getword(userhora,sizeof(userhora),&gwarea,'\t')<0) {
427 debuga(_("Maybe you have a broken time in your %s file\n"),tmp3);
428 exit(1);
429 }
430 if (getword_atoll(&userbytes,&gwarea,'\t')<0) {
431 debuga(_("Maybe you have a broken size in your %s file\n"),tmp3);
432 exit(1);
433 }
434 if (getword_atoll(&userelap,&gwarea,'\t')<0) {
435 debuga(_("Maybe you have a broken elapsed time in your %s file (%d)\n"),tmp3,__LINE__);
436 exit(1);
437 }
438 if(strcmp(user_ip,olduserip) != 0) {
439 sprintf(wwork1,"%s",fixnum(unbytes,1));
440 fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%lld</td></tr>\n",olduserip,wwork1,buildtime(unelap),unelap);
441
442 strcpy(olduserip,user_ip);
443 unacc=0;
444 unbytes=0;
445 unelap=0;
446 }
447
448 unbytes=unbytes+userbytes;
449 unelap=unelap+userelap;
450 }
451
452 fclose(fp_ip);
453 longline_free(&line1);
454
455 unlink(tmp2);
456 unlink(tmp3);
457
458 sprintf(wwork1,"%s",fixnum(unbytes,1));
459 fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%lld</td></tr>\n",olduserip,wwork1,buildtime(unelap),unelap);
460 }
461
462 unacc=0;
463 unbytes=0;
464 unelap=0;
465 }
466
467 fclose(fp_in);
468 longline_free(&line);
469
470 if(iprel)
471 unlink(arqip);
472 unlink(arqin);
473
474 if((UserReportFields & USERREPORTFIELDS_TOTAL) != 0) {
475 fprintf(fp_ou,"<tr><th></th><th class=\"header_l\">%s</th>",_("TOTAL"));
476 if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
477 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",fixnum(tnacc,1));
478 if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
479 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",fixnum(tnbytes,1));
480 if((UserReportFields & USERREPORTFIELDS_SETYB) != 0) {
481 perc=(totbytes) ? tnbytes *100. / totbytes :0.;
482 fprintf(fp_ou,"<th class=\"header_r\">%3.2lf%%</th>",perc);
483 }
484 if((UserReportFields & USERREPORTFIELDS_IN_CACHE_OUT) != 0) {
485 inperc=(tnbytes) ? tnincache * 100. / tnbytes : 0.;
486 ouperc=(tnbytes) ? tnoucache * 100. / tnbytes : 0.;
487 fprintf(fp_ou,"<th class=\"header_r\">%3.2lf%%</th><th class=\"header_r\">%3.2lf%%</th>",inperc,ouperc);
488 }
489 if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
490 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",buildtime(tnelap));
491 if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
492 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",fixnum2(tnelap,1));
493 if((UserReportFields & USERREPORTFIELDS_PTIME) != 0) {
494 perc2=(totelap) ? tnelap * 100. / totelap : 0.;
495 fprintf(fp_ou,"<th class=\"header_r\">%3.2lf%%</th>",perc2);
496 }
497 fputs("</tr>\n",fp_ou);
498 }
499
500 if(PerUserLimit > 0) {
501 if(tnbytes > (PerUserLimit*1000000)) {
502 limit_flag=0;
503 if(access(PerUserLimitFile, R_OK) == 0) {
504 if((fp_usr = fopen(PerUserLimitFile, "r")) == 0) {
505 fprintf(stderr, "SARG: (html9) %s: %s\n",_("Cannot open file"),PerUserLimitFile);
506 exit(1);
507 }
508 while(fgets(tmp6,sizeof(tmp6),fp_usr)!=NULL) {
509 fixendofline(tmp6);
510 if(strcmp(tmp6,uinfo->label) == 0) {
511 limit_flag=1;
512 break;
513 }
514 }
515 fclose(fp_usr);
516 }
517
518 if(!limit_flag) {
519 if((fp_usr = fopen(PerUserLimitFile, "a")) == 0) {
520 debuga(_("(html10) Cannot open file %s\n"),PerUserLimitFile);
521 exit(1);
522 }
523 fprintf(fp_usr,"%s\n",uinfo->label);
524 fclose(fp_usr);
525
526 if(debug)
527 debuga(_("User %s limit exceeded (%d MB). Added to file %s\n"),uinfo->label,PerUserLimit,PerUserLimitFile);
528 }
529 }
530 }
531
532 // if(indexonly) {
533 // unlink(arqou);
534 // continue;
535 // }
536
537 if ((ReportType & REPORT_TYPE_TOPUSERS) != 0 && (UserReportFields & USERREPORTFIELDS_AVERAGE) != 0) {
538 totbytes2=totbytes/ntotuser;
539 totelap2=totelap/ntotuser;
540
541 fprintf(fp_ou,"<tr><th></th><th class=\"header_l\">%s</th>",_("AVERAGE"));
542 if((UserReportFields & USERREPORTFIELDS_CONNECT) != 0)
543 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",fixnum(ttnacc/ntotuser,1));
544 if((UserReportFields & USERREPORTFIELDS_BYTES) != 0)
545 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",fixnum(totbytes2,1));
546 fprintf(fp_ou,"<th></th><th></th><th></th>");
547 if((UserReportFields & USERREPORTFIELDS_USED_TIME) != 0)
548 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",buildtime(totelap2));
549 if((UserReportFields & USERREPORTFIELDS_MILISEC) != 0)
550 fprintf(fp_ou,"<th class=\"header_r\">%s</th>",fixnum2(totelap2,1));
551 if((UserReportFields & USERREPORTFIELDS_PTIME) != 0) {
552 perc2 = (totelap) ? totelap2 * 100. / totelap : 0.;
553 fprintf(fp_ou,"<th class=\"header_r\">%3.2lf%%</th>",perc2);
554 }
555 fputs("</tr>\n",fp_ou);
556 }
557
558 fputs("</table></div>\n",fp_ou);
559 write_html_trailer(fp_ou);
560 fclose(fp_ou);
561
562 htaccess(uinfo);
563 }
564
565 (void)closedir(dirp);
566 greport_cleanup();
567
568 return;
569 }