From: Frédéric Marchal Date: Mon, 5 Apr 2010 05:48:25 +0000 (+0000) Subject: Output the period as an HTML text in the HTML reports X-Git-Tag: v2.3-pre2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd46f0824cfeb23cc26f3c3a9e97f81e2b05ecc7;p=thirdparty%2Fsarg.git Output the period as an HTML text in the HTML reports --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 50f26cb..13639ce 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/authfail.c b/authfail.c index ce4b0ee..d1a2249 100644 --- a/authfail.c +++ b/authfail.c @@ -90,7 +90,7 @@ void authfail_report(void) write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Authentication Failures")); fputs("",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("\n",fp_ou); fprintf(fp_ou,"%s\n",_("Authentication Failures")); close_html_header(fp_ou); diff --git a/configure.in b/configure.in index 23d29d6..cea8a63 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/dansguardian_report.c b/dansguardian_report.c index c5a35a2..44de93b 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -71,7 +71,7 @@ void dansguardian_report(void) write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DansGuardian")); fputs("",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("\n",fp_ou); fprintf(fp_ou,"%s\n",_("DansGuardian")); close_html_header(fp_ou); diff --git a/denied.c b/denied.c index 288e48c..52e5b69 100644 --- 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("",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("\n",fp_ou); fprintf(fp_ou,"%s\n",_("DENIED")); close_html_header(fp_ou); diff --git a/download.c b/download.c index 6c5a99c..1fa63b3 100644 --- a/download.c +++ b/download.c @@ -76,7 +76,7 @@ void download_report(void) write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Downloads")); fputs("",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("\n",fp_ou); fprintf(fp_ou,"%s\n",_("Downloads")); close_html_header(fp_ou); diff --git a/html.c b/html.c index edb1c0d..c023671 100644 --- 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,"%s: %s\n",_("Period"),period.text); + fprintf(fp_ou,"%s: %s\n",_("Period"),period.html); fprintf(fp_ou,"%s: %s\n",_("User"),uinfo->label); fprintf(fp_ou,"%s: %s, %s\n",_("Sort"),UserSortField,UserSortOrder); fprintf(fp_ou,"%s\n",_("User report")); diff --git a/include/conf.h b/include/conf.h index 4191ee2..d47b987 100755 --- a/include/conf.h +++ b/include/conf.h @@ -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]; diff --git a/include/info.h b/include/info.h index da8ee04..b52f442 100755 --- a/include/info.h +++ b/include/info.h @@ -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 ecec946..fa75c4b 100644 --- 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'; diff --git a/repday.c b/repday.c index 042614d..3855fc2 100644 --- a/repday.c +++ b/repday.c @@ -76,7 +76,7 @@ void report_day(const struct userinfostruct *uinfo) close_html_header(fp_ou); fputs("
\n",fp_ou); - fprintf(fp_ou,"\n",_("Period"),period.text); + fprintf(fp_ou,"\n",_("Period"),period.html); fprintf(fp_ou,"\n",_("User"),uinfo->label); diff --git a/report.c b/report.c index 805de2e..5800e6b 100644 --- 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,"\n",_("Period"),period.text); + fprintf(fp_tt,"\n",_("Period"),period.html); fprintf(fp_tt,"\n",_("User"),uinfo->label); fprintf(fp_tt,"\n",_("Sort"),UserSortField,UserSortOrder); fprintf(fp_tt,"\n",_("User")); diff --git a/siteuser.c b/siteuser.c index bbdb5fa..bac2edb 100644 --- a/siteuser.c +++ b/siteuser.c @@ -81,7 +81,7 @@ void siteuser(void) write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Sites & Users")); fputs("\n",fp_ou); fprintf(fp_ou,"\n",_("Sites & Users")); close_html_header(fp_ou); diff --git a/smartfilter.c b/smartfilter.c index 1db43ba..d0d281f 100644 --- a/smartfilter.c +++ b/smartfilter.c @@ -93,7 +93,9 @@ void smartfilter_report(void) write_logo_image(fp_ou); fprintf(fp_ou,"\n",TiColor,Title); - fprintf(fp_ou,"\n",HeaderBgColor,FontSize,_("Period"),period.text); + fprintf(fp_ou,"\n",fp_ou); fprintf(fp_ou,"\n",HeaderBgColor,FontSize,_("SmartFilter")); fputs("
%s: %s
%s: %s
%s: %s
%s: %s
%s: %s
%s: %s
%s: %s, %s
%s
",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("
%s
%s
%s: %s
",HeaderBgColor,FontSize); + fprintf(fp_ou,_("Period: %s"),period.html); + fputs("
%s
\n",fp_ou); @@ -160,7 +162,7 @@ void smartfilter_report(void) if(LogoImage[0]!='\0') fprintf(fp_user,"%s\n",LogoImage,Width,Height,LogoTextColor,LogoText); fprintf(fp_user,"%s\n",TiColor,Title); fputs("",fp_user); - fprintf(fp_user,_("Period: %s"),period.text); + fprintf(fp_user,_("Period: %s"),period.html); fputs("\n",fp_user); fprintf(fp_user,"%s: %s\n",HeaderBgColor,FontSize,_("User"),FontSize,uinfo->label); fputs("\n",fp_user); diff --git a/squidguard_report.c b/squidguard_report.c index 83c538c..62a9893 100644 --- a/squidguard_report.c +++ b/squidguard_report.c @@ -71,7 +71,7 @@ void squidguard_report(void) write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("SQUIDGUARD")); fputs("",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("\n",fp_ou); fprintf(fp_ou,"%s\n",_("SQUIDGUARD")); close_html_header(fp_ou); diff --git a/topsites.c b/topsites.c index 9c4c1e9..ac63459 100644 --- a/topsites.c +++ b/topsites.c @@ -184,7 +184,7 @@ void topsites(void) write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Top sites")); fputs("",fp_ou); - fprintf(fp_ou,_("Period: %s"),period.text); + fprintf(fp_ou,_("Period: %s"),period.html); fputs("\n",fp_ou); fputs("",fp_ou); fprintf(fp_ou,_("Top %d sites"),TopSitesNum); diff --git a/topuser.c b/topuser.c index c0595a7..a864177 100644 --- 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("",fp_top3); - fprintf(fp_top3,_("Period: %s"),period.text); + fprintf(fp_top3,_("Period: %s"),period.html); fputs("\n",fp_top3); fprintf(fp_top3,"%s: %s, %s\n",_("Sort"),TopuserSortField,TopuserSortOrder); fprintf(fp_top3,"%s\n",_("Top users")); diff --git a/util.c b/util.c index 3c7a189..b9bebd1 100644 --- 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—%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); }