From 1219fb1aafb5453daf1a1de2c36f189472be2988 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Thu, 27 Jan 2011 15:27:26 +0000 Subject: [PATCH] Fix the creation of a report when index is set to only Some unnecessary files are not created as they won't be used in the report but too many of them are still created, especially the temporary files. There is room for future improvements. The index doesn't contain any link to the details of the user's connections, visited sites, downloads and so on. --- CMakeLists.txt | 2 +- include/info.h | 2 +- indexonly.c | 2 +- report.c | 2 +- topuser.c | 61 ++++++++++++++++++++++++++------------------------ 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 237a229..756181d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(sarg C) SET(sarg_VERSION 2) SET(sarg_REVISION "3.2-pre1") SET(sarg_BUILD "") -SET(sarg_BUILDDATE "Jan-25-2011") +SET(sarg_BUILDDATE "Jan-27-2011") INCLUDE(AddFileDependencies) INCLUDE(CheckIncludeFile) diff --git a/include/info.h b/include/info.h index 2195f8e..2d4d8b5 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION PACKAGE_VERSION" Jan-25-2011" +#define VERSION PACKAGE_VERSION" Jan-27-2011" #define PGM PACKAGE_NAME #define URL "http://sarg.sourceforge.net" diff --git a/indexonly.c b/indexonly.c index 9b88b4b..d2878fe 100644 --- a/indexonly.c +++ b/indexonly.c @@ -47,7 +47,7 @@ void index_only(const char *dirname,int debug) continue; } if (unlink(remove) == -1) { - debuga(_("Failed to remove the file %s\n"),remove); + debuga(_("Failed to remove the file %s: %s\n"),remove,strerror(errno)); } } diff --git a/report.c b/report.c index 1f8543f..effb23a 100644 --- a/report.c +++ b/report.c @@ -240,7 +240,7 @@ void gerarel(void) nbytes+=accbytes; nelap+=accelap; - if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0 && + if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0 && !indexonly && (!oldurltt || strcmp(oldurltt,accurl) || strcmp(oldaccdiatt,accdia) || strcmp(oldacchoratt,acchora))) { if(!ttopen) { diff --git a/topuser.c b/topuser.c index ae67536..c4ee956 100644 --- a/topuser.c +++ b/topuser.c @@ -202,18 +202,19 @@ void topuser(void) fprintf(fp_top3,"%s\n",_("Top users")); close_html_header(fp_top3); - fputs("
\n",fp_top3); - - if((ReportType & REPORT_TYPE_TOPSITES) != 0 && !Privacy) fprintf(fp_top3,"\n",_("Top sites")); - if((ReportType & REPORT_TYPE_SITES_USERS) != 0 && !Privacy) fprintf(fp_top3,"\n",_("Sites & Users")); - if(dansguardian_count) fprintf(fp_top3,"\n",_("DansGuardian")); - if(squidguard_count) fprintf(fp_top3,"\n",_("Redirector")); - if ((ReportType & REPORT_TYPE_DOWNLOADS) != 0 && download_count && !Privacy && ndownload) fprintf(fp_top3,"\n",_("Downloads")); - if ((ReportType & REPORT_TYPE_DENIED) != 0 && denied_count && !Privacy) fprintf(fp_top3,"\n",_("Denied accesses")); - if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0 && authfail_count && !Privacy) fprintf(fp_top3,"\n",_("Authentication Failures")); - if(smartfilter) fprintf(fp_top3,"\n",_("SmartFilter")); - if(UserAgentLog[0] != '\0' && useragent_count) fprintf(fp_top3,"\n",_("Useragent")); - fputs("\n
%s
%s
%s
%s
%s
%s
%s
%s
%s
\n",fp_top3); + if (!indexonly) { + fputs("
\n",fp_top3); + if((ReportType & REPORT_TYPE_TOPSITES) != 0 && !Privacy) fprintf(fp_top3,"\n",_("Top sites")); + if((ReportType & REPORT_TYPE_SITES_USERS) != 0 && !Privacy) fprintf(fp_top3,"\n",_("Sites & Users")); + if(dansguardian_count) fprintf(fp_top3,"\n",_("DansGuardian")); + if(squidguard_count) fprintf(fp_top3,"\n",_("Redirector")); + if ((ReportType & REPORT_TYPE_DOWNLOADS) != 0 && download_count && !Privacy && ndownload) fprintf(fp_top3,"\n",_("Downloads")); + if ((ReportType & REPORT_TYPE_DENIED) != 0 && denied_count && !Privacy) fprintf(fp_top3,"\n",_("Denied accesses")); + if ((ReportType & REPORT_TYPE_AUTH_FAILURES) != 0 && authfail_count && !Privacy) fprintf(fp_top3,"\n",_("Authentication Failures")); + if(smartfilter) fprintf(fp_top3,"\n",_("SmartFilter")); + if(UserAgentLog[0] != '\0' && useragent_count) fprintf(fp_top3,"\n",_("Useragent")); + fputs("\n
%s
%s
%s
%s
%s
%s
%s
%s
%s
\n",fp_top3); + } if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) { fputs("\n\n",fp_top3); @@ -228,7 +229,7 @@ void topuser(void) if((TopUserFields & TOPUSERFIELDS_NUM) != 0) fprintf(fp_top3,"%s",_("NUM")); - if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) { + if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0 && !indexonly) { fputs("",fp_top3); @@ -307,25 +308,27 @@ void topuser(void) if((TopUserFields & TOPUSERFIELDS_NUM) != 0) fprintf(fp_top3,"%d",posicao); - if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) { - fputs("",fp_top3); + if (!indexonly) { + if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) { + fputs("",fp_top3); #ifdef HAVE_GD - if(Graphs && GraphFont[0]!='\0') { - //fprintf(fp_top3,"\"G\" ",uinfo->filename,ImageFile,_("Graphic")); - fprintf(fp_top3,"\"G\" ",uinfo->filename,ImageFile,_("Graphic")); - } + if(Graphs && GraphFont[0]!='\0') { + //fprintf(fp_top3,"\"G\" ",uinfo->filename,ImageFile,_("Graphic")); + fprintf(fp_top3,"\"G\" ",uinfo->filename,ImageFile,_("Graphic")); + } #endif - fprintf(fp_top3,"\"T\"",uinfo->filename,uinfo->filename,ImageFile,_("date/time report")); - } else { - sprintf(val1,"%s/d%s.html",outdirname,uinfo->filename); - if (unlink(val1)) { - debuga(_("Cannot delete %s - %s\n"),val1,strerror(errno)); - exit(EXIT_FAILURE); + fprintf(fp_top3,"\"T\"",uinfo->filename,uinfo->filename,ImageFile,_("date/time report")); + } else { + sprintf(val1,"%s/d%s.html",outdirname,uinfo->filename); + if (unlink(val1)) { + debuga(_("Cannot delete %s - %s\n"),val1,strerror(errno)); + exit(EXIT_FAILURE); + } } } if((TopUserFields & TOPUSERFIELDS_USERID) != 0) { - if((ReportType & REPORT_TYPE_USERS_SITES) == 0) - fprintf(fp_top3,"%s",name); + if((ReportType & REPORT_TYPE_USERS_SITES) == 0 || indexonly) + fprintf(fp_top3,"%s",uinfo->label); else fprintf(fp_top3,"%s",uinfo->filename,uinfo->filename,uinfo->label); } @@ -383,7 +386,7 @@ void topuser(void) fputs("",fp_top3); if((TopUserFields & TOPUSERFIELDS_NUM) != 0) fputs("",fp_top3); - if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) + if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0 && !indexonly) fputs("",fp_top3); fprintf(fp_top3,"%s",_("TOTAL")); @@ -416,7 +419,7 @@ void topuser(void) fputs("",fp_top3); if((TopUserFields & TOPUSERFIELDS_NUM) != 0) fputs("",fp_top3); - if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) + if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0 && !indexonly) fputs("",fp_top3); fprintf(fp_top3,"%s",_("AVERAGE")); -- 2.47.2