From 942afb43a1357b8189f21937fe3abd413a14a21d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 8 Feb 2021 08:49:21 +0300 Subject: [PATCH] sanity checks: use better CLI detection, shorten most of the text --- include/sanity_check.php | 52 +++++++++++++++------------------------- update.php | 33 ++++--------------------- 2 files changed, 24 insertions(+), 61 deletions(-) diff --git a/include/sanity_check.php b/include/sanity_check.php index fddc26295..a7660795b 100755 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -1,18 +1,5 @@ $ref_self_url_path)" : ""; - array_push($errors, - "Please set SELF_URL_PATH to the correct value for your server: $hint"); - } + if (SELF_URL_PATH == "http://example.org/tt-rss/") { + $hint = $ref_self_url_path ? "(possible value: $ref_self_url_path)" : ""; + array_push($errors, + "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: $ref_self_url_path (you're using: " . SELF_URL_PATH . ")"); + 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: $ref_self_url_path (you're using: " . SELF_URL_PATH . ")"); + } } if (!is_writable(ICONS_DIR)) { @@ -207,7 +193,7 @@ } } - if (count($errors) > 0 && $_SERVER['REQUEST_URI']) { ?> + if (count($errors) > 0 && php_sapi_name() != "cli") { ?> @@ -240,7 +226,7 @@ echo "Please fix errors indicated by the following messages:\n\n"; foreach ($errors as $error) { - echo " * $error\n"; + echo " * " . strip_tags($error)."\n"; } echo "\nYou might want to check tt-rss wiki or the forums for more information.\n"; diff --git a/update.php b/update.php index 2963c00f2..e708aad71 100755 --- a/update.php +++ b/update.php @@ -72,9 +72,6 @@ return $tags_deleted; } - if (!defined('PHP_EXECUTABLE')) - define('PHP_EXECUTABLE', '/usr/bin/php'); - $pdo = Db::pdo(); init_plugins(); @@ -106,34 +103,14 @@ array_push($longopts, $command . $data["suffix"]); } - $options = getopt("", $longopts); - - if (!is_array($options)) { - die("error: getopt() failed. ". - "Most probably you are using PHP CGI to run this script ". - "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". - "additional information.\n"); - } - - if (count($options) == 0 && !defined('STDIN')) { - ?> - - - - Tiny Tiny RSS data update script. - - - - -

- - - - -