Subversion Repositories ALCASAR

Rev

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

Rev 2809 Rev 3108
Line 16... Line 16...
16
 * You should have received a copy of the GNU General Public License
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/>.
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';
-
 
22
require __DIR__ . '/smarty/Smarty.class.php';
-
 
23
require __DIR__ . '/includes/vnstat.php';
-
 
24
require __DIR__ . '/includes/utilities.php';
21
require __DIR__ . '/includes/utilities.php';
-
 
22
require __DIR__ . '/includes/vnstat.php';
25
require __DIR__ . '/includes/config.php';
23
require __DIR__ . '/includes/config.php';
-
 
24
require __DIR__ . '/smarty/Smarty.class.php';
-
 
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
}
26
 
35
 
27
// Initiaite vnStat class
36
// Initiaite vnStat class
28
$vnstat = new vnStat($vnstat_bin_dir);
37
$vnstat = new vnStat($vnstat_cmd);
29
 
38
 
30
// Initiate Smarty
39
// Initiate Smarty
31
$smarty = new Smarty();
40
$smarty = new Smarty();
32
 
41
 
33
// Set the current year
42
// Set the current year
Line 49... Line 58...
49
    }
58
    }
50
} else {
59
} else {
51
    // Assume they mean the first interface
60
    // Assume they mean the first interface
52
    $thisInterface = reset($interface_list);
61
    $thisInterface = reset($interface_list);
53
}
62
}
54
// Add for ALCASAR
-
 
-
 
63
 
55
$thisInterface = "";
64
$smarty->assign('graph_type', $graph_type);
56
 
65
 
57
$smarty->assign('current_interface', $thisInterface);
66
$smarty->assign('current_interface', $thisInterface);
58
 
67
 
59
// Modify for ALCASAR
-
 
60
// Assign interface options
68
// Assign interface options
61
//$smarty->assign('interface_list', $vnstat->getInterfaces());
69
$smarty->assign('interface_list', $interface_list);
-
 
70
 
-
 
71
// JsonVersion
62
$smarty->assign('interface_list', $thisInterface);
72
$smarty->assign('jsonVersion', $vnstat->getVnstatJsonVersion());
63
 
73
 
64
// 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
 
65
$hourlyData = $vnstat->getInterfaceData('hourly', 'table', $thisInterface);
80
$hourlyData = $vnstat->getInterfaceData('hourly', 'table', $thisInterface);
66
$smarty->assign('hourlyTableData', $hourlyData);
81
$smarty->assign('hourlyTableData', $hourlyData);
67
 
82
 
68
$dailyData = $vnstat->getInterfaceData('daily', 'table', $thisInterface);
83
$dailyData = $vnstat->getInterfaceData('daily', 'table', $thisInterface);
69
$smarty->assign('dailyTableData', $dailyData);
84
$smarty->assign('dailyTableData', $dailyData);
Line 73... Line 88...
73
 
88
 
74
$top10Data = $vnstat->getInterfaceData('top10', 'table', $thisInterface);
89
$top10Data = $vnstat->getInterfaceData('top10', 'table', $thisInterface);
75
$smarty->assign('top10TableData', $top10Data);
90
$smarty->assign('top10TableData', $top10Data);
76
 
91
 
77
// 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
 
78
$hourlyGraphData = $vnstat->getInterfaceData('hourly', 'graph', $thisInterface);
100
$hourlyGraphData = $vnstat->getInterfaceData('hourly', 'graph', $thisInterface);
79
$smarty->assign('hourlyGraphData', $hourlyGraphData);
101
$smarty->assign('hourlyGraphData', $hourlyGraphData);
80
$smarty->assign('hourlyLargestPrefix', $hourlyGraphData[1]['delimiter']);
102
$smarty->assign('hourlyLargestPrefix', $hourlyGraphData[0]['delimiter']);
-
 
103
$smarty->assign('hourlyBase', $hourlyGraphData[0]['base']);
81
 
104
 
82
$dailyGraphData = $vnstat->getInterfaceData('daily', 'graph', $thisInterface);
105
$dailyGraphData = $vnstat->getInterfaceData('daily', 'graph', $thisInterface);
83
$smarty->assign('dailyGraphData', $dailyGraphData);
106
$smarty->assign('dailyGraphData', $dailyGraphData);
84
$smarty->assign('dailyLargestPrefix', $dailyGraphData[1]['delimiter']);
107
$smarty->assign('dailyLargestPrefix', $dailyGraphData[0]['delimiter']);
-
 
108
$smarty->assign('dailyBase', $dailyGraphData[0]['base']);
85
 
109
 
86
$monthlyGraphData = $vnstat->getInterfaceData('monthly', 'graph', $thisInterface);
110
$monthlyGraphData = $vnstat->getInterfaceData('monthly', 'graph', $thisInterface);
87
$smarty->assign('monthlyGraphData', $monthlyGraphData);
111
$smarty->assign('monthlyGraphData', $monthlyGraphData);
88
$smarty->assign('monthlyLargestPrefix', $monthlyGraphData[1]['delimiter']);
112
$smarty->assign('monthlyLargestPrefix', $monthlyGraphData[0]['delimiter']);
89
 
113
 
90
// Display the page
114
// Display the page
91
$smarty->display('templates/site_index.tpl');
115
$smarty->display('templates/site_index.tpl');
92
 
116
 
93
?>
117
?>