<?php
require_once('config.php');

$graphs = array('last_90_minutes',
        
'last_72_hours',
        
'last_90_days',
        
'last_90_weeks',
                
'previous_months',
        
'hour_of_day',
        
'day_of_week',
        
'day_of_month',
/*        'week_of_year',
        'month_of_year' */
);
$out[] = '<html>';
$out[] = '<head><title>Cal Neva Availability Report</title></head>';
$out[] = '<body>';

$out[] = '<center><font size=+2>Cal Neva Availability Report</font><p>';

$out[] = '</center>';
$out[] = 'This page serves to report on the state of my cable modem service from Cal Neva Broadband ';
$out[] = 'here in Pine Mountain Club, California.<p>';
$out[] = 'This data does not show the quality of the service when it is up, ';
$out[] = 'just whether or not it is responding to packets within 10 seconds. ';
$out[] = 'In other words, the connection may be 100% up, and these graphs show 100% ';
$out[] = 'availability, yet the connection may be limited to a slow speed, or lagged with up to 10 seconds of latency.<p>';
$out[] = 'The test works by sending a single ICMP ping to 4.2.2.2 (a highly-available GTE nameserver) every ';
$out[] = '60 seconds.  If no reply is received after 10 seconds, it ';
$out[] = 'is counted as 60 seconds of "unavailable" time.  Heavy usage of my ';
$out[] = 'cable line could possibly produce artificial unavailability, ';
$out[] = 'but a 10 second time out should significantly reduce this chance. ';
$out[] = 'I consider the accuracy of the data to be better than +/- 5%. ';
$out[] = 'I have some ideas to improve this accuracy but for now, for ';
$out[] = 'my purposes, this is "good enough". Scroll to the bottom of the ';
$out[] = 'page for source code.';
$out[] = '</font>';
$out[] = '<p>';
$out[] = '<center>';
$out[] = '<font size=1>';
$out[] = '<div style="text-align: left; border: solid black 1px; background-color: #EEEEEE;">';
$out[] = '<div style="text-align: center; font-size: 10px; font-weight: bold;">News</div>';
$out[] = '<li>2010-12-04 - Back in business.  Data from 11/29 - 12/04 unavailable.</li><p>';
$out[] = '</div>';
$out[] = '<p>';

$stats stat('images/cable_'.$graphs[0].'.jpg');
$out[] = 'Last updated: '.date('r',$stats[9]).'';

$out[] = '<p>';
$out[] = file_get_contents($statsfile);
$out[] = '<p>';

foreach(
$graphs as $thisgraph) {
    
$out[] = '<img src="images/cable_'.$thisgraph.'.jpg"><p>';
}

$out[] = '<hr><br>';
$out[] = 'Source:';
$out[] = '<a href="index.phps">index.php</a> /';
$out[] = '<a href="cron.phps">cron.php</a> / ';
$out[] = '<a href="cable_watch.phps">cable_watch.php</a> / ';
$out[] = '<a href="config.phps">config.php</a> / ';
$out[] = '<a href="http://www.aditus.nu/jpgraph/">JPGraph</a>';

$out[] = '</body>';
$out[] = '</html>';
print 
join("\n",$out);