Example #1
0
    <div id="header"><?php 
print T('Traffic data for') . " {$iface_title[$iface]} ({$iface})";
?>
</div>
    <div id="main">
    <?php 
$graph_params = "if={$iface}&amp;page={$page}&amp;style={$style}";
if ($page != 's') {
    if ($graph_format == 'svg') {
        print "<object type=\"image/svg+xml\" width=\"692\" height=\"297\" data=\"graph_svg.php?{$graph_params}\"></object>\n";
    } else {
        print "<img src=\"graph.php?{$graph_params}\" alt=\"graph\"/>\n";
    }
}
if ($page == 's') {
    write_summary();
} else {
    if ($page == 'h') {
        write_data_table(T('Last 24 hours'), $hour);
    } else {
        if ($page == 'd') {
            write_data_table(T('Last 30 days'), $day);
        } else {
            if ($page == 'm') {
                write_data_table(T('Last 12 months'), $month);
            }
        }
    }
}
?>
    </div>
Example #2
0
    $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);
    return $sum;
}
get_vnstat_data(false);
header('Content-type: application/json; charset=utf-8');
$graph_params = "if={$iface}&amp;page={$page}&amp;style={$style}";
if ($page == 's') {
    $sum = 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));
            }
        }
    }
}