Drupal安装中出现的register_globals问题

Drupal或者Joomla等系统都要求运行的PHP环境关闭了register_globals,而有一些主机在默认的情况下 register_globals是开启的,像HostGator就是这样,这里如果我们安装Drupal等就会因为严重错误而停止安装,并要求你关闭主 机的register_globals,如下面的就是在安装Drupal时因为register_globals开启而出现的警告:

register_globals is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when register_globals is enabled. The PHP manual has instructions for how to change configuration settings. (Currently using PHP register globals Enabled (’1′))

这 里,我们应该怎么办呢?当然,因为register_globals开启而出现的重大错误肯定要以关闭register_globals的方式来解决,但 并不是每一个人都是使用自己的服务器能对PHP进行详细的设置,这时我们只有使用其它的方法了,下面是我使用过的三个方法,希望对正遇到这样问题的人有所 帮助。

  • 有使用PHPSUEXEC的主机:这种的比较简单,因为可以直接在根目录下放PHP.ini,所以只要将想要改的设定值加到PHP.ini,上传 到根目录就可以了,如直接在php.ini文件里加入这一行“register_globals = Off”就可以关闭register_globals了
  • 没有使用PHPSUEXEC的主机:这种的,就要去修改虚拟主机的根目录下的一个叫做.htaccess的档案,把里面的php_value register_globals设定改成0就可以了。如HostGator适用这种方法。
  • 还有一种方法,就是直接去掉问题产生的根源,我们把Drupal系统产生这个警告的地方给注释掉:打开
    \modules\system\system.install
$register_globals = trim(ini_get('register_globals'));
  // Unfortunately, ini_get() may return many different values, and we can't
  // be certain which values mean 'on', so we instead check for 'not off'
  // since we never want to tell the user that their site is secure
  // (register_globals off), when it is in fact on. We can only guarantee
  // register_globals is off if the value returned is 'off', '', or 0.
  if (!empty($register_globals) && strtolower($register_globals) != 'off') {
    $requirements['php_register_globals']['description'] = $t('<em>register_globals</em> is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when <em>register_globals</em> is enabled. The PHP manual has instructions for <a href="http://php.net/configuration.changes">how to change configuration settings</a>.');
    $requirements['php_register_globals']['severity'] = REQUIREMENT_ERROR;
    $requirements['php_register_globals']['value'] = $t("Enabled ('@value')", array('@value' => $register_globals));
  }
  else {
    $requirements['php_register_globals']['value'] = $t('Disabled');
  }
  • 本文作者:

    admin

  • 发布时间:

    May 21, 2008

  • 留言统计:

    暂时还没有留言

  • 所属分类:

    PHP

你可以做本文的第一个留言者!

这里还没有留言,你可以做第一个留言者

添加留言

XHTML: 您可以在留言中使用这些标签:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Categories

  • Recent Posts

  • Tags

  • Categories

  • Recent Comments

  • Archives