mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
fix #1068 data size units
This commit is contained in:
parent
b5b2e81d3b
commit
2b3b0eb6c2
@ -49,6 +49,7 @@ if ($timeunits === 'm') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$datasizeunits = filter_input(INPUT_GET, 'dsu');
|
$datasizeunits = filter_input(INPUT_GET, 'dsu');
|
||||||
|
$dsu_factor = $datasizeunits == "mb" ? 1024 * 1024 : 1024;
|
||||||
header('X-Content-Type-Options: nosniff');
|
header('X-Content-Type-Options: nosniff');
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo '[ ';
|
echo '[ ';
|
||||||
@ -73,13 +74,8 @@ for ($i = count($jsonData) - 1; $i >= 0; --$i) {
|
|||||||
echo ',';
|
echo ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($datasizeunits == 'mb') {
|
$datasend = round($jsonData[$i]['tx'] / $dsu_factor, 0);
|
||||||
$datasend = round($jsonData[$i]['tx'] / 1024, 0);
|
$datareceived = round($jsonData[$i]['rx'] / $dsu_factor, 0);
|
||||||
$datareceived = round($jsonData[$i]['rx'] / 1024, 0);
|
|
||||||
} else {
|
|
||||||
$datasend = $jsonData[$i]['rx'];
|
|
||||||
$datareceived = $jsonData[$i]['rx'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($timeunits === 'm') {
|
if ($timeunits === 'm') {
|
||||||
echo '{ "date": "' , $dt->format('Y-m') , '", "rx": "' , $datareceived ,
|
echo '{ "date": "' , $dt->format('Y-m') , '", "rx": "' , $datareceived ,
|
||||||
|
@ -39,11 +39,14 @@ if (filter_input(INPUT_GET, 'tu') == 'h') {
|
|||||||
exit('vnstat error');
|
exit('vnstat error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$datasizeunits = filter_input(INPUT_GET, 'dsu');
|
||||||
|
$dsu_factor = $datasizeunits == "mb" ? 1024 * 1024 : 1024;
|
||||||
|
|
||||||
$jsonobj = json_decode($jsonstdoutvnstat[0], true)['interfaces'][0];
|
$jsonobj = json_decode($jsonstdoutvnstat[0], true)['interfaces'][0];
|
||||||
$jsonData = $jsonobj['traffic']['hour'];
|
$jsonData = $jsonobj['traffic']['hour'];
|
||||||
for ($i = count($jsonData) - 1; $i >= 0 && $i >= count($jsonData)-25; --$i) {
|
for ($i = count($jsonData) - 1; $i >= 0 && $i >= count($jsonData)-25; --$i) {
|
||||||
$data_template[$jsonData[$i]['time']['hour']]['rx'] = round($jsonData[$i]['rx'] / 1024, 0);
|
$data_template[$jsonData[$i]['time']['hour']]['rx'] = round($jsonData[$i]['rx'] / $dsu_factor, 0);
|
||||||
$data_template[$jsonData[$i]['time']['hour']]['tx'] = round($jsonData[$i]['tx'] / 1024, 0);
|
$data_template[$jsonData[$i]['time']['hour']]['tx'] = round($jsonData[$i]['tx'] / $dsu_factor, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
Loading…
Reference in New Issue
Block a user