]>
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" ;
72 strcat ( wger
, "/sarg-general" );
74 strcat ( top2
, "/top.tmp" );
75 strcat ( tusr
, "/sarg-users" );
76 strcat ( top3
, "/index.html" );
79 if (( fp_in
= fopen ( wger
, "r" ))== NULL
) {
80 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], wger
);
84 if (( fp_top2
= fopen ( top2
, "w" ))== NULL
) {
85 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top2
);
92 while ( fgets ( warea
, sizeof ( warea
), fp_in
)) {
93 if ( getword ( user
, sizeof ( user
), warea
, ' ' )< 0 ) {
94 printf ( "SARG: Maybe you have a broken user in your %s file. \n " , wger
);
97 if ( strcmp ( user
, "TOTAL" ) == 0 ) {
100 if ( getword ( nacc
, sizeof ( nacc
), warea
, ' ' )< 0 ) {
101 printf ( "SARG: Maybe you have a broken number of access in your %s file. \n " , wger
);
104 if ( getword ( nbytes
, sizeof ( nbytes
), warea
, ' ' )< 0 ) {
105 printf ( "SARG: Maybe you have a broken number of bytes in your %s file. \n " , wger
);
108 if ( getword ( url
, sizeof ( url
), warea
, ' ' )< 0 ) {
109 printf ( "SARG: Maybe you have a broken url in your %s file. \n " , wger
);
112 if ( getword ( ip
, sizeof ( ip
), warea
, ' ' )< 0 ) {
113 printf ( "SARG: Maybe you have a broken user's IP in your %s file. \n " , wger
);
116 if ( getword ( time
, sizeof ( time
), warea
, ' ' )< 0 ) {
117 printf ( "SARG: Maybe you have a broken time in your %s file. \n " , wger
);
120 if ( getword ( date
, sizeof ( date
), warea
, ' ' )< 0 ) {
121 printf ( "SARG: Maybe you have a broken date in your %s file. \n " , wger
);
124 if ( getword ( elap
, sizeof ( elap
), warea
, ' ' )< 0 ) {
125 printf ( "SARG: Maybe you have a broken download duration in your %s file. \n " , wger
);
128 if ( getword ( incac
, sizeof ( incac
), warea
, ' ' )< 0 ) {
129 printf ( "SARG: Maybe you have a broken in cache download in your %s file. \n " , wger
);
132 if ( getword ( oucac
, sizeof ( oucac
), warea
, ' ' )< 0 ) {
133 printf ( "SARG: Maybe you have a broken not in cache download in your %s file. \n " , wger
);
136 if ( strcmp ( olduser
, user
) != 0 ) {
139 if ( olduser
[ 0 ] != '\0' ) {
140 my_lltoa ( tnbytes
, val1
, 15 );
141 my_lltoa ( tnacc
, val2
, 15 );
142 my_lltoa ( tnelap
, val3
, 15 );
143 my_lltoa ( tnincache
, val4
, 15 );
144 my_lltoa ( tnoucache
, val5
, 15 );
145 fprintf ( fp_top2
, "%s %s %s %s %s %s \n " , olduser
, val1
, val2
, val3
, val4
, val5
);
150 ttnincache
+= tnincache
;
151 ttnoucache
+= tnoucache
;
153 strcpy ( olduser
, user
);
161 tnbytes
+= my_atoll ( nbytes
);
162 tnacc
+= my_atoll ( nacc
);
163 tnelap
+= my_atoll ( elap
);
164 tnincache
+= my_atoll ( incac
);
165 tnoucache
+= my_atoll ( oucac
);
168 if ( olduser
[ 0 ] != '\0' ) {
169 my_lltoa ( tnbytes
, val1
, 15 );
170 my_lltoa ( tnacc
, val2
, 15 );
171 my_lltoa ( tnelap
, val3
, 15 );
172 my_lltoa ( tnincache
, val4
, 15 );
173 my_lltoa ( tnoucache
, val5
, 15 );
174 fprintf ( fp_top2
, "%s %s %s %s %s %s \n " , olduser
, val1
, val2
, val3
, val4
, val5
);
179 ttnincache
+= tnincache
;
180 ttnoucache
+= tnoucache
;
184 my_lltoa ( ttnbytes
, val1
, 15 );
185 my_lltoa ( ttnacc
, val2
, 15 );
186 my_lltoa ( ttnelap
, val3
, 15 );
187 my_lltoa ( ttnincache
, val4
, 15 );
188 my_lltoa ( ttnoucache
, val5
, 15 );
189 if ( fp_in
) fclose ( fp_in
);
190 if ( fp_top2
) fclose ( fp_top2
);
192 strup ( TopuserSortField
);
193 strlow ( TopuserSortOrder
);
195 if ( strcmp ( TopuserSortField
, "USER" ) == 0 )
196 strcpy ( sfield
, "1,1" );
198 if ( strcmp ( TopuserSortField
, "CONNECT" ) == 0 )
199 strcpy ( sfield
, "3,3" );
201 if ( strcmp ( TopuserSortField
, "TIME" ) == 0 )
202 strcpy ( sfield
, "4,4" );
204 if ( strcmp ( TopuserSortOrder
, "normal" ) == 0 )
207 sprintf ( csort
, "sort -n -T \" %s \" %s -k %s -o \" %s \" \" %s \" " , TempDir
, order
, sfield
, top1
, top2
);
208 cstatus
= system ( csort
);
209 if (! WIFEXITED ( cstatus
) || WEXITSTATUS ( cstatus
)) {
210 fprintf ( stderr
, "SARG: sort command return status %d \n " , WEXITSTATUS ( cstatus
));
211 fprintf ( stderr
, "SARG: sort command: %s \n " , csort
);
214 if (( fp_top1
= fopen ( top1
, "a" ))== NULL
) {
215 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top1
);
216 fprintf ( stderr
, "SARG: sort command: %s \n " , csort
);
222 fprintf ( fp_top1
, "TOTAL %s %s %s %s %s \n " , val1
, val2
, val3
, val4
, val5
);
229 strcpy ( arqper
, dirname
);
230 strcat ( arqper
, "/sarg-period" );
232 if (( fp_in
= fopen ( arqper
, "r" )) == 0 ) {
233 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], arqper
);
237 if (! fgets ( period
, sizeof ( period
), fp_in
)) {
238 fprintf ( stderr
, "SARG: (topuser) Read error in %s \n " , arqper
);
243 if (( fp_top1
= fopen ( top1
, "r" ))== NULL
) {
244 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top1
);
248 if (( fp_top3
= fopen ( top3
, "w" ))== NULL
) {
249 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], top3
);
253 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
);
255 fprintf ( fp_top3
, "</head> \n <body class= \" body \" >" );
256 write_logo_image ( fp_top3
);
258 if ( strcmp ( IndexTree
, "date" ) == 0 )
259 show_sarg ( fp_top3
, "../../.." );
261 show_sarg ( fp_top3
, ".." );
262 fputs ( "<div align= \" center \" ><table cellpadding= \" 0 \" cellspacing= \" 0 \" > \n " , fp_top3
);
263 fprintf ( fp_top3
, "<tr><th align= \" center \" class= \" title \" >%s</th></tr> \n " , Title
);
265 fprintf ( fp_top3
, "<tr><td class= \" header3 \" >%s: %s</td></tr> \n " , text
[ 89 ], period
);
266 strcat ( wheader
,( char *) text
[ 104 ]);
267 strcat ( wheader
, ": " );
268 strcat ( wheader
, TopuserSortField
);
269 strcat ( wheader
, ", " );
270 strcat ( wheader
, TopuserSortOrder
);
271 fprintf ( fp_top3
, "<tr><td class= \" header3 \" >%s</td></tr> \n " , wheader
);
272 fprintf ( fp_top3
, "<tr><th class= \" header3 \" >%s</th></tr> \n " , text
[ 137 ]);
274 fputs ( "</table></div> \n " , fp_top3
);
275 fputs ( "<div align= \" center \" ><table cellpadding= \" 1 \" cellspacing= \" 2 \" > \n " , fp_top3
);
276 fputs ( "<tr><td><br></td><td></td></tr> \n " , fp_top3
);
278 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 ]);
279 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 ]);
280 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 ]);
281 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 ]);
282 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 ]);
283 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 ]);
284 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 ]);
285 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 ]);
286 fputs ( "<tr><td></td></tr> \n " , fp_top3
);
288 if ( strstr ( ReportType
, "topuser" ) == 0 ) {
289 fputs ( "</body> \n </html> \n " , fp_top3
);
290 if ( fp_top3
) fclose ( fp_top3
);
294 strcpy ( hbc10
, "class= \" header \" " );
296 if ( strstr ( TopUserFields
, "NUM" ) == 0 ) {
300 strcpy ( val1
, text
[ 100 ]);
301 strcpy ( hbc1
, "class= \" header \" " );
303 if ( strstr ( TopUserFields
, "USERID" ) == 0 ) {
307 strcpy ( val2
, text
[ 98 ]);
308 strcpy ( hbc2
, "class= \" header \" " );
310 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
314 strcpy ( val3
, text
[ 92 ]);
315 strcpy ( hbc3
, "class= \" header \" " );
317 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
321 strcpy ( val4
, text
[ 93 ]);
322 strcpy ( hbc4
, "class= \" header \" " );
324 if ( strstr ( TopUserFields
, "SETYB" ) == 0 ) {
328 sprintf ( val11
, "%%%s" , text
[ 93 ]);
329 strcpy ( hbc9
, "class= \" header \" " );
331 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
335 strcpy ( val10
, "<td></td>" );
337 sprintf ( val5
, "%s-%s-%s" , text
[ 113 ], text
[ 114 ], text
[ 112 ]);
338 strcpy ( hbc5
, "class= \" header3 \" " );
339 strcpy ( val9
, "colspan= \" 2 \" " );
342 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
346 strcpy ( val6
, text
[ 94 ]);
347 strcpy ( hbc6
, "class= \" header \" " );
349 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
353 strcpy ( val7
, text
[ 95 ]);
354 strcpy ( hbc7
, "class= \" header \" " );
356 if ( strstr ( TopUserFields
, "%TIME" ) == 0 ) {
360 sprintf ( val8
, "%%%s" , text
[ 99 ]);
361 strcpy ( hbc8
, "class= \" header \" " );
364 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
);
368 while ( fgets ( warea
, sizeof ( warea
), fp_top1
)) {
369 if ( getword ( user
, sizeof ( user
), warea
, ' ' )< 0 ) {
370 printf ( "SARG: Maybe you have a broken user in your %s file. \n " , top1
);
373 if ( getword ( nbytes
, sizeof ( nbytes
), warea
, ' ' )< 0 ) {
374 printf ( "SARG: Maybe you have a broken number of bytes in your %s file. \n " , top1
);
377 if ( getword ( nacc
, sizeof ( nacc
), warea
, ' ' )< 0 ) {
378 printf ( "SARG: Maybe you have a broken number of access in your %s file. \n " , top1
);
381 if ( getword ( elap
, sizeof ( elap
), warea
, ' ' )< 0 ) {
382 printf ( "SARG: Maybe you have a broken elpased time in your %s file. \n " , wger
);
385 if ( getword ( incac
, sizeof ( incac
), warea
, ' ' )< 0 ) {
386 printf ( "SARG: Maybe you have a broken in-cache size in your %s file. \n " , wger
);
389 if ( getword ( oucac
, sizeof ( oucac
), warea
, ' ' )< 0 ) {
390 printf ( "SARG: Maybe you have a broken out-of-cache size in your %s file. \n " , wger
);
397 if ( TopUsersNum
> 0 && topcount
>= TopUsersNum
) goto final
;
399 tnbytes
= my_atoll ( nbytes
);
403 perc
= perc
/ ttnbytes
;
408 perc2
=(( perc2
* 100 ) / ttnelap
);
413 inperc
=(( inperc
* 100 ) / tnbytes
);
418 ouperc
=(( ouperc
* 100 ) / tnbytes
);
421 if ( strcmp ( user
, "TOTAL" ) != 0 ){
422 sprintf ( href1
, "<a href= \" %s/%s.html \" >" , user
, user
);
423 strcpy ( href1end
, "</a>" );
424 sprintf ( href2
, "<a href= \" %s/d%s.html \" >" , user
, user
);
425 strcpy ( href2end
, "</a>" );
426 sprintf ( href3
, "<a href= \" %s/graph_day.png \" >" , user
);
427 strcpy ( href3end
, "</a>" );
438 if ( strcmp ( Graphs
, "yes" ) != 0 ) {
443 tnelap
= my_atoll ( elap
);
447 if ( strcmp ( Ip2Name
, "yes" ) == 0 ) {
448 if ( strcmp ( user2
, ipantes
) != 0 ) {
449 strcpy ( ipantes
, user2
);
450 ip2name ( user2
, sizeof ( user2
));
451 strcpy ( nameantes
, user2
);
452 } else strcpy ( user2
, nameantes
);
456 if ( strstr ( ReportType
, "date_time" ) != 0 ) {
457 sprintf ( ltext110
, "%s" , text
[ 110 ]);
458 for ( s
= ltext110
; * s
; ++ s
)
461 bzero ( href2
, MAXLEN
);
464 sprintf ( val1
, "%s/d%s.html" , dirname
, user
);
468 if ( strcmp ( user2
, "TOTAL" ) != 0 ) {
469 get_usertab_name ( user2
, name
, sizeof ( name
));
471 if (( strcmp ( Ip2Name
, "yes" ) == 0 ) &&
472 (( str
=( char *) strstr ( name
, "." )) != ( char *) NULL
) &&
473 (( str
=( char *) strstr ( str
+ 1 , "." )) != ( char *) NULL
))
474 ip2name ( name
, sizeof ( name
));
479 twork
= my_atoll ( nacc
);
480 my_lltoa ( twork
, nacc
, 0 );
481 strcpy ( wwork1
, fixnum ( twork
, 1 ));
482 strcpy ( wwork2
, fixnum ( tnbytes
, 1 ));
483 strcpy ( wwork3
, fixnum2 ( tnelap
, 1 ));
485 sprintf ( val1
, "%d" , posicao
);
487 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
);
489 sprintf ( val2
, "%s<img src= \" %s/datetime.png \" border= \" 0 \" title= \" %s \" alt= \" T \" >%s \n " , href2
, ImageFile
, ltext110
, href2end
);
492 sprintf ( val3
, "%3.2f%%" , perc
);
493 sprintf ( val4
, "%3.2f%%" , inperc
);
494 sprintf ( val5
, "%3.2f%%" , ouperc
);
495 sprintf ( val6
, "%s" , buildtime ( tnelap
));
496 sprintf ( val7
, "%3.2f%%" , perc2
);
498 strcpy ( hbc1
, "class= \" data \" " );
499 strcpy ( hbc2
, "class= \" data2 \" " );
500 strcpy ( hbc3
, "class= \" data \" " );
501 strcpy ( hbc4
, "class= \" data \" " );
502 strcpy ( hbc5
, "class= \" data \" " );
503 strcpy ( hbc6
, "class= \" data \" " );
504 strcpy ( hbc7
, "class= \" data \" " );
505 strcpy ( hbc8
, "class= \" data \" " );
506 strcpy ( hbc9
, "class= \" data \" " );
507 strcpy ( hbc10
, "class= \" data \" " );
509 if ( strstr ( TopUserFields
, "NUM" ) == 0 ) {
513 if ( strstr ( TopUserFields
, "USERID" ) == 0 ) {
517 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
521 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
525 if ( strstr ( TopUserFields
, "SETYB" ) == 0 ) {
530 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
534 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
538 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
542 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
546 if ( strstr ( TopUserFields
, "%TIME" ) == 0 ) {
551 if ( strstr ( ReportType
, "users_sites" ) == 0 ) {
556 if ( dotinuser
&& strchr ( name
, '_' )) {
557 subs ( name
, sizeof ( name
), "_" , "." );
560 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
);
562 if ( strstr ( user
, "TOTAL" ) != 0 ) {
565 inperc
= ttnbytes
/ 100 ;
566 inperc
= atol ( incac
) / inperc
;
570 ouperc
= ttnbytes
/ 100 ;
571 ouperc
= atol ( oucac
) / ouperc
;
574 sprintf ( wwork1
, "%s" , fixnum ( ttnacc
, 1 ));
575 sprintf ( wwork2
, "%s" , fixnum ( ttnbytes
, 1 ));
576 sprintf ( wwork3
, "%s" , fixnum2 ( ttnelap
, 1 ));
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= \" header2 \" " );
587 strcpy ( hbc10
, "class= \" header \" " );
589 sprintf ( val4
, "%3.2f%%" , inperc
);
590 sprintf ( val5
, "%3.2f%%" , ouperc
);
591 sprintf ( val6
, "%s" , buildtime ( ttnelap
));
592 sprintf ( val7
, "%3.2f%%" , perc2
);
594 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
598 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
602 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
608 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
612 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
617 if ( strstr ( ReportType
, "date_time" ) != 0 ) {
618 if ( strstr ( TopUserFields
, "TOTAL" ) != 0 )
619 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
);
620 } else if ( strstr ( TopUserFields
, "TOTAL" ) != 0 )
621 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
);
629 if ( ttnbytes
) tnbytes
= ttnbytes
/ totuser
;
632 twork
= ttnacc
/ totuser
;
633 twork2
= ttnelap
/ totuser
;
634 strcpy ( wwork1
, fixnum ( twork
, 1 ));
635 strcpy ( wwork2
, fixnum ( tnbytes
, 1 ));
636 strcpy ( wwork3
, fixnum2 ( twork2
, 1 ));
638 if ( strstr ( TopUserFields
, "CONNECT" ) == 0 ) {
642 if ( strstr ( TopUserFields
, "BYTES" ) == 0 ) {
646 if ( strstr ( TopUserFields
, "IN-CACHE-OUT" ) == 0 ) {
652 if ( strstr ( TopUserFields
, "USED_TIME" ) == 0 ) {
656 if ( strstr ( TopUserFields
, "MILISEC" ) == 0 ) {
662 if (( strstr ( ReportType
, "date_time" ) != 0 && strstr ( TopUserFields
, "AVERAGE" ) != 0 ))
663 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
);
664 else if ( strstr ( TopUserFields
, "AVERAGE" ) != 0 )
665 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
);
668 if ( UserAgentLog
[ 0 ] != '\0' ) {
669 fputs ( "<tr><td></td></tr> \n " , fp_top3
);
670 fputs ( "<tr><td></td></tr> \n " , fp_top3
);
671 fputs ( "<td align= \" left \" colspan= \" 8 \" ><font size=-1><a href= \" useragent.html \" >Useragent</a> Report</td> \n " , fp_top3
);
674 fputs ( "</table></div>" , fp_top3
);
682 if (( fp_ou
= fopen ( tusr
, "w" ))== NULL
) {
683 fprintf ( stderr
, "SARG: (topuser) %s: %s \n " , text
[ 45 ], tusr
);
687 fprintf ( fp_ou
, "%d \n " , totuser
);
689 fputs ( "</body> \n </html> \n " , fp_top3
);