diff --git a/constant_inc.php b/constant_inc.php index 184dc607b3..d67b282847 100644 --- a/constant_inc.php +++ b/constant_inc.php @@ -9,18 +9,6 @@ # CONFIGURATION VARIABLES ########################################################################### - ######################## - # PHP Constants - ######################## - - # Directory separator was introduced in PHP 4.0.6 - if ( !defined( 'DIRECTORY_SEPARATOR' ) ) { - if (substr(php_uname(), 0, 7) == 'Windows') { - define('DIRECTORY_SEPARATOR', '\\'); - } else { - define('DIRECTORY_SEPARATOR', '/'); - } - } ######################## # Mantis Constants diff --git a/core_API.php b/core_API.php index 1d303d4829..0612133e23 100644 --- a/core_API.php +++ b/core_API.php @@ -9,6 +9,13 @@ # INCLUDES ########################################################################### + # Before doing anything else, start output buffering so we don't prevent + # headers from being sent if there's a blank line in an included file + ob_start(); + + # Include compatibility file before anything else + include( 'core_php_API.php' ); + require( 'constant_inc.php' ); if ( file_exists( 'custom_constant_inc.php' ) ) { include( 'custom_constant_inc.php' ); @@ -40,40 +47,6 @@ function obsolete_config_variable($var, $replace) { obsolete_config_variable('g_notify_on_new_threshold', 'g_notify_flags'); obsolete_config_variable('g_notify_admin_on_new', 'g_notify_flags'); - ini_set('magic_quotes_runtime', 0); - - # @@@ Experimental - # deal with register_globals being Off - $t_phpversion = explode('.', phpversion()); - if ( OFF == $g_register_globals ) { - if ( $t_phpversion[0] == 4 && $t_phpversion[1] >= 1 ) { - extract( $_REQUEST ); - extract( $_SERVER ); - } else { - extract( $HTTP_POST_VARS ); - extract( $HTTP_GET_VARS ); - extract( $HTTP_SERVER_VARS ); - } - } - - # Experimental support for $_* variables in PHP < 4.1.0 - if ( $t_phpversion[0] < 4 || $t_phpversion[1] < 1 ) { - global $_REQUEST, $_GET, $_POST, $_COOKIE, $_SERVER; - - $_GET = $HTTP_GET_VARS; - $_POST = $HTTP_POST_VARS; - $_COOKIE = $HTTP_COOKIE_VARS; - $_SERVER = $HTTP_SERVER_VARS; - - $_REQUEST = $HTTP_COOKIE_VARS; - foreach ($HTTP_POST_VARS as $key => $value) { - $_REQUEST[$key] = $value; - } - foreach ($HTTP_GET_VARS as $key => $value) { - $_REQUEST[$key] = $value; - } - } - include( 'core_timer_API.php' ); # initialize our timer diff --git a/core_php_API.php b/core_php_API.php new file mode 100644 index 0000000000..4cac3a31ed --- /dev/null +++ b/core_php_API.php @@ -0,0 +1,91 @@ + (int)$t_minver[$i] ) { + return true; + } + } + + # if we get here, the versions must match exactly so: + return true; + } + # -------------------- + + # Enforce our minimum requirements + if ( ! php_version_at_least( '4.2.2' ) ) { + echo "Your version of PHP is too old. Mantis requires PHP version 4.0.3 or newer to operate"; + ob_flush(); + die(); + } + + ini_set('magic_quotes_runtime', 0); + + # @@@ Experimental + # deal with register_globals being Off + # @@@ NOTE we want to get rid of this once we start getting all + # our GPC variables with functions. In fact we may want to + # turn off register_global_variables if we can + if ( OFF == $g_register_globals ) { + if ( php_version_at_least( '4.1.0' ) ) { + extract( $_REQUEST ); + extract( $_SERVER ); + } else { + extract( $HTTP_POST_VARS ); + extract( $HTTP_GET_VARS ); + extract( $HTTP_SERVER_VARS ); + } + } + + # Experimental support for $_* auto-global variables in PHP < 4.1.0 + if ( ! php_version_at_least( '4.1.0' ) ) { + global $_REQUEST, $_GET, $_POST, $_COOKIE, $_SERVER; + + $_GET = $HTTP_GET_VARS; + $_POST = $HTTP_POST_VARS; + $_COOKIE = $HTTP_COOKIE_VARS; + $_SERVER = $HTTP_SERVER_VARS; + + $_REQUEST = $HTTP_COOKIE_VARS; + foreach ($HTTP_POST_VARS as $key => $value) { + $_REQUEST[$key] = $value; + } + foreach ($HTTP_GET_VARS as $key => $value) { + $_REQUEST[$key] = $value; + } + } + + ######################## + # PHP Constants + ######################## + + # Directory separator was introduced in PHP 4.0.6 + if ( !defined( 'DIRECTORY_SEPARATOR' ) ) { + if (substr(php_uname(), 0, 7) == 'Windows') { + define('DIRECTORY_SEPARATOR', '\\'); + } else { + define('DIRECTORY_SEPARATOR', '/'); + } + } + +?> diff --git a/core_security_API.php b/core_security_API.php index 0c9ec22c40..fd652ff22c 100644 --- a/core_security_API.php +++ b/core_security_API.php @@ -6,11 +6,11 @@ # See the files README and LICENSE for details # -------------------------------------------------------- - # $Revision: 1.2 $ - # $Author: jlatour $ - # $Date: 2002-08-22 18:15:10 $ + # $Revision: 1.3 $ + # $Author: jfitzell $ + # $Date: 2002-08-23 01:34:08 $ # - # $Id: core_security_API.php,v 1.2 2002-08-22 18:15:10 jlatour Exp $ + # $Id: core_security_API.php,v 1.3 2002-08-23 01:34:08 jfitzell Exp $ # -------------------------------------------------------- ########################################################################### @@ -22,7 +22,10 @@ # If the variable is not set, the default is returned. # If magic_quotes_gpc is on, slashes will be stripped from the value before being returned. function get_var( $p_var_name, $p_default = 'nil' ) { - global $_REQUEST; + # simulate auto-globals from PHP v4.1.0 (see also code in core_php_API.php) + if ( ! php_version_at_least( '4.1.0' ) ) { + global $_REQUEST; + } if ( isset( $_REQUEST[$p_var_name] ) ) { $t_result = $_REQUEST[$p_var_name];