Interface

'.$info[2][1].'

Total (GB)

TX: '.round(($info[7][1] + ($info[11][1]/1024))/1024, 1).'
RX: '.round(($info[6][1] + ($info[10][1]/1024))/1024, 1).'

Uptime

'.floor((time() - $info[12][1]) / 3600).'h '.floor(((time() - $info[12][1]) / 60) % 60).'min

Database

Created:
'.date("d.m.Y H:i:s", $info[4][1]).'
Last update:
'.date("d.m.Y H:i:s", $info[5][1]).'

→ reload

'; // check if we have all the data we need, and if not, warn the user if (sizeof($hour) != 24 || sizeof($day) != 30 || sizeof($month) != 12 || sizeof($top10) != 10) { echo '

Failed to retrieve data from vnstat!


Ensure that:
'; } echo '

'. table($hour, "hours", "H:00", "GB",$precision). table($day, "days", "D, d.m.Y", "TB", $precision). table($month, "months", "M Y", "TB", $precision). table($top10, "top10", "d.m.Y, H:i", "TB", $precision, 1).'
'; /* Turns a php array into a javascript-readable array. * This new array has only two columns, hence the index argument (2. column) */ function jsarray($array2D, $index, $offset = 0) { $out = "["; for ($i = 0; $i < sizeof($array2D); ++$i) { $out .= "[".($i+$offset).",".$array2D[$i][$index]."],"; } return substr($out, 0, -1)."]"; } function table($array2d, $name, $dateformat, $unit, $precision, $offset = 0) { $class = ''; $out = '
'; for ($i = 0; $i < sizeof($array2d); ++$i) { if (($i % 2) == 1) {$class = "odd";} else {$class="even";} $out .= ' '; if ($array2d[$i][2] != 0) { $out .= ''; } else { $out .= ''; } $out .= ''; } $out .= '
TimeTXRXRatioTotal
'.date($dateformat, $array2d[$i][2]).'-'.round($array2d[$i][4] / 1024, $precision).' '.$unit.' '.round($array2d[$i][3] / 1024, $precision).' '.$unit.' '.round($array2d[$i][4] / ($array2d[$i][3] + 0.001), $precision).' '.round(($array2d[$i][3] + $array2d[$i][4]) / 1024, $precision).' '.$unit.'
'; return $out; } function fix($a){ foreach(array(3,4) as $i){ $a[$i] = round($a[$i]/1024, 2);} return $a; } ?>