diff options
author | Andrew Dolgov <[email protected]> | 2021-02-24 21:56:52 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-24 21:56:52 +0300 |
commit | 93940d2a9f80d9e1dac49b5eb7db23230d31c5f6 (patch) | |
tree | 71016661f6017918d0934eb462bd9552018d557a /include/sanity_check.php | |
parent | 8b022c2bfb356d7dddaf334bc931d6dec77086fb (diff) | |
parent | 1adacd057230aea4ede29dab510385bf01cf99a3 (diff) |
Merge branch 'master' of git.fakecake.org:fox/tt-rss into weblate-integration
Diffstat (limited to 'include/sanity_check.php')
-rwxr-xr-x | include/sanity_check.php | 66 |
1 files changed, 20 insertions, 46 deletions
diff --git a/include/sanity_check.php b/include/sanity_check.php index c5ffb87ec..4831209ba 100755 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -21,7 +21,7 @@ $sth = $pdo->prepare("SELECT engine, table_name FROM information_schema.tables WHERE table_schema = ? AND table_name LIKE 'ttrss_%' AND engine != 'InnoDB'"); - $sth->execute([DB_NAME]); + $sth->execute([Config::get(Config::DB_NAME)]); $bad_tables = []; @@ -40,14 +40,12 @@ array_push($errors, "Configuration file not found. Looks like you forgot to copy config.php-dist to config.php and edit it."); } else { - require_once "sanity_config.php"; - if (!file_exists("config.php")) { array_push($errors, "Please copy config.php-dist to config.php"); } - if (strpos(PLUGINS, "auth_") === false) { - array_push($errors, "Please enable at least one authentication module via PLUGINS constant in config.php"); + if (strpos(Config::get(Config::PLUGINS), "auth_") === false) { + array_push($errors, "Please enable at least one authentication module via Config::get(Config::PLUGINS) constant in config.php"); } if (function_exists('posix_getuid') && posix_getuid() == 0) { @@ -62,41 +60,25 @@ array_push($errors, "PHP UConverter class is missing, it's provided by the Internationalization (intl) module."); } - if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { - array_push($errors, "Configuration file (config.php) has incorrect version. Update it with new options from config.php-dist and set CONFIG_VERSION to the correct value."); - } - - if (!is_writable(CACHE_DIR . "/images")) { - array_push($errors, "Image cache is not writable (chmod -R 777 ".CACHE_DIR."/images)"); + if (!is_writable(Config::get(Config::CACHE_DIR) . "/images")) { + array_push($errors, "Image cache is not writable (chmod -R 777 ".Config::get(Config::CACHE_DIR)."/images)"); } - if (!is_writable(CACHE_DIR . "/upload")) { - array_push($errors, "Upload cache is not writable (chmod -R 777 ".CACHE_DIR."/upload)"); + if (!is_writable(Config::get(Config::CACHE_DIR) . "/upload")) { + array_push($errors, "Upload cache is not writable (chmod -R 777 ".Config::get(Config::CACHE_DIR)."/upload)"); } - if (!is_writable(CACHE_DIR . "/export")) { - array_push($errors, "Data export cache is not writable (chmod -R 777 ".CACHE_DIR."/export)"); + if (!is_writable(Config::get(Config::CACHE_DIR) . "/export")) { + array_push($errors, "Data export cache is not writable (chmod -R 777 ".Config::get(Config::CACHE_DIR)."/export)"); } - if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) { - array_push($errors, - "Configuration option checker sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh"); - } - - foreach ($required_defines as $d) { - if (!defined($d)) { - array_push($errors, - "Required configuration file parameter $d is not defined in config.php. You might need to copy it from config.php-dist."); - } - } - - if (SINGLE_USER_MODE && class_exists("PDO")) { + if (Config::get(Config::SINGLE_USER_MODE) && class_exists("PDO")) { $pdo = Db::pdo(); $res = $pdo->query("SELECT id FROM ttrss_users WHERE id = 1"); if (!$res->fetch()) { - array_push($errors, "SINGLE_USER_MODE is enabled in config.php but default admin account is not found."); + array_push($errors, "Config::get(Config::SINGLE_USER_MODE) is enabled in config.php but default admin account is not found."); } } @@ -107,26 +89,26 @@ $ref_self_url_path = preg_replace("/\w+\.php$/", "", $ref_self_url_path); } - if (SELF_URL_PATH == "http://example.org/tt-rss/") { + if (Config::get(Config::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 Config::get(Config::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)) { + Config::get(Config::SELF_URL_PATH) != $ref_self_url_path && Config::get(Config::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> (you're using: <b>" . SELF_URL_PATH . "</b>)"); + "Please set Config::get(Config::SELF_URL_PATH) to the correct value detected for your server: <b>$ref_self_url_path</b> (you're using: <b>" . Config::get(Config::SELF_URL_PATH) . "</b>)"); } } - if (!is_writable(ICONS_DIR)) { - array_push($errors, "ICONS_DIR defined in config.php is not writable (chmod -R 777 ".ICONS_DIR.").\n"); + if (!is_writable(Config::get(Config::ICONS_DIR))) { + array_push($errors, "ICONS_DIR defined in config.php is not writable (chmod -R 777 ".Config::get(Config::ICONS_DIR).").\n"); } - if (!is_writable(LOCK_DIRECTORY)) { - array_push($errors, "LOCK_DIRECTORY defined in config.php is not writable (chmod -R 777 ".LOCK_DIRECTORY.").\n"); + if (!is_writable(Config::get(Config::LOCK_DIRECTORY))) { + array_push($errors, "Config::get(Config::LOCK_DIRECTORY) defined in config.php is not writable (chmod -R 777 ".Config::get(Config::LOCK_DIRECTORY).").\n"); } if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { @@ -137,14 +119,6 @@ array_push($errors, "PHP support for JSON is required, but was not found."); } - if (DB_TYPE == "mysql" && !function_exists("mysqli_connect")) { - array_push($errors, "PHP support for MySQL is required for configured DB_TYPE in config.php."); - } - - if (DB_TYPE == "pgsql" && !function_exists("pg_connect")) { - array_push($errors, "PHP support for PostgreSQL is required for configured DB_TYPE in config.php"); - } - if (!class_exists("PDO")) { array_push($errors, "PHP support for PDO is required but was not found."); } @@ -169,7 +143,7 @@ array_push($errors, "PHP support for DOMDocument is required, but was not found."); } - if (DB_TYPE == "mysql") { + if (Config::get(Config::DB_TYPE) == "mysql") { $bad_tables = check_mysql_tables(); if (count($bad_tables) > 0) { |