]>
git.ipfire.org Git - thirdparty/sarg.git/blob - topuser.c
2 * AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
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
= NULL
, * fp_ou
= NULL
, * fp_top1
= NULL
, * fp_top2
= NULL
, * fp_top3
= NULL
;
33 long long int ttnbytes
= 0 , ttnacc
= 0 , tnacc
= 0 ;
34 long long int tnbytes
= 0 , ttnelap
= 0 , tnelap
= 0 ;
35 long long int tnincache
= 0 , tnoucache
= 0 , ttnincache
= 0 , ttnoucache
= 0 ;
40 float inperc
= 0.00 , ouperc
= 0.00 ;
42 char olduser
[ MAXLEN
], csort
[ MAXLEN
], period
[ MAXLEN
], arqper
[ MAXLEN
];
43 char wger
[ MAXLEN
], top1
[ MAXLEN
], top2
[ MAXLEN
], top3
[ MAXLEN
];
44 char user
[ MAXLEN
], nacc
[ 20 ], nbytes
[ 20 ], preg
[ MAXLEN
], tusr
[ MAXLEN
];
45 char ip
[ MAXLEN
], time
[ 30 ], date
[ 30 ], elap
[ 30 ], incac
[ 30 ], oucac
[ 30 ];
46 char ipantes
[ MAXLEN
], nameantes
[ MAXLEN
];
47 char sfield
[ 10 ]= "2,2" ;
63 struct getwordstruct gwarea
;
73 strcat ( wger
, "/sarg-general" );
75 strcat ( top2
, "/top.tmp" );
76 strcat ( tusr
, "/sarg-users" );
77 strcat ( top3
, "/index.html" );
80 if (( fp_in
= fopen ( wger
, "r" ))== NULL
) {
81 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], wger
);
85 if (( fp_top2
= fopen ( top2
, "w" ))== NULL
) {
86 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top2
);
93 while ( fgets ( warea
, sizeof ( warea
), fp_in
)) {
94 getword_start (& gwarea
, warea
);
95 if ( getword ( user
, sizeof ( user
),& gwarea
, ' \t ' )< 0 ) {
96 printf ( "SARG: Maybe you have a broken user in your %s file. \n " , wger
);
99 if ( strcmp ( user
, "TOTAL" ) == 0 ) {
102 if ( getword ( nacc
, sizeof ( nacc
),& gwarea
, ' \t ' )< 0 ) {
103 printf ( "SARG: Maybe you have a broken number of access in your %s file. \n " , wger
);
106 if ( getword ( nbytes
, sizeof ( nbytes
),& gwarea
, ' \t ' )< 0 ) {
107 printf ( "SARG: Maybe you have a broken number of bytes in your %s file. \n " , wger
);
110 if ( getword ( url
, sizeof ( url
),& gwarea
, ' \t ' )< 0 ) {
111 printf ( "SARG: Maybe you have a broken url in your %s file. \n " , wger
);
114 if ( getword ( ip
, sizeof ( ip
),& gwarea
, ' \t ' )< 0 ) {
115 printf ( "SARG: Maybe you have a broken user's IP in your %s file. \n " , wger
);
118 if ( getword ( time
, sizeof ( time
),& gwarea
, ' \t ' )< 0 ) {
119 printf ( "SARG: Maybe you have a broken time in your %s file. \n " , wger
);
122 if ( getword ( date
, sizeof ( date
),& gwarea
, ' \t ' )< 0 ) {
123 printf ( "SARG: Maybe you have a broken date in your %s file. \n " , wger
);
126 if ( getword ( elap
, sizeof ( elap
),& gwarea
, ' \t ' )< 0 ) {
127 printf ( "SARG: Maybe you have a broken download duration in your %s file. \n " , wger
);
130 if ( getword ( incac
, sizeof ( incac
),& gwarea
, ' \t ' )< 0 ) {
131 printf ( "SARG: Maybe you have a broken in cache download in your %s file. \n " , wger
);
134 if ( getword ( oucac
, sizeof ( oucac
),& gwarea
, ' \t ' )< 0 ) {
135 printf ( "SARG: Maybe you have a broken not in cache download in your %s file. \n " , wger
);
138 if ( strcmp ( olduser
, user
) != 0 ) {
141 if ( olduser
[ 0 ] != '\0' ) {
142 my_lltoa ( tnbytes
, val1
, 15 );
143 my_lltoa ( tnacc
, val2
, 15 );
144 my_lltoa ( tnelap
, val3
, 15 );
145 my_lltoa ( tnincache
, val4
, 15 );
146 my_lltoa ( tnoucache
, val5
, 15 );
147 fprintf ( fp_top2
, "%s \t %s \t %s \t %s \t %s \t %s \n " , olduser
, val1
, val2
, val3
, val4
, val5
);
152 ttnincache
+= tnincache
;
153 ttnoucache
+= tnoucache
;
155 strcpy ( olduser
, user
);
163 tnbytes
+= my_atoll ( nbytes
);
164 tnacc
+= my_atoll ( nacc
);
165 tnelap
+= my_atoll ( elap
);
166 tnincache
+= my_atoll ( incac
);
167 tnoucache
+= my_atoll ( oucac
);
170 if ( olduser
[ 0 ] != '\0' ) {
171 my_lltoa ( tnbytes
, val1
, 15 );
172 my_lltoa ( tnacc
, val2
, 15 );
173 my_lltoa ( tnelap
, val3
, 15 );
174 my_lltoa ( tnincache
, val4
, 15 );
175 my_lltoa ( tnoucache
, val5
, 15 );
176 fprintf ( fp_top2
, "%s \t %s \t %s \t %s \t %s \t %s \n " , olduser
, val1
, val2
, val3
, val4
, val5
);
181 ttnincache
+= tnincache
;
182 ttnoucache
+= tnoucache
;
186 my_lltoa ( ttnbytes
, val1
, 15 );
187 my_lltoa ( ttnacc
, val2
, 15 );
188 my_lltoa ( ttnelap
, val3
, 15 );
189 my_lltoa ( ttnincache
, val4
, 15 );
190 my_lltoa ( ttnoucache
, val5
, 15 );
191 if ( fp_in
) fclose ( fp_in
);
192 if ( fp_top2
) fclose ( fp_top2
);
194 strup ( TopuserSortField
);
195 strlow ( TopuserSortOrder
);
197 if ( strcmp ( TopuserSortField
, "USER" ) == 0 )
198 strcpy ( sfield
, "1,1" );
200 if ( strcmp ( TopuserSortField
, "CONNECT" ) == 0 )
201 strcpy ( sfield
, "3,3" );
203 if ( strcmp ( TopuserSortField
, "TIME" ) == 0 )
204 strcpy ( sfield
, "4,4" );
206 if ( strcmp ( TopuserSortOrder
, "normal" ) == 0 )
209 sprintf ( csort
, "sort -n -T \" %s \" %s -k %s -o \" %s \" \" %s \" " , TempDir
, order
, sfield
, top1
, top2
);
210 cstatus
= system ( csort
);
211 if (! WIFEXITED ( cstatus
) || WEXITSTATUS ( cstatus
)) {
212 fprintf ( stderr
, "SARG: sort command return status %d \n " , WEXITSTATUS ( cstatus
));
213 fprintf ( stderr
, "SARG: sort command: %s \n " , csort
);
216 if (( fp_top1
= fopen ( top1
, "a" ))== NULL
) {
217 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top1
);
218 fprintf ( stderr
, "SARG: sort command: %s \n " , csort
);
224 fprintf ( fp_top1
, "TOTAL \t %s \t %s \t %s \t %s \t %s \n " , val1
, val2
, val3
, val4
, val5
);
231 strcpy ( arqper
, dirname
);
232 strcat ( arqper
, "/sarg-period" );
234 if (( fp_in
= fopen ( arqper
, "r" )) == 0 ) {
235 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], arqper
);
239 if (! fgets ( period
, sizeof ( period
), fp_in
)) {
240 fprintf ( stderr
, "SARG: (topuser) Read error in %s \n " , arqper
);
245 if (( fp_top1
= fopen ( top1
, "r" ))== NULL
) {
246 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top1
);
250 if (( fp_top3
= fopen ( top3
, "w" ))== NULL
) {
251 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top3
);
255 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
);
257 fprintf ( fp_top3
, "</head> \n <body class= \" body \" >" );
258 write_logo_image ( fp_top3
);
260 if ( strcmp ( IndexTree
, "date" ) == 0 )
261 show_sarg ( fp_top3
, "../../.." );
263 show_sarg ( fp_top3
, ".." );
264 fputs ( "<div align= \" center \" ><table cellpadding= \" 0 \" cellspacing= \" 0 \" > \n " , fp_top3
);
265 fprintf ( fp_top3
, "<tr><th align= \" center \" class= \" title \" >%s</th></tr> \n " , Title
);
267 fprintf ( fp_top3
, "<tr><td class= \" header3 \" >%s: %s</td></tr> \n " , text
[ 89 ], period
);
268 strcat ( wheader
,( char *) text
[ 104 ]);
269 strcat ( wheader
, ": " );
270 strcat ( wheader
, TopuserSortField
);
271 strcat ( wheader
, ", " );
272 strcat ( wheader
, TopuserSortOrder
);
273 fprintf ( fp_top3
, "<tr><td class= \" header3 \" >%s</td></tr> \n " , wheader
);
274 fprintf ( fp_top3
, "<tr><th class= \" header3 \" >%s</th></tr> \n " , text
[ 137 ]);
276 fputs ( "</table></div> \n " , fp_top3
);
277 fputs ( "<div align= \" center \" ><table cellpadding= \" 1 \" cellspacing= \" 2 \" > \n " , fp_top3
);
278 fputs ( "<tr><td><br></td><td></td></tr> \n " , fp_top3
);
280 if ( strstr ( ReportType
, "topsites" ) != 0 && strcmp ( Privacy
, "yes" ) != 0 ) 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 ]);
281 if ( strstr ( ReportType
, "sites_users" ) != 0 && strcmp ( Privacy
, "yes" ) != 0 ) 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 ]);
282 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 ]);
283 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 ]);
284 if ( strstr ( ReportType
, "downloads" ) != 0 && download_count
&& strcmp ( Privacy
, "yes" ) != 0 && 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 ]);
285 if ( strstr ( ReportType
, "denied" ) != 0 && denied_count
&& strcmp ( Privacy
, "yes" ) != 0 ) 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 ]);
286 if ( strstr ( ReportType
, "auth_failures" ) != 0 && authfail_count
&& strcmp ( Privacy
, "yes" ) != 0 ) 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 ]);
287 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 ]);
288 fputs ( "<tr><td></td></tr> \n " , fp_top3
);
290 if ( strstr ( ReportType
, "topuser" ) == 0 ) {
291 fputs ( "</body> \n </html> \n " , fp_top3
);
292 if ( fp_top3
) fclose ( fp_top3
);
296 strcpy ( hbc10
, "class= \" header \" " );
298 if ( strstr ( TopUserFields
, "NUM" ) == 0 ) {
302 strcpy ( val1
, text
[ 100 ]);
303 strcpy ( hbc1
, "class= \" header \" " );
305 if ( strstr ( TopUserFields
, "USERID" ) == 0 ) {
309 strcpy ( val2
, text
[ 98 ]);
310 strcpy ( hbc2
, "class= \" header \" " );
312 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
316 strcpy ( val3
, text
[ 92 ]);
317 strcpy ( hbc3
, "class= \" header \" " );
319 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
323 strcpy ( val4
, text
[ 93 ]);
324 strcpy ( hbc4
, "class= \" header \" " );
326 if ( strstr ( TopUserFields
, "SETYB" ) == 0 ) {
330 sprintf ( val11
, "%%%s" , text
[ 93 ]);
331 strcpy ( hbc9
, "class= \" header \" " );
333 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
337 strcpy ( val10
, "<td></td>" );
339 sprintf ( val5
, "%s-%s-%s" , text
[ 113 ], text
[ 114 ], text
[ 112 ]);
340 strcpy ( hbc5
, "class= \" header3 \" " );
341 strcpy ( val9
, "colspan= \" 2 \" " );
344 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
348 strcpy ( val6
, text
[ 94 ]);
349 strcpy ( hbc6
, "class= \" header \" " );
351 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
355 strcpy ( val7
, text
[ 95 ]);
356 strcpy ( hbc7
, "class= \" header \" " );
358 if ( strstr ( TopUserFields
, "%TIME" ) == 0 ) {
362 sprintf ( val8
, "%%%s" , text
[ 99 ]);
363 strcpy ( hbc8
, "class= \" header \" " );
366 fprintf ( fp_top3
, "<tr><th %s>%s</th><th %s></th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s %s>%s%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr> \n " , hbc1
, val1
, hbc1
, hbc2
, val2
, hbc3
, val3
, hbc4
, val4
, hbc9
, val11
, hbc5
, val9
, val5
, val10
, hbc6
, val6
, hbc7
, val7
, hbc8
, val8
);
370 while ( fgets ( warea
, sizeof ( warea
), fp_top1
)) {
371 getword_start (& gwarea
, warea
);
372 if ( getword ( user
, sizeof ( user
),& gwarea
, ' \t ' )< 0 ) {
373 printf ( "SARG: Maybe you have a broken user in your %s file. \n " , top1
);
376 if ( getword ( nbytes
, sizeof ( nbytes
),& gwarea
, ' \t ' )< 0 ) {
377 printf ( "SARG: Maybe you have a broken number of bytes in your %s file. \n " , top1
);
380 if ( getword ( nacc
, sizeof ( nacc
),& gwarea
, ' \t ' )< 0 ) {
381 printf ( "SARG: Maybe you have a broken number of access in your %s file. \n " , top1
);
384 if ( getword ( elap
, sizeof ( elap
),& gwarea
, ' \t ' )< 0 ) {
385 printf ( "SARG: Maybe you have a broken elpased time in your %s file. \n " , wger
);
388 if ( getword ( incac
, sizeof ( incac
),& gwarea
, ' \t ' )< 0 ) {
389 printf ( "SARG: Maybe you have a broken in-cache size in your %s file. \n " , wger
);
392 if ( getword ( oucac
, sizeof ( oucac
),& gwarea
, ' \t ' )< 0 ) {
393 printf ( "SARG: Maybe you have a broken out-of-cache size in your %s file. \n " , wger
);
400 if ( TopUsersNum
> 0 && topcount
>= TopUsersNum
) goto final
;
402 tnbytes
= my_atoll ( nbytes
);
406 perc
= perc
/ ttnbytes
;
411 perc2
=(( perc2
* 100 ) / ttnelap
);
416 inperc
=(( inperc
* 100 ) / tnbytes
);
421 ouperc
=(( ouperc
* 100 ) / tnbytes
);
424 if ( strcmp ( user
, "TOTAL" ) != 0 ){
425 sprintf ( href1
, "<a href= \" %s/%s.html \" >" , user
, user
);
426 strcpy ( href1end
, "</a>" );
427 sprintf ( href2
, "<a href= \" %s/d%s.html \" >" , user
, user
);
428 strcpy ( href2end
, "</a>" );
429 sprintf ( href3
, "<a href= \" %s/graph_day.png \" >" , user
);
430 strcpy ( href3end
, "</a>" );
441 if ( strcmp ( Graphs
, "yes" ) != 0 ) {
446 tnelap
= my_atoll ( elap
);
450 if ( strcmp ( Ip2Name
, "yes" ) == 0 ) {
451 if ( strcmp ( user2
, ipantes
) != 0 ) {
452 strcpy ( ipantes
, user2
);
453 ip2name ( user2
, sizeof ( user2
));
454 strcpy ( nameantes
, user2
);
455 } else strcpy ( user2
, nameantes
);
459 if ( strstr ( ReportType
, "date_time" ) != 0 ) {
460 sprintf ( ltext110
, "%s" , text
[ 110 ]);
461 for ( s
= ltext110
; * s
; ++ s
)
464 bzero ( href2
, MAXLEN
);
467 sprintf ( val1
, "%s/d%s.html" , dirname
, user
);
471 if ( strcmp ( user2
, "TOTAL" ) != 0 ) {
472 get_usertab_name ( user2
, name
, sizeof ( name
));
474 if (( strcmp ( Ip2Name
, "yes" ) == 0 ) &&
475 (( str
=( char *) strstr ( name
, "." )) != ( char *) NULL
) &&
476 (( str
=( char *) strstr ( str
+ 1 , "." )) != ( char *) NULL
))
477 ip2name ( name
, sizeof ( name
));
482 twork
= my_atoll ( nacc
);
483 my_lltoa ( twork
, nacc
, 0 );
484 strcpy ( wwork1
, fixnum ( twork
, 1 ));
485 strcpy ( wwork2
, fixnum ( tnbytes
, 1 ));
486 strcpy ( wwork3
, fixnum2 ( tnelap
, 1 ));
488 sprintf ( val1
, "%d" , posicao
);
490 sprintf ( val2
, "%s<img src= \" %s/graph.png \" border= \" 0 \" title= \" %s \" alt= \" G \" >%s %s<img src= \" %s/datetime.png \" border= \" 0 \" title= \" %s %s \" alt= \" T \" >%s \n " , href3
, ImageFile
, text
[ 126 ], href3end
, href2
, ImageFile
, ltext110
, text
[ 55 ], href2end
);
492 sprintf ( val2
, "%s<img src= \" %s/datetime.png \" border= \" 0 \" title= \" %s \" alt= \" T \" >%s \n " , href2
, ImageFile
, ltext110
, href2end
);
495 sprintf ( val3
, "%3.2f%%" , perc
);
496 sprintf ( val4
, "%3.2f%%" , inperc
);
497 sprintf ( val5
, "%3.2f%%" , ouperc
);
498 sprintf ( val6
, "%s" , buildtime ( tnelap
));
499 sprintf ( val7
, "%3.2f%%" , perc2
);
501 strcpy ( hbc1
, "class= \" data \" " );
502 strcpy ( hbc2
, "class= \" data2 \" " );
503 strcpy ( hbc3
, "class= \" data \" " );
504 strcpy ( hbc4
, "class= \" data \" " );
505 strcpy ( hbc5
, "class= \" data \" " );
506 strcpy ( hbc6
, "class= \" data \" " );
507 strcpy ( hbc7
, "class= \" data \" " );
508 strcpy ( hbc8
, "class= \" data \" " );
509 strcpy ( hbc9
, "class= \" data \" " );
510 strcpy ( hbc10
, "class= \" data \" " );
512 if ( strstr ( TopUserFields
, "NUM" ) == 0 ) {
516 if ( strstr ( TopUserFields
, "USERID" ) == 0 ) {
520 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
524 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
528 if ( strstr ( TopUserFields
, "SETYB" ) == 0 ) {
533 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
537 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
541 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
545 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
549 if ( strstr ( TopUserFields
, "%TIME" ) == 0 ) {
554 if ( strstr ( ReportType
, "users_sites" ) == 0 ) {
559 if ( dotinuser
&& strchr ( name
, '_' )) {
560 subs ( name
, sizeof ( name
), "_" , "." );
563 sprintf ( preg
, "<tr><td %s>%s</td><td %s>%s</td><td %s>%s%s%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s</td><td %s>%s<td %s>%s</td></tr> \n " , hbc1
, val1
, hbc2
, val2
, hbc2
, href1
, name
, href1end
, hbc3
, wwork1
, hbc4
, wwork2
, hbc5
, val3
, hbc6
, val4
, hbc7
, val5
, hbc8
, val6
, hbc9
, wwork3
, hbc10
, val7
);
565 if ( strstr ( user
, "TOTAL" ) != 0 ) {
568 inperc
= ttnbytes
/ 100 ;
569 inperc
= atol ( incac
) / inperc
;
573 ouperc
= ttnbytes
/ 100 ;
574 ouperc
= atol ( oucac
) / ouperc
;
577 sprintf ( wwork1
, "%s" , fixnum ( ttnacc
, 1 ));
578 sprintf ( wwork2
, "%s" , fixnum ( ttnbytes
, 1 ));
579 sprintf ( wwork3
, "%s" , fixnum2 ( ttnelap
, 1 ));
581 strcpy ( hbc1
, "class= \" header2 \" " );
582 strcpy ( hbc2
, "class= \" header2 \" " );
583 strcpy ( hbc3
, "class= \" header2 \" " );
584 strcpy ( hbc4
, "class= \" header2 \" " );
585 strcpy ( hbc5
, "class= \" header2 \" " );
586 strcpy ( hbc6
, "class= \" header2 \" " );
587 strcpy ( hbc7
, "class= \" header2 \" " );
588 strcpy ( hbc8
, "class= \" header2 \" " );
589 strcpy ( hbc9
, "class= \" header2 \" " );
590 strcpy ( hbc10
, "class= \" header \" " );
592 sprintf ( val4
, "%3.2f%%" , inperc
);
593 sprintf ( val5
, "%3.2f%%" , ouperc
);
594 sprintf ( val6
, "%s" , buildtime ( ttnelap
));
595 sprintf ( val7
, "%3.2f%%" , perc2
);
597 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
601 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
605 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
611 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
615 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
620 if ( strstr ( ReportType
, "date_time" ) != 0 ) {
621 if ( strstr ( TopUserFields
, "TOTAL" ) != 0 )
622 sprintf ( preg
, "<tr><td></td><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr> \n " , hbc10
, text
[ 107 ], hbc1
, wwork1
, hbc2
, wwork2
, hbc3
, val4
, hbc4
, val5
, hbc5
, val6
, hbc6
, wwork3
);
623 } else if ( strstr ( TopUserFields
, "TOTAL" ) != 0 )
624 sprintf ( preg
, "<tr><td></td><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><th %s>%s</th><th %s>%s</th><th %s>%s</th><th %s>%s</th></tr> \n " , hbc10
, text
[ 107 ], hbc1
, wwork1
, hbc2
, wwork2
, hbc3
, val4
, hbc4
, val5
, hbc5
, val6
, hbc6
, wwork3
);
632 if ( ttnbytes
) tnbytes
= ttnbytes
/ totuser
;
635 twork
= ttnacc
/ totuser
;
636 twork2
= ttnelap
/ totuser
;
637 strcpy ( wwork1
, fixnum ( twork
, 1 ));
638 strcpy ( wwork2
, fixnum ( tnbytes
, 1 ));
639 strcpy ( wwork3
, fixnum2 ( twork2
, 1 ));
641 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
645 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
649 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
655 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
659 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
665 if (( strstr ( ReportType
, "date_time" ) != 0 && strstr ( TopUserFields
, "AVERAGE" ) != 0 ))
666 fprintf ( fp_top3
, "<tr><td></td><th></th><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr> \n " , hbc10
, text
[ 96 ], hbc1
, wwork1
, hbc2
, wwork2
, hbc3
, buildtime ( ttnelap
/ totuser
), hbc4
, wwork3
);
667 else if ( strstr ( TopUserFields
, "AVERAGE" ) != 0 )
668 fprintf ( fp_top3
, "<tr><td></td><th></th><td></td><th %s>%s</th><th %s>%s</th><th %s>%15s</th><td></td><td></td><td></td><th %s>%s</th><th %s>%s</th></tr> \n " , hbc10
, text
[ 96 ], hbc1
, wwork1
, hbc2
, wwork2
, hbc3
, buildtime ( ttnelap
/ totuser
), hbc4
, wwork3
);
671 if ( UserAgentLog
[ 0 ] != '\0' ) {
672 fputs ( "<tr><td></td></tr> \n " , fp_top3
);
673 fputs ( "<tr><td></td></tr> \n " , fp_top3
);
674 fputs ( "<td align= \" left \" colspan= \" 8 \" ><font size=-1><a href= \" useragent.html \" >Useragent</a> Report</td> \n " , fp_top3
);
677 fputs ( "</table></div>" , fp_top3
);
685 if (( fp_ou
= fopen ( tusr
, "w" ))== NULL
) {
686 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], tusr
);
690 fprintf ( fp_ou
, "%d \n " , totuser
);
692 fputs ( "</body> \n </html> \n " , fp_top3
);