今天更新dede到最新版5.6,结果出现登陆不了后台出现Warning: – headers already sent by………(省略)的错误,看着这个错误一把爪的啊,谷歌了下,很多提问的但没有答案,最好终于在博客http://www.lzpnb.com/archives/719 中发现解决办法,原来这是一个典型的编码错误原因是相关PHP文件中含有多余的BOM信息,但笔者写的不是很详细,这里我再啰嗦几句:

解决方法 :

这里以dedecmsV5.6为例 :找到inculude文件夹下的channelunit.func.php文件(不同版本文件名不同,反正都是在一个目录下),在首部加入以下代码:加入后执行http://……../include/channelunit.func.php 省略部分为你的网站地址,然后即可登陆,重要的是,能登陆后,再找到channelunit.func.php删除刚加入的代码,不然无法生成主页。此代码的作用只是删除多余的BOM,若你了解dede也可手动删除,在文件channelunit.func.php  中和common.inc.php中均有,删除即可O(∩_∩)O~

<?php
//此文件用于快速测试UTF8编码的文件是不是加了BOM,并可自动移除
//By Bob Shen
 
$basedir="."; //修改此行为需要检测的目录,点表示当前目录
$auto=1; //是否自动移除发现的BOM信息。1为是,0为否。
 
//以下不用改动
 
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file!='.' && $file!='..' && !is_dir($basedir."/".$file)) echo "filename: $file ".checkBOM("$basedir/$file")."
";
}
closedir($dh);
}
 
function checkBOM ($filename) {
global $auto;
$contents=file_get_contents($filename);
$charset[1]=substr($contents, 0, 1);
$charset[2]=substr($contents, 1, 1);
$charset[3]=substr($contents, 2, 1);
if (ord($charset[1])==239 && ord($charset[2])==187 && ord($charset[3])==191) {
if ($auto==1) {
$rest=substr($contents, 3);
rewrite ($filename, $rest);
return ("<font color=red>BOM found, automatically removed.</font>");
} else {
return ("<font color=red>BOM found.</font>");
}
}
else return ("BOM Not Found.");
}
 
function rewrite ($filename, $data) {
$filenum=fopen($filename,"w");
flock($filenum,LOCK_EX);
fwrite($filenum,$data);
fclose($filenum);
}
?>

本文地址:更新dedecms5.6后出现Cannot modify header information错误

与他有一腿的文章:

TAG标签:, , ,

暂无留言我要留言 »

必填

必填,绝不公开

Spam Protection by WP-SpamFree