找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 10423|回复: 0

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

[复制链接]
发表于 2014-8-9 11:03:07 | 显示全部楼层 |阅读模式
dedecms安装完成后会出现登陆后台空白,发布文章时提示”标题不能为空”。
6 U9 j' r( ^- v& v
, P* E# ^( ]% B! C4 T6 o1.解决dedecms登陆后台空白错误7 M, {- G# P2 |& _! C
因为php5.5的版本废除了session_register,所以需要去掉session_register函数
7 N# m0 ]' s3 W2 a& T8 z
! t1 e# m' ~1 Z% {2 `5 j修改:“include/userlogin.class.php”,注释掉session_register,修改后如下
) I# a- A: u! f( M: G//@session_register($this->keepUserIDTag);2 c) N6 k  i" R3 g. ~
$_SESSION[$this->keepUserIDTag] = $this->userID;% Y2 Y1 ]. P6 V8 M
! c5 f1 G7 _( B0 v9 x  t
// @session_register($this->keepUserTypeTag);
( r5 {" r1 U7 ^" ?( t# _# R8 A$_SESSION[$this->keepUserTypeTag] = $this->userType;
) U4 {9 ]9 f2 `4 [! Y' x  w8 _3 C3 ]; x( [% [+ `
// @session_register($this->keepUserChannelTag);  H/ o1 M1 p  Y
$_SESSION[$this->keepUserChannelTag] = $this->userChannel;5 [7 x  F* u# F9 }5 f9 |& J* e

0 l' k4 h. w8 I( P" k/ r// @session_register($this->keepUserNameTag);
" a5 @# L, i7 h& Q$_SESSION[$this->keepUserNameTag] = $this->userName;% g3 H& C1 P! H2 _
) }, N) h. T: P/ i& ^
// @session_register($this->keepUserPurviewTag);5 y: H! ^2 {% h' O
$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;
8 X+ M1 |% j& z$ e' N; G% h3 I, H- x* @1 @; |$ _
// @session_register($this->keepAdminStyleTag);0 m4 u6 d7 w! r# ^
$_SESSION[$this->keepAdminStyleTag] = $adminstyle;/ G3 f' x/ C1 P# R/ V' Y8 Z" g
) M  N( g6 g$ q2 q5 w. {5 i
2.dedecms发布文章提示"标题不能为空"
% R0 `; F& Y$ D, H" @; {7 K* F& o. `9 }! ?( ~/ b- O. Z% T- \
现象是发布英文标题没问题,发布中文会提示“标题不能为空”
+ Z9 M( Q7 j1 ~* H  e+ u$ b2 v因为htmlspecialchars在php5.4默认为utf8编码,+ a5 e4 c3 e. a, G, Z2 G# c4 g4 Z
gbk编码字符串经 htmlspecialchars 转义后的中文字符串为空,也就是标题为空。  ]* z+ Z; ]5 L" s8 E. g. J
所以给htmlspecialchars添加ENT_COMPAT ,'GB2312'参数修改编码默认值。
" W9 M7 m8 u' i1 L
7 K4 _1 h/ O' \% `, \具体方法:
+ w3 N* l# y% m1.在dede安装目录执行
, [5 h. j9 t+ N; i8 T# bsed -i "s/htmlspecialchars(/gbkhtmlspecialchars(/g" `grep htmlspecialchars\( -rl *`
* R8 O$ g/ q$ ?" w- ?
0 c0 D, M5 S& N0 t4 }2./include/common.func.php中任意位置添加函数
3 T$ O6 S3 O3 x9 ?1 u* Q" B9 x( U" V7 E2 x1 G
function gbkhtmlspecialchars($str)
- C& F3 U; ^0 V0 h- l0 P{
8 L9 g' e/ _( J* r7 O# S, w9 J        return htmlspecialchars($str, ENT_COMPAT ,'ISO-8859-1');, S8 Y9 U# b0 d( Z, J4 x5 C7 y
}
, ]" l4 I. s% p) F# W+ u- o) H注意:使用了本文方法的就不用理会这篇文章了:http://bbs.swdyz.com/thread329sw1dyz1.shtml
8 V& X' N1 p. U, e4 Z9 L  {9 y% F
0 m8 k& w5 ^, g+ ?5 U! L* L
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-4-4 18:40 , Processed in 0.066827 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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