]> git.ipfire.org Git - thirdparty/sarg.git/blame - topuser.c
More messages to translate
[thirdparty/sarg.git] / topuser.c
CommitLineData
25697a35 1/*
94ff9470 2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
1164c474 3 * 1998, 2010
25697a35
GS
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
1164c474
FM
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
25697a35
GS
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"
5f3cfd1d 28#include "include/defs.h"
25697a35 29
32e71fa4 30void topuser(void)
25697a35
GS
31{
32
491b862f 33 FILE *fp_in = NULL, *fp_ou = NULL, *fp_top1 = NULL, *fp_top2 = NULL, *fp_top3 = NULL;
25697a35
GS
34 long long int ttnbytes=0, ttnacc=0, tnacc=0;
35 long long int tnbytes=0, ttnelap=0, tnelap=0;
36 long long int tnincache=0, tnoucache=0, ttnincache=0, ttnoucache=0;
6e792ade
FM
37 long long int nbytes;
38 long long int nacc;
39 long long int elap, incac, oucac;
9f20cdae
FM
40 double perc=0.00;
41 double perc2=0.00;
42 double inperc=0.00, ouperc=0.00;
25697a35 43 int posicao=0;
2240dcea 44 char olduser[MAX_USER_LEN], csort[MAXLEN], period[MAXLEN], arqper[MAXLEN];
25697a35 45 char wger[MAXLEN], top1[MAXLEN], top2[MAXLEN], top3[MAXLEN];
2240dcea 46 char user[MAX_USER_LEN], tusr[MAXLEN];
25697a35 47 char ipantes[MAXLEN], nameantes[MAXLEN];
f2ec8c75
FM
48 const char *sfield="-n -k 2,2";
49 const char *order="-r";
c0ec9cc7 50 char title[80];
ac422f9b 51 char *warea;
ac422f9b 52 char ltext110[100];
25697a35
GS
53 int totuser=0;
54 int topcount=0;
ac422f9b 55 int i;
25697a35 56 char *s;
456d78a5 57 int cstatus;
9c7c6346 58 struct getwordstruct gwarea;
ac422f9b 59 struct longlinestruct line;
2240dcea 60 struct generalitemstruct item;
f2ec8c75 61 const struct userinfostruct *uinfo;
25697a35
GS
62
63 ipantes[0]='\0';
64 nameantes[0]='\0';
65
9f20cdae
FM
66 /*
67 * get period
68 */
d5d021c5 69 snprintf(arqper,sizeof(arqper),"%s/sarg-period",outdirname);
9f20cdae 70 if ((fp_in = fopen(arqper, "r")) == 0) {
d5d021c5 71 debuga(_("(topuser) Cannot open file: %s\n"),arqper);
9f20cdae
FM
72 exit(1);
73 }
74 if (!fgets(period,sizeof(period),fp_in)) {
d5d021c5 75 debuga(_("(topuser) Read error in %s\n"),arqper);
9f20cdae
FM
76 exit(1);
77 }
78 fclose(fp_in);
79
d5d021c5
FM
80 strcpy(wger,outdirname);
81 strcpy(top1,outdirname);
82 strcpy(top2,outdirname);
83 strcpy(top3,outdirname);
84 strcpy(tusr,outdirname);
d6e703cc 85 strcat(wger,"/sarg-general");
25697a35
GS
86 strcat(top1,"/top");
87 strcat(top2,"/top.tmp");
d6e703cc 88 strcat(tusr,"/sarg-users");
25697a35
GS
89 strcat(top3,"/index.html");
90
d6e703cc 91 ntopuser = 0;
25697a35 92 if((fp_in=fopen(wger,"r"))==NULL) {
d5d021c5 93 debuga(_("(topuser) Cannot open file: %s\n"),wger);
936c9905 94 exit(1);
25697a35
GS
95 }
96
97 if((fp_top2=fopen(top2,"w"))==NULL) {
d5d021c5 98 debuga(_("(topuser) Cannot open file: %s\n"),top2);
936c9905 99 exit(1);
25697a35
GS
100 }
101
fb7c5f27
FM
102 olduser[0]='\0';
103 totuser=0;
25697a35 104
ac422f9b 105 if (longline_prepare(&line)<0) {
10210234 106 debuga(_("Not enough memory to read the file %s\n"),wger);
ac422f9b
FM
107 exit(1);
108 }
109
110 while((warea=longline_read(fp_in,&line))!=NULL) {
2240dcea
FM
111 ger_read(warea,&item,wger);
112 if(item.total) continue;
113 if(strcmp(olduser,item.user) != 0) {
fb7c5f27
FM
114 totuser++;
115
116 if (olduser[0] != '\0') {
f2ec8c75 117 fprintf(fp_top2,"%s\t%lld\t%lld\t%lld\t%lld\t%lld\n",olduser,tnbytes,tnacc,tnelap,tnincache,tnoucache);
fb7c5f27
FM
118
119 ttnbytes+=tnbytes;
120 ttnacc+=tnacc;
121 ttnelap+=tnelap;
122 ttnincache+=tnincache;
123 ttnoucache+=tnoucache;
124 }
2240dcea 125 strcpy(olduser,item.user);
25697a35
GS
126 tnbytes=0;
127 tnacc=0;
4157aa09 128 tnelap=0;
25697a35
GS
129 tnincache=0;
130 tnoucache=0;
131 }
132
2240dcea
FM
133 tnbytes+=item.nbytes;
134 tnacc+=item.nacc;
135 tnelap+=item.nelap;
136 tnincache+=item.incache;
137 tnoucache+=item.oucache;
25697a35 138 }
9f20cdae 139 fclose(fp_in);
ac422f9b 140 longline_free(&line);
25697a35 141
fb7c5f27 142 if (olduser[0] != '\0') {
f2ec8c75 143 fprintf(fp_top2,"%s\t%lld\t%lld\t%lld\t%lld\t%lld\n",olduser,tnbytes,tnacc,tnelap,tnincache,tnoucache);
fb7c5f27
FM
144
145 ttnbytes+=tnbytes;
146 ttnacc+=tnacc;
147 ttnelap+=tnelap;
148 ttnincache+=tnincache;
149 ttnoucache+=tnoucache;
fb7c5f27 150 }
9f20cdae 151 fclose(fp_top2);
25697a35
GS
152
153 strup(TopuserSortField);
154 strlow(TopuserSortOrder);
155
156 if(strcmp(TopuserSortField,"USER") == 0)
f2ec8c75 157 sfield="-k 1,1";
25697a35
GS
158
159 if(strcmp(TopuserSortField,"CONNECT") == 0)
f2ec8c75 160 sfield="-n -k 3,3";
25697a35
GS
161
162 if(strcmp(TopuserSortField,"TIME") == 0)
f2ec8c75 163 sfield="-n -k 4,4";
25697a35
GS
164
165 if(strcmp(TopuserSortOrder,"normal") == 0)
f2ec8c75 166 order="";
25697a35 167
f2ec8c75 168 sprintf(csort,"sort -T \"%s\" %s %s -o \"%s\" \"%s\"", TempDir, order, sfield, top1, top2);
456d78a5
FM
169 cstatus=system(csort);
170 if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
10210234
FM
171 debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
172 debuga(_("sort command: %s\n"),csort);
456d78a5
FM
173 exit(1);
174 }
25697a35 175
fb7c5f27 176 if((fp_top1=fopen(top1,"r"))==NULL) {
10210234 177 debuga("(topuser) %s: %s\n",_("Cannot open file"),top1);
fb7c5f27
FM
178 exit(1);
179 }
180
9f20cdae
FM
181 unlink(top2);
182
fb7c5f27 183 if((fp_top3=fopen(top3,"w"))==NULL) {
c36c7384 184 fprintf(stderr, "SARG: (topuser) %s: %s\n",_("Cannot open file"),top3);
fb7c5f27
FM
185 exit(1);
186 }
187
c0ec9cc7
FM
188 snprintf(title,sizeof(title),_("SARG report for %s"),period);
189 write_html_header(fp_top3,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,title);
c36c7384
FM
190 fprintf(fp_top3,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period);
191 fprintf(fp_top3,"<tr><td class=\"header_c\">%s: %s, %s</td></tr>\n",_("Sort"),TopuserSortField,TopuserSortOrder);
192 fprintf(fp_top3,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Topuser"));
c0ec9cc7 193 close_html_header(fp_top3);
9f20cdae 194
c0ec9cc7 195 fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
9f20cdae 196 fputs("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n",fp_top3);
25697a35 197
c36c7384
FM
198 if((ReportType & REPORT_TYPE_TOPSITES) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"topsites.html\">%s</a></td></tr>\n",_("Topsites"));
199 if((ReportType & REPORT_TYPE_SITES_USERS) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"siteuser.html\">%s</a></td></tr>\n",_("Sites & Users"));
200 if(dansguardian_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"dansguardian.html\">%s</a></td></tr>\n",_("DansGuardian"));
201 if(squidguard_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"squidguard.html\">%s</a></td></tr>\n",_("squidGuard"));
202 if ((ReportType & REPORT_TYPE_DOWNLOADS) != 0 && download_count && !Privacy && ndownload) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"download.html\">%s</a></td></tr>\n",_("Downloads"));
203 if ((ReportType & REPORT_TYPE_DENIED) != 0 && denied_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"denied.html\">%s</a></td></tr>\n",_("Denied"));
204 if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0 && authfail_count && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"authfail.html\">%s</a></td></tr>\n",_("Authentication Failures"));
205 if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"smartfilter.html\">%s</a></td></tr>\n",_("SmartFilter"));
c0ec9cc7 206 if(UserAgentLog[0] != '\0' && useragent_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"useragent.html\">%s</a></td></tr>\n",_("Useragent"));
5a1b55b7 207 fputs("<tr><td></td></tr>\n</table></div>\n",fp_top3);
25697a35 208
085c1e1f 209 if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
491b862f 210 fputs("</body>\n</html>\n",fp_top3);
9f20cdae 211 fclose (fp_top3);
491b862f
GS
212 return;
213 }
fb7c5f27 214
5a1b55b7 215 fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
9f20cdae
FM
216 fputs("<tr>",fp_top3);
217
218 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
c36c7384 219 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("NUM"));
9f20cdae 220 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0)
b18ce4a0 221 fputs("<th class=\"header_l\"></th>",fp_top3);
9f20cdae 222 if((TopUserFields & TOPUSERFIELDS_USERID) != 0)
c36c7384 223 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("USERID"));
9f20cdae 224 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
c36c7384 225 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("CONNECT"));
9f20cdae 226 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
c36c7384 227 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("BYTES"));
9f20cdae 228 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
c36c7384 229 fprintf(fp_top3,"<th class=\"header_l\">%%%s</th>",_("BYTES"));
9f20cdae 230 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
c36c7384 231 fprintf(fp_top3,"<th class=\"header_c\" colspan=\"2\">%s-%s-%s</th>",_("IN"),_("CACHE"),_("OUT"));
9f20cdae 232 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
c36c7384 233 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("ELAPSED TIME"));
9f20cdae 234 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
c36c7384 235 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("MILISEC"));
9f20cdae 236 if((TopUserFields & TOPUSERFIELDS_PTIME) != 0)
c36c7384 237 fprintf(fp_top3,"<th class=\"header_l\">%%%s</th>",_("TIME"));
9f20cdae
FM
238
239 fputs("</tr>\n",fp_top3);
25697a35 240
d6e703cc 241 ntopuser = 0;
25697a35 242
ac422f9b 243 if (longline_prepare(&line)<0) {
10210234 244 debuga(_("Not enough memory to read the downloaded files\n"));
ac422f9b
FM
245 exit(1);
246 }
247
248 while((warea=longline_read(fp_top1,&line))!=NULL) {
9c7c6346
FM
249 getword_start(&gwarea,warea);
250 if (getword(user,sizeof(user),&gwarea,'\t')<0) {
10210234 251 debuga(_("There is a broken user in file %s\n"),top1);
05b90947
FM
252 exit(1);
253 }
6e792ade 254 if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
10210234 255 debuga(_("There is a broken number of bytes in file %s\n"),top1);
05b90947
FM
256 exit(1);
257 }
6e792ade 258 if (getword_atoll(&nacc,&gwarea,'\t')<0) {
10210234 259 debuga(_("There is a broken number of access in file %s\n"),top1);
05b90947
FM
260 exit(1);
261 }
6e792ade 262 if (getword_atoll(&elap,&gwarea,'\t')<0) {
10210234 263 debuga(_("There is a broken elpased time in file %s\n"),top1);
05b90947
FM
264 exit(1);
265 }
6e792ade 266 if (getword_atoll(&incac,&gwarea,'\t')<0) {
10210234 267 debuga(_("There is a broken in-cache size in file %s\n"),top1);
05b90947
FM
268 exit(1);
269 }
6e792ade 270 if (getword_atoll(&oucac,&gwarea,'\n')<0) {
10210234 271 debuga(_("There is a broken out-of-cache size in file %s\n"),top1);
05b90947
FM
272 exit(1);
273 }
9f20cdae 274 if(nacc < 1)
d6e703cc 275 continue;
05b90947 276 ntopuser = 1;
c0ec9cc7 277 if(TopUsersNum > 0 && topcount >= TopUsersNum) break;
6e792ade 278 tnbytes=nbytes;
6e792ade 279 tnelap=elap;
25697a35 280
f2ec8c75
FM
281 uinfo=userinfo_find_from_id(user);
282 if (!uinfo) {
10210234 283 debuga(_("Unknown user ID %s in file %s\n"),user,top1);
f2ec8c75 284 exit(1);
25697a35 285 }
dfb337be 286
9f20cdae 287 fputs("<tr>",fp_top3);
25697a35 288
9f20cdae
FM
289 posicao++;
290 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
291 fprintf(fp_top3,"<td class=\"data\">%d</td>",posicao);
25697a35 292
9f20cdae 293 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) {
c36c7384 294 s=_("DATE/TIME");
ac422f9b
FM
295 for(i=0 ; i<sizeof(ltext110)-1 && s[i] ; i++)
296 ltext110[i]=tolower(s[i]);
297 ltext110[i]='\0';
9f20cdae 298 fputs("<td class=\"data2\">",fp_top3);
25697a35 299#ifdef HAVE_GD
3becf85c 300 if(Graphs && GraphFont[0]!='\0') {
c36c7384 301 fprintf(fp_top3,"<a href=\"%s/graph_day.png\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
9f20cdae 302 }
25697a35 303#endif
f2ec8c75 304 fprintf(fp_top3,"<a href=\"%s/d%s.html\"><img src=\"%s/datetime.png\" title=\"%s",uinfo->filename,uinfo->filename,ImageFile,ltext110);
9f20cdae 305#ifdef HAVE_GD
c36c7384 306 fprintf(fp_top3," %s",_("Report"));
9f20cdae
FM
307#endif
308 fputs("\" alt=\"T\"></a></td>",fp_top3);
309 } else {
d5d021c5 310 sprintf(val1,"%s/d%s.html",outdirname,uinfo->filename);
9f20cdae 311 unlink(val1);
25697a35 312 }
9f20cdae
FM
313 if((TopUserFields & TOPUSERFIELDS_USERID) != 0) {
314 if((ReportType & REPORT_TYPE_USERS_SITES) == 0)
315 fprintf(fp_top3,"<td class=\"data2\">%s</td>",name);
316 else
f2ec8c75 317 fprintf(fp_top3,"<td class=\"data2\"><a href=\"%s/%s.html\">%s</a></td>",uinfo->filename,uinfo->filename,uinfo->label);
25697a35 318 }
9f20cdae
FM
319 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
320 fprintf(fp_top3,"<td class=\"data\">%s</td>",fixnum(nacc,1));
321 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
322 fprintf(fp_top3,"<td class=\"data\">%s</td>",fixnum(tnbytes,1));
323 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0) {
324 perc=(ttnbytes) ? tnbytes * 100. / ttnbytes : 0.;
325 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td>",perc);
25697a35 326 }
9f20cdae
FM
327 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0) {
328 inperc=(tnbytes) ? incac * 100. / tnbytes : 0.;
329 ouperc=(tnbytes) ? oucac * 100. / tnbytes : 0.;
330 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",inperc,ouperc);
25697a35 331 }
9f20cdae
FM
332 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
333 fprintf(fp_top3,"<td class=\"data\">%s</td>",buildtime(tnelap));
334 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
335 fprintf(fp_top3,"<td class=\"data\">%s</td>",fixnum2(tnelap,1));
336 if((TopUserFields & TOPUSERFIELDS_PTIME) != 0) {
337 perc2=(ttnelap) ? elap * 100. / ttnelap : 0.;
338 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td>",perc2);
dfb337be 339 }
25697a35 340
9f20cdae 341 fputs("</tr>\n",fp_top3);
25697a35
GS
342
343 topcount++;
25697a35 344 }
c0ec9cc7
FM
345 fclose(fp_top1);
346 unlink(top1);
ac422f9b 347 longline_free(&line);
25697a35 348
9f20cdae 349 if((TopUserFields & TOPUSERFIELDS_TOTAL) != 0) {
9f20cdae
FM
350 fputs("<tr>",fp_top3);
351 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
352 fputs("<td></td>",fp_top3);
353 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0)
354 fputs("<td></td>",fp_top3);
c36c7384 355 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("TOTAL"));
9f20cdae
FM
356
357 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
b18ce4a0 358 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum(ttnacc,1));
9f20cdae 359 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
b18ce4a0 360 fprintf(fp_top3,"<th class=\"header_r\">%15s</th>",fixnum(ttnbytes,1));
9f20cdae
FM
361 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
362 fputs("<td></td>",fp_top3);
363 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
364 {
365 inperc=(ttnbytes) ? ttnincache * 100. / ttnbytes : 0.;
366 ouperc=(ttnbytes) ? ttnoucache *100. / ttnbytes : 0.;
b18ce4a0 367 fprintf(fp_top3,"<th class=\"header_r\">%3.2lf%%</th><th class=\"header_r\">%3.2lf%%</th>",inperc,ouperc);
9f20cdae
FM
368 }
369 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
b18ce4a0 370 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",buildtime(ttnelap));
9f20cdae 371 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
b18ce4a0 372 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum2(ttnelap,1));
9f20cdae
FM
373
374 fputs("</tr>\n",fp_top3);
25697a35
GS
375 }
376
9f20cdae
FM
377 if(ntopuser && (TopUserFields & TOPUSERFIELDS_AVERAGE) != 0) {
378 fputs("<tr>",fp_top3);
379 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
380 fputs("<td></td>",fp_top3);
381 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0)
382 fputs("<td></td>",fp_top3);
c36c7384 383 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("AVERAGE"));
9f20cdae
FM
384
385 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
b18ce4a0 386 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum(ttnacc/totuser,1));
9f20cdae
FM
387 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0) {
388 tnbytes=(totuser) ? ttnbytes / totuser : 0;
b18ce4a0 389 fprintf(fp_top3,"<th class=\"header_r\">%15s</th>",fixnum(tnbytes,1));
9f20cdae
FM
390 }
391 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
392 fputs("<td></td>",fp_top3);
393 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
394 fputs("<td></td><td></td>",fp_top3);
395 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
b18ce4a0 396 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",buildtime(ttnelap/totuser));
9f20cdae 397 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
b18ce4a0 398 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum2(ttnelap/totuser,1));
9f20cdae 399 fputs("</tr>\n",fp_top3);
25697a35
GS
400 }
401
c0ec9cc7
FM
402 fputs("</table></div>\n",fp_top3);
403 write_html_trailer(fp_top3);
404 fclose(fp_top3);
25697a35
GS
405
406 if((fp_ou=fopen(tusr,"w"))==NULL) {
c36c7384 407 fprintf(stderr, "SARG: (topuser) %s: %s\n",_("Cannot open file"),tusr);
25697a35
GS
408 exit(1);
409 }
d6e703cc 410 fprintf(fp_ou,"%d\n",totuser);
25697a35
GS
411 fclose(fp_ou);
412
413 return;
414}