2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
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.
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.
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.
27 #include "include/conf.h"
28 #include "include/defs.h"
30 extern struct globalstatstruct globstat
;
34 FILE *fp_in
, *fp_ou
, *fp_ip
, *fp_ip2
, *fp_usr
;
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;
40 long long int ntotuser
;
41 long long int userbytes
, userelap
;
43 char arqin
[MAXLEN
], arqou
[MAXLEN
], arqper
[MAXLEN
], arqip
[MAXLEN
];
44 char *url
, tmsg
[50], csort
[MAXLEN
];
46 char user_ip
[MAXLEN
], olduserip
[MAXLEN
], tmp2
[MAXLEN
], tmp3
[MAXLEN
];
51 long long int tnacc
=0, ttnacc
=0, unacc
=0;
52 double perc
=0, perc2
=0, ouperc
=0, inperc
=0;
55 int have_denied_report
;
56 const char *sort_field
;
57 const char *sort_order
;
59 char siteind
[MAX_TRUNCATED_URL
];
60 struct getwordstruct gwarea
;
62 const struct userinfostruct
*uinfo
;
65 if((ReportType
& REPORT_TYPE_USERS_SITES
) == 0) return;
68 strcat(tmp2
,"/sargtmp.unsort");
71 strcat(tmp3
,"/sargtmp.log");
74 totbytes
=globstat
.nbytes
;
75 totelap
=globstat
.elap
;
77 snprintf(arqper
,sizeof(arqper
),"%s/sarg-users",outdirname
);
78 if ((fp_in
= fopen(arqper
, "r")) == 0){
79 debuga(_("(html11) Cannot open file %s\n"),arqper
);
82 if (!fgets(totuser
,sizeof(totuser
),fp_in
)) {
83 debuga(_("(html11) read error in %s\n"),arqper
);
87 ntotuser
=my_atoll(totuser
);
88 if (ntotuser
<=0) ntotuser
=1;
92 sort_labels(&sort_field
,&sort_order
);
94 uscan
=userinfo_startscan();
96 debuga(_("Cannot enumerate the user list\n"));
99 while ( (uinfo
= userinfo_advancescan(uscan
)) != NULL
) {
100 user
=uinfo
->filename
;
102 if (snprintf(warea
,sizeof(warea
),"%s/%s",outdirname
,user
)>=sizeof(warea
)) {
103 debuga(_("Destination directory too long: %s/%s\n"),outdirname
,user
);
106 if (access(warea
, R_OK
) != 0) {
107 if (mkdir(warea
,0755)) {
108 debuga(_("Cannot create directory %s - %s\n"),warea
,strerror(errno
));
116 if (snprintf(arqin
,sizeof(arqin
),"%s/%s.txt",tmp
,uinfo
->filename
)>=sizeof(arqin
)) {
117 debuga(_("Input file name too long: %s/%s.txt\n"),tmp
,uinfo
->filename
);
120 if ((fp_in
= fopen(arqin
, "r")) == 0){
121 if (uinfo
->no_report
) continue;
122 debuga(_("(html3) Cannot open file %s\n"),arqin
);
126 if (snprintf(arqou
,sizeof(arqou
),"%s/%s/%s.html",outdirname
,uinfo
->filename
,uinfo
->filename
)>=sizeof(arqou
)) {
127 debuga(_("Output file name too long: %s/%s/%s.html\n"),outdirname
,uinfo
->filename
,uinfo
->filename
);
130 if (snprintf(duser
,sizeof(duser
),"%s/%s/denied_%s.html",tmp
,uinfo
->filename
,uinfo
->filename
)>=sizeof(duser
)) {
131 debuga(_("File name too long: %s/%s/denied_%s.html\n"),tmp
,uinfo
->filename
,uinfo
->filename
);
134 if(access(duser
, R_OK
) != 0)
135 have_denied_report
=0;
137 have_denied_report
=1;
139 if ((line
=longline_create())==NULL
) {
140 debuga(_("Not enough memory to read file %s\n"),arqin
);
149 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
150 getword_start(&gwarea
,buf
);
151 if (getword_atoll(<emp
,&gwarea
,'\t')<0) {
152 debuga(_("There is a broken number of access in file %s\n"),arqin
);
156 if (getword_atoll(<emp
,&gwarea
,'\t')<0) {
157 debuga(_("There is a broken downloaded size in file %s\n"),arqin
);
161 if (getword_ptr(NULL
,NULL
,&gwarea
,'\t')<0) {
162 debuga(_("There is a broken url in file %s\n"),arqin
);
165 if (getword_skip(MAXLEN
,&gwarea
,'\t')<0) {
166 debuga(_("There is a broken access code in file %s\n"),arqin
);
169 if (getword_atoll(<emp
,&gwarea
,'\t')<0) {
170 debuga(_("There is a broken elapsed time in file %s\n"),arqin
);
174 if (getword_atoll(<emp
,&gwarea
,'\t')<0) {
175 debuga(_("There is a broken in-cache volume in file %s\n"),arqin
);
179 if (getword_atoll(<emp
,&gwarea
,'\n')<0) {
180 debuga(_("There is a broken out-cache volume in file %s\n"),arqin
);
188 if ((fp_ou
= fopen(arqou
, "w")) == 0){
189 debuga(_("(html5) Cannot open file %s\n"),arqou
);
193 write_html_header(fp_ou
,(IndexTree
== INDEX_TREE_DATE
) ? 4 : 2,_("User report"),HTML_JS_SORTTABLE
);
194 fprintf(fp_ou
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period
.html
);
195 fprintf(fp_ou
,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo
->label
);
196 fputs("<tr><td class=\"header_c\">",fp_ou
);
197 fprintf(fp_ou
,_("Sort: %s, %s"),sort_field
,sort_order
);
198 fputs("</td></tr>\n",fp_ou
);
199 fprintf(fp_ou
,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User report"));
200 close_html_header(fp_ou
);
202 fputs("<div class=\"report\"><table cellpadding=\"2\" cellspacing=\"1\"",fp_ou
);
203 if (SortTableJs
[0]) fputs(" class=\"sortable\"",fp_ou
);
206 /*! \bug This line lays before the header of the table and is therefore invalid
207 HTML. It will also break the sorttable script. Beside, I suspect it serves no purpose.
209 if(have_denied_report
) {
210 fprintf(fp_ou
,"<tr><td class=\"header_l\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a> %s</td></tr>\n",uinfo
->filename
,_("SmartFilter"),_("Report"));
213 fputs("<thead><tr><th class=\"sorttable_nosort\"></th><th class=\"header_l",fp_ou
);
214 if (SortTableJs
[0]) fputs(" sorttable_alpha",fp_ou
);
215 fprintf(fp_ou
,"\">%s</th>",_("ACCESSED SITE"));
217 if((UserReportFields
& USERREPORTFIELDS_CONNECT
) != 0)
218 fprintf(fp_ou
,"<th class=\"header_l\">%s</th>",_("CONNECT"));
219 if((UserReportFields
& USERREPORTFIELDS_BYTES
) != 0)
220 fprintf(fp_ou
,"<th class=\"header_l\">%s</th>",_("BYTES"));
221 if((UserReportFields
& USERREPORTFIELDS_SETYB
) != 0)
222 fprintf(fp_ou
,"<th class=\"header_l\">%%%s</th>",_("BYTES"));
223 if((UserReportFields
& USERREPORTFIELDS_IN_CACHE_OUT
) != 0)
224 fprintf(fp_ou
,"<th class=\"header_c\" colspan=\"2\">%s</th><th style=\"display:none;\"></th>",_("IN-CACHE-OUT"));
225 if((UserReportFields
& USERREPORTFIELDS_USED_TIME
) != 0)
226 fprintf(fp_ou
,"<th class=\"header_l\">%s</th>",_("ELAPSED TIME"));
227 if((UserReportFields
& USERREPORTFIELDS_MILISEC
) != 0)
228 fprintf(fp_ou
,"<th class=\"header_l\">%s</th>",_("MILLISEC"));
229 if((UserReportFields
& USERREPORTFIELDS_PTIME
) != 0)
230 fprintf(fp_ou
,"<th class=\"header_l\">%%%s</th>",_("TIME"));
232 fputs("</tr></thead>\n",fp_ou
);
235 debuga(_("Making report: %s\n"),uinfo
->id
);
239 while((buf
=longline_read(fp_in
,line
))!=NULL
) {
240 getword_start(&gwarea
,buf
);
241 if (getword_atoll(&twork
,&gwarea
,'\t')<0) {
242 debuga(_("There is a broken number of access in file %s\n"),arqin
);
245 if (getword_atoll(&nnbytes
,&gwarea
,'\t')<0) {
246 debuga(_("There is a broken number of bytes in file %s\n"),arqin
);
249 if (getword_ptr(buf
,&url
,&gwarea
,'\t')<0) {
250 debuga(_("There is a broken url in file %s\n"),arqin
);
253 if (getword(tmsg
,sizeof(tmsg
),&gwarea
,'\t')<0) {
254 debuga(_("There is a broken access code in file %s\n"),arqin
);
257 if (getword_atoll(&nnelap
,&gwarea
,'\t')<0) {
258 debuga(_("There is a broken elapsed time in file %s\n"),arqin
);
261 if (getword_atoll(&incache
,&gwarea
,'\t')<0) {
262 debuga(_("There is a broken in cache column in file %s\n"),arqin
);
265 if (getword_atoll(&oucache
,&gwarea
,'\n')<0) {
266 debuga(_("There is a broken out of cache column in file %s (%d)\n"),arqin
,__LINE__
);
270 if(UserReportLimit
<=0 || count
<=UserReportLimit
) {
273 if(IndexTree
== INDEX_TREE_DATE
)
274 sprintf(tmp6
,"../%s",ImageFile
);
276 strcpy(tmp6
,"../../images");
278 if((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0) {
279 url_to_file(url
,siteind
,sizeof(siteind
));
280 fprintf(fp_ou
,"<td class=\"data\"><a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" title=\"%s\" alt=\"T\"></a></td>",uinfo
->filename
,siteind
,tmp6
,_("date/time report"));
282 fprintf(fp_ou
,"<td class=\"data\"></td>");
286 fprintf(fp_ou
,"<td class=\"data2\"><span style=\"color:%s;\">%s</span></td>",PrivacyStringColor
,PrivacyString
);
288 fputs("<td class=\"data2\">",fp_ou
);
289 if(BlockIt
[0]!='\0') {
290 fprintf(fp_ou
,"<a href=\"%s%s?url=",wwwDocumentRoot
,BlockIt
);
291 output_html_url(fp_ou
,url
);
292 fprintf(fp_ou
,"\"><img src=\"%s/sarg-squidguard-block.png\"></a> ",tmp6
);
294 fputs("<a href=\"http://",fp_ou
);
295 output_html_url(fp_ou
,url
);
297 output_html_string(fp_ou
,url
,100);
298 fputs("</a></td>",fp_ou
);
301 if((UserReportFields
& USERREPORTFIELDS_CONNECT
) != 0) {
302 fputs("<td class=\"data\"",fp_ou
);
303 if (SortTableJs
[0]) fprintf(fp_ou
," sorttable_customkey=\"%"PRId64
"\"",(int64_t)twork
);
304 fprintf(fp_ou
,">%s</td>",fixnum(twork
,1));
306 if((UserReportFields
& USERREPORTFIELDS_BYTES
) != 0) {
307 fputs("<td class=\"data\"",fp_ou
);
308 if (SortTableJs
[0]) fprintf(fp_ou
," sorttable_customkey=\"%"PRId64
"\"",(int64_t)nnbytes
);
309 fprintf(fp_ou
,">%s</td>",fixnum(nnbytes
,1));
311 if((UserReportFields
& USERREPORTFIELDS_SETYB
) != 0) {
312 perc
=(tnbytes
) ? nnbytes
* 100. / tnbytes
: 0.;
313 fprintf(fp_ou
,"<td class=\"data\">%3.2lf%%</td>",perc
);
315 if((UserReportFields
& USERREPORTFIELDS_IN_CACHE_OUT
) != 0) {
316 inperc
=(nnbytes
) ? incache
* 100. / nnbytes
: 0.;
317 ouperc
=(nnbytes
) ? oucache
* 100. / nnbytes
: 0.;
318 fprintf(fp_ou
,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",inperc
,ouperc
);
320 if((UserReportFields
& USERREPORTFIELDS_USED_TIME
) != 0) {
321 fputs("<td class=\"data\"",fp_ou
);
322 if (SortTableJs
[0]) fprintf(fp_ou
," sorttable_customkey=\"%"PRId64
"\"",(int64_t)nnelap
);
323 fprintf(fp_ou
,">%s</td>",buildtime(nnelap
));
325 if((UserReportFields
& USERREPORTFIELDS_MILISEC
) != 0) {
326 fputs("<td class=\"data\"",fp_ou
);
327 if (SortTableJs
[0]) fprintf(fp_ou
," sorttable_customkey=\"%"PRId64
"\"",(int64_t)nnelap
);
328 fprintf(fp_ou
,">%s</td>",fixnum2(nnelap
,1));
330 if((UserReportFields
& USERREPORTFIELDS_PTIME
) != 0) {
331 perc2
=(tnelap
) ? nnelap
* 100. / tnelap
: 0.;
332 fprintf(fp_ou
,"<td class=\"data\">%3.2lf%%</td>",perc2
);
335 if(strncmp(tmsg
,"OK",2) != 0)
336 fprintf(fp_ou
,"<td class=\"data\">%s</td>",_("DENIED"));
338 fputs("</tr>\n",fp_ou
);
340 } else if ((ReportType
& REPORT_TYPE_SITE_USER_TIME_DATE
) != 0) {
341 url_to_file(url
,siteind
,sizeof(siteind
));
342 snprintf(tmp2
,sizeof(tmp2
),"%s/%s/tt%s-%s.html",outdirname
,uinfo
->filename
,uinfo
->filename
,siteind
);
343 if (unlink(tmp2
)!=0) {
344 debuga(_("Cannot delete unused file \"%s\" - %s\n"),tmp2
,strerror(errno
));
349 if (snprintf(arqip
,sizeof(arqip
),"%s/%s.ip",tmp
,uinfo
->filename
)>=sizeof(arqip
)) {
350 debuga(_("File name too long: %s/%s.ip\n"),tmp
,uinfo
->filename
);
354 if ((fp_ip
= fopen(arqip
, "r")) == 0){
355 debuga(_("(html6) Cannot open file %s\n"),arqip
);
359 if ((fp_ip2
= MY_FOPEN(tmp2
, "a")) == 0){
360 debuga(_("(html7) Cannot open file %s\n"),tmp2
);
364 if ((line1
=longline_create())==NULL
) {
365 debuga(_("Not enough memory to read file %s\n"),arqip
);
368 while((buf
=longline_read(fp_ip
,line1
))!=NULL
) {
369 getword_start(&gwarea
,buf
);
370 if (getword(user_ip
,sizeof(user_ip
),&gwarea
,'\t')<0) {
371 debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3
);
374 if (getword_ptr(buf
,&user_url
,&gwarea
,'\t')<0) {
375 debuga(_("Maybe you have a broken url in your %s file\n"),tmp3
);
378 if (strncmp(user_url
,url
,strlen(url
))!=0) continue;
379 if (getword_skip(15,&gwarea
,'\t')<0) {
380 debuga(_("Maybe you have a broken day in your %s file\n"),tmp3
);
383 if (getword_skip(15,&gwarea
,'\t')<0) {
384 debuga(_("Maybe you have a broken time in your %s file\n"),tmp3
);
387 if (getword_atoll(&userbytes
,&gwarea
,'\t')<0) {
388 debuga(_("Maybe you have a broken size in your %s file\n"),tmp3
);
391 if (getword_atoll(&userelap
,&gwarea
,'\0')<0) {
392 debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3
);
395 fprintf(fp_ip2
,"%s\t%"PRIu64
"\t%"PRIu64
"\n",user_ip
,(uint64_t)userbytes
,(uint64_t)userelap
);
397 longline_destroy(&line1
);
402 sprintf(csort
,"sort -n -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp
,tmp3
,tmp2
);
403 cstatus
=system(csort
);
404 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
405 debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus
));
406 debuga(_("sort command: %s\n"),csort
);
410 if ((fp_ip
= MY_FOPEN(tmp3
, "r")) == 0) {
411 debuga(_("(html8) Cannot open file %s\n"),tmp3
);
417 if ((line1
=longline_create())==NULL
) {
418 debuga(_("Not enough memory to read file %s\n"),arqip
);
421 while((buf
=longline_read(fp_ip
,line1
))!=NULL
) {
422 getword_start(&gwarea
,buf
);
423 if (getword(user_ip
,sizeof(user_ip
),&gwarea
,'\t')<0) {
424 debuga(_("Maybe you have a broken user IP in your %s file\n"),tmp3
);
427 if (getword_atoll(&userbytes
,&gwarea
,'\t')<0) {
428 debuga(_("Maybe you have a broken size in your %s file\n"),tmp3
);
431 if (getword_atoll(&userelap
,&gwarea
,'\0')<0) {
432 debuga(_("Maybe you have a broken elapsed time in your %s file\n"),tmp3
);
435 if(strcmp(user_ip
,olduserip
) != 0) {
436 if (olduserip
[0]!='\0') {
437 fprintf(fp_ou
,"<tr><td></td><td class=\"data\">%s</td>",olduserip
);
438 if((UserReportFields
& USERREPORTFIELDS_CONNECT
) != 0)
439 fputs("<td></td>",fp_ou
);
440 if((UserReportFields
& USERREPORTFIELDS_BYTES
) != 0)
441 fprintf(fp_ou
,"<td class=\"data\">%s</td>",fixnum(unbytes
,1));
442 if((UserReportFields
& USERREPORTFIELDS_SETYB
) != 0)
443 fputs("<td></td>",fp_ou
);
444 if((UserReportFields
& USERREPORTFIELDS_IN_CACHE_OUT
) != 0)
445 fputs("</td><td></td><td></td>",fp_ou
);
446 if((UserReportFields
& USERREPORTFIELDS_USED_TIME
) != 0)
447 fprintf(fp_ou
,"<td class=\"data\">%s</td>",buildtime(unelap
));
448 if((UserReportFields
& USERREPORTFIELDS_MILISEC
) != 0)
449 fprintf(fp_ou
,"<td class=\"data\">%s</td>",fixnum2(unelap
,1));
450 fputs("</tr>\n",fp_ou
);
453 strcpy(olduserip
,user_ip
);
464 longline_destroy(&line1
);
467 debuga(_("Cannot delete %s - %s\n"),tmp2
,strerror(errno
));
471 debuga(_("Cannot delete %s - %s\n"),tmp3
,strerror(errno
));
475 if (olduserip
[0]!='\0') {
476 fprintf(fp_ou
,"<tr><td></td><td class=\"data\">%s</td>",olduserip
);
477 if((UserReportFields
& USERREPORTFIELDS_CONNECT
) != 0)
478 fputs("<td></td>",fp_ou
);
479 if((UserReportFields
& USERREPORTFIELDS_BYTES
) != 0)
480 fprintf(fp_ou
,"<td class=\"data\">%s</td>",fixnum(unbytes
,1));
481 if((UserReportFields
& USERREPORTFIELDS_SETYB
) != 0)
482 fputs("<td></td>",fp_ou
);
483 if((UserReportFields
& USERREPORTFIELDS_IN_CACHE_OUT
) != 0)
484 fputs("</td><td></td><td></td>",fp_ou
);
485 if((UserReportFields
& USERREPORTFIELDS_USED_TIME
) != 0)
486 fprintf(fp_ou
,"<td class=\"data\">%s</td>",buildtime(unelap
));
487 if((UserReportFields
& USERREPORTFIELDS_MILISEC
) != 0)
488 fprintf(fp_ou
,"<td class=\"data\">%s</td>",fixnum2(unelap
,1));
489 fputs("</tr>\n",fp_ou
);
499 longline_destroy(&line
);
503 debuga(_("Cannot delete %s - %s\n"),arqip
,strerror(errno
));
508 debuga(_("Cannot delete %s - %s\n"),arqin
,strerror(errno
));
512 if ((UserReportFields
& (USERREPORTFIELDS_TOTAL
| USERREPORTFIELDS_AVERAGE
)) != 0)
513 fputs("<tfoot>",fp_ou
);
515 if((UserReportFields
& USERREPORTFIELDS_TOTAL
) != 0) {
516 fprintf(fp_ou
,"<tr><th></th><th class=\"header_l\">%s</th>",_("TOTAL"));
517 if((UserReportFields
& USERREPORTFIELDS_CONNECT
) != 0)
518 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",fixnum(tnacc
,1));
519 if((UserReportFields
& USERREPORTFIELDS_BYTES
) != 0)
520 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",fixnum(tnbytes
,1));
521 if((UserReportFields
& USERREPORTFIELDS_SETYB
) != 0) {
522 perc
=(totbytes
) ? tnbytes
*100. / totbytes
:0.;
523 fprintf(fp_ou
,"<th class=\"header_r\">%3.2lf%%</th>",perc
);
525 if((UserReportFields
& USERREPORTFIELDS_IN_CACHE_OUT
) != 0) {
526 inperc
=(tnbytes
) ? tnincache
* 100. / tnbytes
: 0.;
527 ouperc
=(tnbytes
) ? tnoucache
* 100. / tnbytes
: 0.;
528 fprintf(fp_ou
,"<th class=\"header_r\">%3.2lf%%</th><th class=\"header_r\">%3.2lf%%</th>",inperc
,ouperc
);
530 if((UserReportFields
& USERREPORTFIELDS_USED_TIME
) != 0)
531 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",buildtime(tnelap
));
532 if((UserReportFields
& USERREPORTFIELDS_MILISEC
) != 0)
533 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",fixnum2(tnelap
,1));
534 if((UserReportFields
& USERREPORTFIELDS_PTIME
) != 0) {
535 perc2
=(totelap
) ? tnelap
* 100. / totelap
: 0.;
536 fprintf(fp_ou
,"<th class=\"header_r\">%3.2lf%%</th>",perc2
);
538 fputs("</tr>\n",fp_ou
);
541 if(PerUserLimit
> 0) {
542 if(tnbytes
> (PerUserLimit
*1000000)) {
544 if(access(PerUserLimitFile
, R_OK
) == 0) {
545 if((fp_usr
= fopen(PerUserLimitFile
, "r")) == 0) {
546 debuga(_("(html9) Cannot open file %s\n"),PerUserLimitFile
);
549 while(fgets(tmp6
,sizeof(tmp6
),fp_usr
)!=NULL
) {
551 if(strcmp(tmp6
,uinfo
->label
) == 0) {
560 if((fp_usr
= fopen(PerUserLimitFile
, "a")) == 0) {
561 debuga(_("(html10) Cannot open file %s\n"),PerUserLimitFile
);
564 fprintf(fp_usr
,"%s\n",uinfo
->label
);
568 debuga(_("User %s limit exceeded (%d MB). Added to file %s\n"),uinfo
->label
,PerUserLimit
,PerUserLimitFile
);
573 if ((ReportType
& REPORT_TYPE_TOPUSERS
) != 0 && (UserReportFields
& USERREPORTFIELDS_AVERAGE
) != 0) {
574 totbytes2
=totbytes
/ntotuser
;
575 totelap2
=totelap
/ntotuser
;
577 fprintf(fp_ou
,"<tr><th></th><th class=\"header_l\">%s</th>",_("AVERAGE"));
578 if((UserReportFields
& USERREPORTFIELDS_CONNECT
) != 0)
579 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",fixnum(ttnacc
/ntotuser
,1));
580 if((UserReportFields
& USERREPORTFIELDS_BYTES
) != 0)
581 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",fixnum(totbytes2
,1));
582 fprintf(fp_ou
,"<th></th><th></th><th></th>");
583 if((UserReportFields
& USERREPORTFIELDS_USED_TIME
) != 0)
584 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",buildtime(totelap2
));
585 if((UserReportFields
& USERREPORTFIELDS_MILISEC
) != 0)
586 fprintf(fp_ou
,"<th class=\"header_r\">%s</th>",fixnum2(totelap2
,1));
587 if((UserReportFields
& USERREPORTFIELDS_PTIME
) != 0) {
588 perc2
= (totelap
) ? totelap2
* 100. / totelap
: 0.;
589 fprintf(fp_ou
,"<th class=\"header_r\">%3.2lf%%</th>",perc2
);
591 fputs("</tr>\n",fp_ou
);
594 if ((UserReportFields
& (USERREPORTFIELDS_TOTAL
| USERREPORTFIELDS_AVERAGE
)) != 0)
595 fputs("</tfoot>",fp_ou
);
597 fputs("</table></div>\n",fp_ou
);
598 if (write_html_trailer(fp_ou
)<0)
599 debuga(_("Write error in file %s\n"),arqou
);
600 if (fclose(fp_ou
)==EOF
)
601 debuga(_("Failed to close file %s - %s\n"),arqou
,strerror(errno
));
606 userinfo_stopscan(uscan
);