sanity_check: config.php is now optional, also cleanup some error messages

This commit is contained in:
Andrew Dolgov 2021-02-28 17:42:21 +03:00
parent a22ddb2fe0
commit 1bb0d9b603
1 changed files with 98 additions and 107 deletions

View File

@ -36,14 +36,6 @@
$errors = array();
if (!file_exists("config.php")) {
array_push($errors, "Configuration file not found. Looks like you forgot to copy config.php-dist to config.php and edit it.");
} else {
if (!file_exists("config.php")) {
array_push($errors, "Please copy config.php-dist to 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");
}
@ -52,8 +44,8 @@
array_push($errors, "Please don't run this script as root.");
}
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 (version_compare(PHP_VERSION, '7.1.0', '<')) {
array_push($errors, "PHP version 7.1.0 or newer required. You're using " . PHP_VERSION . ".");
}
if (!class_exists("UConverter")) {
@ -78,7 +70,7 @@
$res = $pdo->query("SELECT id FROM ttrss_users WHERE id = 1");
if (!$res->fetch()) {
array_push($errors, "Config::get(Config::SINGLE_USER_MODE) is enabled in config.php but default admin account is not found.");
array_push($errors, "SINGLE_USER_MODE is enabled but default admin account is not found.");
}
}
@ -92,14 +84,14 @@
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 Config::get(Config::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) &&
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 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>)");
"Please set 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>)");
}
}
@ -108,7 +100,7 @@
}
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");
array_push($errors, "LOCK_DIRECTORY is not writable (chmod -R 777 ".Config::get(Config::LOCK_DIRECTORY).").\n");
}
if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) {
@ -165,7 +157,6 @@
array_push($errors, $msg);
}
}
}
if (count($errors) > 0 && php_sapi_name() != "cli") { ?>
<!DOCTYPE html>