1675 |
richard |
1 |
<?php
|
|
|
2 |
//
|
|
|
3 |
// vnStat PHP frontend (c)2006-2010 Bjorge Dijkstra (bjd@jooz.net)
|
|
|
4 |
//
|
|
|
5 |
// This program is free software; you can redistribute it and/or modify
|
|
|
6 |
// it under the terms of the GNU General Public License as published by
|
|
|
7 |
// the Free Software Foundation; either version 2 of the License, or
|
|
|
8 |
// (at your option) any later version.
|
|
|
9 |
//
|
|
|
10 |
// This program is distributed in the hope that it will be useful,
|
|
|
11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
13 |
// GNU General Public License for more details.
|
|
|
14 |
//
|
|
|
15 |
// You should have received a copy of the GNU General Public License
|
|
|
16 |
// along with this program; if not, write to the Free Software
|
|
|
17 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
18 |
//
|
|
|
19 |
//
|
|
|
20 |
// see file COPYING or at http://www.gnu.org/licenses/gpl.html
|
|
|
21 |
// for more information.
|
|
|
22 |
//
|
|
|
23 |
require 'config.php';
|
|
|
24 |
require 'localize.php';
|
|
|
25 |
require 'vnstat.php';
|
|
|
26 |
|
|
|
27 |
validate_input();
|
|
|
28 |
|
|
|
29 |
require "./themes/$style/theme.php";
|
|
|
30 |
|
|
|
31 |
function write_summary()
|
|
|
32 |
{
|
|
|
33 |
global $summary,$top,$day,$hour,$month;
|
|
|
34 |
|
|
|
35 |
$trx = $summary['totalrx']*1024+$summary['totalrxk'];
|
|
|
36 |
$ttx = $summary['totaltx']*1024+$summary['totaltxk'];
|
|
|
37 |
|
|
|
38 |
//
|
|
|
39 |
// build array for write_data_table
|
|
|
40 |
//
|
|
|
41 |
$sum['hour']['act'] = 1;
|
|
|
42 |
$sum['hour']['rx'] = $hour[0]['rx'];
|
|
|
43 |
$sum['hour']['tx'] = $hour[0]['tx'];
|
|
|
44 |
|
|
|
45 |
$sum['day']['act'] = 1;
|
|
|
46 |
$sum['day']['rx'] = $day[0]['rx'];
|
|
|
47 |
$sum['day']['tx'] = $day[0]['tx'];
|
|
|
48 |
|
|
|
49 |
$sum['month']['act'] = 1;
|
|
|
50 |
$sum['month']['rx'] = $month[0]['rx'];
|
|
|
51 |
$sum['month']['tx'] = $month[0]['tx'];
|
|
|
52 |
|
|
|
53 |
$sum['total']['act'] = 1;
|
|
|
54 |
$sum['total']['rx'] = $trx;
|
|
|
55 |
$sum['total']['tx'] = $ttx;
|
|
|
56 |
|
|
|
57 |
print json_encode($sum);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
get_vnstat_data(false);
|
|
|
62 |
|
|
|
63 |
header('Content-type: application/json; charset=utf-8');
|
|
|
64 |
$graph_params = "if=$iface&page=$page&style=$style";
|
|
|
65 |
if ($page == 's')
|
|
|
66 |
{
|
|
|
67 |
write_summary();
|
|
|
68 |
}
|
|
|
69 |
else if ($page == 'h')
|
|
|
70 |
{
|
|
|
71 |
print json_encode(array('hours' => $hour));
|
|
|
72 |
}
|
|
|
73 |
else if ($page == 'd')
|
|
|
74 |
{
|
|
|
75 |
print json_encode(array('days' => $day));
|
|
|
76 |
}
|
|
|
77 |
else if ($page == 'm')
|
|
|
78 |
{
|
|
|
79 |
print json_encode(array('months' => $month));
|
|
|
80 |
}
|
|
|
81 |
?>
|