找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 11405|回复: 0

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

[复制链接]
发表于 2014-8-9 11:03:07 | 显示全部楼层 |阅读模式
dedecms安装完成后会出现登陆后台空白,发布文章时提示”标题不能为空”。# l" v. T8 ~0 \5 x

" H$ t  u/ Y% m: Y8 i1 c1.解决dedecms登陆后台空白错误1 a% U  n3 {; _8 V
因为php5.5的版本废除了session_register,所以需要去掉session_register函数
% E3 C: q1 d+ l1 T# N0 Q' k# x+ m, ?. q. m
修改:“include/userlogin.class.php”,注释掉session_register,修改后如下2 p+ G# v, T' {" s$ E, k+ F2 A- _
//@session_register($this->keepUserIDTag);
0 E# P  V; w$ U# b$_SESSION[$this->keepUserIDTag] = $this->userID;
5 d+ a( n( j2 x9 f1 V6 U
9 l& a9 ^- I$ P, z, ]( k0 d// @session_register($this->keepUserTypeTag);: C/ }1 ]2 A5 a. U: Z/ O
$_SESSION[$this->keepUserTypeTag] = $this->userType;
* L; B% E2 U/ L& s  U4 [1 @$ A  s1 e: Y; s5 V- S. l  r% ^; s0 L
// @session_register($this->keepUserChannelTag);
7 h4 c% F- d: k( h' v3 x1 c" a2 b$_SESSION[$this->keepUserChannelTag] = $this->userChannel;
: c; U: s+ _' M5 r9 g( C6 A1 p5 ^9 y
+ O6 R" U- M7 v7 s- l5 p" D! S8 a" A// @session_register($this->keepUserNameTag);  N+ P' S+ Y' l2 I; T8 f* X
$_SESSION[$this->keepUserNameTag] = $this->userName;
# u0 [1 {: V' y/ S7 }( a) N( v' {5 ?1 R& p, k' M, W+ X* F7 [  k- f
// @session_register($this->keepUserPurviewTag);4 {+ k; o1 S& a# i% z& K9 Q# m
$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;8 b3 L- m4 b% T. V) y& e7 \' D2 s
  F' ]& K$ _0 }7 T" M! X- D
// @session_register($this->keepAdminStyleTag);& J* }& ^* J# ], k) o
$_SESSION[$this->keepAdminStyleTag] = $adminstyle;+ k: o" o* \% T
8 o* M9 {: g2 g' `8 g" D! E4 t
2.dedecms发布文章提示"标题不能为空"
0 Y9 N! G( M$ k* ^7 R: N
1 j1 |- y, d3 ]- ~4 y0 r现象是发布英文标题没问题,发布中文会提示“标题不能为空”3 ~9 U* q/ I# v3 S2 ^& i% n( K
因为htmlspecialchars在php5.4默认为utf8编码,
6 f+ y( N( q  y) ], c7 Z$ B+ Ugbk编码字符串经 htmlspecialchars 转义后的中文字符串为空,也就是标题为空。9 \! ]0 Y  e/ S
所以给htmlspecialchars添加ENT_COMPAT ,'GB2312'参数修改编码默认值。
- a; N% k4 j$ n9 d  \- }7 @! g
, c2 u  y: h# D' _& d具体方法:
" \: @" Z; [8 b1.在dede安装目录执行/ H; H. Z7 F* a% w" }
sed -i "s/htmlspecialchars(/gbkhtmlspecialchars(/g" `grep htmlspecialchars\( -rl *`
6 E% O7 M" h* G# D2 N1 P" K7 \9 W. R; u
2./include/common.func.php中任意位置添加函数& c/ O& ]) e- F% d$ o' ]( M

3 [5 w2 j* k; e+ N( S" a: Vfunction gbkhtmlspecialchars($str), j+ r- Y# h8 W' w. b, y" q2 F+ {; E
{. d/ m/ M/ P3 e: D4 N6 k* A
        return htmlspecialchars($str, ENT_COMPAT ,'ISO-8859-1');
" x. E8 C9 z: L+ h& ?5 I/ j8 o}6 A8 e) P+ j" l( ]: U& p
注意:使用了本文方法的就不用理会这篇文章了:http://bbs.swdyz.com/thread329sw1dyz1.shtml8 |/ h- l! g7 n& ~* g# A
4 }6 A. G! e7 W. e
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-9-9 03:19 , Processed in 0.064118 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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