From 5a4d3d420f9d152dddd0021094ebb4fd1a49e5ea Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Fri, 3 Dec 2021 20:20:40 +0300 Subject: [PATCH] Fix potential problem with some absent HTTP request headers --- src/mibew/libs/chat.php | 6 ++++-- src/mibew/libs/pagination.php | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index c24af18d..6431c139 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -609,9 +609,11 @@ function visitor_from_request() */ function get_remote_host() { - $ext_addr = $_SERVER['REMOTE_ADDR']; + $ext_addr = isset($_SERVER['REMOTE_ADDR']) + ? $_SERVER['REMOTE_ADDR'] + : ''; $has_proxy = isset($_SERVER['HTTP_X_FORWARDED_FOR']) - && $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']; + && $_SERVER['HTTP_X_FORWARDED_FOR'] != $ext_addr; if ($has_proxy) { $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'], 2); $ext_addr = (count($ips) > 1) diff --git a/src/mibew/libs/pagination.php b/src/mibew/libs/pagination.php index 6625421b..4f81277d 100644 --- a/src/mibew/libs/pagination.php +++ b/src/mibew/libs/pagination.php @@ -36,7 +36,9 @@ */ function generate_pagination_link($page, $title) { - $lnk = $_SERVER['REQUEST_URI']; + $lnk = isset($_SERVER['REQUEST_URI']) + ? $_SERVER['REQUEST_URI'] + : ''; $href = preg_replace("/\?page=\d+\&/", "?", preg_replace("/\&page=\d+/", "", $lnk)); $href .= strstr($href, "?") ? "&page=$page" : "?page=$page";