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() { ...@@ -67,8 +67,8 @@ function main() {
function listfolders_configure() { function listfolders_configure() {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"])) { if (php_sapi_name() != "cli") {
echo "This script should not be called in a browser.\n"; printf("This script should not be called in a browser. Called from: %s\n", php_sapi_name());
exit(1); exit(1);
} }
......
...@@ -191,8 +191,8 @@ class ZPushAdminCLI { ...@@ -191,8 +191,8 @@ class ZPushAdminCLI {
* @access public * @access public
*/ */
static public function CheckEnv() { static public function CheckEnv() {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"])) if (php_sapi_name() != "cli")
self::$errormessage = "This script should not be called in a browser."; self::$errormessage = sprintf("This script should not be called in a browser. Called from: %s", php_sapi_name());
if (!function_exists("getopt")) if (!function_exists("getopt"))
self::$errormessage = "PHP Function getopt not found. Please check your PHP version and settings."; self::$errormessage = "PHP Function getopt not found. Please check your PHP version and settings.";
......
...@@ -52,8 +52,8 @@ define('ZPUSH_BASE_PATH', "../src"); ...@@ -52,8 +52,8 @@ define('ZPUSH_BASE_PATH', "../src");
* MAIN * MAIN
*/ */
try { try {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"])) if (php_sapi_name() != "cli")
die("This script should not be called in a browser."); 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")) 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"); 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