$t = $tab[$i]['label']; $rx = kbytes_to_string($tab[$i]['rx']); $tx = kbytes_to_string($tab[$i]['tx']); $total = kbytes_to_string($tab[$i]['rx'] + $tab[$i]['tx']); $id = $i & 1 ? 'odd' : 'even'; print "<tr>"; print "<td class=\"label_{$id}\">{$t}</td>"; print "<td class=\"numeric_{$id}\">{$rx}</td>"; print "<td class=\"numeric_{$id}\">{$tx}</td>"; print "<td class=\"numeric_{$id}\">{$total}</td>"; print "</tr>\n"; } } print "</table>\n"; } get_vnstat_data(); // // html start // header('Content-type: text/html; charset=utf-8'); print '<?xml version="1.0"?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>vnStat - PHP frontend</title> <link rel="stylesheet" type="text/css" href="themes/<?php echo $style; ?> /style.css"/> </head>
// $sum['hour']['act'] = 1; $sum['hour']['rx'] = $hour[0]['rx']; $sum['hour']['tx'] = $hour[0]['tx']; $sum['day']['act'] = 1; $sum['day']['rx'] = $day[0]['rx']; $sum['day']['tx'] = $day[0]['tx']; $sum['month']['act'] = 1; $sum['month']['rx'] = $month[0]['rx']; $sum['month']['tx'] = $month[0]['tx']; $sum['total']['act'] = 1; $sum['total']['rx'] = $trx; $sum['total']['tx'] = $ttx; print json_encode($sum); } get_vnstat_data(false); header('Content-type: application/json; charset=utf-8'); $graph_params = "if={$iface}&page={$page}&style={$style}"; if ($page == 's') { write_summary(); } else { if ($page == 'h') { print json_encode(array('hours' => $hour)); } else { if ($page == 'd') { print json_encode(array('days' => $day)); } else { if ($page == 'm') { print json_encode(array('months' => $month)); } }