]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Output the period as an HTML text in the HTML reports
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 5 Apr 2010 05:48:25 +0000 (05:48 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 5 Apr 2010 05:48:25 +0000 (05:48 +0000)
18 files changed:
CMakeLists.txt
authfail.c
configure.in
dansguardian_report.c
denied.c
download.c
html.c
include/conf.h
include/info.h
log.c
repday.c
report.c
siteuser.c
smartfilter.c
squidguard_report.c
topsites.c
topuser.c
util.c

index 50f26cbbcf9a583aeed52b9828d80f2da2d88a47..13639cec919507ae12ddc6943b1ad9c86cc5e174 100755 (executable)
@@ -1,9 +1,9 @@
 CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
 PROJECT(sarg C)
 SET(sarg_VERSION 2)
-SET(sarg_REVISION "3-pre1")
+SET(sarg_REVISION "3-pre2")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Apr-02-2010")
+SET(sarg_BUILDDATE "Apr-04-2010")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index ce4b0eed7ce37c00e67dbca8647f8b5af6d6bdfa..d1a22498f835346ac3e9ba89810b77909be503ea 100644 (file)
@@ -90,7 +90,7 @@ void authfail_report(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Authentication Failures"));
    fputs("<tr><td class=\"header_l\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Authentication Failures"));
    close_html_header(fp_ou);
index 23d29d6e38e78bd13868f5d9e0f22e0c4a241d82..cea8a63869f6a8573882a7b65a9f61a90fa67ee0 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([sarg],[2.3-pre1])
+AC_INIT([sarg],[2.3-pre2])
 AC_CONFIG_SRCDIR([log.c])
 AC_CONFIG_AUX_DIR(cfgaux)
 
index c5a35a2555b1f4a60fa5c8ea787970391017be72..44de93b4110def16de5a001a000c557b1dc54f21 100644 (file)
@@ -71,7 +71,7 @@ void dansguardian_report(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DansGuardian"));
    fputs("<tr><td class=\"header_l\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("DansGuardian"));
    close_html_header(fp_ou);
index 288e48c92f378cda9e62683d746876b7812e9df4..52e5b6990e534e4160ae2ef8ad9b51d9b2759020 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -73,7 +73,7 @@ void gen_denied_report(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DENIED"));
    fputs("<tr><td class=\"header_l\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("DENIED"));
    close_html_header(fp_ou);
index 6c5a99cbea13d1ab9e0998412e977e7e0d543327..1fa63b341d21c9290dfa0cd5d9d2ca271008fe66 100644 (file)
@@ -76,7 +76,7 @@ void download_report(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Downloads"));
    fputs("<tr><td class=\"header_l\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Downloads"));
    close_html_header(fp_ou);
diff --git a/html.c b/html.c
index edb1c0d748d3e285ff39403a6930295d42df8c3d..c0236716a1d7a28640b25d237d00532a7226e176 100644 (file)
--- a/html.c
+++ b/html.c
@@ -222,7 +222,7 @@ void htmlrel(void)
       }
 
       write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("User report"));
-      fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("Period"),period.text);
+      fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("Period"),period.html);
       fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("User"),uinfo->label);
       fprintf(fp_ou,"<tr><td class=\"header_l\">%s:&nbsp;%s, %s</td></tr>\n",_("Sort"),UserSortField,UserSortOrder);
       fprintf(fp_ou,"<tr><td class=\"header_c\">%s</td></tr>\n",_("User report"));
index 4191ee20cb12511fab8718002ff7a94292df6566..d47b987b1bf653c16fa992f5b80bdbc403ca23bc 100755 (executable)
@@ -235,9 +235,14 @@ int mkstemps(char *template, int suffixlen);
 
 struct periodstruct
 {
+   //! The first date of the period.
    struct tm start;
+   //! The last date of the period.
    struct tm end;
+   //! The textual representation of the date.
    char text[40];
+   //! The HTML representation of the date.
+   char html[40];
 };
 
 char outdir[MAXLEN];
index da8ee042edc766d2a88b4868b9d39e60d79f4554..b52f442c21dae351ee57d05217322effe11ac57c 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Apr-02-2010"
+#define VERSION PACKAGE_VERSION" Apr-04-2010"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/log.c b/log.c
index ecec946032f3f4708f01a4af6f42b404d9c0e58b..fa75c4bbda70e0cba42b10632cb683ffcac796e8 100644 (file)
--- a/log.c
+++ b/log.c
@@ -157,9 +157,18 @@ int main(int argc,char *argv[])
 #endif
 
 #if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H)
-   setlocale (LC_ALL, "");
-   bindtextdomain (PACKAGE_NAME, LOCALEDIR);
-   textdomain (PACKAGE_NAME);
+   if (!setlocale (LC_ALL, "")) {
+      fprintf(stderr,"SARG: Cannot set the locale LC_ALL to the environment variable\n");
+      exit(EXIT_FAILURE);
+   }
+   if (!bindtextdomain (PACKAGE_NAME, LOCALEDIR)) {
+      fprintf(stderr,"SARG: Cannot bind to text domain %s in directory %s (%s)\n",PACKAGE_NAME,LOCALEDIR,strerror(errno));
+      exit(EXIT_FAILURE);
+   }
+   if (!textdomain (PACKAGE_NAME)) {
+      fprintf(stderr,"SARG: Cannot set gettext domain for %s PACKAGE_NAME (%s)\n",PACKAGE_NAME,strerror(errno));
+      exit(EXIT_FAILURE);
+   }
 #endif //ENABLE_NLS
 
    BgImage[0]='\0';
index 042614de84c8dcee60adacd4bba7ddb71fb9a270..3855fc29d47b8953f7b883423b1c2714ffbfd848 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -76,7 +76,7 @@ void report_day(const struct userinfostruct *uinfo)
    close_html_header(fp_ou);
    fputs("<div class=\"report\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ou);
 
-   fprintf(fp_ou,"<tr><td class=\"header_c\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",_("Period"),period.text);
+   fprintf(fp_ou,"<tr><td class=\"header_c\" colspan=\"2\">%s:&nbsp;%s</td></tr>\n",_("Period"),period.html);
 
    fprintf(fp_ou,"<tr><th class=\"header_c\" colspan=\"2\">%s:&nbsp;%s</th></tr>\n",_("User"),uinfo->label);
 
index 805de2e61c6beedec317435171879d31cdf2c4ba..5800e6b47bd33639b9cb276c463c6f994021ffda 100644 (file)
--- a/report.c
+++ b/report.c
@@ -276,7 +276,7 @@ void gerarel(void)
                */
 
                write_html_header(fp_tt,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Site access report"));
-               fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("Period"),period.text);
+               fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("Period"),period.html);
                fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s</td></tr>\n",_("User"),uinfo->label);
                fprintf(fp_tt,"<tr><td class=\"header_l\">%s:&nbsp;%s, %s</td></tr>\n",_("Sort"),UserSortField,UserSortOrder);
                fprintf(fp_tt,"<tr><th class=\"header_c\">%s</th></tr>\n",_("User"));
index bbdb5fac98906a64539ff0a3962a84026674e919..bac2edbac7ee8519f2b152954ec41a3b8a428d11 100644 (file)
@@ -81,7 +81,7 @@ void siteuser(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Sites & Users"));
    fputs("<tr><td class=\"header_c\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Sites & Users"));
    close_html_header(fp_ou);
index 1db43ba3fb60b1e61d5fcb3c3c11c935bc95346b..d0d281f611ea61021e4a182d795a2e07bfa01047 100644 (file)
@@ -93,7 +93,9 @@ void smartfilter_report(void)
    write_logo_image(fp_ou);
 
    fprintf(fp_ou,"<tr><th align=\"center\"><b><font color=\"%s\" size=\"+1\">%s</font></b></th></tr>\n",TiColor,Title);
-   fprintf(fp_ou,"<tr><td align=\"center\" bgcolor=\"%s\"><font size=\"%s\">%s: %s</font></td></tr>\n",HeaderBgColor,FontSize,_("Period"),period.text);
+   fprintf(fp_ou,"<tr><td align=\"center\" bgcolor=\"%s\"><font size=\"%s\">",HeaderBgColor,FontSize);
+   fprintf(fp_ou,_("Period: %s"),period.html);
+   fputs("</font></td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th bgcolor=\"%s\" align=\"center\"><font size=\"%s\">%s</font></th></tr>\n",HeaderBgColor,FontSize,_("SmartFilter"));
    fputs("</table></div>\n",fp_ou);
 
@@ -160,7 +162,7 @@ void smartfilter_report(void)
          if(LogoImage[0]!='\0') fprintf(fp_user,"<tr><th align=left><img src=\"%s\" border=\"0\" align=\"absmiddle\" width=\"%s\" height=\"%s\"><font color=\"%s\">%s</font>\n",LogoImage,Width,Height,LogoTextColor,LogoText);
          fprintf(fp_user,"<tr><th align=\"center\"><b><font color=\"%s\" size=\"+1\">%s</font></b></th></tr>\n",TiColor,Title);
          fputs("<tr><td align=center bgcolor=\"%s\"><font size=\"%s\">",fp_user);
-         fprintf(fp_user,_("Period: %s"),period.text);
+         fprintf(fp_user,_("Period: %s"),period.html);
          fputs("</font></td></tr>\n",fp_user);
          fprintf(fp_user,"<tr><td align=\"center\" bgcolor=\"%s\"><font size=\"%s\">%s:</font><font size=\"%s\"> %s</font></td></tr>\n",HeaderBgColor,FontSize,_("User"),FontSize,uinfo->label);
          fputs("</table></div>\n",fp_user);
index 83c538c31d489b65fd125f19c428f7ae500120e8..62a9893b5fbf92ff0cf1203bd49eded30e332489 100644 (file)
@@ -71,7 +71,7 @@ void squidguard_report(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("SQUIDGUARD"));
    fputs("<tr><td class=\"header_l\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("SQUIDGUARD"));
    close_html_header(fp_ou);
index 9c4c1e94b7d0042c9aba048dbdecb2b6c4897324..ac63459d5de610c24a62fd33b916d205ccea02b2 100644 (file)
@@ -184,7 +184,7 @@ void topsites(void)
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Top sites"));
    fputs("<tr><td class=\"header_c\">",fp_ou);
-   fprintf(fp_ou,_("Period: %s"),period.text);
+   fprintf(fp_ou,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_ou);
    fputs("<tr><th class=\"header_c\">",fp_ou);
    fprintf(fp_ou,_("Top %d sites"),TopSitesNum);
index c0595a7e1ce71a0d502957b26226002c5b6a6abe..a86417718930a0ababe45d807bcbed8433a8081f 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -174,7 +174,7 @@ void topuser(void)
    snprintf(title,sizeof(title),_("SARG report for %s"),period.text);
    write_html_header(fp_top3,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,title);
    fputs("<tr><td class=\"header_c\">",fp_top3);
-   fprintf(fp_top3,_("Period: %s"),period.text);
+   fprintf(fp_top3,_("Period: %s"),period.html);
    fputs("</td></tr>\n",fp_top3);
    fprintf(fp_top3,"<tr><td class=\"header_c\">%s: %s, %s</td></tr>\n",_("Sort"),TopuserSortField,TopuserSortOrder);
    fprintf(fp_top3,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Top users"));
diff --git a/util.c b/util.c
index 3c7a189b41823a4106cb4575185f6479251350ed..b9bebd1b3fdd88d4e98da4546f4b3f3841c32d5a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -844,28 +844,42 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
 int getperiod_buildtext(struct periodstruct *period)
 {
    int i;
-
-   if(df[0]=='u')
-      i=strftime(period->text, sizeof(period->text), "%Y %b %d", &period->start);
-   else if(df[0]=='e')
-      i=strftime(period->text, sizeof(period->text), "%d %b %Y", &period->start);
-   else /*if(df[0]=='w')*/ {
+   int range;
+   char text1[40], text2[40];
+
+   if(df[0]=='u') {
+      i=strftime(text1, sizeof(text1), "%Y %b %d", &period->start);
+   }else if(df[0]=='e') {
+      i=strftime(text1, sizeof(text1), "%d %b %Y", &period->start);
+   } else /*if(df[0]=='w')*/ {
       IndexTree=INDEX_TREE_FILE;
-      i=strftime(period->text, sizeof(period->text), "%Y.%U", &period->start);
+      i=strftime(text1, sizeof(text1), "%Y.%U", &period->start);
    }
+   if (i == 0) return(-1);
 
-   if (period->start.tm_year!=period->end.tm_year ||
+   range=(period->start.tm_year!=period->end.tm_year ||
        period->start.tm_mon!=period->end.tm_mon ||
-       period->start.tm_mday!=period->end.tm_mday) {
-      period->text[i++]='-';
-      if(df[0]=='u')
-         i=strftime(period->text+i, sizeof(period->text)-i, "%Y %b %d", &period->end);
-      else if(df[0]=='e')
-         i=strftime(period->text+i, sizeof(period->text)-i, "%d %b %Y", &period->end);
-      else
-         i=strftime(period->text+i, sizeof(period->text)-i, "%Y.%U", &period->end);
+       period->start.tm_mday!=period->end.tm_mday);
+   if (range) {
+      if(df[0]=='u') {
+         i=strftime(text2, sizeof(text2)-i, "%Y %b %d", &period->end);
+      } else if(df[0]=='e') {
+         i=strftime(text2, sizeof(text2)-i, "%d %b %Y", &period->end);
+      } else {
+         i=strftime(text2, sizeof(text2)-i, "%Y.%U", &period->end);
+      }
       if (i == 0) return(-1);
    }
+
+   if (range) {
+      snprintf(period->text,sizeof(period->text),"%s-%s",text1,text2);
+      snprintf(period->html,sizeof(period->html),"%s&mdash;%s",text1,text2);
+   } else {
+      strncpy(period->text,text1,sizeof(period->text)-1);
+      period->text[sizeof(period->text)-1]='\0';
+      strncpy(period->html,text1,sizeof(period->html)-1);
+      period->html[sizeof(period->html)-1]='\0';
+   }
    return(0);
 }