';
$tab_array[0] = array ("Daily", true, "ifbwstats_cur.php");
$tab_array[1] = array ("Monthly", false, "ifbwstats_disp.php");
$tab_array[2] = array ("Settings", false, "pkg_edit.php?xml=ifbwstats.xml");
display_top_tabs($tab_array);
echo ' |
';
echo '';
//cycle through all valid data files found
foreach ($datafilestores as $wandataallfile)
{
//----------------------------------------begin file statistics monthly display----------------------------------------
//read data file
$fp = fopen($wandataallfile,"r") or die("Error Reading File");
$data = fread($fp, filesize($wandataallfile));
fclose($fp);
$wandataall = explode("\n", $data);
$n = count($wandataall);
$monthintotal = 0;
$monthouttotal = 0;
$interfacename = str_replace('.data', '', $wandataallfile);
$interfacename = str_replace('/tmp/ifbwstats-', '', $interfacename);
$interfacename = str_replace('/cf/conf/ifbwstats-', '', $interfacename);
echo '';
echo ' ';
echo ''.$interfacename.' Statistics Summary | | ';
echo '';
echo '';
echo '';
echo 'Date | ';
echo 'Downloaded | ';
echo 'Uploaded | ';
echo 'Total Transfered | ';
echo ' ';
echo ' ';
echo ' | ';
echo '';
echo ' ';
$htmlcode = '';
for ($i=0 ; $i < $n ; $i++ )
{
$dataset=explode("|", $wandataall[$i]);
$dateset=explode("-", $dataset[0]);
$monthintotal = $monthintotal + $dataset[1];
$monthouttotal = $monthouttotal + $dataset[2];
$total = round((($dataset[1]+$dataset[2])/1024/1024/1024),2);
$dataset[1] = round(($dataset[1]/1024/1024),2);
$dataset[2] = round(($dataset[2]/1024/1024),2);
//show daily stats
$htmlcode = $htmlcode.''.$dataset[0].' | '.$dataset[1].'MB | '.$dataset[2].'MB | '.$total.'GB | ';
//if there is no more data, show month
if (($n-1) == $i)
{
$total = round((($monthintotal + $monthouttotal)/1024/1024/1024),2);
$monthintotal = round(($monthintotal/1024/1024/1024),2);
$monthouttotal = round(($monthouttotal/1024/1024/1024),2);
$htmlcode = $htmlcode.'Current Month Total | ↓'.$monthintotal.'GB | ↑'.$monthouttotal.'GB | ↕'.$total.'GB | ';
echo $htmlcode;
}
//if at the end of the billing cycle, erase month htlmcode as we only want to show the current month
if ($dateset[2] == ($firstday-1))
{
$htmlcode = '';
$monthintotal = 0;
$monthouttotal = 0;
}
//if the billing cycle starts on the first day of the month, figure out the last day of the previous month, and if appropriate erase htmlcode
if ($firstday == '1')
{
//find the last day of the month
$maxday = date("t", strtotime($dateset[0]."-".$dateset[1]."-".$dateset[2]));
if ($dateset[2]==$maxday)
{
$htmlcode = '';
$monthintotal = 0;
$monthouttotal = 0;
}
}
}
echo ' ';
echo ' ';
echo ' | ';
echo ' ';
unset ($writedata);
//----------------------------------------end file statistics monthly display----------------------------------------
}
//end foreach loop
echo ' |
';
echo '