ZP-686 Replace $_SERVER["TERM"] with php_sapi_name(). Released under the...

ZP-686 Replace $_SERVER["TERM"] with php_sapi_name(). Released under the Affero GNU General Public License (AGPL) version 3.
parent 80c61fc1
......@@ -67,8 +67,8 @@ function main() {
function listfolders_configure() {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"])) {
echo "This script should not be called in a browser.\n";
if (php_sapi_name() != "cli") {
printf("This script should not be called in a browser. Called from: %s\n", php_sapi_name());
exit(1);
}
......
......@@ -191,8 +191,8 @@ class ZPushAdminCLI {
* @access public
*/
static public function CheckEnv() {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"]))
self::$errormessage = "This script should not be called in a browser.";
if (php_sapi_name() != "cli")
self::$errormessage = sprintf("This script should not be called in a browser. Called from: %s", php_sapi_name());
if (!function_exists("getopt"))
self::$errormessage = "PHP Function getopt not found. Please check your PHP version and settings.";
......
......@@ -52,8 +52,8 @@ define('ZPUSH_BASE_PATH', "../src");
* MAIN
*/
try {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"]))
die("This script should not be called in a browser.");
if (php_sapi_name() != "cli")
die(sprintf("This script should not be called in a browser. Called from: %s", php_sapi_name()));
if (!defined('ZPUSH_BASE_PATH') || !file_exists(ZPUSH_BASE_PATH . "/config.php"))
die("ZPUSH_BASE_PATH not set correctly or no config.php file found\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment