summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-08 08:49:21 +0300
committerAndrew Dolgov <[email protected]>2021-02-08 08:49:21 +0300
commit942afb43a1357b8189f21937fe3abd413a14a21d (patch)
tree9f5301795bdbc62b2f8e71da1b200368bac94783
parent5d0f65358fc233dd3fde24d60cbfc74c846af7a6 (diff)
sanity checks: use better CLI detection, shorten most of the textwip-php8
-rwxr-xr-xinclude/sanity_check.php52
-rwxr-xr-xupdate.php33
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 @@
<?php
- /* WARNING!
- *
- * If you modify this file, you are ON YOUR OWN!
- *
- * Believe it or not, all of the checks below are required to succeed for
- * tt-rss to actually function properly.
- *
- * If you think you have a better idea about what is or isn't required, feel
- * free to modify the file, note though that you are therefore automatically
- * disqualified from any further support by official channels, e.g. tt-rss.org
- * issue tracker or the forums.
- *
- * If you come crying when stuff inevitably breaks, you will be mocked and told
- * to get out. */
+ /* WARNING! If you modify this file, you are ON YOUR OWN! */
function make_self_url() {
$proto = is_server_https() ? 'https' : 'http';
@@ -45,9 +32,6 @@
return $bad_tables;
}
-/**
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
- */
function initial_sanity_check() {
$errors = array();
@@ -116,23 +100,25 @@
}
}
- $ref_self_url_path = make_self_url_path();
+ if (php_sapi_name() != "cli") {
+ $ref_self_url_path = make_self_url_path();
- if ($ref_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: $hint");
- }
+ 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: $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: <b>$ref_self_url_path</b> (you're using: <b>" . SELF_URL_PATH . "</b>)");
+ 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: <b>$ref_self_url_path</b> (you're using: <b>" . SELF_URL_PATH . "</b>)");
+ }
}
if (!is_writable(ICONS_DIR)) {
@@ -207,7 +193,7 @@
}
}
- if (count($errors) > 0 && $_SERVER['REQUEST_URI']) { ?>
+ if (count($errors) > 0 && php_sapi_name() != "cli") { ?>
<!DOCTYPE html>
<html>
<head>
@@ -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')) {
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Tiny Tiny RSS data update script.</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- </head>
-
- <body>
- <h1><?php echo __("Tiny Tiny RSS data update script.") ?></h1>
-
- <?php print_error("Please run this script from the command line. Use option \"--help\" to display command help if this error is displayed erroneously."); ?>
-
- </body></html>
- <?php
+ if (php_sapi_name() != "cli") {
+ header("Content-type: text/plain");
+ print "Please run this script from the command line.\n";
exit;
}
+ $options = getopt("", $longopts);
+
if (count($options) == 0 || isset($options["help"]) ) {
print "Tiny Tiny RSS data update script.\n\n";
print "Options:\n";