<?php
    print("<div class=\"todaysumcontainer\">\n");
    
    $date = localtime(time(), 1);
    $date['tm_mon']++;
    $date['tm_year'] = $date['tm_year'] + 1900;
    
    
    $pgsqlfmtdate = sprintf('%02d', $date['tm_mon']) . "/" . sprintf('%02d', $date['tm_mday']) . "/" . $date['tm_year'];
    
    $res = pg_query("select count(distinct receivinghost) from history where connectdate>='".$pgsqlfmtdate." 00:00:00' and connectdate<='".$pgsqlfmtdate." 23:59:59';");
    $totalhosts = pg_fetch_array($res);
    
    print("<table class=\"today\">\n");
    print("<tr class=\"todaysum\">
	<th colspan=\"5\" class=\"todaysum\">Today, " . sprintf('%02d', $date['tm_mday']) . "/" . sprintf('%02d', $date['tm_mon']) . "/" . $date['tm_year'] . "</th>
    </tr>\n");
    print("<tr class=\"todaysum\">\n");
    print("<td class=\"todaysum\">\n");
    print("Hosts: ".$totalhosts['count']."\n");
    print("</td>\n");
    
    $res = pg_query("select count(*) from history where connectdate>='".$pgsqlfmtdate." 00:00:00' and connectdate<='".$pgsqlfmtdate." 23:59:59';");
    $totalmsgs = pg_fetch_array($res);
    
    print("<td class=\"todaysum\">\n");
    print("Total msgs/tries: ".$totalmsgs['count']."\n");
    print("</td>\n");
    
    $res = pg_query("select count(*) from history where action='passed' and connectdate>='".$pgsqlfmtdate." 00:00:00' and connectdate<='".$pgsqlfmtdate." 23:59:59';");
    $totalmsgs = pg_fetch_array($res);
    
    print("<td class=\"todaysum\">\n");
    print("Accepted msgs: ".$totalmsgs['count']."\n");
    print("</td>\n");
    
    $res = pg_query("select count(*) from history where action='dropped' and connectdate>='".$pgsqlfmtdate." 00:00:00' and connectdate<='".$pgsqlfmtdate." 23:59:59';");
    $totalmsgs = pg_fetch_array($res);
    
    print("<td class=\"todaysum\">\n");
    print("Dropped msgs: ".$totalmsgs['count']."\n");
    print("</td>\n");
    
    $res = pg_query("select count(*) from history where action='tempfailed' and connectdate>='".$pgsqlfmtdate." 00:00:00' and connectdate<='".$pgsqlfmtdate." 23:59:59';");
    $totalmsgs = pg_fetch_array($res);
    
    print("<td class=\"todaysum\">\n");
    print("Tempfailed msgs: ".$totalmsgs['count']."\n");
    print("</td>\n");
    
    print("</table>\n");
    print("</div>\n");
?>