update.php: better error reporting if invoked with PHP SAPI other than CLI

This commit is contained in:
Andrew Dolgov 2022-02-20 16:35:32 +03:00
parent f7e2f62022
commit 9a5c21630b
1 changed files with 8 additions and 6 deletions

View File

@ -10,6 +10,14 @@
require_once "autoload.php";
require_once "functions.php";
if (php_sapi_name() != "cli") {
header("Content-type: text/plain");
printf("Please run this script using PHP CLI executable (you're using PHP SAPI: %s, PHP_EXECUTABLE is set to '%s')\n",
php_sapi_name(), Config::get(Config::PHP_EXECUTABLE));
exit(1);
}
Config::sanity_check();
function make_stampfile(string $filename): bool {
@ -100,12 +108,6 @@
$options_map[$command . $data["suffix"]] = [ $data["arghelp"], $data["description"] ];
}
if (php_sapi_name() != "cli") {
header("Content-type: text/plain");
print "Please run this script from the command line.\n";
exit;
}
$options = getopt("", array_keys($options_map));
if ($options === false || count($options) == 0 || isset($options["help"]) ) {