From: Frédéric Marchal Date: Sun, 30 Oct 2011 19:04:33 +0000 (+0000) Subject: Add links on the Sites & Users page to the user's page X-Git-Tag: v2.3.2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a58e6d54a9dec11ac287ea6912f0c784f37a3797;p=thirdparty%2Fsarg.git Add links on the Sites & Users page to the user's page The page listing the links visited and who visited them contains links to jump directly to the page of each user provided they are on the top users page. --- diff --git a/ChangeLog b/ChangeLog index 674b847..d621462 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ Oct-30-2011 Version 2.3.2-pre2 - Discriminate between users whose name produce the same mangled temporary file name. - Write a note about the number of entries ignored in the reports (thanks to Iain Lopata). - Command line option -z output some messages to explain why the reports are not generated due to the configuration. + - The Sites & Users report page links to the user's page if the user is listed in the Top Users page. Sep-18-2010 Version 2.3.1 - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway. diff --git a/include/conf.h b/include/conf.h index 3e8582c..c939c29 100755 --- a/include/conf.h +++ b/include/conf.h @@ -468,7 +468,6 @@ int realtime_refresh; int realtime_access_log_lines; int rc; int ntopsites; -int nsitesusers; int nrepday; int ndownload; int ntopuser; diff --git a/include/defs.h b/include/defs.h index d113468..f276c45 100755 --- a/include/defs.h +++ b/include/defs.h @@ -51,6 +51,10 @@ struct userinfostruct char label[MAX_USER_LEN]; //! The mangled name to use in file names of that user. char filename[MAX_USER_FNAME_LEN]; + //! \c True if this user is in the topuser list. + int topuser; + //! A general purpose flag that can be set when scanning the user's list. + int flag; }; //! Scan through the known users. @@ -208,6 +212,7 @@ void userinfo_free(void); userscan userinfo_startscan(void); void userinfo_stopscan(userscan uscan); struct userinfostruct *userinfo_advancescan(userscan uscan); +void userinfo_clearflag(void); // usertab.c void init_usertab(const char *UserTabFile); diff --git a/siteuser.c b/siteuser.c index 02df1f6..997b271 100644 --- a/siteuser.c +++ b/siteuser.c @@ -32,7 +32,6 @@ void siteuser(void) FILE *fp_in, *fp_ou; char *buf; - char wuser[MAXLEN]; char *ourl; char csort[255]; char general[MAXLEN]; @@ -40,15 +39,14 @@ void siteuser(void) char sites[MAXLEN]; char report[MAXLEN]; int regs=0; - int ucount=0; int ourl_size; int url_len; - char *users; - long long int obytes; + int topuser_link; + int nsitesusers; int cstatus; longline line; struct generalitemstruct item; - const struct userinfostruct *uinfo; + struct userinfostruct *uinfo; if(Privacy) { if (debugz) debugaz(_("Sites and users report not generated because privacy option is on\n")); @@ -103,13 +101,9 @@ void siteuser(void) ourl=NULL; ourl_size=0; - obytes=0; - if((users=(char *) malloc(204800))==NULL){ - debuga(_("ERROR: Cannot load. Memory fault\n")); - exit(EXIT_FAILURE); - } - strcpy(users," "); + userinfo_clearflag(); + topuser_link=((ReportType & REPORT_TYPE_USERS_SITES) != 0 && !indexonly); if ((line=longline_create())==NULL) { debuga(_("Not enough memory to read file %s\n"),general2); @@ -126,9 +120,18 @@ void siteuser(void) } if (item.nacc > 0) nsitesusers = 1; - if(!regs) { + if (!nsitesusers) continue; + + if (ourl==NULL || strcmp(item.url,ourl) != 0) { + if (regs>0) fputs("\n",fp_ou); + + regs++; + if (SiteUsersReportLimit && regs >= SiteUsersReportLimit) + break; + fprintf(fp_ou,"%d",regs); + url_len=strlen(item.url); - if (!ourl || url_len>=ourl_size) { + if (url_len>=ourl_size) { ourl_size=url_len+1; ourl=realloc(ourl,ourl_size); if (!ourl) { @@ -137,28 +140,7 @@ void siteuser(void) } } strcpy(ourl,item.url); - obytes=item.nbytes; - regs++; - } - - sprintf(wuser," %s ",uinfo->label); - if(strstr(users,wuser) == 0 && strcmp(item.url,ourl) == 0) { - strcat(users,uinfo->label); - strcat(users," "); - ucount++; - if(ucount>4) { - strcat(users,"
"); - ucount=0; - } - } - - if(SiteUsersReportLimit) { - if(regs >= SiteUsersReportLimit) - continue; - } - - if(strcmp(item.url,ourl) != 0 && nsitesusers) { - fprintf(fp_ou,"%d",regs); + if(BlockIt[0]!='\0' && ourl[0]!=ALIAS_PREFIX) { fprintf(fp_ou,"%s",fixnum(obytes,1)); + if (SortTableJs[0]) fprintf(fp_ou," sorttable_customkey=\"%"PRId64"\"",(int64_t)item.nbytes); + fprintf(fp_ou,">%s",fixnum(item.nbytes,1)); } - fprintf(fp_ou,"%s\n",users); - - regs++; - ucount=0; - strcpy(users,uinfo->label); - strcat(users," "); - url_len=strlen(item.url); - if (url_len>=ourl_size) { - ourl_size=url_len+1; - ourl=realloc(ourl,ourl_size); - if (!ourl) { - debuga(_("Not enough memory to store the url\n")); - exit(EXIT_FAILURE); - } - } - strcpy(ourl,item.url); - obytes=item.nbytes; + fputs("",fp_ou); + + userinfo_clearflag(); + if (topuser_link && uinfo->topuser) + fprintf(fp_ou,"%s",uinfo->filename,uinfo->filename,uinfo->label); + else + fprintf(fp_ou,"%s",uinfo->label); + uinfo->flag=1; + } + else if (uinfo->flag==0) { + if (topuser_link && uinfo->topuser) + fprintf(fp_ou," %s",uinfo->filename,uinfo->filename,uinfo->label); + else + fprintf(fp_ou," %s",uinfo->label); + uinfo->flag=1; } + } fclose(fp_in); longline_destroy(&line); - if(nsitesusers) { - fprintf(fp_ou,"%d",regs); - if(BlockIt[0]!='\0' && ourl[0]!=ALIAS_PREFIX) { - fprintf(fp_ou," ",fp_ou); - } - output_html_link(fp_ou,ourl,100); - fputs("",fp_ou); - if (BytesInSitesUsersReport) { - fputs("%s",fixnum(obytes,1)); - } - fprintf(fp_ou,"%s\n",users); + if(regs>0) { + fputs("\n",fp_ou); } if (ourl) free(ourl); @@ -223,8 +191,5 @@ void siteuser(void) if (fclose(fp_ou)==EOF) debuga(_("Failed to close file %s - %s\n"),report,strerror(errno)); - if(users) - free(users); - return; } diff --git a/topuser.c b/topuser.c index 2148c85..b58de85 100644 --- a/topuser.c +++ b/topuser.c @@ -60,7 +60,7 @@ void topuser(void) struct getwordstruct gwarea; longline line; struct generalitemstruct item; - const struct userinfostruct *uinfo; + struct userinfostruct *uinfo; ipantes[0]='\0'; nameantes[0]='\0'; @@ -305,6 +305,7 @@ void topuser(void) debuga(_("Unknown user ID %s in file %s\n"),user,top1); exit(EXIT_FAILURE); } + uinfo->topuser=1; fputs("",fp_top3); diff --git a/userinfo.c b/userinfo.c index 4339ba6..8cdabc0 100644 --- a/userinfo.c +++ b/userinfo.c @@ -218,3 +218,18 @@ struct userinfostruct *userinfo_advancescan(userscan uscan) } return(uinfo); } + +/*! +Clear the general purpose flag from all the user's info. +*/ +void userinfo_clearflag(void) +{ + struct usergroupstruct *group; + int i; + + for (group=first_user_group ; group ; group=group->next) { + for (i=0 ; inusers ; i++) + group->list[i].flag=0; + } +} +