]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the creation of a report when index is set to only
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 27 Jan 2011 15:27:26 +0000 (15:27 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 27 Jan 2011 15:27:26 +0000 (15:27 +0000)
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
include/info.h
indexonly.c
report.c
topuser.c

index 237a2298d961cb3839b2a9dc880247f8d7a6d66d..756181d9c49d974440bc70863db6e059adcefd98 100755 (executable)
@@ -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)
index 2195f8e1b55102263271f01386bae04c94f4cfd9..2d4d8b502f7e171a77851d9a6abc889c4ef71eb7 100755 (executable)
@@ -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"
index 9b88b4b3ae1e268bbe2557d85e599e7a6e8e1941..d2878fea6f63f194e6148070b9655aff61354b5b 100644 (file)
@@ -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));
                }
        }
 
index 1f8543f64254652121b1099ff205956d6d749b3a..effb23ab8517cfc6a6904e934cf4ca67de196b65 100644 (file)
--- 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) {
index ae67536705af4971ec4a37bab7092250d758ce11..c4ee9568d337368954b28ee36b9f15f060ee507f 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -202,18 +202,19 @@ void topuser(void)
        fprintf(fp_top3,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Top users"));
        close_html_header(fp_top3);
 
-       fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
-
-       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",_("Top sites"));
-       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"));
-       if(dansguardian_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"dansguardian.html\">%s</a></td></tr>\n",_("DansGuardian"));
-       if(squidguard_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"redirector.html\">%s</a></td></tr>\n",_("Redirector"));
-       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"));
-       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 accesses"));
-       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"));
-       if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"smartfilter.html\">%s</a></td></tr>\n",_("SmartFilter"));
-       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"));
-       fputs("<tr><td></td></tr>\n</table></div>\n",fp_top3);
+       if (!indexonly) {
+               fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
+               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",_("Top sites"));
+               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"));
+               if(dansguardian_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"dansguardian.html\">%s</a></td></tr>\n",_("DansGuardian"));
+               if(squidguard_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"redirector.html\">%s</a></td></tr>\n",_("Redirector"));
+               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"));
+               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 accesses"));
+               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"));
+               if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"smartfilter.html\">%s</a></td></tr>\n",_("SmartFilter"));
+               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"));
+               fputs("<tr><td></td></tr>\n</table></div>\n",fp_top3);
+       }
 
        if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
                fputs("</body>\n</html>\n",fp_top3);
@@ -228,7 +229,7 @@ void topuser(void)
 
        if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
                fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("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("<th class=\"header_l",fp_top3);
                if (SortTableJs[0]) fputs(" sorttable_nosort",fp_top3);
                fputs("\"></th>",fp_top3);
@@ -307,25 +308,27 @@ void topuser(void)
                if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
                        fprintf(fp_top3,"<td class=\"data\">%d</td>",posicao);
 
-               if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) {
-                       fputs("<td class=\"data2\">",fp_top3);
+               if (!indexonly) {
+                       if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) {
+                               fputs("<td class=\"data2\">",fp_top3);
 #ifdef HAVE_GD
-                       if(Graphs && GraphFont[0]!='\0') {
-                               //fprintf(fp_top3,"<a href=\"%s/graph_day.png\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
-                               fprintf(fp_top3,"<a href=\"%s/graph.html\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
-                       }
+                               if(Graphs && GraphFont[0]!='\0') {
+                                       //fprintf(fp_top3,"<a href=\"%s/graph_day.png\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
+                                       fprintf(fp_top3,"<a href=\"%s/graph.html\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
+                               }
 #endif
-                       fprintf(fp_top3,"<a href=\"%s/d%s.html\"><img src=\"%s/datetime.png\" title=\"%s\" alt=\"T\"></a></td>",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,"<a href=\"%s/d%s.html\"><img src=\"%s/datetime.png\" title=\"%s\" alt=\"T\"></a></td>",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,"<td class=\"data2\">%s</td>",name);
+                       if((ReportType & REPORT_TYPE_USERS_SITES) == 0 || indexonly)
+                               fprintf(fp_top3,"<td class=\"data2\">%s</td>",uinfo->label);
                        else
                                fprintf(fp_top3,"<td class=\"data2\"><a href=\"%s/%s.html\">%s</a></td>",uinfo->filename,uinfo->filename,uinfo->label);
                }
@@ -383,7 +386,7 @@ void topuser(void)
                fputs("<tfoot><tr>",fp_top3);
                if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
                        fputs("<td></td>",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("<td></td>",fp_top3);
                fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("TOTAL"));
 
@@ -416,7 +419,7 @@ void topuser(void)
                fputs("<tr>",fp_top3);
                if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
                        fputs("<td></td>",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("<td></td>",fp_top3);
                fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("AVERAGE"));