Array // ( // [id] => 48032 // [date] => Array // ( // [year] => 2020 // [month] => 8 // [day] => 23 // ) // [time] => Array // ( // [hour] => 16 // [minute] => 0 // ) // [rx] => 2538730 // [tx] => 2175640 // ) // per-day data // FIXME: instead of using array_reverse, sorting by date/time keys would be more reliable $day_data = array_reverse($traffic_data['day']); for($i = 0; $i < min(30, count($day_data)); $i++) { $d = $day_data[$i]; $ts = mktime(0, 0, 0, $d['date']['month'], $d['date']['day'], $d['date']['year']); $day[$i]['time'] = $ts; $day[$i]['rx'] = $d['rx'] / 1024; $day[$i]['tx'] = $d['tx'] / 1024; $day[$i]['act'] = 1; if($use_label) { $day[$i]['label'] = strftime(T('datefmt_days'), $ts); $day[$i]['img_label'] = strftime(T('datefmt_days_img'), $ts); } } // per-month data $month_data = array_reverse($traffic_data['month']); for($i = 0; $i < min(12, count($month_data)); $i++) { $d = $month_data[$i]; $ts = mktime(0, 0, 0, $d['date']['month']+1, 0, $d['date']['year']); $month[$i]['time'] = $ts; $month[$i]['rx'] = $d['rx'] / 1024; $month[$i]['tx'] = $d['tx'] / 1024; $month[$i]['act'] = 1; if($use_label) { $month[$i]['label'] = strftime(T('datefmt_months'), $ts); $month[$i]['img_label'] = strftime(T('datefmt_months_img'), $ts); } } // per-hour data $hour_data = array_reverse($traffic_data['hour']); for($i = 0; $i < min(24, count($hour_data)); $i++) { $d = $hour_data[$i]; $ts = mktime($d['time']['hour'], $d['time']['minute'], 0, $d['date']['month'], $d['date']['day'], $d['date']['year']); $hour[$i]['time'] = $ts; $hour[$i]['rx'] = $d['rx'] / 1024; $hour[$i]['tx'] = $d['tx'] / 1024; $hour[$i]['act'] = 1; if($use_label) { $hour[$i]['label'] = strftime(T('datefmt_hours'), $ts); $hour[$i]['img_label'] = strftime(T('datefmt_hours_img'), $ts); } } // top10 days data $top10_data = $traffic_data['top']; for($i = 0; $i < min(10, count($top10_data)); $i++) { $d = $top10_data[$i]; $ts = mktime(0, 0, 0, $d['date']['month'], $d['date']['day'], $d['date']['year']); $top[$i]['time'] = $ts; $top[$i]['rx'] = $d['rx'] / 1024; $top[$i]['tx'] = $d['tx'] / 1024; $top[$i]['act'] = 1; if($use_label) { $top[$i]['label'] = strftime(T('datefmt_top'), $ts); $top[$i]['img_label'] = ''; } } // summary data from old dumpdb command // all time total received/transmitted MB $summary['totalrx'] = $traffic_data['total']['rx'] / 1024 / 1024; $summary['totaltx'] = $traffic_data['total']['tx'] / 1024 / 1024; // FIXME: used to be "total rx kB counter" from dumpdb, no idea how to get those $summary['totalrxk'] = 0; $summary['totaltxk'] = 0; $summary['interface'] = $iface_data['name']; } ?>