".WEB_log_detail_for." $fip :: "); ?>
> DNS:  >
= ?", "ts < ?", "auth_id = ?"]; // Фильтр по gateway if (!empty($rgateway) && $rgateway > 0) { $conditions[] = "router_id = ?"; $params[] = (int)$rgateway; } // Фильтр по IP (если search — валидный IPv4) if (!empty($search) && filter_var($search, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $ip_long = sprintf('%u', ip2long($search)); // беззнаковое число $conditions[] = "(src_ip = ? OR dst_ip = ?)"; $params[] = $ip_long; $params[] = $ip_long; } $whereClause = implode(' AND ', $conditions); // === 2. Подсчёт записей === $countSQL = "SELECT COUNT(*) FROM traffic_detail WHERE $whereClause"; $count_records = (int)get_single_field($db_link, $countSQL, $params); // === 3. Пагинация === $total = ceil($count_records / $displayed); $page = max(1, min($page, $total)); $start = ($page - 1) * $displayed; print_navigation($page_url, $page, $displayed, $count_records, $total); // === 4. Безопасная сортировка (БЕЛЫЙ СПИСОК!) === $allowed_sort_fields = ['ts', 'proto', 'src_ip', 'dst_ip', 'bytes', 'pkt']; $allowed_order = ['ASC', 'DESC']; $sort_field = in_array($sort_field, $allowed_sort_fields, true) ? $sort_field : 'ts'; $order = in_array(strtoupper($order), $allowed_order, true) ? strtoupper($order) : 'ASC'; // === 5. Запрос данных с пагинацией === $limit = (int)$displayed; $offset = (int)$start; $dataParams = array_merge($params, [$limit, $offset]); // Используем прямой запрос (без подзапроса — он не нужен для пагинации по id) $fsql = " SELECT id, ts, router_id, proto, src_ip, src_port, dst_ip, dst_port, bytes, pkt FROM traffic_detail WHERE $whereClause ORDER BY $sort_field $order LIMIT ? OFFSET ? "; $userdata = get_records_sql($db_link, $fsql, $dataParams); ?>
\n"; print "\n"; print "\n"; $proto_name = getprotobynumber($row['proto']); if (!$proto_name) { $proto_name = $row['proto']; } print "\n"; print "\n"; $ip_name = '-'; if ($rdns) { $ip_name = ResolveIP($db_link, $row['src_ip']); } print "\n"; print "\n"; print "\n"; $ip_name = '-'; if ($rdns) { $ip_name = ResolveIP($db_link, $row['dst_ip']); } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } ?>
".WEB_date.""; print $url; ?> ".WEB_traffic_source_address.""; print $url; ?> DNS ".WEB_traffic_dest_address.""; print $url; ?> DNS ".WEB_bytes.""; print $url; ?> ".WEB_pkts.""; print $url; ?>
" . $row['ts'] . "" . $gateway_list[$row['router_id']] . "" . $proto_name . "" . long2ip($row['src_ip']) . "" . $ip_name . "" . $row['src_port'] . "" . long2ip($row['dst_ip']) . "" . $ip_name . "" . $row['dst_port'] . "" . fbytes($row['bytes']) . "" . $row['pkt'] . "