exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Authentication Failures"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Authentication Failures"),HTML_JS_NONE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DansGuardian"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("DansGuardian"),HTML_JS_NONE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Denied"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Denied"),HTML_JS_NONE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
-/*! \fn void write_html_head(FILE *fp_ou, const char *page_title)
+/*! \fn void write_html_head(FILE *fp_ou,int depth, const char *page_title,int javascript)
Write the header of the HTML document. The DTD corresponds to a
transitional HTML version 4.01. The title of the document is taken from
the global variable ::Title.
\param fp_ou The file to which the HTML header is written.
+\param depth How deep is the page in the directory tree. The path of the relative javascripts is adjusted accordingly.
\param title The title of the page.
+\param javascript Which javascript to include in the page. Is a combination of the following bits:
+ \arg HTML_JS_SORTTABLE
*/
\param fp_ou The file to which the HTML header is written.
\param depth How deep is the page in the directory tree. The depth is passed to show_sarg().
\param title The title of the page.
+\param javascript Which javascript to include in the page. Is a combination of bits.
+See \see write_html_header() for the possible values.
*/
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Downloads"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Downloads"),HTML_JS_NONE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
debuga(_("(grepday) Cannot open output file %s\n"),wdirname);
exit(EXIT_FAILURE);
}
- write_html_head(fp_ou,_("Graph report"));
+ write_html_head(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Graph report"),HTML_JS_NONE);
fputs("<table class=\"report\" cellpadding=\"0\" cellspacing=\"2\">\n", fp_ou);
if((datetimeby & DATETIME_BYTE)!=0) {
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("User report"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("User report"),HTML_JS_SORTTABLE);
fprintf(fp_ou,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period.html);
fprintf(fp_ou,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo->label);
fputs("<tr><td class=\"header_c\">",fp_ou);
#define USER_SORT_CONNECT 0x0008UL
#define USER_SORT_TIME 0x0010UL
+//! Value to exclude all the javascripts from the html page.
+#define HTML_JS_NONE 0x0000
+//! Bit to include sorttable.js in the html plage.
+#define HTML_JS_SORTTABLE 0x0001
+
struct periodstruct
{
//! The first date of the period.
void show_info(FILE *fp_ou);
void show_sarg(FILE *fp_ou, int depth);
void write_logo_image(FILE *fp_ou);
-void write_html_head(FILE *fp_ou, const char *page_title);
-void write_html_header(FILE *fp_ou, int depth, const char *title);
+void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript);
+void write_html_header(FILE *fp_ou, int depth, const char *title,int javascript);
void close_html_header(FILE *fp_ou);
__attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
void output_html_string(FILE *fp_ou,const char *str,int maxlen);
debuga(_("(index) Cannot open file %s - %s\n"),yearindex,strerror(errno));
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nyears));
+ write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nyears),HTML_JS_NONE);
close_html_header(fp_ou);
fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou);
fprintf(fp_ou,"<tr><th class=\"header_l\">%s</th><th class=\"header_l\">%s</th></tr>\n",_("YEAR"),_("SIZE"));
exit(EXIT_FAILURE);
}
snprintf(title,sizeof(title),ngettext("SARG: report for %04d","SARG: reports for %04d",nmonths),year);
- write_html_header(fp_ou2,1,title);
+ write_html_header(fp_ou2,1,title,HTML_JS_NONE);
close_html_header(fp_ou2);
fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou2);
fprintf(fp_ou2,"<tr><th class=\"header_l\">%s/%s</th></tr>\n",_("YEAR"),_("MONTH"));
exit(EXIT_FAILURE);
}
snprintf(title,sizeof(title),ngettext("SARG: report for %04d/%02d","SARG: reports for %04d/%02d",ndays),year,month);
- write_html_header(fp_ou3,2,title);
+ write_html_header(fp_ou3,2,title,HTML_JS_NONE);
close_html_header(fp_ou3);
fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\">\n<tr><td></td><td></td></tr>\n",fp_ou3);
fprintf(fp_ou3,"<tr><th class=\"header_l\">%s/%s/%s</th></tr>\n",_("YEAR"),_("MONTH"),_("DAYS"));
debuga(_("(index) Cannot open file %s\n"),wdir);
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nsort));
+ write_html_header(fp_ou,0,ngettext("SARG report","SARG reports",nsort),HTML_JS_SORTTABLE);
close_html_header(fp_ou);
fputs("<div class=\"index\"><table cellpadding=\"1\" cellspacing=\"2\"",fp_ou);
if (SortTableJs[0]) fputs(" class=\"sortable\"",fp_ou);
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Day report"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Day report"),HTML_JS_NONE);
fprintf(fp_ou,"<tr><td class=\"header_c\" colspan=\"2\">%s: %s</td></tr>\n",_("Period"),period.html);
fprintf(fp_ou,"<tr><th class=\"header_c\" colspan=\"2\">%s: %s</th></tr>\n",_("User"),uinfo->label);
close_html_header(fp_ou);
sprintf(httplink,"<font size=%s><a href=\"http://%s\">%s</a>",FontSize,accurl,accurl);
*/
- write_html_header(fp_tt,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Site access report"));
+ write_html_header(fp_tt,(IndexTree == INDEX_TREE_DATE) ? 4 : 2,_("Site access report"),HTML_JS_NONE);
fprintf(fp_tt,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("Period"),period.html);
fprintf(fp_tt,"<tr><td class=\"header_c\">%s: %s</td></tr>\n",_("User"),uinfo->label);
fputs("<tr><td class=\"header_c\">",fp_tt);
# TAG: sorttable path
# The full path to a javascript script to dynamically sort the tables.
# The path is the path a browser must follow to find the script.
+#
+# If the path starts with "../" then it is assumed to be a relative
+# path and sarg adds as many "../" as necessary to locate the js script from
+# the output directory. Therefore, ../../sorttable.js searches for the javascript
+# one level above output_dir.
+#
# If this entry is set, each sortable table will have the "sortable" class set.
# You may have a look at http://www.kryogenix.org/code/browser/sorttable/
-# for such as implementation.
+# for the implementation on which sarg is based.
#
# sorttable /sorttable.js
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Sites & Users"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Sites & Users"),HTML_JS_SORTTABLE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Redirector report"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Redirector report"),HTML_JS_NONE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
exit(EXIT_FAILURE);
}
- write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Top sites"));
+ write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Top sites"),HTML_JS_SORTTABLE);
fputs("<tr><td class=\"header_c\">",fp_ou);
fprintf(fp_ou,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_ou);
}
snprintf(title,sizeof(title),_("SARG report for %s"),period.text);
- write_html_header(fp_top3,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,title);
+ write_html_header(fp_top3,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,title,HTML_JS_SORTTABLE);
fputs("<tr><td class=\"header_c\">",fp_top3);
fprintf(fp_top3,_("Period: %s"),period.html);
fputs("</td></tr>\n",fp_top3);
if(debug)
debuga(_("Making Useragent report\n"));
- write_html_header(fp_ht,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Squid Useragent's Report"));
+ write_html_header(fp_ht,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Squid Useragent's Report"),HTML_JS_NONE);
fprintf(fp_ht,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Squid Useragent's Report"));
fprintf(fp_ht,"<tr><td class=\"header_c\">%s: %s - %s</td></tr>\n",_("Period"),idate,fdate);
close_html_header(fp_ht);
fprintf(fp_ou, "<div class=\"logo\"><img src=\"%s\" width=\"%s\" height=\"%s\" alt=\"Logo\"> %s</div>\n",LogoImage,Width,Height,LogoText);
}
-void write_html_head(FILE *fp_ou, const char *page_title)
+void write_html_head(FILE *fp_ou, int depth, const char *page_title,int javascript)
{
+ int i;
+
fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n",fp_ou);
fprintf(fp_ou, "<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">\n",CharSet);
if (page_title) fprintf(fp_ou,"<title>%s</title>\n",page_title);
css(fp_ou);
- if (SortTableJs[0])
- fprintf(fp_ou,"<script type=\"text/javascript\" src=\"%s\"></script>\n",SortTableJs);
+ if ((javascript & HTML_JS_SORTTABLE)!=0 && SortTableJs[0]) {
+ fputs("<script type=\"text/javascript\" src=\"",fp_ou);
+ if (strncmp(SortTableJs,"../",3)==0) {
+ for (i=0 ; i<depth ; i++) fputs("../",fp_ou);
+ }
+ fputs(SortTableJs,fp_ou);
+ fputs("\"></script>\n",fp_ou);
+ }
fputs("</head>\n<body>\n",fp_ou);
}
-void write_html_header(FILE *fp_ou, int depth, const char *page_title)
+void write_html_header(FILE *fp_ou, int depth, const char *page_title,int javascript)
{
- write_html_head(fp_ou,page_title);
+ write_html_head(fp_ou,depth,page_title,javascript);
write_logo_image(fp_ou);
show_sarg(fp_ou, depth);
fprintf(fp_ou,"<div class=\"title\"><table cellpadding=\"0\" cellspacing=\"0\">\n<tr><th class=\"title_c\">%s</th></tr>\n",Title);