]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Hopefully fix the smart filter
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 15 Jul 2012 16:40:58 +0000 (18:40 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 15 Jul 2012 16:40:58 +0000 (18:40 +0200)
I can't test it as I don't have any sample log with smartfilter enabled.

html.c

diff --git a/html.c b/html.c
index 4ca7bca10a7d2a3ba07b2c0d18dcf07a6df0b71c..751fdbc5297b9e3fa3d2bb3a27642102a727c074 100644 (file)
--- a/html.c
+++ b/html.c
@@ -51,7 +51,7 @@ void htmlrel(void)
        double perc=0, perc2=0, ouperc=0, inperc=0;
        int count;
        int cstatus;
-       int have_denied_report;
+       bool have_denied_report;
        const char *sort_field;
        const char *sort_order;
        char siteind[MAX_TRUNCATED_URL];
@@ -115,14 +115,14 @@ void htmlrel(void)
                        debuga(_("Output file name too long: %s/%s/%s.html\n"),outdirname,uinfo->filename,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
-               if (snprintf(duser,sizeof(duser),"%s/%s/denied_%s.html",tmp,uinfo->filename,uinfo->filename)>=sizeof(duser)) {
-                       debuga(_("File name too long: %s/%s/denied_%s.html\n"),tmp,uinfo->filename,uinfo->filename);
+               if (snprintf(duser,sizeof(duser),"%s/denied_%s.html",outdirname,uinfo->filename)>=sizeof(duser)) {
+                       debuga(_("File name too long: %s/denied_%s.html\n"),outdirname,uinfo->filename);
                        exit(EXIT_FAILURE);
                }
                if(access(duser, R_OK) != 0)
-                       have_denied_report=0;
+                       have_denied_report=false;
                else
-                       have_denied_report=1;
+                       have_denied_report=true;
 
                if ((line=longline_create())==NULL) {
                        debuga(_("Not enough memory to read file %s\n"),arqin);
@@ -187,17 +187,16 @@ void htmlrel(void)
                fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User report"));
                close_html_header(fp_ou);
 
+               if (have_denied_report) {
+                       fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_ou);
+                       fprintf(fp_ou,"<tr><td class=\"header_l\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a></td></tr>\n",uinfo->filename,_("SmartFilter report"));
+                       fputs("<tr><td></td></tr>\n</table></div>\n",fp_ou);
+               }
+
                fputs("<div class=\"report\"><table cellpadding=\"2\" cellspacing=\"1\"",fp_ou);
                if (SortTableJs[0]) fputs(" class=\"sortable\"",fp_ou);
                fputs(">\n",fp_ou);
 
-               /*! \bug This line lays before the header of the table and is therefore invalid
-               HTML. It will also break the sorttable script. Beside, I suspect it serves no purpose.
-               */
-               if(have_denied_report) {
-                       fprintf(fp_ou,"<tr><td class=\"header_l\" colspan=\"11\"><a href=\"denied_%s.html\">%s</a> %s</td></tr>\n",uinfo->filename,_("SmartFilter"),_("Report"));
-               }
-
                fputs("<thead><tr><th class=\"sorttable_nosort\"></th><th class=\"header_l",fp_ou);
                if (SortTableJs[0]) fputs(" sorttable_alpha",fp_ou);
                fprintf(fp_ou,"\">%s</th>",_("ACCESSED SITE"));