diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/errorhandler.php | 8 | ||||
-rw-r--r-- | include/functions.php | 24 | ||||
-rwxr-xr-x | include/login_form.php | 4 | ||||
-rwxr-xr-x | include/sanity_check.php | 12 | ||||
-rw-r--r-- | include/sanity_config.php | 4 |
5 files changed, 37 insertions, 15 deletions
diff --git a/include/errorhandler.php b/include/errorhandler.php index 95c9edc69..188c8c5ce 100644 --- a/include/errorhandler.php +++ b/include/errorhandler.php @@ -31,7 +31,13 @@ function format_backtrace($trace) { return $rv; } -function ttrss_error_handler($errno, $errstr, $file, $line, $context) { +function ttrss_error_handler($errno, $errstr, $file, $line) { + if (version_compare(PHP_VERSION, '8.0.0', '<')) { + if (error_reporting() == 0 || !$errno) return false; + } else { + if (!(error_reporting() & $errno)) return false; + } + if (error_reporting() == 0 || !$errno) return false; $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); diff --git a/include/functions.php b/include/functions.php index 538239218..41d6e5853 100644 --- a/include/functions.php +++ b/include/functions.php @@ -7,6 +7,10 @@ define('COOKIE_LIFETIME_LONG', 86400*365); + // this CSS file is included for everyone (if it exists in themes.local) + // on login, registration, and main (index and prefs) pages + define('LOCAL_OVERRIDE_STYLESHEET', '.local-overrides.css'); + $fetch_last_error = false; $fetch_last_error_code = false; $fetch_last_content_type = false; @@ -14,7 +18,10 @@ $fetch_effective_url = false; $fetch_curl_used = false; - libxml_disable_entity_loader(true); + if (version_compare(PHP_VERSION, '8.0.0', '<')) { + libxml_disable_entity_loader(true); + } + libxml_use_internal_errors(true); // separate test because this is included before sanity checks @@ -323,7 +330,7 @@ function sanity_check() { require_once 'errors.php'; - global $ERRORS; + $ERRORS = get_error_types(); $error_code = 0; $schema_version = get_schema_version(true); @@ -389,17 +396,16 @@ return uniqid(base_convert(rand(), 10, 36)); } - function trim_array($array) { - $tmp = $array; - array_walk($tmp, 'trim'); - return $tmp; - } - function T_sprintf() { $args = func_get_args(); return vsprintf(__(array_shift($args)), $args); } + function T_nsprintf() { + $args = func_get_args(); + return vsprintf(_ngettext(array_shift($args), array_shift($args), array_shift($args)), $args); + } + function is_server_https() { return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'; } @@ -536,7 +542,7 @@ */ function error_json($code) { require_once "errors.php"; - global $ERRORS; + $ERRORS = get_error_types(); @$message = $ERRORS[$code]; diff --git a/include/login_form.php b/include/login_form.php index d2688d0ec..586d6fe78 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -18,6 +18,10 @@ } ?> + <?php if (theme_exists(LOCAL_OVERRIDE_STYLESHEET)) { + echo stylesheet_tag(get_theme_path(LOCAL_OVERRIDE_STYLESHEET)); + } ?> + <style type="text/css"> @media (prefers-color-scheme: dark) { body { diff --git a/include/sanity_check.php b/include/sanity_check.php index 86dc7a5f0..e6c0e5d4b 100755 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -21,6 +21,8 @@ } function make_self_url_path() { + if (!isset($_SERVER["HTTP_HOST"])) return false; + $proto = is_server_https() ? 'https' : 'http'; $url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); @@ -115,14 +117,18 @@ } $ref_self_url_path = make_self_url_path(); - $ref_self_url_path = preg_replace("/\w+\.php$/", "", $ref_self_url_path); + + if ($ref_self_url_path) { + $ref_self_url_path = preg_replace("/\w+\.php$/", "", $ref_self_url_path); + } 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 (possible value: <b>$ref_self_url_path</b>)"); + "Please set SELF_URL_PATH to the correct value for your server $hint"); } - if (isset($_SERVER["HTTP_HOST"]) && + 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, diff --git a/include/sanity_config.php b/include/sanity_config.php index 49080e212..e13eb2cd0 100644 --- a/include/sanity_config.php +++ b/include/sanity_config.php @@ -1,3 +1,3 @@ -<?php # This file has been generated at: Thu Nov 22 22:14:43 MSK 2018 +<?php # This file has been generated at: Fri Dec 11 09:30:20 MSK 2020 define('GENERATED_CONFIG_CHECK', 26); -$required_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?> +$required_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?> |