Home > Backend Development > PHP Tutorial > 解决更换PHP5.4以上版本后Dedecms后台登录空白问题的方法_PHP

解决更换PHP5.4以上版本后Dedecms后台登录空白问题的方法_PHP

WBOY
Release: 2016-05-29 11:48:45
Original
747 people have browsed it

把PHP的版本从5.2.14升到了5.4.15,升级完后dedecms后台却打开空白,检查了各种权限和文件,都没有问题,找来找去,原来是PHP版本函数的问题,它是用session_register来注册一个session变量,但是在php5.4以上中已经移除了这个功能
解决办法:
找到include/userlogin.class.php,里面有一个keepuser()函数,它是用session_register来注册一个session变量,但是在php5.4中已经移除了这个功能,见官网介绍:

如果使用的该php版本肯定会出错的,不过我们可以修改下代码:
把@session_register($this->keepUserIDTag); 注释掉,然后改为
if (!isset($_SESSION[$this->keepUserIDTag]))
一共有六个,全部改为下面这样:

if (!isset($_SESSION[$this->keepUserIDTag])) 
//@session_register($this->keepUserIDTag); 
 
$_SESSION[$this->keepUserIDTag] = $this->userID; 
 
if (!isset($_SESSION[$this->keepUserTypeTag])) 
//@session_register($this->keepUserTypeTag); 
 
$_SESSION[$this->keepUserTypeTag] = $this->userType; 
 
if (!isset($_SESSION[$this->keepUserChannelTag])) 
//@session_register($this->keepUserChannelTag); 
 
$_SESSION[$this->keepUserChannelTag] = $this->userChannel; 
 
if (!isset($_SESSION[$this->keepUserNameTag])) 
//@session_register($this->keepUserNameTag); 
 
$_SESSION[$this->keepUserNameTag] = $this->userName; 
 
if (!isset($_SESSION[$this->keepUserPurviewTag])) 
//@session_register($this->keepUserPurviewTag); 
 
$_SESSION[$this->keepUserPurviewTag] = $this->userPurview; 
 
if (!isset($_SESSION[$this->keepAdminStyleTag])) 
//@session_register($this->keepAdminStyleTag); 
 
$_SESSION[$this->keepAdminStyleTag] = $adminstyle; 
Copy after login

重新进入后台登录,就可以正常跳转到管理页面了。
因为对PHP并不熟,网上一般都说是data/common.inc.php文件编码的问题,把编码要改为无BOM格式文件保存,居然没有说是php5.4版本的问题
另外一种方法:
在include/helpers/util.helper.php末尾加入以下代码

function fix_session_register(){  
  function session_register(){  
    $args = func_get_args();  
    foreach ($args as $key){  
      $_SESSION[$key]=$GLOBALS[$key];  
    }  
  }  
  function session_is_registered($key){  
    return isset($_SESSION[$key]);  
  }  
  function session_unregister($key){  
    unset($_SESSION[$key]);  
  }  
}  
if (!function_exists('session_register')) fix_session_register(); 
Copy after login

这样php5.4下dedecms就能正常使用了,希望本文分享的两种方法都可以帮助大家顺利解决问题。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template