]>
git.ipfire.org Git - thirdparty/sarg.git/blob - html.c
2 * AUTHOR: Pedro Lineu Orso orso@penguintech.com.br
4 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
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.
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.
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.
26 #include "include/conf.h"
27 #include "include/defs.h"
32 FILE *fp_in
, *fp_ou
, *fp_ip
, *fp_ip2
, *fp_usr
;
34 struct dirent
*direntp
;
35 long long int nnbytes
=0, unbytes
=0, tnbytes
=0, totbytes
=0, totbytes2
=0;
36 long long int totelap
=0, totelap2
=0, nnelap
=0, unelap
=0, tnelap
=0;
37 long long int incache
=0, oucache
=0, tnincache
=0, tnoucache
=0, twork
=0, twork2
=0;
38 char arqin
[MAXLEN
], arqou
[MAXLEN
], arqper
[MAXLEN
], arqip
[MAXLEN
];
39 char nacc
[20], nbytes
[20], url
[MAXLEN
], tmsg
[50], nelap
[20], csort
[MAXLEN
];
40 char period
[MAXLEN
], usuario
[MAXLEN
], wusuario
[MAXLEN
], u2
[MAXLEN
], duser
[MAXLEN
];
41 char userbytes
[20], userelap
[20], userurl
[1024], userhora
[9], userdia
[9];
42 char user_ip
[MAXLEN
], olduserip
[MAXLEN
], tmp2
[MAXLEN
], tmp3
[MAXLEN
], incac
[20], oucac
[20];
43 char denied_report
[255], name2
[MAXLEN
];
44 //char ttd1[3], ttd2[3], ttd3[5], ttt1[3], ttt2[3], ttt3[3];
47 char wtemp
[MAXLEN
], totuser
[8];
48 long long int tnacc
=0, ttnacc
=0, unacc
=0;
49 float perc
=0, perc2
=0, ouperc
=0, inperc
=0;
53 const char txtext
[]=".txt";
59 if(strstr(ReportType
,"users_sites") == 0) return;
62 strcat(tmp2
,"/sargtmp.unsort");
65 strcat(tmp3
,"/sargtmp.log");
67 strcpy(arqper
,dirname
);
68 strcat(arqper
,"/sarg-period");
70 if ((fp_in
= fopen(arqper
, "r")) == 0){
71 fprintf(stderr
, "SARG: (html1) %s: %s\n",text
[45],arqper
);
75 if (!fgets(period
,sizeof(period
),fp_in
)) {
76 fprintf(stderr
,"SARG: (html1) read error in %s\n",arqper
);
81 strcpy(arqper
,dirname
);
82 strcat(arqper
,"/sarg-general");
84 if ((fp_in
= fopen(arqper
, "r")) == 0){
85 fprintf(stderr
, "SARG: (html2) %s: %s\n",text
[45],arqper
);
89 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
90 if(strstr(buf
,"TOTAL") == 0) {
91 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
92 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqper
);
95 ttnacc
+=my_atoll(buf
);
96 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 || getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
97 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqper
);
100 totbytes
+=my_atoll(wtemp
);
101 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 || getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 ||
102 getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 || getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 ||
103 getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
104 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqper
);
107 totelap
+=my_atoll(wtemp
);
114 while ( (direntp
= readdir( dirp
)) != NULL
) {
115 dlen
=strlen(direntp
->d_name
)-(sizeof(txtext
)-1);
116 if (dlen
<0) continue;
117 if(strcmp(direntp
->d_name
+dlen
,txtext
) != 0)
122 if (dlen
>=sizeof(wusuario
)) continue;
123 strncpy(wusuario
,direntp
->d_name
,dlen
);
128 str
=strrchr(wusuario
,'.');
130 strcpy(denied_report
,str
+1);
132 strcpy(denied_report
,wusuario
);
134 if (snprintf(warea
,sizeof(warea
),"%s/%s",dirname
,wusuario
)>=sizeof(warea
)) {
135 fprintf(stderr
,"SARG: destination directory too long: %s/%s\n",dirname
,wusuario
);
140 report_day(wusuario
);
141 greport_day(wusuario
);
143 strcpy(usuario
,wusuario
);
146 strcpy(arqou
,dirname
);
148 strcat(arqou
,usuario
);
150 strcat(arqou
,usuario
);
151 strcat(arqou
,".html");
153 strcat(duser
,"denied_");
154 strcat(arqin
,direntp
->d_name
);
156 if((str
=(char *) strstr(denied_report
, "_")) != (char *) NULL
) {
157 if((str
=(char *) strstr(str
+1, "_")) != (char *) NULL
)
158 fixip(denied_report
);
160 strcat(duser
,denied_report
);
161 strcat(duser
,".html");
162 if(access(duser
, R_OK
) != 0)
163 denied_report
[0]='\0';
168 if(strcmp(Ip2Name
,"yes") == 0)
169 ip2name(u2
,sizeof(u2
));
171 // get_usertab_name(u2,name2,sizeof(name2));
172 user_find(name2
, u2
);
174 if(dotinuser
&& strchr(name2
,'_')) {
175 subs(name2
,sizeof(name2
),"_",".");
178 if ((fp_in
= fopen(arqin
, "r")) == 0){
179 fprintf(stderr
, "SARG: (html3) %s: %s\n",text
[45],arqin
);
183 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
184 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
185 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqin
);
188 tnacc
+=my_atoll(wtemp
);
189 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
190 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqin
);
193 tnbytes
+=my_atoll(wtemp
);
194 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 || getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0 ||
195 getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
196 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqin
);
199 tnelap
+=my_atoll(wtemp
);
200 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
201 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqin
);
204 tnincache
+=my_atoll(wtemp
);
205 if (getword(wtemp
,sizeof(wtemp
),buf
,'\t')<0) {
206 printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arqin
);
209 tnoucache
+=my_atoll(wtemp
);
214 if ((fp_ou
= fopen(arqou
, "w")) == 0){
215 fprintf(stderr
, "SARG: (html5) %s: %s\n",text
[45],arqou
);
219 fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n",fp_ou
);
220 fputs("<html>\n",fp_ou
);
221 fputs("<head>\n",fp_ou
);
222 fprintf(fp_ou
," <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet
);
224 fputs("</head>\n",fp_ou
);
226 fprintf(fp_ou
,"<body style=\"font-family:%s;font-size:%s;background-color:%s; \
227 background-image:url(%s)\">\n",FontFace
,TitleFontSize
,BgColor
,BgImage
);
229 write_logo_image(fp_ou
);
231 if(strcmp(IndexTree
,"date") == 0)
232 show_sarg(fp_ou
, "../../../..");
234 show_sarg(fp_ou
, "../..");
236 fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ou
);
237 fprintf(fp_ou
,"<tr><th class=\"title\" colspan=\"2\">%s</th></tr>\n",Title
);
239 fprintf(fp_ou
,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text
[89],period
);
240 fprintf(fp_ou
,"<tr><td class=\"header\" colspan=\"2\">%s: %s</td></tr>\n",text
[90],name2
);
241 fprintf(fp_ou
,"<tr><td class=\"header\" colspan=\"2\">%s: %s, %s</td></tr>\n",text
[104],UserSortField
,UserSortOrder
);
242 fprintf(fp_ou
,"<tr><td class=\"header3\" colspan=\"2\">%s %s</td></tr>\n",text
[32],text
[55]);
243 fputs("<tr><td></td></tr>\n",fp_ou
);
245 fputs("</table></div>\n",fp_ou
);
246 fputs("<div align=\"center\"><table cellpadding=\"2\" cellspacing=\"1\">\n",fp_ou
);
248 if(denied_report
[0]!='\0') {
249 fprintf(fp_ou
,"<tr><td class=\"header\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a> %s</td></tr>\n",denied_report
,text
[116],text
[55]);
252 strcpy(val3
,text
[92]);
253 strcpy(val4
,text
[93]);
254 sprintf(val11
,"%%%s",text
[93]);
255 sprintf(val5
,"%s-%s-%s",text
[113],text
[114],text
[112]);
256 strcpy(val6
,text
[94]);
257 strcpy(val7
,text
[95]);
258 sprintf(val8
,"%%%s",text
[99]);
259 strcpy(val9
,"colspan=\"2\"");
262 if(strstr(UserReportFields
,"CONNECT") == 0)
264 if(strstr(UserReportFields
,"BYTES") == 0)
266 if(strstr(UserReportFields
,"SETYB") == 0)
268 if(strstr(UserReportFields
,"IN-CACHE-OUT") == 0) {
271 strcpy(val10
,"<td></td>");
273 if(strstr(UserReportFields
,"USED_TIME") == 0)
275 if(strstr(UserReportFields
,"MILISEC") == 0)
277 if(strstr(UserReportFields
,"%TIME") == 0)
280 fprintf(fp_ou
,"<tr><th></th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header3\" %s>%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th><th class=\"header\">%s</th></tr>\n",text
[91],val3
,val4
,val11
,val9
,val5
,val6
,val7
,val8
);
286 debuga("%s: %s",text
[61],u2
);
288 debuga("%s: %s",text
[61],usuario
);
291 while(fgets(buf
,sizeof(buf
),fp_in
)!=NULL
) {
292 if (getword(nacc
,sizeof(nacc
),buf
,'\t')<0) {
293 printf("SARG: Maybe you have a broken number of access in your %s file.\n",arqin
);
296 if (getword(nbytes
,sizeof(nbytes
),buf
,'\t')<0) {
297 printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",arqin
);
300 if (getword(url
,sizeof(url
),buf
,'\t')<0) {
301 printf("SARG: Maybe you have a broken url in your %s file.\n",arqin
);
304 if (getword(tmsg
,sizeof(tmsg
),buf
,'\t')<0) {
305 printf("SARG: Maybe you have a broken status in your %s file.\n",arqin
);
308 if (getword(nelap
,sizeof(nelap
),buf
,'\t')<0) {
309 printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",arqin
);
312 if (getword(incac
,sizeof(incac
),buf
,'\t')<0) {
313 printf("SARG: Maybe you have a broken in cache column in your %s file.\n",arqin
);
316 if (getword(oucac
,sizeof(oucac
),buf
,'\t')<0) {
317 printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",arqin
);
321 if(strncmp(tmsg
,"OK",2) != 0)
322 sprintf(tmsg
,"<td class=\"data\">%s</td>",text
[46]);
323 else bzero(tmsg
, 50);
325 nnbytes
=my_atoll(nbytes
);
326 nnelap
=my_atoll(nelap
);
327 incache
=my_atoll(incac
);
328 oucache
=my_atoll(oucac
);
340 perc2
=perc2
/ tnelap
;
344 inperc
=incache
* 100;
345 inperc
=inperc
/ nnbytes
;
349 ouperc
=oucache
* 100;
350 ouperc
=ouperc
/ nnbytes
;
353 twork
=my_atoll(nacc
);
354 strcpy(wwork1
,fixnum(twork
,1));
355 strcpy(wwork2
,fixnum(nnbytes
,1));
356 strcpy(wwork3
,fixnum2(nnelap
,1));
358 if(strcmp(LongUrl
,"yes") != 0) {
359 char *endofhost
=strchr(url
,'/');
360 if (endofhost
) *endofhost
='\0';
364 url_module(url
, module
);
365 if (getword(warea
,sizeof(warea
),url
,'/')<0) {
366 printf("SARG: Maybe you have a broken record or garbage in the url of the %s file.\n",arqin
);
369 sprintf(url
,"%s...%s",warea
,module
);
372 if(strcmp(Privacy
,"yes") == 0)
373 sprintf(httplink
,"<span style=\"color:%s;\">%s</span>",PrivacyStringColor
,PrivacyString
);
375 if(strcmp(IndexTree
,"date") == 0)
376 sprintf(tmp6
,"../%s",ImageFile
);
378 strcpy(tmp6
,"../../images");
380 snprintf(httplink
,sizeof(httplink
),"<a href=\"%s%s?url=%s\"><img src=\"%s/sarg-squidguard-block.png\" border=\"0\"></a><a href=http://%s> %s</a>",wwwDocumentRoot
,BlockIt
,urly
,tmp6
,urly
,urly
);
382 snprintf(httplink
,sizeof(httplink
),"<a href=\"http://%s\" title=\"%s\">%s</a>",urly
,urly
,url
);
385 if(strstr(ReportType
,"site_user_time_date") != 0) {
386 strcpy(ltext110
,text
[110]);
387 for(s
=ltext110
; *s
; ++s
)
389 strcpy(siteind
,urly
);
391 for(z1
=0; str
[z1
]; z1
++) {
392 if(str
[z1
]=='?' || str
[z1
]=='-' || str
[z1
]=='.' || str
[z1
]==':' || str
[z1
]=='/' || str
[z1
]=='\\' || str
[z1
]=='*' ||
393 str
[z1
]=='\'' || str
[z1
]=='\"' || str
[z1
]=='$')
396 sprintf(href2
,"<a href=\"tt%s-%s.html\"><img src=\"%s/datetime.png\" border=\"0\" title=\"%s %s\" alt=\"T\"></a>",usuario
,siteind
,tmp6
,ltext110
,text
[55]);
398 bzero(href2
, MAXLEN
);
402 sprintf(val2
,"%s",href2
);
403 sprintf(val3
,"%3.2f%%",perc
);
404 sprintf(val4
,"%3.2f%%",inperc
);
405 sprintf(val5
,"%3.2f%%",ouperc
);
406 sprintf(val6
,"%s",buildtime(nnelap
));
407 sprintf(val7
,"%3.2f%%",perc2
);
409 if(strstr(UserReportFields
,"CONNECT") == 0) {
413 if(strstr(UserReportFields
,"BYTES") == 0) {
417 if(strstr(UserReportFields
,"MILISEC") == 0) {
421 if(strstr(UserReportFields
,"SETYB") == 0) {
425 if(strstr(UserReportFields
,"IN-CACHE-OUT") == 0) {
431 if(strstr(UserReportFields
,"USED_TIME") == 0) {
435 if(strstr(UserReportFields
,"%TIME") == 0) {
439 if(strncmp(tmsg
," ",1) == 0)
443 if(UserReportLimit
<=0 || count
<=UserReportLimit
) {
444 fprintf(fp_ou
,"<tr><td class=\"data\">%s</td><td class=\"data2\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td><td class=\"data\">%s</td>%s</tr>\n",val2
,httplink
,wwork1
,wwork2
,val3
,val4
,val5
,val6
,wwork3
,val7
,tmsg
);
451 strcat(arqip
,usuario
);
454 if ((fp_ip
= fopen(arqip
, "r")) == 0){
455 fprintf(stderr
, "SARG: (html6) %s: %s\n",text
[45],arqip
);
459 if ((fp_ip2
= MY_FOPEN(tmp2
, "a")) == 0){
460 fprintf(stderr
, "SARG: (html7) %s: %s\n",text
[45],tmp2
);
464 while(fgets(buf
,sizeof(buf
),fp_ip
)!=NULL
) {
465 if(strstr(buf
,url
) != 0)
472 sprintf(csort
,"sort -n -T \"%s\" -k 1,1 -k 5,5 -o \"%s\" \"%s\"",TempDir
,tmp3
,tmp2
);
473 cstatus
=system(csort
);
474 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
475 fprintf(stderr
, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus
));
476 fprintf(stderr
, "SARG: sort command: %s\n",csort
);
480 if ((fp_ip
= MY_FOPEN(tmp3
, "r")) == 0) {
481 fprintf(stderr
, "SARG: (html8) %s: %s\n",text
[45],tmp3
);
487 while(fgets(buf
,sizeof(buf
),fp_ip
)) {
488 if (getword(user_ip
,sizeof(user_ip
),buf
,'\t')<0) {
489 printf("SARG: Maybe you have a broken user IP in your %s file.\n",tmp3
);
492 if (getword(userurl
,sizeof(userurl
),buf
,'\t')<0) {
493 printf("SARG: Maybe you have a broken user URL in your %s file.\n",tmp3
);
496 if (getword(userdia
,sizeof(userdia
),buf
,'\t')<0) {
497 printf("SARG: Maybe you have a broken day in your %s file.\n",tmp3
);
500 if (getword(userhora
,sizeof(userhora
),buf
,'\t')<0) {
501 printf("SARG: Maybe you have a broken time in your %s file.\n",tmp3
);
504 if (getword(userbytes
,sizeof(userbytes
),buf
,'\t')<0) {
505 printf("SARG: Maybe you have a broken size in your %s file.\n",tmp3
);
508 if (getword(userelap
,sizeof(userelap
),buf
,'\t')<0) {
509 printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",tmp3
);
512 if(strcmp(user_ip
,olduserip
) != 0) {
513 my_lltoa(unelap
,val2
,0);
514 sprintf(wwork1
,"%s",fixnum(unbytes
,1));
515 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\">%s</td></tr>\n",olduserip
,wwork1
,buildtime(unelap
),val2
);
517 strcpy(olduserip
,user_ip
);
523 unbytes
=unbytes
+my_atoll(userbytes
);
524 unelap
=unelap
+my_atoll(userelap
);
532 my_lltoa(unelap
,val3
,0);
533 sprintf(wwork1
,"%s",fixnum(unbytes
,1));
534 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\">%s</td></tr>\n",olduserip
,wwork1
,buildtime(unelap
),val3
);
554 perc2
=tnelap
/ perc2
;
558 ouperc
=tnoucache
* 100;
559 ouperc
=ouperc
/ tnbytes
;
563 inperc
=tnincache
* 100;
564 inperc
=inperc
/ tnbytes
;
567 sprintf(wwork1
,"%s",fixnum(tnacc
,1));
568 sprintf(wwork2
,"%s",fixnum(tnbytes
,1));
569 sprintf(wwork3
,"%s",fixnum2(tnelap
,1));
571 sprintf(val2
,"%s%s",href2
,ltext110
);
572 sprintf(val3
,"%3.2f%%",perc
);
573 sprintf(val4
,"%3.2f%%",inperc
);
574 sprintf(val5
,"%3.2f%%",ouperc
);
575 sprintf(val6
,"%s",buildtime(tnelap
));
576 sprintf(val7
,"%3.2f%%",perc2
);
578 strcpy(hbc1
,"class=\"header2\"");
579 strcpy(hbc2
,"class=\"header2\"");
580 strcpy(hbc3
,"class=\"header2\"");
581 strcpy(hbc4
,"class=\"header2\"");
582 strcpy(hbc5
,"class=\"header2\"");
583 strcpy(hbc6
,"class=\"header2\"");
584 strcpy(hbc7
,"class=\"header2\"");
585 strcpy(hbc8
,"class=\"header2\"");
586 strcpy(hbc9
,"class=\"header\"");
588 if(strstr(UserReportFields
,"CONNECT") == 0) {
592 if(strstr(UserReportFields
,"BYTES") == 0) {
596 if(strstr(UserReportFields
,"MILISEC") == 0) {
600 if(strstr(UserReportFields
,"SETYB") == 0) {
604 if(strstr(UserReportFields
,"IN-CACHE-OUT") == 0) {
608 if(strstr(UserReportFields
,"IN-CACHE-OUT") == 0) {
612 if(strstr(UserReportFields
,"USED_TIME") == 0) {
616 if(strstr(UserReportFields
,"%TIME") == 0) {
621 if(strstr(UserReportFields
,"TOTAL") != 0) {
622 fprintf(fp_ou
,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc9
,text
[107],hbc1
,wwork1
,hbc2
,wwork2
,hbc4
,val3
,hbc5
,val4
,hbc6
,val5
,hbc7
,val6
,hbc3
,wwork3
,hbc8
,val7
);
627 if(atoi(PerUserLimit
) > 0) {
628 if(tnbytes
> (atoi(PerUserLimit
)*1000000)) {
630 if(access(PerUserLimitFile
, R_OK
) == 0) {
631 if((fp_usr
= fopen(PerUserLimitFile
, "r")) == 0) {
632 fprintf(stderr
, "SARG: (html9) %s: %s\n",text
[45],PerUserLimitFile
);
635 while(fgets(tmp6
,sizeof(tmp6
),fp_usr
)!=NULL
) {
636 if(strstr(tmp6
,"\n") != 0)
637 tmp6
[strlen(tmp6
)-1]='\0';
638 if(strcmp(tmp6
,u2
) == 0) {
647 if((fp_usr
= fopen(PerUserLimitFile
, "a")) == 0) {
648 fprintf(stderr
, "SARG: (html10) %s: %s\n",text
[45],PerUserLimitFile
);
651 fprintf(fp_usr
,"%s\n",u2
);
655 debuga("%s %s %s (%s MB). %s %s",text
[32],u2
,text
[74],PerUserLimit
,text
[75],PerUserLimitFile
);
665 if (strstr(ReportType
,"topuser") != 0) {
666 strcpy(arqper
,dirname
);
667 strcat(arqper
,"/sarg-users");
669 if ((fp_in
= fopen(arqper
, "r")) == 0){
670 fprintf(stderr
, "SARG: (html11) %s: %s\n",text
[45],arqper
);
674 if (!fgets(totuser
,8,fp_in
)) {
675 fprintf(stderr
,"SARG: (html11) read error in %s\n",arqper
);
680 totbytes2
=totbytes
/my_atoll(totuser
);
681 totelap2
=totelap
/my_atoll(totuser
);
684 perc
= totbytes
/ 100;
685 perc
= totbytes2
/ perc
;
689 perc2
= totelap
/ 100;
690 perc2
= totelap2
/ perc2
;
693 twork2
=my_atoll(totuser
);
696 strcpy(wwork1
,fixnum(twork
,1));
697 strcpy(wwork2
,fixnum(totbytes2
,1));
698 strcpy(wwork3
,fixnum2(totelap2
,1));
700 sprintf(val6
,"%s",buildtime(totelap2
));
701 sprintf(val7
,"%3.2f%%",perc2
);
703 strcpy(hbc1
,"class=\"header2\"");
704 strcpy(hbc2
,"class=\"header2\"");
705 strcpy(hbc3
,"class=\"header2\"");
706 strcpy(hbc4
,"class=\"header2\"");
707 strcpy(hbc5
,"class=\"header2\"");
708 strcpy(hbc6
,"class=\"header\"");
710 if(strstr(UserReportFields
,"CONNECT") == 0) {
714 if(strstr(UserReportFields
,"BYTES") == 0) {
718 if(strstr(UserReportFields
,"MILISEC") == 0) {
722 if(strstr(UserReportFields
,"USED_TIME") == 0) {
726 if(strstr(UserReportFields
,"%TIME") == 0) {
731 if(strstr(UserReportFields
,"AVERAGE") != 0) {
732 fprintf(fp_ou
,"<tr><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th></th><th></th><th></th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr>\n",hbc6
,text
[96],hbc1
,wwork1
,hbc2
,wwork2
,hbc4
,val6
,hbc3
,wwork3
,hbc5
,val7
);
741 fputs("</table></div>\n",fp_ou
);
745 fputs("</body>\n</html>\n",fp_ou
);
753 (void)rewinddir(dirp
);
754 (void)closedir(dirp
);