欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

DedeCMS后台,页面无显示 ,后台页面空白

程序员文章站 2022-05-01 12:57:17
...
想试试织梦的产品,下载了DedeCMS V5.7版本,在本地部署后,正确登录后台的情况下页面没有任何输出和显示(错误登录或密码错误时才有显示),也没有报错。进到脚本调试,发现问题出在登录页login.php中以下部分。login.php

[php] view plaincopy

  1. ...
  2. $cuserLogin = new userLogin($admindir);
  3. if(!empty($userid) && !empty($pwd))
  4. {
  5. $res = $cuserLogin->checkUser($userid,$pwd);
  6. //success
  7. if($res==1)
  8. {
  9. $cuserLogin->keepUser();//此处以下无输出
  10. if(!empty($gotopage))
  11. {
  12. ShowMsg('成功登录,正在转向管理管理主页!',$gotopage);
  13. exit();
  14. }
  15. else
  16. {
  17. ShowMsg('成功登录,正在转向管理管理主页!',"index.php");
  18. exit();
  19. }
  20. echo "ok";
  21. }
  22. ...

DedeCMS后台,页面无显示 ,后台页面空白到封装userLogin类所在的脚本userlogin.class.php中查看(路径./include/),所用的keepUser()方法代码如下:userlogin.class.php

[php] view plaincopy

  1. ...
  2. function keepUser()
  3. {
  4. if($this->userID != '' && $this->userType != '')
  5. {
  6. global $admincachefile,$adminstyle;
  7. if(empty($adminstyle)) $adminstyle = 'dedecms';
  8. @session_register($this->keepUserIDTag);
  9. $_SESSION[$this->keepUserIDTag] = $this->userID;
  10. @session_register($this->keepUserTypeTag);
  11. $_SESSION[$this->keepUserTypeTag] = $this->userType;
  12. @session_register($this->keepUserChannelTag);
  13. $_SESSION[$this->keepUserChannelTag] = $this->userChannel;
  14. @session_register($this->keepUserNameTag);
  15. $_SESSION[$this->keepUserNameTag] = $this->userName;
  16. @session_register($this->keepUserPurviewTag);
  17. $_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
  18. @session_register($this->keepAdminStyleTag);
  19. $_SESSION[$this->keepAdminStyleTag] = $adminstyle;
  20. PutCookie('DedeUserID', $this->userID, 3600 * 24, '/');
  21. PutCookie('DedeLoginTime', time(), 3600 * 24, '/');
  22. $this->ReWriteAdminChannel();
  23. return 1;
  24. }
  25. else
  26. {
  27. return -1;
  28. }
  29. }

把@去掉,session_register()报出错误:
Call to undefined function session_register()
证实了问题来源于此。查手册的描述如下:
"版本:(PHP 4, PHP 5 "本函数已自 PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除。"查看手册session_register()在PHP5.4后来的版本中已经多余,可以省去而直接用$_SESSION['abc'] ="" ;
查看Stack Overflow关于此方法的问题。
解决方法:去掉或注释掉所有的session_register(),改用直接存$_SESSION数组。keepUser()部分

[php] view plaincopy

  1. ...
  2. //session_register($this->keepUserIDTag);
  3. $_SESSION[$this->keepUserIDTag] = $this->userID;
  4. //session_register($this->keepUserTypeTag);
  5. $_SESSION[$this->keepUserTypeTag] = $this->userType;
  6. //session_register($this->keepUserChannelTag);
  7. $_SESSION[$this->keepUserChannelTag] = $this->userChannel;
  8. //session_register($this->keepUserNameTag);
  9. $_SESSION[$this->keepUserNameTag] = $this->userName;
  10. //session_register($this->keepUserPurviewTag);
  11. $_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
  12. //session_register($this->keepAdminStyleTag);
  13. $_SESSION[$this->keepAdminStyleTag] = $adminstyle;
  14. ...

修改后就正常显示了。我是从织梦主页上下载的"最新"版本,很奇怪难道没有人遇到同样的问题吗。这种问题既然这里能出现,别的部分就无法保证不会有更多这样的隐患存在了。

以上就介绍了DedeCMS后台,页面无显示 ,后台页面空白,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。