long long int totelap=0, totelap2=0, nnelap=0, unelap=0, tnelap=0;
long long int incache=0, oucache=0, tnincache=0, tnoucache=0, twork=0;
long long int ltemp;
- long long int ntotuser=1;
+ long long int ntotuser;
long long int userbytes, userelap;
char *buf;
- char arqin[MAXLEN], arqou[MAXLEN], arqper[MAXLEN], arqip[MAXLEN];
+ char arqin[MAXLEN], arqou[MAXLEN], arqip[MAXLEN];
char *url, tmsg[50], csort[MAXLEN];
char duser[MAXLEN];
char user_ip[MAXLEN], olduserip[MAXLEN], tmp2[MAXLEN], tmp3[MAXLEN];
char warea[MAXLEN];
- char totuser[8];
char tmp6[MAXLEN];
char *user_url;
long long int tnacc=0, ttnacc=0, unacc=0;
int have_denied_report;
const char *sort_field;
const char *sort_order;
- const char *user;
char siteind[MAX_TRUNCATED_URL];
struct getwordstruct gwarea;
longline line,line1;
tnacc=globstat.nacc;
totbytes=globstat.nbytes;
totelap=globstat.elap;
-
- if ((ReportType & REPORT_TYPE_TOPUSERS) != 0) {
- snprintf(arqper,sizeof(arqper),"%s/sarg-users",outdirname);
- if ((fp_in = fopen(arqper, "r")) == 0){
- debuga(_("(html11) Cannot open file %s - %s\n"),arqper,strerror(errno));
- exit(EXIT_FAILURE);
- }
- if (!fgets(totuser,sizeof(totuser),fp_in)) {
- debuga(_("(html11) read error in %s\n"),arqper);
- exit(EXIT_FAILURE);
- }
- fclose(fp_in);
- ntotuser=my_atoll(totuser);
- if (ntotuser<=0) ntotuser=1;
- }
+ ntotuser=globstat.totuser;
greport_prepare();
exit(EXIT_FAILURE);
}
while ( (uinfo = userinfo_advancescan(uscan)) != NULL ) {
- user=uinfo->filename;
+ if (!uinfo->topuser) {
+ continue;
+ }
+ tmpsort(uinfo);
- if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,user)>=sizeof(warea)) {
- debuga(_("Destination directory too long: %s/%s\n"),outdirname,user);
+ if (snprintf(warea,sizeof(warea),"%s/%s",outdirname,uinfo->filename)>=sizeof(warea)) {
+ debuga(_("Destination directory too long: %s/%s\n"),outdirname,uinfo->filename);
exit(EXIT_FAILURE);
}
if (access(warea, R_OK) != 0) {
report_day(uinfo);
greport_day(uinfo);
- if (snprintf(arqin,sizeof(arqin),"%s/%s.txt",tmp,uinfo->filename)>=sizeof(arqin)) {
- debuga(_("Input file name too long: %s/%s.txt\n"),tmp,uinfo->filename);
+ if (snprintf(arqin,sizeof(arqin),"%s/htmlrel.txt",tmp)>=sizeof(arqin)) {
+ debuga(_("Input file name too long: %s/htmlrel.txt\n"),tmp);
exit(EXIT_FAILURE);
}
if ((fp_in = fopen(arqin, "r")) == 0){
long long int incache;
//! Amount of data not fetched from the cache.
long long int oucache;
+ //! The number of users in the topuser list.
+ int totuser;
};
// auth.c
// sort.c
void sort_users_log(const char *tmp, int debug);
-void tmpsort(void);
+void tmpsort(const struct userinfostruct *uinfo);
void sort_labels(const char **label,const char **order);
// splitlog.c
fclose(fp_gen);
if (puinfo && !indexonly) day_totalize(tmp,puinfo);
- if (!indexonly)
- tmpsort();
- else if (debugz)
- debugaz(_("Only the index is generated as requested\n"));
-
if(email[0] == '\0') {
if (!indexonly) {
if((ReportType & REPORT_TYPE_DOWNLOADS) != 0)
#include "include/conf.h"
#include "include/defs.h"
-void tmpsort(void)
+void tmpsort(const struct userinfostruct *uinfo)
{
- userscan uscan;
- struct userinfostruct *uinfo;
int cstatus;
char csort[MAXLEN];
char arqou[MAXLEN], arqin[MAXLEN];
const char *field3="3,3";
const char *order;
- if((ReportType & REPORT_TYPE_USERS_SITES) == 0) return;
-
if((UserSort & USER_SORT_CONNECT) != 0) {
field1="1,1";
field2="2,2";
else
order="-r";
- uscan=userinfo_startscan();
- if (uscan == NULL) {
- debuga(_("Cannot enumerate the user list\n"));
+ if (snprintf(arqin,sizeof(arqin),"%s/%s.utmp",tmp,uinfo->filename)>=sizeof(arqin)) {
+ debuga(_("file name too long: %s/%s.utmp\n"),tmp,uinfo->filename);
+ exit(EXIT_FAILURE);
+ }
+ if (snprintf(arqou,sizeof(arqou),"%s/htmlrel.txt",tmp)>=sizeof(arqou)) {
+ debuga(_("file name too long: %s/htmlrel.txt\n"),tmp);
exit(EXIT_FAILURE);
}
- while ((uinfo = userinfo_advancescan(uscan)) != NULL ){
- if (snprintf(arqin,sizeof(arqin),"%s/%s.utmp",tmp,uinfo->filename)>=sizeof(arqin)) {
- debuga(_("file name too long: %s/%s.utmp\n"),tmp,uinfo->filename);
- exit(EXIT_FAILURE);
- }
- if (snprintf(arqou,sizeof(arqou),"%s/%s.txt",tmp,uinfo->filename)>=sizeof(arqou)) {
- debuga(_("file name too long: %s/%s.utmp\n"),tmp,uinfo->filename);
- exit(EXIT_FAILURE);
- }
- if(debug) {
- debuga(_("Sorting file: %s\n"),arqou);
- }
+ if(debug) {
+ debuga(_("Sorting file: %s\n"),arqin);
+ }
- if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof(csort)) {
- debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
- exit(EXIT_FAILURE);
- }
- cstatus=system(csort);
- if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
- debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
- debuga(_("sort command: %s\n"),csort);
- exit(EXIT_FAILURE);
- }
- if (unlink(arqin)) {
- debuga(_("Cannot delete %s - %s\n"),arqin,strerror(errno));
- exit(EXIT_FAILURE);
- }
+ if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
+ exit(EXIT_FAILURE);
+ }
+ cstatus=system(csort);
+ if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
+ debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
+ debuga(_("sort command: %s\n"),csort);
+ exit(EXIT_FAILURE);
+ }
+ if (unlink(arqin)) {
+ debuga(_("Cannot delete %s - %s\n"),arqin,strerror(errno));
+ exit(EXIT_FAILURE);
}
- userinfo_stopscan(uscan);
return;
}
#include "include/conf.h"
#include "include/defs.h"
-#ifdef ENABLE_DOUBLE_CHECK_DATA
extern struct globalstatstruct globstat;
-#endif
void topuser(void)
{
fprintf(fp_ou,"%d\n",totuser);
if (fclose(fp_ou)==EOF)
debuga(_("Failed to close file %s - %s\n"),tusr,strerror(errno));
+ globstat.totuser=totuser;
return;
}