diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/errorhandler.php | 14 | ||||
-rw-r--r-- | include/functions.php | 21 | ||||
-rwxr-xr-x | include/sanity_check.php | 8 |
3 files changed, 27 insertions, 16 deletions
diff --git a/include/errorhandler.php b/include/errorhandler.php index 188c8c5ce..16afcabcf 100644 --- a/include/errorhandler.php +++ b/include/errorhandler.php @@ -10,10 +10,12 @@ function format_backtrace($trace) { if (is_array($e["args"])) { foreach ($e["args"] as $a) { - if (!is_object($a)) { - array_push($fmt_args, $a); - } else { + if (is_object($a)) { array_push($fmt_args, "[" . get_class($a) . "]"); + } else if (is_array($a)) { + array_push($fmt_args, "[" . truncate_string(json_encode($a), 128, "...")) . "]"; + } else { + array_push($fmt_args, $a); } } } @@ -21,7 +23,11 @@ function format_backtrace($trace) { $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]); $rv .= sprintf("%d. %s(%s): %s(%s)\n", - $idx, $filename, $e["line"], $e["function"], implode(", ", $fmt_args)); + $idx, + $filename, + $e["line"], + $e["function"], + implode(", ", $fmt_args)); $idx++; } diff --git a/include/functions.php b/include/functions.php index 41d6e5853..0ec0ba30b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -138,7 +138,11 @@ function startup_gettext() { # Get locale from Accept-Language header - $lang = al2gt(array_keys(get_translations()), "text/html"); + if (version_compare(PHP_VERSION, '8.0.0', '<')) { + $lang = al2gt(array_keys(get_translations()), "text/html"); + } else { + $lang = ""; // FIXME: do something with accept-to-gettext.php + } if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) { $lang = _TRANSLATION_OVERRIDE_DEFAULT; @@ -222,13 +226,13 @@ /* end compat shims */ function get_ssl_certificate_id() { - if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) { + if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] ?? false) { return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] . $_SERVER["REDIRECT_SSL_CLIENT_V_START"] . $_SERVER["REDIRECT_SSL_CLIENT_V_END"] . $_SERVER["REDIRECT_SSL_CLIENT_S_DN"]); } - if ($_SERVER["SSL_CLIENT_M_SERIAL"]) { + if ($_SERVER["SSL_CLIENT_M_SERIAL"] ?? false) { return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] . $_SERVER["SSL_CLIENT_V_START"] . $_SERVER["SSL_CLIENT_V_END"] . @@ -240,11 +244,11 @@ // this is used for user http parameters unless HTML code is actually needed function clean($param) { if (is_array($param)) { - return array_map("strip_tags", $param); + return trim(array_map("strip_tags", $param)); } else if (is_string($param)) { - return strip_tags($param); + return trim(strip_tags($param)); } else { - return $param; + return trim($param); } } @@ -407,7 +411,8 @@ } function is_server_https() { - return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'; + return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || + (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); } function is_prefix_https() { @@ -577,7 +582,7 @@ if (is_array($ttrss_version) && isset($ttrss_version['version'])) { $git_commit = $ttrss_version['commit']; $git_timestamp = $ttrss_version['timestamp']; - $last_error = $ttrss_version['last_error']; + $last_error = $ttrss_version['last_error'] ?? ""; return $ttrss_version['version']; } else { diff --git a/include/sanity_check.php b/include/sanity_check.php index e6c0e5d4b..fddc26295 100755 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -70,8 +70,8 @@ array_push($errors, "Please don't run this script as root."); } - if (version_compare(PHP_VERSION, '5.6.0', '<')) { - array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); + if (version_compare(PHP_VERSION, '7.0.0', '<')) { + array_push($errors, "PHP version 7.0.0 or newer required. You're using " . PHP_VERSION . "."); } if (!class_exists("UConverter")) { @@ -125,14 +125,14 @@ if (SELF_URL_PATH == "http://example.org/tt-rss/") { $hint = $ref_self_url_path ? "(possible value: <b>$ref_self_url_path</b>)" : ""; array_push($errors, - "Please set SELF_URL_PATH to the correct value for your server $hint"); + "Please set SELF_URL_PATH to the correct value for your server: $hint"); } if ($ref_self_url_path && (!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) && SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) { array_push($errors, - "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>"); + "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b> (you're using: <b>" . SELF_URL_PATH . "</b>)"); } if (!is_writable(ICONS_DIR)) { |