diff --git a/admin/admin-cli.php b/admin/admin-cli.php
index 791bef6810..c5be2c7380 100755
--- a/admin/admin-cli.php
+++ b/admin/admin-cli.php
@@ -13,7 +13,7 @@
chdir(dirname(__FILE__)); // to enable our relative pathes to work
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling admin-cli as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page
{
die('
admin-cli.php must NOT be called as web-page --> exiting !!!
');
}
diff --git a/doc/fix_depricated.php b/doc/fix_depricated.php
index 3be382d768..41bf1b45f1 100755
--- a/doc/fix_depricated.php
+++ b/doc/fix_depricated.php
@@ -14,7 +14,7 @@
* @version $Id$
*/
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page
{
die('fix_depricated.php must NOT be called as web-page --> exiting !!!
');
}
@@ -119,7 +119,7 @@ function fix_depricated($file,$replace_file=false)
// fix call to not longer existing PDO method $result->fetchSingle()
$lines = str_replace('->fetchSingle(','->fetchColumn(',$lines);
-
+
// fix calls to deprecated call_user_method(_array)?(method,object[,args])
if (preg_match('/call_user_method(_array)?\(/',$lines,$matches))
{
diff --git a/doc/rpm-build/checkout-build-archives.php b/doc/rpm-build/checkout-build-archives.php
index 4eb80b3094..93876588c7 100755
--- a/doc/rpm-build/checkout-build-archives.php
+++ b/doc/rpm-build/checkout-build-archives.php
@@ -9,7 +9,7 @@
* @version $Id$
*/
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling setup-cli as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page
{
die('checkout-build-archives.php must NOT be called as web-page --> exiting !!!
');
}
diff --git a/doc/rpm-build/post_install.php b/doc/rpm-build/post_install.php
index a3e94551de..bb2cf5e685 100755
--- a/doc/rpm-build/post_install.php
+++ b/doc/rpm-build/post_install.php
@@ -9,7 +9,7 @@
* @version $Id$
*/
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling post_install as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling post_install as web-page
{
die('rpm_post_install.php must NOT be called as web-page --> exiting !!!
');
}
diff --git a/filemanager/cli.php b/filemanager/cli.php
index 7cfcaa5c42..5b71190eac 100755
--- a/filemanager/cli.php
+++ b/filemanager/cli.php
@@ -17,7 +17,7 @@ chdir(dirname(__FILE__)); // to enable our relative pathes to work
error_reporting(error_reporting() & ~E_NOTICE);
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling ls as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling filemanager/cli.php as web-page
{
die(''.basename(__FILE__).' must NOT be called as web-page --> exiting !!!
');
}
diff --git a/phpgwapi/ischedule-cli.php b/phpgwapi/ischedule-cli.php
index 01d2f89b56..336b779418 100755
--- a/phpgwapi/ischedule-cli.php
+++ b/phpgwapi/ischedule-cli.php
@@ -12,7 +12,7 @@
* @version $Id$
*/
-if (isset($_SERVER['HTTP_HOST'])) die("This is a commandline ONLY tool!\n");
+if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n");
/**
* iSchedule command line client, primary for testing and development purpose
diff --git a/setup/doc/chown.php b/setup/doc/chown.php
index 634388bedb..b1eb10d636 100755
--- a/setup/doc/chown.php
+++ b/setup/doc/chown.php
@@ -13,7 +13,7 @@
chdir(dirname(__FILE__)); // to enable our relative pathes to work
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page
{
die('setup/doc/chown.php must NOT be called as web-page --> exiting !!!
');
}
diff --git a/setup/setup-cli.php b/setup/setup-cli.php
index 8f14d9ac01..a6f5168333 100755
--- a/setup/setup-cli.php
+++ b/setup/setup-cli.php
@@ -13,7 +13,7 @@
chdir(dirname(__FILE__)); // to enable our relative pathes to work
-if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling setup-cli as web-page
+if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page
{
die('setup-cli.php must NOT be called as web-page --> exiting !!!
');
}
diff --git a/svn-helper.php b/svn-helper.php
index 30cb9950b0..e36ec44990 100755
--- a/svn-helper.php
+++ b/svn-helper.php
@@ -10,7 +10,7 @@
* @version $Id$
*/
-if (isset($_SERVER['HTTP_HOST'])) die("This is a commandline ONLY tool!\n");
+if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n");
if ($_SERVER['argc'] <= 1) die('
Usage: ./svn-helper.php