common.php
  • FIND:

    // The following code (unsetting globals) was contributed by Matt Kavanagh
    
  • REPLACE WITH:

    // The following code (unsetting globals)
    // Thanks to Matt Kavanagh and Stefan Esser for providing feedback as well as patch files
    
  • FIND:

    // PHP5 with register_long_arrays off?
    if (!isset($HTTP_POST_VARS) && isset($_POST))
    {
    	$HTTP_POST_VARS = $_POST;
    	$HTTP_GET_VARS = $_GET;
    	$HTTP_SERVER_VARS = $_SERVER;
    	$HTTP_COOKIE_VARS = $_COOKIE;
    	$HTTP_ENV_VARS = $_ENV;
    	$HTTP_POST_FILES = $_FILES;
    
    	// _SESSION is the only superglobal which is conditionally set
    	if (isset($_SESSION))
    	{
    		$HTTP_SESSION_VARS = $_SESSION;
    	}
    }
    
  • REPLACE WITH:

    // PHP5 with register_long_arrays off?
    if (@phpversion() >= '5.0.0' && (!@ini_get('register_long_arrays') || @ini_get('register_long_arrays') == '0' || strtolower(@ini_get('register_long_arrays')) == 'off'))
    {
    	$HTTP_POST_VARS = $_POST;
    	$HTTP_GET_VARS = $_GET;
    	$HTTP_SERVER_VARS = $_SERVER;
    	$HTTP_COOKIE_VARS = $_COOKIE;
    	$HTTP_ENV_VARS = $_ENV;
    	$HTTP_POST_FILES = $_FILES;
    
    	// _SESSION is the only superglobal which is conditionally set
    	if (isset($_SESSION))
    	{
    		$HTTP_SESSION_VARS = $_SESSION;
    	}
    }
    
    // Protect against GLOBALS tricks
    if (isset($HTTP_POST_VARS['GLOBALS']) || isset($HTTP_POST_FILES['GLOBALS']) || isset($HTTP_GET_VARS['GLOBALS']) || isset($HTTP_COOKIE_VARS['GLOBALS']))
    {
    	die("Hacking attempt");
    }
    
    // Protect against HTTP_SESSION_VARS tricks
    if (isset($HTTP_SESSION_VARS) && !is_array($HTTP_SESSION_VARS))
    {
    	die("Hacking attempt");
    }
    
  • FIND:

    if (@phpversion() < '4.0.0')
    {
    	// PHP3 path; in PHP3, globals are _always_ registered
    	
    	// We 'flip' the array of variables to test like this so that
    	// we can validate later with isset($test[$var]) (no in_array())
    	$test = array('HTTP_GET_VARS' => NULL, 'HTTP_POST_VARS' => NULL, 'HTTP_COOKIE_VARS' => NULL, 'HTTP_SERVER_VARS' => NULL, 'HTTP_ENV_VARS' => NULL, 'HTTP_POST_FILES' => NULL, 'phpEx' => NULL, 'phpbb_root_path' => NULL);
    
    	// Loop through each input array
    	@reset($test);
    	while (list($input,) = @each($test))
    	{
    		while (list($var,) = @each($$input))
    		{
    			// Validate the variable to be unset
    			if (!isset($test[$var]) && $var != 'test' && $var != 'input')
    			{
    				unset($$var);
    			}
    		}
    	}
    }
    else if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
    {
    
  • REPLACE WITH:

    if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
    {
    
  • FIND:

    	if (!isset($HTTP_SESSION_VARS))
    	{
    		$HTTP_SESSION_VARS = array();
    	}
    
    	// Merge all into one extremely huge array; unset
    	// this later
    	$input = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);
    
    	unset($input['input']);
    	unset($input['not_unset']);
    
    	while (list($var,) = @each($input))
    	{
    		if (!in_array($var, $not_unset))
    		{
    			unset($$var);
    		}
    	}
    
    	unset($input);
    }
    
  • REPLACE WITH:

    	if (!isset($HTTP_SESSION_VARS) || !is_array($HTTP_SESSION_VARS))
    	{
    		$HTTP_SESSION_VARS = array();
    	}
    
    	// Merge all into one extremely huge array; unset
    	// this later
    	$input = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);
    
    	unset($input['input']);
    	unset($input['not_unset']);
    
    	while (list($var,) = @each($input))
    	{
    		if (!in_array($var, $not_unset))
    		{
    			unset($$var);
    		}
    	}
    
    	unset($input);
    }
    
  • FIND:

    	header("Location: install/install.$phpEx");
    
  • REPLACE WITH:

    	header('Location: ' . $phpbb_root_path . 'install/install.' . $phpEx);
    
  • FIND:

    include($phpbb_root_path . 'includes/db.'.$phpEx);
    
  • AFTER, ADD:

    // We do not need this any longer, unset for safety purposes
    unset($dbpasswd);