Browse Source

fix overwrite issues

The $jsonobj array is iterated from the back, so the first entries overwrite the newest entries (that is, the ones from the back). So it happens that instead of the traffic for today 16 o'clock ,the traffic from the day before yesterday 16 o'clock ends up in the array $data_template and is displayed in the graph. But this should not be like this!
pull/1158/head
Lukas 8 months ago
committed by GitHub
parent
commit
b5b2e81d3b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ajax/bandwidth/get_bandwidth_hourly.php

2
ajax/bandwidth/get_bandwidth_hourly.php

@ -41,7 +41,7 @@ if (filter_input(INPUT_GET, 'tu') == 'h') {
$jsonobj = json_decode($jsonstdoutvnstat[0], true)['interfaces'][0];
$jsonData = $jsonobj['traffic']['hour'];
for ($i = count($jsonData) - 1; $i >= 0; --$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']]['tx'] = round($jsonData[$i]['tx'] / 1024, 0);
}

Loading…
Cancel
Save