找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 10027|回复: 0

dedecms(织梦)发布文章提示"标题不能为空"及与php5.5兼容问题的解决

[复制链接]
发表于 2014-8-9 11:03:07 | 显示全部楼层 |阅读模式
dedecms安装完成后会出现登陆后台空白,发布文章时提示”标题不能为空”。
( H/ M8 L+ W2 ^5 \& a3 }
6 p; ^! M& f  l4 I$ p1.解决dedecms登陆后台空白错误
0 n( B% B' i, ~# O* G& _0 K因为php5.5的版本废除了session_register,所以需要去掉session_register函数3 s0 `8 ^( t* X6 C7 x2 V
# o7 m, W: d( {" g% T5 M
修改:“include/userlogin.class.php”,注释掉session_register,修改后如下8 S  s# T7 \2 F
//@session_register($this->keepUserIDTag);0 x7 s' h9 k$ j4 c$ t* w
$_SESSION[$this->keepUserIDTag] = $this->userID;
: ]; `& x2 |# T9 u" Z7 S2 z
% U) f- g8 K; W6 W7 z5 v// @session_register($this->keepUserTypeTag);
! ~( q) b7 P$ _1 I$_SESSION[$this->keepUserTypeTag] = $this->userType;+ ^2 Z* X6 E" y: ^

. U' P- y+ v2 t* {0 }  t// @session_register($this->keepUserChannelTag);% _/ Y, n7 I6 \6 ^1 }+ r; D6 e$ b
$_SESSION[$this->keepUserChannelTag] = $this->userChannel;
5 G* R1 k0 z1 u: H7 f* }. s3 O6 T/ M8 e( c, H
// @session_register($this->keepUserNameTag);
& j7 u* _9 x' q- d6 M$_SESSION[$this->keepUserNameTag] = $this->userName;
/ @& N5 C; i+ z) a1 S: Z7 o* g0 w6 s! O( |9 r% C
// @session_register($this->keepUserPurviewTag);0 D) Y+ X$ p6 s5 K
$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;7 p+ n  D5 Z7 B3 e

7 Y, V2 z$ h" X% i8 I8 G1 `// @session_register($this->keepAdminStyleTag);
2 U& W7 Q# T2 w/ h1 c$_SESSION[$this->keepAdminStyleTag] = $adminstyle;1 }) M% t* J1 [. w5 j+ T7 t0 B) A' e

' L8 y+ T9 B0 u  M% G2.dedecms发布文章提示"标题不能为空"
& k2 y! ]7 ]  u7 s% r' F- {  h% F; r0 k/ f! O
现象是发布英文标题没问题,发布中文会提示“标题不能为空”* n: X$ M) d% y
因为htmlspecialchars在php5.4默认为utf8编码,. t$ }  r, F. c
gbk编码字符串经 htmlspecialchars 转义后的中文字符串为空,也就是标题为空。
- z6 l2 t; M" ]: m$ u9 Z所以给htmlspecialchars添加ENT_COMPAT ,'GB2312'参数修改编码默认值。- t% Z& Z6 W: G

$ }* q) T$ c+ E* p: H, o具体方法:2 e) B' n) ]) U9 V3 Z6 \
1.在dede安装目录执行9 q& C" ?( S  p8 ~5 P8 F6 e
sed -i "s/htmlspecialchars(/gbkhtmlspecialchars(/g" `grep htmlspecialchars\( -rl *`
9 W$ {. ~; S4 `" ]' K9 v8 |' g. Z0 `7 M1 B8 m" w$ l, U) |) v
2./include/common.func.php中任意位置添加函数
* {9 M$ B6 c+ `& s) g. T, F3 @, D
function gbkhtmlspecialchars($str)7 ^8 i) K3 z% {/ M$ a5 [1 |
{
7 \  [' Q2 m0 A: {# S5 ~9 n        return htmlspecialchars($str, ENT_COMPAT ,'ISO-8859-1');
7 ~$ _. ?0 p- j# ]3 k( u4 R& P* ~0 Z}, `2 U0 {2 x. D& E
注意:使用了本文方法的就不用理会这篇文章了:http://bbs.swdyz.com/thread329sw1dyz1.shtml
) B4 ?% _  G  I; c% Z7 ~7 ~  z  X! Z" C) N0 _/ S2 i
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|第一站论坛 ( 蜀ICP备06004864号-6 )

GMT+8, 2026-2-7 04:02 , Processed in 0.048865 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表