Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/*
4
 * Copyright (C) 2019 Alexander Marston (alexander.marston@gmail.com)
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
 
20
// Require includes
21
//require __DIR__ . '/vendor/autoload.php';
22
require __DIR__ . '/smarty/Smarty.class.php';
23
require __DIR__ . '/includes/vnstat.php';
24
require __DIR__ . '/includes/utilities.php';
25
require __DIR__ . '/includes/config.php';
26
 
27
// Initiaite vnStat class
28
$vnstat = new vnStat($vnstat_bin_dir);
29
 
30
// Initiate Smarty
31
$smarty = new Smarty();
32
 
33
// Set the current year
34
$smarty->assign('year', date("Y"));
35
 
36
// Set the list of interfaces
37
$interface_list = $vnstat->getInterfaces();
38
 
39
// Set the current interface
40
$thisInterface = "";
41
 
42
if (isset($_GET['i'])) {
43
    $interfaceChosen = rawurldecode($_GET['i']);
44
 
45
    if (in_array($interfaceChosen, $interface_list, true)) {
46
        $thisInterface = $interfaceChosen;
47
    } else {
48
        $thisInterface = reset($interface_list);
49
    }
50
} else {
51
    // Assume they mean the first interface
52
    $thisInterface = reset($interface_list);
53
}
54
// Add for ALCASAR
55
$thisInterface = "";
56
 
57
$smarty->assign('current_interface', $thisInterface);
58
 
59
// Modify for ALCASAR
60
// Assign interface options
61
//$smarty->assign('interface_list', $vnstat->getInterfaces());
62
$smarty->assign('interface_list', $thisInterface);
63
 
64
// Populate table data
65
$hourlyData = $vnstat->getInterfaceData('hourly', 'table', $thisInterface);
66
$smarty->assign('hourlyTableData', $hourlyData);
67
 
68
$dailyData = $vnstat->getInterfaceData('daily', 'table', $thisInterface);
69
$smarty->assign('dailyTableData', $dailyData);
70
 
71
$monthlyData = $vnstat->getInterfaceData('monthly', 'table', $thisInterface);
72
$smarty->assign('monthlyTableData', $monthlyData);
73
 
74
$top10Data = $vnstat->getInterfaceData('top10', 'table', $thisInterface);
75
$smarty->assign('top10TableData', $top10Data);
76
 
77
// Populate graph data
78
$hourlyGraphData = $vnstat->getInterfaceData('hourly', 'graph', $thisInterface);
79
$smarty->assign('hourlyGraphData', $hourlyGraphData);
80
$smarty->assign('hourlyLargestPrefix', $hourlyGraphData[1]['delimiter']);
81
 
82
$dailyGraphData = $vnstat->getInterfaceData('daily', 'graph', $thisInterface);
83
$smarty->assign('dailyGraphData', $dailyGraphData);
84
$smarty->assign('dailyLargestPrefix', $dailyGraphData[1]['delimiter']);
85
 
86
$monthlyGraphData = $vnstat->getInterfaceData('monthly', 'graph', $thisInterface);
87
$smarty->assign('monthlyGraphData', $monthlyGraphData);
88
$smarty->assign('monthlyLargestPrefix', $monthlyGraphData[1]['delimiter']);
89
 
90
// Display the page
91
$smarty->display('templates/site_index.tpl');
92
 
93
?>