" . $user['login'] . " "; print WEB_report_traffic_for_ip." ".$auth['ip'].""; ?>
>

getAttribute(PDO::ATTR_DRIVER_NAME); // === 2. Выбираем формат даты для каждой СУБД === if ($days_shift <= 1) { $mysql_format = '%Y-%m-%d %H'; $pg_format = 'YYYY-MM-DD HH24'; } elseif ($days_shift <= 30) { $mysql_format = '%Y-%m-%d'; $pg_format = 'YYYY-MM-DD'; } elseif ($days_shift <= 730) { $mysql_format = '%Y-%m'; $pg_format = 'YYYY-MM'; } else { $mysql_format = '%Y'; $pg_format = 'YYYY'; } // === 3. Базовые параметры (все значения — через параметры!) === $params = [$date1, $date2, (int)$id]; // === 4. Дополнительное условие по router_id (если нужно) === $router_condition = ''; if (!empty($rgateway) && $rgateway > 0) { $router_condition = ' AND router_id = ?'; $params[] = (int)$rgateway; } // === 5. Формируем запрос в зависимости от СУБД === if ($db_type === 'mysql') { $sSQL = " SELECT router_id, DATE_FORMAT(ts, '$mysql_format') AS tHour, SUM(byte_in) AS byte_in_sum, SUM(byte_out) AS byte_out_sum, MAX(ROUND(pkt_in / step)) AS pkt_in_max, MAX(ROUND(pkt_out / step)) AS pkt_out_max FROM user_stats_full WHERE ts >= ? AND ts < ? AND auth_id = ?$router_condition GROUP BY DATE_FORMAT(ts, '$mysql_format'), router_id ORDER BY tHour" . ($rgateway > 0 ? '' : ', router_id'); } elseif ($db_type === 'pgsql') { $sSQL = " SELECT router_id, TO_CHAR(ts, '$pg_format') AS tHour, SUM(byte_in) AS byte_in_sum, SUM(byte_out) AS byte_out_sum, MAX(ROUND(pkt_in / step)) AS pkt_in_max, MAX(ROUND(pkt_out / step)) AS pkt_out_max FROM user_stats_full WHERE ts >= ? AND ts < ? AND auth_id = ?$router_condition GROUP BY TO_CHAR(ts, '$pg_format'), router_id ORDER BY tHour" . ($rgateway > 0 ? '' : ', router_id'); } else { throw new RuntimeException("Unsupported database driver: $db_type"); } // === 6. Выполняем запрос === $userdata = get_records_sql($db_link, $sSQL, $params); $sum_in = 0; $sum_out = 0; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach ($userdata as $row) { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $sum_in += $row['byte_in_sum']; $sum_out += $row['byte_out_sum']; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; ?>
".$auth['description']."TOP 10".WEB_report_detail."
" . $gateway_list[$row['router_id']] . "" . $row['tHour'] . "" . fbytes($row['byte_in_sum']) . "" . fbytes($row['byte_out_sum']) . "" . fpkts($row['pkt_in_max']) . "" . fpkts($row['pkt_out_max']) . "
" . WEB_title_itog . " " . fbytes($sum_in) . "" . fbytes($sum_out) . "