fprintf(fp_css,".logo {font-family:Verdana,Tahoma,Arial;font-size:11px;color:%s;text-align:center;vertical-align:middle;border:none;padding:0px;margin-bottom:5px;}\n",LogoTextColor);
fprintf(fp_css,".logo th {padding:0px;}\n");
fprintf(fp_css,".logo img {vertical-align:middle;padding:0px;border:0px none;}\n");
- fprintf(fp_css,".body {font-family:%s;color:%s;background-color:%s;}\n",FontFace,TxColor,BgColor);
+ fprintf(fp_css,".body {font-family:%s;font-size:%s;color:%s;background-color:%s;background-image:url(%s);}\n",FontFace,TitleFontSize,TxColor,BgColor,BgImage);
fprintf(fp_css,".info {font-family:%s;font-size:10px;text-align:center;margin-top:1em;margin-bottom:1em;}\n", FontFace);
fprintf(fp_css,".info a:link,a:visited {font-family:%s;color:#0000FF;font-size:10px;text-decoration:none;}\n", FontFace);
-
-/*! \fn void write_html_header(FILE *fp_ou, int depth, const char *title)
-Write the HTML header of a HTML report file. The DTD correspond to a
+/*! \fn void write_html_head(FILE *fp_ou, const char *page_title)
+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 title The title of the page.
+*/
+
+
+
+
+
+/*! \fn void write_html_header(FILE *fp_ou, int depth, const char *title)
+Write the HTML header of a HTML report file including the sarg logo and
+the beginning of the header of the report.
+
+The header of the report must be closed by a call to close_html_header().
+
\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.
const char *XLabel;
//! The label to write on the Y axis.
const char *YLabel;
+ //! The name of the output PNG file.
+ const char *pngfile;
};
enum TextRefPos
}
}
- if (snprintf(graph,sizeof(graph),"%s/%s/graph_day.png",outdirname,uinfo->filename)>=sizeof(graph)) {
- debuga(_("user name too long for %s/%s/graph_day.png\n"),outdirname,uinfo->filename);
+ if (snprintf(graph,sizeof(graph),"%s/%s/%s",outdirname,uinfo->filename,pdata->pngfile)>=sizeof(graph)) {
+ debuga(_("user name too long for %s/%s/%s\n"),outdirname,uinfo->filename,pdata->pngfile);
exit(EXIT_FAILURE);
}
if((pngout=fopen(graph,"wb"))==NULL) {
void greport_day(const struct userinfostruct *uinfo)
{
#ifdef HAVE_GD
- FILE *fp_in;
+ FILE *fp_in, *fp_ou;
char wdirname[MAXLEN];
char buf[MAXLEN];
char colsep;
fclose(fp_in);
unlink(wdirname);
+ if (snprintf(wdirname,sizeof(wdirname),"%s/%s/graph.html",outdirname,uinfo->filename)>=sizeof(wdirname)) {
+ debuga(_("user name too long for %s/%s/%s\n"),outdirname,uinfo->filename,"graph.html");
+ exit(EXIT_FAILURE);
+ }
+ if ((fp_ou=fopen(wdirname,"wt"))==NULL) {
+ debuga(_("(grepday) Cannot open output file %s\n"),wdirname);
+ exit(EXIT_FAILURE);
+ }
+ write_html_head(fp_ou,_("Graph report"));
+
+ fputs("<table class=\"report\" cellpadding=\"0\" cellspacing=\"2\">\n", fp_ou);
if((datetimeby & DATETIME_BYTE)!=0) {
memset(&pdata,0,sizeof(pdata));
pdata.datapoints=bytespoints;
pdata.ymax=5LL*1024LL*1024LL*1024LL;
pdata.ytype=PTG_LogBin;
pdata.YLabel=_("BYTES");
+ pdata.pngfile="graph_day_byte.png";
greport_plot(uinfo,&pdata);
- } else {
+ fprintf(fp_ou,"<tr><td><img src=\"%s\" alt=\"B\"/></td></tr>\n",pdata.pngfile);
+ }
+ if((datetimeby & DATETIME_ELAP)!=0) {
memset(&pdata,0,sizeof(pdata));
pdata.datapoints=elappoints;
pdata.npoints=31;
pdata.ymax=86400000;
pdata.ytype=PTG_Time;
pdata.YLabel=_("ELAPSED TIME");
+ pdata.pngfile="graph_day_elap.png";
greport_plot(uinfo,&pdata);
+ fprintf(fp_ou,"<tr><td><img src=\"%s\" alt=\"E\"/></td></tr>\n",pdata.pngfile);
}
+ fputs("</table>\n",fp_ou);
+
+ if (write_html_trailer(fp_ou)<0)
+ debuga(_("Write error in file %s\n"),wdirname);
+ if (fclose(fp_ou)==EOF)
+ debuga(_("Failed to close file %s - %s\n"),wdirname,strerror(errno));
#endif //HAVE_GD
return;
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 close_html_header(FILE *fp_ou);
__attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
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> ",uinfo->filename,ImageFile,_("Graphic"));
+ //fprintf(fp_top3,"<a href=\"%s/graph_day.png\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a> ",uinfo->filename,ImageFile,_("Graphic"));
+ fprintf(fp_top3,"<a href=\"%s/graph.html\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a> ",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"));
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_header(FILE *fp_ou, int depth, const char *page_title)
+void write_html_head(FILE *fp_ou, const char *page_title)
{
- //fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n",fp_ou);
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);
- fprintf(fp_ou,"</head>\n<body style=\"font-family:%s;font-size:%s;background-color:%s;background-image:url(%s)\">\n",FontFace,TitleFontSize,BgColor,BgImage);
+ fputs("</head>\n<body>\n",fp_ou);
+}
+
+void write_html_header(FILE *fp_ou, int depth, const char *page_title)
+{
+ write_html_head(fp_ou,page_title);
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);