From f2d3cba2316a39e3d27e2e93e52562e72e7bd99d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:20:04 +0300 Subject: add HTTP_ACCEPT_LANGUAGE handling for php8 --- include/functions.php | 78 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index f870f3382..6362adbbe 100644 --- a/include/functions.php +++ b/include/functions.php @@ -91,14 +91,8 @@ define('SUBSTRING_FOR_DATE', 'SUBSTRING'); } - /** - * Return available translations names. - * - * @access public - * @return array A array of available translations. - */ function get_translations() { - $tr = array( + $t = array( "auto" => __("Detect automatically"), "ar_SA" => "العربيّة (Arabic)", "bg_BG" => "Bulgarian", @@ -129,38 +123,76 @@ "fi_FI" => "Suomi", "tr_TR" => "Türkçe"); - return $tr; + return $t; } - require_once "lib/accept-to-gettext.php"; require_once "lib/gettext/gettext.inc.php"; function startup_gettext() { - # Get locale from Accept-Language header - 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 - } + $selected_locale = ""; + + // https://www.codingwithjesse.com/blog/use-accept-language-header/ + if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $valid_langs = []; + $translations = array_keys(get_translations()); + + array_shift($translations); // remove "auto" + + // full locale first + foreach ($translations as $t) { + $lang = strtolower(str_replace("_", "-", (string)$t)); + $valid_langs[$lang] = $t; + + $lang = substr($lang, 0, 2); + if (!isset($valid_langs[$lang])) + $valid_langs[$lang] = $t; + } - if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) { - $lang = _TRANSLATION_OVERRIDE_DEFAULT; + // break up string into pieces (languages and q factors) + preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', + $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); + + if (count($lang_parse[1])) { + // create a list like "en" => 0.8 + $langs = array_combine($lang_parse[1], $lang_parse[4]); + + if (is_array($langs)) { + // set default to 1 for any without q factor + foreach ($langs as $lang => $val) { + if ($val === '') $langs[$lang] = 1; + } + + // sort list based on value + arsort($langs, SORT_NUMERIC); + + foreach (array_keys($langs) as $lang) { + $lang = strtolower($lang); + + foreach ($valid_langs as $vlang => $vlocale) { + if ($vlang == $lang) { + $selected_locale = $vlocale; + break 2; + } + } + } + } + } } if (!empty($_SESSION["uid"]) && get_schema_version() >= 120) { - $pref_lang = get_pref("USER_LANGUAGE", $_SESSION["uid"]); + $pref_locale = get_pref("USER_LANGUAGE", $_SESSION["uid"]); - if ($pref_lang && $pref_lang != 'auto') { - $lang = $pref_lang; + if (!empty($pref_locale) && $pref_locale != 'auto') { + $selected_locale = $pref_locale; } } - if ($lang) { + if ($selected_locale) { if (defined('LC_MESSAGES')) { - _setlocale(LC_MESSAGES, $lang); + _setlocale(LC_MESSAGES, $selected_locale); } else if (defined('LC_ALL')) { - _setlocale(LC_ALL, $lang); + _setlocale(LC_ALL, $selected_locale); } _bindtextdomain("messages", "locale"); -- cgit v1.2.3 From 119a4226d812918733a815a896cfed8380188c15 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:21:23 +0300 Subject: validate_csrf: remove warning --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 6362adbbe..eaf7d8243 100644 --- a/include/functions.php +++ b/include/functions.php @@ -310,7 +310,7 @@ } function validate_csrf($csrf_token) { - return isset($csrf_token) && hash_equals($_SESSION['csrf_token'], $csrf_token); + return isset($csrf_token) && hash_equals($_SESSION['csrf_token'] ?? "", $csrf_token); } function truncate_string($str, $max_len, $suffix = '…') { -- cgit v1.2.3 From 020f062a76746a313fae9c82fbcf9b37fcc9d459 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 15:43:07 +0300 Subject: feeds: unify naming --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index eaf7d8243..4557c0411 100644 --- a/include/functions.php +++ b/include/functions.php @@ -217,7 +217,7 @@ // @deprecated function getFeedUnread($feed, $is_cat = false) { - return Feeds::getFeedArticles($feed, $is_cat, true, $_SESSION["uid"]); + return Feeds::_get_counters($feed, $is_cat, true, $_SESSION["uid"]); } // @deprecated -- cgit v1.2.3 From 26d6b84a572b5cbd99acffc5ae727ea6d1be543a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:23:00 +0300 Subject: add namespaced controls with unified naming; deprecated old-style control shortcuts --- include/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 4557c0411..174ef39f0 100644 --- a/include/functions.php +++ b/include/functions.php @@ -203,6 +203,7 @@ require_once 'db-prefs.php'; require_once 'controls.php'; + require_once 'controls_compat.php'; define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)'); ini_set('user_agent', SELF_USER_AGENT); -- cgit v1.2.3 From 02a9485966dbbac1ed52ecbfb29fcc15125cba43 Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 21 Feb 2021 23:30:31 +0000 Subject: Try to limit max favicon size, don't store current/old in a var. --- include/functions.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 174ef39f0..df8730aca 100644 --- a/include/functions.php +++ b/include/functions.php @@ -68,6 +68,8 @@ // do not cache files larger than that (bytes) define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); // do not download general files larger than that (bytes) + define_default('MAX_FAVICON_FILE_SIZE', 1*1024*1024); + // do not download favicon files larger than that (bytes) define_default('CACHE_MAX_DAYS', 7); // max age in days for various automatically cached (temporary) files define_default('MAX_CONDITIONAL_INTERVAL', 3600*12); -- cgit v1.2.3 From be4e7b13403666fc477d4b563ea8c075d0fd2022 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 14:41:09 +0300 Subject: fix several issues reported by phpstan --- include/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 174ef39f0..bf9b374a2 100644 --- a/include/functions.php +++ b/include/functions.php @@ -34,8 +34,8 @@ error_reporting(E_ALL & ~E_NOTICE); } - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); + ini_set('display_errors', "false"); + ini_set('display_startup_errors', "false"); require_once 'config.php'; @@ -281,7 +281,7 @@ } else if (is_string($param)) { return trim(strip_tags($param)); } else { - return trim($param); + return $param; } } @@ -430,7 +430,7 @@ } function uniqid_short() { - return uniqid(base_convert(rand(), 10, 36)); + return uniqid(base_convert((string)rand(), 10, 36)); } function T_sprintf() { -- cgit v1.2.3 From add6242e5148d29be506d753ca4123b900427b7f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 17:35:52 +0300 Subject: do not use define_default() because it screws with static analyzers --- include/functions.php | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 21459da9c..1f25f6947 100644 --- a/include/functions.php +++ b/include/functions.php @@ -39,49 +39,42 @@ require_once 'config.php'; - /** - * Define a constant if not already defined - */ - function define_default($name, $value) { - defined($name) or define($name, $value); - } - /* Some tunables you can override in config.php using define(): */ - define_default('FEED_FETCH_TIMEOUT', 45); + if (!defined('FEED_FETCH_TIMEOUT')) define('FEED_FETCH_TIMEOUT', 45); // How may seconds to wait for response when requesting feed from a site - define_default('FEED_FETCH_NO_CACHE_TIMEOUT', 15); + if (!defined('FEED_FETCH_NO_CACHE_TIMEOUT')) define('FEED_FETCH_NO_CACHE_TIMEOUT', 15); // How may seconds to wait for response when requesting feed from a // site when that feed wasn't cached before - define_default('FILE_FETCH_TIMEOUT', 45); + if (!defined('FILE_FETCH_TIMEOUT')) define('FILE_FETCH_TIMEOUT', 45); // Default timeout when fetching files from remote sites - define_default('FILE_FETCH_CONNECT_TIMEOUT', 15); + if (!defined('FILE_FETCH_CONNECT_TIMEOUT')) define('FILE_FETCH_CONNECT_TIMEOUT', 15); // How many seconds to wait for initial response from website when // fetching files from remote sites - define_default('DAEMON_UPDATE_LOGIN_LIMIT', 30); + if (!defined('DAEMON_UPDATE_LOGIN_LIMIT')) define('DAEMON_UPDATE_LOGIN_LIMIT', 30); // stop updating feeds if users haven't logged in for X days - define_default('DAEMON_FEED_LIMIT', 500); + if (!defined('DAEMON_FEED_LIMIT')) define('DAEMON_FEED_LIMIT', 500); // feed limit for one update batch - define_default('DAEMON_SLEEP_INTERVAL', 120); + if (!defined('DAEMON_SLEEP_INTERVAL')) define('DAEMON_SLEEP_INTERVAL', 120); // default sleep interval between feed updates (sec) - define_default('MAX_CACHE_FILE_SIZE', 64*1024*1024); + if (!defined('MAX_CACHE_FILE_SIZE')) define('MAX_CACHE_FILE_SIZE', 64*1024*1024); // do not cache files larger than that (bytes) - define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); + if (!defined('MAX_DOWNLOAD_FILE_SIZE')) define('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); // do not download general files larger than that (bytes) - define_default('MAX_FAVICON_FILE_SIZE', 1*1024*1024); + if (!defined('MAX_FAVICON_FILE_SIZE')) define('MAX_FAVICON_FILE_SIZE', 1*1024*1024); // do not download favicon files larger than that (bytes) - define_default('CACHE_MAX_DAYS', 7); + if (!defined('CACHE_MAX_DAYS')) define('CACHE_MAX_DAYS', 7); // max age in days for various automatically cached (temporary) files - define_default('MAX_CONDITIONAL_INTERVAL', 3600*12); + if (!defined('MAX_CONDITIONAL_INTERVAL')) define('MAX_CONDITIONAL_INTERVAL', 3600*12); // max interval between forced unconditional updates for servers // not complying with http if-modified-since (seconds) - // define_default('MAX_FETCH_REQUESTS_PER_HOST', 25); + // if (!defined('MAX_FETCH_REQUESTS_PER_HOST')) define('MAX_FETCH_REQUESTS_PER_HOST', 25); // a maximum amount of allowed HTTP requests per destination host // during a single update (i.e. within PHP process lifetime) // this is used to not cause excessive load on the origin server on // e.g. feed subscription when all articles are being processes // (not implemented) - define_default('DAEMON_UNSUCCESSFUL_DAYS_LIMIT', 30); + if (!defined('DAEMON_UNSUCCESSFUL_DAYS_LIMIT')) define('DAEMON_UNSUCCESSFUL_DAYS_LIMIT', 30); // automatically disable updates for feeds which failed to // update for this amount of days; 0 disables -- cgit v1.2.3 From 42173386b39bed4b06c5ac6c2fc0da510673b354 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 17:38:46 +0300 Subject: dirname(__FILE__) -> __DIR__ --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 1f25f6947..7c4e32963 100644 --- a/include/functions.php +++ b/include/functions.php @@ -620,7 +620,7 @@ $ttrss_version['version'] = "UNKNOWN (Unsupported)"; date_default_timezone_set('UTC'); - $root_dir = dirname(dirname(__FILE__)); + $root_dir = dirname(__DIR__); if (PHP_OS === "Darwin") { $ttrss_version['version'] = "UNKNOWN (Unsupported, Darwin)"; -- cgit v1.2.3 From e4107ac9520ca404d4ab49ef79ca74430e8fd772 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 21:47:48 +0300 Subject: wip: initial for config object --- include/functions.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 7c4e32963..526c6058a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -80,7 +80,9 @@ /* tunables end here */ - if (DB_TYPE == "pgsql") { + require_once "autoload.php"; + + if (Config::get(Config::DB_TYPE) == "pgsql") { define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE'); } else { define('SUBSTRING_FOR_DATE', 'SUBSTRING'); @@ -375,9 +377,9 @@ } function file_is_locked($filename) { - if (file_exists(LOCK_DIRECTORY . "/$filename")) { + if (file_exists(Config::get(Config::LOCK_DIRECTORY) . "/$filename")) { if (function_exists('flock')) { - $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r"); + $fp = @fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "r"); if ($fp) { if (flock($fp, LOCK_EX | LOCK_NB)) { flock($fp, LOCK_UN); @@ -397,11 +399,11 @@ } function make_lockfile($filename) { - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); + $fp = fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "w"); if ($fp && flock($fp, LOCK_EX | LOCK_NB)) { $stat_h = fstat($fp); - $stat_f = stat(LOCK_DIRECTORY . "/$filename"); + $stat_f = stat(Config::get(Config::LOCK_DIRECTORY) . "/$filename"); if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { if ($stat_h["ino"] != $stat_f["ino"] || @@ -444,15 +446,15 @@ } function is_prefix_https() { - return parse_url(SELF_URL_PATH, PHP_URL_SCHEME) == 'https'; + return parse_url(Config::get(Config::SELF_URL_PATH), PHP_URL_SCHEME) == 'https'; } - // this returns SELF_URL_PATH sans ending slash + // this returns Config::get(Config::SELF_URL_PATH) sans ending slash function get_self_url_prefix() { - if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH)-1) { - return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH)-1); + if (strrpos(Config::get(Config::SELF_URL_PATH), "/") === strlen(Config::get(Config::SELF_URL_PATH))-1) { + return substr(Config::get(Config::SELF_URL_PATH), 0, strlen(Config::get(Config::SELF_URL_PATH))-1); } else { - return SELF_URL_PATH; + return Config::get(Config::SELF_URL_PATH); } } @@ -467,7 +469,7 @@ } // function encrypt_password function init_plugins() { - PluginHost::getInstance()->load(PLUGINS, PluginHost::KIND_ALL); + PluginHost::getInstance()->load(Config::get(Config::PLUGINS), PluginHost::KIND_ALL); return true; } -- cgit v1.2.3 From 211f699aa0c4211e4ee8a02446d51b9811d0c28c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 22:35:27 +0300 Subject: migrate the rest into Config:: --- include/functions.php | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 526c6058a..59c824e43 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5,12 +5,6 @@ define('LABEL_BASE_INDEX', -1024); define('PLUGIN_FEED_BASE_INDEX', -128); - 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; @@ -37,49 +31,7 @@ ini_set('display_errors', "false"); ini_set('display_startup_errors', "false"); - require_once 'config.php'; - - /* Some tunables you can override in config.php using define(): */ - - if (!defined('FEED_FETCH_TIMEOUT')) define('FEED_FETCH_TIMEOUT', 45); - // How may seconds to wait for response when requesting feed from a site - if (!defined('FEED_FETCH_NO_CACHE_TIMEOUT')) define('FEED_FETCH_NO_CACHE_TIMEOUT', 15); - // How may seconds to wait for response when requesting feed from a - // site when that feed wasn't cached before - if (!defined('FILE_FETCH_TIMEOUT')) define('FILE_FETCH_TIMEOUT', 45); - // Default timeout when fetching files from remote sites - if (!defined('FILE_FETCH_CONNECT_TIMEOUT')) define('FILE_FETCH_CONNECT_TIMEOUT', 15); - // How many seconds to wait for initial response from website when - // fetching files from remote sites - if (!defined('DAEMON_UPDATE_LOGIN_LIMIT')) define('DAEMON_UPDATE_LOGIN_LIMIT', 30); - // stop updating feeds if users haven't logged in for X days - if (!defined('DAEMON_FEED_LIMIT')) define('DAEMON_FEED_LIMIT', 500); - // feed limit for one update batch - if (!defined('DAEMON_SLEEP_INTERVAL')) define('DAEMON_SLEEP_INTERVAL', 120); - // default sleep interval between feed updates (sec) - if (!defined('MAX_CACHE_FILE_SIZE')) define('MAX_CACHE_FILE_SIZE', 64*1024*1024); - // do not cache files larger than that (bytes) - if (!defined('MAX_DOWNLOAD_FILE_SIZE')) define('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); - // do not download general files larger than that (bytes) - if (!defined('MAX_FAVICON_FILE_SIZE')) define('MAX_FAVICON_FILE_SIZE', 1*1024*1024); - // do not download favicon files larger than that (bytes) - if (!defined('CACHE_MAX_DAYS')) define('CACHE_MAX_DAYS', 7); - // max age in days for various automatically cached (temporary) files - if (!defined('MAX_CONDITIONAL_INTERVAL')) define('MAX_CONDITIONAL_INTERVAL', 3600*12); - // max interval between forced unconditional updates for servers - // not complying with http if-modified-since (seconds) - // if (!defined('MAX_FETCH_REQUESTS_PER_HOST')) define('MAX_FETCH_REQUESTS_PER_HOST', 25); - // a maximum amount of allowed HTTP requests per destination host - // during a single update (i.e. within PHP process lifetime) - // this is used to not cause excessive load on the origin server on - // e.g. feed subscription when all articles are being processes - // (not implemented) - if (!defined('DAEMON_UNSUCCESSFUL_DAYS_LIMIT')) define('DAEMON_UNSUCCESSFUL_DAYS_LIMIT', 30); - // automatically disable updates for feeds which failed to - // update for this amount of days; 0 disables - - /* tunables end here */ - + require_once "config.php"; require_once "autoload.php"; if (Config::get(Config::DB_TYPE) == "pgsql") { -- cgit v1.2.3 From 12bcf826e4f2672afbda85264a970fb4735d97f1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 22:39:20 +0300 Subject: don't include config.php everywhere --- include/functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 59c824e43..d42306147 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,5 +1,4 @@ Date: Mon, 22 Feb 2021 22:51:12 +0300 Subject: finalize config:: migration; make config.php optional --- include/functions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index d42306147..172ba169d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -30,7 +30,10 @@ ini_set('display_errors', "false"); ini_set('display_startup_errors', "false"); - require_once "config.php"; + // config.php is optional + if (stream_resolve_include_path("config.php")) + require_once "config.php"; + require_once "autoload.php"; if (Config::get(Config::DB_TYPE) == "pgsql") { -- cgit v1.2.3 From 29ada58b4ac06178c908869e0bb078949e1cb465 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 23:25:14 +0300 Subject: move db-prefs shortcut functions to functions.php --- include/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index 172ba169d..a698fa79d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -42,6 +42,14 @@ define('SUBSTRING_FOR_DATE', 'SUBSTRING'); } + function get_pref($pref_name, $user_id = false, $die_on_error = false) { + return Db_Prefs::get()->read($pref_name, $user_id, $die_on_error); + } + + function set_pref($pref_name, $value, $user_id = false, $strip_tags = true) { + return Db_Prefs::get()->write($pref_name, $value, $user_id, $strip_tags); + } + function get_translations() { $t = array( "auto" => __("Detect automatically"), @@ -152,7 +160,6 @@ } } - require_once 'db-prefs.php'; require_once 'controls.php'; require_once 'controls_compat.php'; -- cgit v1.2.3 From 8d2e3c2528e67f8650c122f014364a34bf690d2a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 22:26:07 +0300 Subject: drop errors.php and simplify error handling --- include/functions.php | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index a698fa79d..d916301fb 100644 --- a/include/functions.php +++ b/include/functions.php @@ -323,20 +323,6 @@ } } - function sanity_check() { - require_once 'errors.php'; - $ERRORS = get_error_types(); - - $error_code = 0; - $schema_version = get_schema_version(true); - - if ($schema_version != SCHEMA_VERSION) { - $error_code = 5; - } - - return array("code" => $error_code, "message" => $ERRORS[$error_code]); - } - function file_is_locked($filename) { if (file_exists(Config::get(Config::LOCK_DIRECTORY) . "/$filename")) { if (function_exists('flock')) { @@ -533,20 +519,6 @@ return file_exists("themes/$theme") || file_exists("themes.local/$theme"); } - /** - * @SuppressWarnings(unused) - */ - function error_json($code) { - require_once "errors.php"; - $ERRORS = get_error_types(); - - @$message = $ERRORS[$code]; - - return json_encode(array("error" => - array("code" => $code, "message" => $message))); - - } - function arr_qmarks($arr) { return str_repeat('?,', count($arr) - 1) . '?'; } -- cgit v1.2.3