Fatally exit if register_globals is set
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 31 Dec 2009 23:04:47 +0000 (16:04 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 5 Jan 2010 20:43:55 +0000 (13:43 -0700)
horde/docs/CODING_STANDARDS
horde/lib/core.php
horde/test.php

index 162f346..ab0a962 100644 (file)
@@ -308,15 +308,9 @@ Use ``example.com`` for all example URLs, per `RFC 2606`_.
 php.ini settings
 ================
 
-All Horde code should work with `register_globals`_ disabled.  This means
-using ``$_COOKIE``, ``$_SESSION``, ``$_SERVER`` and ``$_ENV`` to access all
-cookie, session, server and environment data, respectively.  By the same token,
-all Horde code should also work with `register_globals`_ enabled.  Since
-applications can be expected to store data in $_SESSION['application'] it is
-therefor important that applications NOT register $GLOBALS in their own
-application name.  For instance the application "foo" may create and use
-$_SESSION['foo'] but not $GLOBALS['foo'].  Failing this rule may cause problems
-on PHP installations on which `register_globals`_ is enabled.
+Horde code MUST NOT use global variables set by EGPCS (Environment, GET, POST,
+Cookie, Server) data.  Instead, the magic variables ``$_ENV``, ``$_GET``,
+``$_POST``, $_COOKIE``, and ``$_SERVER`` must be used instead.
 
 To retrieve posted data (in the global ``$_GET`` and ``$_POST`` variables),
 you should normally use `Horde_Util::getFormData()`_ which will automatically
@@ -334,7 +328,6 @@ No Horde code should assume that '.' is in the include path. Always specify
 './' in front of a filename when you are including a file in the same
 directory.
 
-.. _register_globals: http://www.php.net/manual/en/security.registerglobals.php
 .. _magic_quotes_gpc: http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc
 .. _error_reporting: http://www.php.net/manual/en/ref.errorfunc.php#ini.error-reporting
 .. _Horde_Util::getFormData(): http://dev.horde.org/api/framework/Horde_Util/Horde_Util.html#methodgetFormData
index 30baa2f..437f711 100644 (file)
@@ -17,13 +17,9 @@ ini_set('magic_quotes_runtime', 0);
 ini_set('zend.ze1_compatibility_mode', 0);
 ini_set('allow_url_include', 0);
 
-/* Unset all variables populated through register_globals. */
+/* Exit immediately if register_globals is active. */
 if (ini_get('register_globals')) {
-    foreach (array($_GET, $_POST, $_COOKIE, $_ENV, $_SERVER) as $var) {
-        foreach (array_keys($var) as $key) {
-            unset($$key);
-        }
-    }
+    exit('Register globals is enabled. Exiting.');
 }
 
 if (!defined('HORDE_BASE')) {
index 1d9718d..07dcb04 100644 (file)
@@ -151,6 +151,10 @@ $setting_list = array(
         'setting' => 'value',
         'error' => 'If PHP\'s internal memory limit is not set high enough Horde will not be able to handle large data items. You should set the value of memory_limit in php.ini to a sufficiently high value - at least 64M is recommended.'
     ),
+    'register_globals' => array(
+        'setting' => false,
+        'error' => 'Register globals has been deprecated in PHP 5. Horde will fatally exit if it is set. Turn it off.'
+    ),
     'safe_mode' => array(
         'setting' => false,
         'error' => 'If safe_mode is enabled, Horde cannot set enviroment variables, which means Horde will be unable to translate the user interface into different languages.'