DEDECMS中文注册会员无法打开空间的解决方法

2019-10-23,,

解决中文注册的会员空间打不开问题 

 

这个问题我也很苦恼,不过还是被解决了。大家分享下哈。 

 

其实说到底还是个字符编码转换问题。 

 

因为汉字没有在判断uid值时出现了错误,导致系统无法识别用户,所以发生了“你访问的用户可能已经被删除!”错误 

 

方法是 

在“member\config.php”文件的最后,PHP结束之前添加 isUTF8($str)函数 

 

function isUTF8($str){ 

$length=strlen($str); 

for($i=0;$i<$length;$i++){ 

$high=ord($str{$i}); 

if(($high==0xC0)||($high==0xC1)){ 

return false; 

}elseif($high<0x80){ 

continue; 

}elseif($high<0xC0){ 

return false; 

}elseif($high<0xE0){ 

if(++$i>=$length) 

return true; 

elseif(($str{$i}&"\xC0")=="\x80") 

continue; 

}elseif($high<0xF0){ 

if(++$i>=$length){ 

return true; 

}elseif(($str{$i}&"\xC0")=="\x80"){ 

if(++$i>=$length) 

return true; 

elseif(($str{$i}&"\xC0")=="\x80") 

continue; 

}elseif($high<0xF5){ 

if(++$i>=$length){ 

return true; 

}elseif(($str{$i}&"\xC0")=="\x80"){ 

if(++$i>=$length){ 

return true; 

}elseif(($str{$i}&"\xC0")=="\x80"){ 

if(++$i>=$length) 

return true; 

elseif(($str{$i}&"\xC0")=="\x80") 

continue; 

return false; 

return true; 

 

然后修改“member\index.php”中的代码:将 

$tmpstr = @gb2utf8($uid); 

$tmpstr2 = @utf82gb($tmpstr); 

if($tmpstr2==$uid) $uid = $tmpstr; 

修改为 

if(!isUTF8($uid)) $uid = @gb2utf8($uid); 

 

问题解决。

《DEDECMS中文注册会员无法打开空间的解决方法.doc》

下载本文的Word格式文档,以方便收藏与打印。