char *jquery_url = "http://code.jquery.com/jquery-latest.js";\r
char *lms_url = "/lms/?m=customerinfo&id=";\r
int use_jquery_popups = 1;\r
+int row_odd_even = 0; /*<tr class="odd/even"> */\r
+\r
+const char *tr_odd_even(void)\r
+{\r
+ row_odd_even = 1 - row_odd_even;\r
+ if(row_odd_even)\r
+ {\r
+ return "<tr class=\"even\">\n";\r
+ }\r
+ else\r
+ {\r
+ return "<tr class=\"odd\">\n";\r
+ }\r
+}\r
\r
/* ======= Help screen is hopefuly self-documenting part of code :-) ======= */\r
\r
f=fopen(str,"w");\r
if(f)\r
{\r
- fprintf(f, "<table border><tr><th colspan=\"2\">%s %s</th><th align=\"right\">lms</th><th colspan=\"2\">Data transfers</th><th align=\"right\">Min.speed</th></tr>\n ",\r
+ fprintf(f, "<table border=\"1\"><thead><tr class=\"bgGrey\"><th colspan=\"2\">%s %s</th><th align=\"right\">lms</th><th colspan=\"2\">Data transfers</th><th align=\"right\">Min.speed</th></tr></thead><tbody>\n ",\r
month, year);\r
\r
+ row_odd_even = 0;\r
for_each(iplog, iplogs)\r
{\r
if(iplog->traffic)\r
{\r
- fprintf(f, "<tr><td align=\"right\">%d</td><td align=\"left\"><a href=\"%s%s.log\">%s</td></td><td align=\"right\">", \r
- i++, log_url, iplog->name, iplog->name); \r
+ fprintf(f, "%s<td align=\"right\">%d</td><td align=\"left\"><a href=\"%s%s.log\">%s</td></td><td align=\"right\">", \r
+ tr_odd_even(), i++, log_url, iplog->name, iplog->name); \r
if(iplog->lmsid > 0)\r
{\r
/*base URL will be configurable soon ... */\r
iplog->l=total;\r
}\r
}\r
- fprintf(f,"<tr><th colspan=\"4\" align=\"left\">Total:</th><th align=\"right\">%ld GB</th><th align=\"right\">%Ld kbps</th></tr>\n", total, line);\r
- fputs("</table>\n", f);\r
+ fprintf(f,"<tr class=\"bgGrey\"><th colspan=\"4\" align=\"left\">Total:</th><th align=\"right\">%ld GB</th><th align=\"right\">%Ld kbps</th></tr>\n", total, line);\r
+ fputs("</tbody></table>\n", f);\r
\r
+ row_odd_even = 0;\r
if(i>10)\r
{\r
- fputs("<a name=\"erp\"></a><p><table border><tr><th colspan=\"5\">Enterprise Resource Planning (ERP)</th></tr>\n",f);\r
- fputs("<tr><td>Analytic category</td>\n",f);\r
- fputs("<td colspan=\"2\" align=\"center\">Active Classes</td><td colspan=\"2\" align=\"center\">Data transfers</td></tr>\n",f);\r
+ fputs("<a name=\"erp\"></a><p><table border=\"0\"><thead><caption>Enterprise Resource Planning (ERP)</caption></tr>\n",f);\r
+ fputs("<tr class=\"bgGrey\"><td>Analytic category</td>\n",f);\r
+ fputs("<td colspan=\"2\" align=\"center\">Active Classes</td><td colspan=\"2\" align=\"center\">Data transfers</td></tr>\n</thead><tbody>\n",f);\r
\r
if_exists(iplog,iplogs,iplog->l>=total/4)\r
{\r
- fprintf(f,"<tr><td>Top 25%% of traffic</td>\n");\r
+ fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%ld G</td><td align=\"right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists(iplog,iplogs,iplog->i==10)\r
{\r
- fprintf(f,"<tr><td>Top 10 downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());\r
fprintf(f,"<th align=\"right\">10</th><td align=\"right\">%d %%</td><td align=\"right\">%ld G</td><td align=\"right\">%d %%</td></tr>\n",(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists(iplog,iplogs,iplog->l>=total/2)\r
{\r
- fprintf(f,"<tr><td>Top 50%% of traffic</td>\n");\r
+ fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%ld G</td><th align=\"right\">%d %%</th></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists(iplog,iplogs,iplog->l>=4*total/5)\r
{\r
- fprintf(f,"<tr><td>Top 80%% of traffic</td>\n");\r
+ fprintf(f,"%s<td>Top 80%% of traffic</td>\n",tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%ld G</td><th align=\"right\">%d %%</th></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists (iplog,iplogs,iplog->i>=i/5)\r
{\r
- fprintf(f,"<tr><td>Top 20%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 20%% downloaders</td>\n",tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><th align=\"right\">%d %%</th><td align=\"right\">%ld G</td><td align=\"right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists(iplog,iplogs,iplog->i>=i/4)\r
{\r
- fprintf(f,"<tr><td>Top 25%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%ld G</td><td align=\"right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists(iplog,iplogs,iplog->i>=i/2)\r
{\r
- fprintf(f,"<tr><td>Top 50%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 50%% downloaders</td>\n",tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><th align=\"right\">%d %%</th><td align=\"right\">%ld G</td><td align=\"right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
if_exists(iplog,iplogs,iplog->i>=4*i/5)\r
{\r
- fprintf(f,"<tr><td>Top 80%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 80%% downloaders</td>\n",tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%ld G</td><td align=\"right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
}\r
\r
- fprintf(f,"<tr><td>All users, all traffic</td>\n");\r
+ fprintf(f,"<tr class=\"bgGrey\"><td>All users, all traffic</td>\n");\r
fprintf(f,"<th align=\"right\">%d</th><th align=\"right\">100 %%</th><th align=\"right\">%ld G</th><th align=\"right\">100 %%</th></tr>\n",i-1,total);\r
- fputs("</table>\n", f);\r
+ fputs("</tbody></table>\n", f);\r
}\r
\r
fprintf(f, stats_html_signature, version);\r
{\r
fprintf(f,"<script type=\"text/javascript\" src=\"%s\"></script>\n", jquery_url);\r
}\r
- fputs("<table border>\n<tr><th align=\"right\">#</th><th align=\"right\">group</th><th align=\"right\">IPs</th><th align=\"right\">requested</th>\n",f);\r
+ fputs("<table border=\"0\">\n<thead><tr class=\"bgGrey\"><th align=\"right\">#</th><th align=\"right\">group</th><th align=\"right\">IPs</th><th align=\"right\">requested</th>\n",f);\r
fprintf(f,"<th colspan=\"%d\">data limits</th>\n", keywordcount);\r
- fputs("</tr>\n",f);\r
+ fputs("</tr></thead><tbody>\n",f);\r
\r
+ row_odd_even = 0;\r
for_each(group, groups) \r
{ \r
#ifdef DEBUG\r
printf("%d k group: %d bandwidth requested: %d k\n",group->min,group->count,group->desired);\r
#endif\r
- fprintf(f,"<tr><td align=\"right\">%d</td><td align=\"right\">%d k</td>",\r
- count, group->min);\r
- fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d k</td>",\r
- group->count, group->desired);\r
+ fprintf(f, "%s<td align=\"right\">%d</td><td align=\"right\">%d k</td>",\r
+ tr_odd_even(), count, group->min);\r
+ fprintf(f, "<td align=\"right\">%d</td><td align=\"right\">%d k</td>",\r
+ group->count, group->desired);\r
\r
for_each(keyword, keywords)\r
{\r
printf("Total groups: %d Total bandwidth requested: %d k\nAGGREGATION: 1/%d\n",\r
count, i, i/line);\r
#endif\r
- fprintf(f,"<tr><th colspan=\"2\" align=\"left\">Line %Ld k</td>",line);\r
+ fprintf(f,"<tr class=\"bgGrey\"><th colspan=\"2\" align=\"left\">Line %Ld k</td>",line);\r
fprintf(f,"<th align=\"right\">%d</td><th align=\"right\">%d k</td>",total,i);\r
\r
for_each(keyword, keywords)\r
fprintf(f,"</tr><tr><th colspan=\"4\">Aggregation 1/%d</th>\n", (int)(0.5+i/line));\r
fprintf(f,"<th colspan=\"%d\">%d traffic classes</th></tr>\n", keywordcount, total);\r
\r
- fputs("</table>\n",f);\r
+ fputs("</tbody></table>\n",f);\r
}\r
else if(!dry_run && !just_flush)\r
{\r
colspan++;\r
}\r
\r
- fprintf(f,"<p><table border>\n<tr><th colspan=\"%d\">%s",colspan,title);\r
- fprintf(f," (%s)</th></tr>\n", d);\r
- fputs("<tr><td align=\"right\">#</td><td>hostname</td>",f);\r
+ fprintf(f,"<p><table border>\n<thead><caption>%s",title);\r
+ fprintf(f," (%s)</caption>\n", d);\r
+ fputs("<tr class=\"bgGrey\"><td align=\"right\">#</td><td>hostname</td>",f);\r
if(found_lmsid)\r
{\r
fputs("<td align=\"right\">lms</td>\n",f);\r
<td align=\"right\">minimum</td>\\r
<td align=\"right\">desired</td>\\r
<td align=\"right\">maximum</td>\\r
-<td>prio</td></tr>\n",f); \r
+<td>prio</td></tr>\n\\r
+</thead><tbody>\n",f); \r
\r
+ row_odd_even = 0;\r
for_each(ip,ips) if(!use_jquery_popups || !ip->sharing)\r
{\r
char *f1="", *f2="";\r
printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); \r
#endif\r
/* hostnames -------------------------------------- */\r
- fprintf(f,"<tr><td align=\"right\"><a name=\"%s\"></a>%d</td><td><a href=\"%s%s.log\">%s</a>\n", ip->name, i, log_url, ip->name, ip->name);\r
+ fprintf(f,"%s<td align=\"right\"><a name=\"%s\"></a>%d</td><td><a href=\"%s%s.log\">%s</a>\n", \r
+ tr_odd_even(), ip->name, i, log_url, ip->name, ip->name);\r
if(use_jquery_popups)\r
{\r
fprintf(f,"<span id=\"sharing_%d\" style=\"display:none\">",i);\r
}\r
}\r
}\r
- fprintf(f,"<tr><th colspan=\"%d\" align=\"left\">%d CLASSES</th>", colspan-7, i);\r
+ fprintf(f,"<tr class=\"bgGrey\"><th colspan=\"%d\" align=\"left\">%d CLASSES</th>", colspan-7, i);\r
fprintf(f,"<th align=\"right\">%Lu M</th><th align=\"right\">%Lu M</th>\n", total_traffic, total_direct);\r
if(qos_proxy)\r
{\r
fprintf(f,"<th align=\"right\">%Lu M</th>\n", total_proxy);\r
}\r
fprintf(f,"<th align=\"right\">%Lu M</th>", total_upload);\r
- fprintf(f,"<th colspan=\"4\"><span style=\"color:red\">FUP-LIMIT %dx</span> <span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</table>\n",limit_count,prio_count);\r
+ fprintf(f,"<th colspan=\"4\"><span style=\"color:red\">FUP-LIMIT %dx</span> <span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</tbody></table>\n",limit_count,prio_count);\r
\r
+ row_odd_even = 0;\r
if(active_classes>10)\r
{\r
int top20_count=0,top20_perc1=0;\r
long long top20_perc2=0;\r
unsigned long long top20_sum=0l;\r
\r
- fputs("<a name=\"erp\"></a><p><table border><tr><th colspan=\"5\">Enterprise Resource Planning (ERP)</th></tr>\n",f);\r
- fputs("<tr><td>Analytic category</td>\n",f);\r
- fputs("<td colspan=\"2\" align=\"center\">Active Classes</td><td colspan=\"2\" align=\"center\">Data transfers</td></tr>\n",f);\r
+ fputs("<a name=\"erp\"></a><p><table border><thead><caption>Enterprise Resource Planning (ERP)</caption>\n",f);\r
+ fputs("<tr class=\"bgGrey\"><td>Analytic category</td>\n",f);\r
+ fputs("<td colspan=\"2\" align=\"center\">Active Classes</td><td colspan=\"2\" align=\"center\">Data transfers</td></tr></thead><tbody>\n",f);\r
\r
if_exists(sum,sums,sum->l>=total_traffic/4)\r
{\r
- fprintf(f,"<tr><td>Top 25%% of traffic</td>\n");\r
+ fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i==10)\r
{\r
- fprintf(f,"<tr><td>Top 10 downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());\r
fprintf(f,"<th align=\"right\">10</th><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->l>=total_traffic/2)\r
{\r
- fprintf(f,"<tr><td>Top 50%% of traffic</td>\n");\r
+ fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><th align=\"right\">%Ld %%</th></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->l>=4*total_traffic/5)\r
{\r
- fprintf(f,"<tr><td>Top 80%% of traffic</td>\n");\r
+ fprintf(f,"%s<td>Top 80%% of traffic</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><th align=\"right\">%Ld %%</th></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i>=(active_classes+1)/5)\r
{\r
- fprintf(f,"<tr><td>Top 20%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 20%% downloaders</td>\n", tr_odd_even());\r
top20_count=sum->i;\r
top20_perc1=(100*sum->i+50)/active_classes;\r
top20_sum=sum->l;\r
\r
if_exists(sum,sums,sum->i>=(active_classes+1)/4)\r
{\r
- fprintf(f,"<tr><td>Top 25%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i>=(active_classes+1)/2)\r
{\r
- fprintf(f,"<tr><td>Top 50%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 50%% downloaders</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><th align=\"right\">%d %%</th><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i>=4*(active_classes+1)/5)\r
{\r
- fprintf(f,"<tr><td>Top 80%% downloaders</td>\n");\r
+ fprintf(f,"%s<td>Top 80%% downloaders</td>\n", tr_odd_even());\r
fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
- fprintf(f,"<tr><td><a href=\"%sERP.log\">All users, all traffic</a></td>\n", log_url);\r
+ fprintf(f,"<tr class=\"bgGrey\"><td><a href=\"%sERP.log\">All users, all traffic</a></td>\n", log_url);\r
fprintf(f,"<th align=\"right\">%d</th><th align=\"right\">100 %%</th><th align=\"right\">%Lu M</th><th align=\"right\">100 %%</th></tr>\n",active_classes,total_traffic);\r
- fputs("</table>\n", f);\r
+ fputs("</tbody></table>\n", f);\r
\r
/* write basic ERP data to log directory */\r
if(!just_preview)\r