osCMax 2.0 php 5.6注册全局变量

时间:2017-06-14 09:03:03

标签: global-variables upgrade php-5.6 oscommerce register-globals

我使用osCMax 2.0,我的ISP将把php版本升级到5.6,为了使它与php 5.6兼容,我应用了来自https://apps.oscommerce.com/0ma2w的补丁,该网站现在正在打开,但是点击添加到购物车将我带到一个空白页面,产品也没有添加到购物车。帐户页面也是空白的。我在这里添加补丁代码。

INSTALLATION INSTRUCTIONS 

OPEN: 

catalog/includes/application_top.php 

FIND: 

// start the timer for the page parse time log
  define('PAGE_PARSE_START_TIME', microtime()); 

BEFORE, ADD: 

// Register Globals MOD - http://www.magic-seo-url.com

  if (version_compare(phpversion(), "4.1.0", "<") === true) {
    $_GET &= $HTTP_GET_VARS;
    $_POST &= $HTTP_POST_VARS;
    $_SERVER &= $HTTP_SERVER_VARS;
    $_FILES &= $HTTP_POST_FILES;
    $_ENV &= $HTTP_ENV_VARS;
    if (isset($HTTP_COOKIE_VARS)) $_COOKIE &= $HTTP_COOKIE_VARS;
  }

  if (!ini_get("register_globals")) {
    extract($_GET, EXTR_SKIP);
    extract($_POST, EXTR_SKIP);
    extract($_COOKIE, EXTR_SKIP);
  } 

FIND: 

// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  if (function_exists('ini_get')) {
    ini_get('register_globals') or exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.');
  } 

REPLACE WITH: 

// Check if register_globals is enabled.
// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  /*if (function_exists('ini_get')) { // Register Globals MOD - http://www.magic-seo-url.com
    ini_get('register_globals') or exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.');
  }*/ 

FIND: 

// set SID once, even if empty
  $SID = (defined('SID') ? SID : ''); 

BEFORE, ADD: 

// Register Globals MOD - http://www.magic-seo-url.com
  if (!ini_get("register_globals")) {
    if (version_compare(phpversion(), "4.1.0", "<") === true) {
      if (isset($HTTP_SESSION_VARS)) $_SESSION &= $HTTP_SESSION_VARS;
    }
    extract($_SESSION, EXTR_SKIP);
  } 

OPEN: 

catalog/includes/functions/sessions.php 

FIND: 

  function tep_session_register($variable) {
    global $session_started;

    if ($session_started == true) {
      return session_register($variable);
    } else {
      return false;
    }
  }

  function tep_session_is_registered($variable) {
    return session_is_registered($variable);
  }

  function tep_session_unregister($variable) {
    return session_unregister($variable);
  } 

REPLACE WITH: 

// Register Globals MOD - http://www.magic-seo-url.com
  function tep_session_register($variable) {
    global $session_started;
    if ($session_started == true) {
      $_SESSION[$variable] = null;
      return true;
    } else {
      return false;
    }
  }

  function tep_session_is_registered($variable) {
    if(isset($_SESSION[$variable])) {
      return true;
    } else {
      return false;
    }
  }

  function tep_session_unregister($variable) {
    unset($_SESSION[$variable]);
  } 

FIND: 

  function tep_session_close() {
    if (PHP_VERSION >= '4.0.4') {
      return session_write_close();
    } elseif (function_exists('session_close')) {
      return session_close();
    }
  } 

REPLACE WITH: 

// Register Globals MOD - http://www.magic-seo-url.com
  function tep_session_close() {
    foreach($_SESSION as $key => $value) {
      global $$key;
      $_SESSION[$key] = $$key;
    }
  } 

OPEN: 

catalog/admin/includes/application_top.php 

FIND: 

// Start the clock for the page parse time log
  define('PAGE_PARSE_START_TIME', microtime()); 

BEFORE, ADD: 

  // Register Globals MOD - http://www.magic-seo-url.com
  if (version_compare(phpversion(), "4.1.0", "<") === true) {
    $_GET &= $HTTP_GET_VARS;
    $_POST &= $HTTP_POST_VARS;
    $_SERVER &= $HTTP_SERVER_VARS;
    $_FILES &= $HTTP_POST_FILES;
    $_ENV &= $HTTP_ENV_VARS;
    if (isset($HTTP_COOKIE_VARS)) $_COOKIE &= $HTTP_COOKIE_VARS;
  }

  if (!ini_get("register_globals")) {
    extract($_GET, EXTR_SKIP);
    extract($_POST, EXTR_SKIP);
    extract($_COOKIE, EXTR_SKIP);
  } 

FIND: 

// Check if register_globals is enabled.
// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  if (function_exists('ini_get')) {
    ini_get('register_globals') or exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.');
  } 

REPLACE WITH: 

// Check if register_globals is enabled.
// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  /*if (function_exists('ini_get')) { // Register Globals MOD - http://www.magic-seo-url.com
    ini_get('register_globals') or exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.');
  }*/ 

FIND: 

// lets start our session
  tep_session_start(); 

AFTER, ADD: 

// Register Globals MOD - http://www.magic-seo-url.com
  if (!ini_get("register_globals")) {
    if (version_compare(phpversion(), "4.1.0", "<") === true) {
      if (isset($HTTP_SESSION_VARS)) $_SESSION &= $HTTP_SESSION_VARS;
    }
    extract($_SESSION, EXTR_SKIP);
  } 

OPEN: 

catalog/admin/includes/functions/sessions.php 

FIND: 

  function tep_session_register($variable) {
    return session_register($variable);
  }

  function tep_session_is_registered($variable) {
    return session_is_registered($variable);
  }

  function tep_session_unregister($variable) {
    return session_unregister($variable);
  } 

REPLACE WITH: 

// Register Globals MOD - http://www.magic-seo-url.com
  function tep_session_register($variable) {
    $_SESSION[$variable] = null;
  }

  function tep_session_is_registered($variable) {
    if(isset($_SESSION[$variable])) {
      return true;
    } else {
      return false;
    }
  }

  function tep_session_unregister($variable) {
    unset($_SESSION[$variable]);
  } 

FIND: 

  function tep_session_close() {
    if (function_exists('session_close')) {
      return session_close();
    }
  } 

REPLACE WITH: 

// Register Globals MOD - http://www.magic-seo-url.com
  function tep_session_close() {
    foreach($_SESSION as $key => $value) {
      global $$key;
      $_SESSION[$key] = $$key;
    }
  } 

OPEN: 

catalog/install/includes/application.php 

FIND: 

// Set the level of error reporting
  error_reporting(E_ALL & ~E_NOTICE); 

AFTER, ADD: 

  // Register Globals MOD - http://www.magic-seo-url.com
  if (version_compare(phpversion(), "4.1.0", "<") === true) {
    $_GET &= $HTTP_GET_VARS;
    $_POST &= $HTTP_POST_VARS;
    $_SERVER &= $HTTP_SERVER_VARS;
    $_FILES &= $HTTP_POST_FILES;
    $_ENV &= $HTTP_ENV_VARS;
    if (isset($HTTP_COOKIE_VARS)) $_COOKIE &= $HTTP_COOKIE_VARS;
  }

  if (!ini_get("register_globals")) {
    extract($_GET, EXTR_SKIP);
    extract($_POST, EXTR_SKIP);
    extract($_COOKIE, EXTR_SKIP);
  } 

FIND: 

// Check if register_globals is enabled.
// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  if (function_exists('ini_get')) {
    ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
  } 

REPLACE WITH: 

// Check if register_globals is enabled.
// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
  /*if (function_exists('ini_get')) {
    ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
  }*/

1 个答案:

答案 0 :(得分:0)

而不是非常复杂的方法尝试这个模拟代码,适用于application_top.php:

// Emulate register_globals on
if (!ini_get('register_globals')) {
   $superglobals = array($_SERVER, $_ENV,
       $_FILES, $_COOKIE, $_POST, $_GET);
   if (isset($_SESSION)) {
       array_unshift($superglobals, $_SESSION);
   }
   foreach ($superglobals as $superglobal) {
       extract($superglobal, EXTR_SKIP);
   }
}