There are questions remain, We'll search for the answers together. But one thing we known for sure,the future is not set!

【原创文章】升级PHP5.4后dede和帝国发表文章中文标题和内容不识别的解决办法

dedecms 百蔬君 4158℃ 已收录 0评论

最近没事,想更新几个老站,不成想,一堆一堆的错误,就是中文不识别,如果标题有中文,不好意思,不认得,如果文章内容是中文,不好意思,全是空白,哎,这都是以前用gbk版本网站系统惹的祸。

记录一下修改的几个文件。

一,dedecms,升级php后。

dede/article_add.php 和 dede/article_edit.php

$title = htmlspecialchars(cn_substrR($title,$cfg_title_maxlen));
改成
$title = htmlspecialchars(cn_substrR($title,$cfg_title_maxlen),ENT_COMPAT ,’GB2312′);

而我的那个站因为版本更高级原因是修改include/common.func.php

function dede_htmlspecialchars($str) {
global $cfg_soft_lang;
if (version_compare(PHP_VERSION, ‘5.4.0’, ‘<‘)) return htmlspecialchars($str);
if ($cfg_soft_lang==’gb2312′) return htmlspecialchars($str,ENT_COMPAT,’ISO-8859-1′);
else return htmlspecialchars($str);
}

加了一个判断是不是5.4.

有的还需要修改include/ckeditor/ckeditor_php5.php

htmlspecialchars($value)
替换为
htmlspecialchars($value, ENT_COMPAT ,’GB2312′)

 

反正都是htmlspecialchars惹的祸。

2,帝国的下载站程序。

当打开文章编辑页面,无法显示中文的时候,需要修改

您的网站后台/AddSoft.php
把 $softsay=htmlspecialchars($r[softsay]);
修改为
$softsay=htmlspecialchars($r[softsay],ENT_COMPAT ,’GB2312’);

当标题为中文时无法提交文章的时候,需要修改class/infofun.php把
$add[‘softname’]=htmlspecialchars($add[‘softname’]);

修改为
$add[‘softname’]=htmlspecialchars($add[‘softname’],ENT_COMPAT ,’GB2312′);

 

好了,自己mark一下,老了记不住

 

 

转载请注明:百蔬君 » 【原创文章】升级PHP5.4后dede和帝国发表文章中文标题和内容不识别的解决办法

喜欢 (2)or分享 (0)
发表我的评论
取消评论

请证明您不是机器人(^v^):

表情