Subversion Repositories ALCASAR

Rev

Rev 2809 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2809 Rev 3108
Line 17... Line 17...
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
18
 */
19
 
19
 
20
// Require includes
20
// Require includes
21
require __DIR__ . '/vendor/autoload.php';
21
require __DIR__ . '/vendor/autoload.php';
22
require __DIR__ . '/includes/vnstat.php';
-
 
23
require __DIR__ . '/includes/utilities.php';
22
require __DIR__ . '/includes/utilities.php';
-
 
23
require __DIR__ . '/includes/vnstat.php';
24
require __DIR__ . '/includes/config.php';
24
require __DIR__ . '/includes/config.php';
25
 
25
 
-
 
26
if (isset($vnstat_config)) {
-
 
27
    $vnstat_cmd = $vnstat_bin_dir.' --config '.$vnstat_config;
-
 
28
} else {
-
 
29
    $vnstat_cmd = $vnstat_bin_dir;
-
 
30
}
-
 
31
 
-
 
32
if (empty($graph_type)) {
-
 
33
    $graph_type = 'linear';
-
 
34
}
-
 
35
 
26
// Initiaite vnStat class
36
// Initiaite vnStat class
27
$vnstat = new vnStat($vnstat_bin_dir);
37
$vnstat = new vnStat($vnstat_cmd);
28
 
38
 
29
// Initiate Smarty
39
// Initiate Smarty
30
$smarty = new Smarty();
40
$smarty = new Smarty();
31
 
41
 
32
// Set the current year
42
// Set the current year
Line 49... Line 59...
49
} else {
59
} else {
50
    // Assume they mean the first interface
60
    // Assume they mean the first interface
51
    $thisInterface = reset($interface_list);
61
    $thisInterface = reset($interface_list);
52
}
62
}
53
 
63
 
-
 
64
$smarty->assign('graph_type', $graph_type);
54
 
65
 
55
$smarty->assign('current_interface', $thisInterface);
66
$smarty->assign('current_interface', $thisInterface);
56
 
67
 
57
// Assign interface options
68
// Assign interface options
58
$smarty->assign('interface_list', $vnstat->getInterfaces());
69
$smarty->assign('interface_list', $interface_list);
-
 
70
 
-
 
71
// JsonVersion
-
 
72
$smarty->assign('jsonVersion', $vnstat->getVnstatJsonVersion());
59
 
73
 
60
// Populate table data
74
// Populate table data
-
 
75
if ($vnstat->getVnstatJsonVersion() > 1) {
-
 
76
    $fiveData = $vnstat->getInterfaceData('five', 'table', $thisInterface);
-
 
77
    $smarty->assign('fiveTableData', $fiveData);
-
 
78
}
-
 
79
 
61
$hourlyData = $vnstat->getInterfaceData('hourly', 'table', $thisInterface);
80
$hourlyData = $vnstat->getInterfaceData('hourly', 'table', $thisInterface);
62
$smarty->assign('hourlyTableData', $hourlyData);
81
$smarty->assign('hourlyTableData', $hourlyData);
63
 
82
 
64
$dailyData = $vnstat->getInterfaceData('daily', 'table', $thisInterface);
83
$dailyData = $vnstat->getInterfaceData('daily', 'table', $thisInterface);
65
$smarty->assign('dailyTableData', $dailyData);
84
$smarty->assign('dailyTableData', $dailyData);
Line 69... Line 88...
69
 
88
 
70
$top10Data = $vnstat->getInterfaceData('top10', 'table', $thisInterface);
89
$top10Data = $vnstat->getInterfaceData('top10', 'table', $thisInterface);
71
$smarty->assign('top10TableData', $top10Data);
90
$smarty->assign('top10TableData', $top10Data);
72
 
91
 
73
// Populate graph data
92
// Populate graph data
-
 
93
if ($vnstat->getVnstatJsonVersion() > 1) {
-
 
94
    $fiveGraphData = $vnstat->getInterfaceData('five', 'graph', $thisInterface);
-
 
95
    $smarty->assign('fiveGraphData', $fiveGraphData);
-
 
96
    $smarty->assign('fiveLargestPrefix', $fiveGraphData[0]['delimiter']);
-
 
97
    $smarty->assign('fiveBase', $fiveGraphData[0]['base']);
-
 
98
}
-
 
99
 
74
$hourlyGraphData = $vnstat->getInterfaceData('hourly', 'graph', $thisInterface);
100
$hourlyGraphData = $vnstat->getInterfaceData('hourly', 'graph', $thisInterface);
75
$smarty->assign('hourlyGraphData', $hourlyGraphData);
101
$smarty->assign('hourlyGraphData', $hourlyGraphData);
76
$smarty->assign('hourlyLargestPrefix', $hourlyGraphData[1]['delimiter']);
102
$smarty->assign('hourlyLargestPrefix', $hourlyGraphData[0]['delimiter']);
-
 
103
$smarty->assign('hourlyBase', $hourlyGraphData[0]['base']);
77
 
104
 
78
$dailyGraphData = $vnstat->getInterfaceData('daily', 'graph', $thisInterface);
105
$dailyGraphData = $vnstat->getInterfaceData('daily', 'graph', $thisInterface);
79
$smarty->assign('dailyGraphData', $dailyGraphData);
106
$smarty->assign('dailyGraphData', $dailyGraphData);
80
$smarty->assign('dailyLargestPrefix', $dailyGraphData[1]['delimiter']);
107
$smarty->assign('dailyLargestPrefix', $dailyGraphData[0]['delimiter']);
-
 
108
$smarty->assign('dailyBase', $dailyGraphData[0]['base']);
81
 
109
 
82
$monthlyGraphData = $vnstat->getInterfaceData('monthly', 'graph', $thisInterface);
110
$monthlyGraphData = $vnstat->getInterfaceData('monthly', 'graph', $thisInterface);
83
$smarty->assign('monthlyGraphData', $monthlyGraphData);
111
$smarty->assign('monthlyGraphData', $monthlyGraphData);
84
$smarty->assign('monthlyLargestPrefix', $monthlyGraphData[1]['delimiter']);
112
$smarty->assign('monthlyLargestPrefix', $monthlyGraphData[0]['delimiter']);
85
 
113
 
86
// Display the page
114
// Display the page
87
$smarty->display('templates/site_index.tpl');
115
$smarty->display('templates/site_index.tpl');
88
 
116
 
89
?>
117
?>