|
使用织梦dede也很长一段时间了,可是今天遇到一个问题就是验证码不显示,我网上找了很多资料,几乎全都是说权限和GD库的问题。 可是按照这些方法试过后,验证码仍然不能显示。 后来想到以前做网站的时候遇到一个UTF-8编码的BOM问题。于是就去网上找了段代码,去掉了整个网站文件的BOM。 去掉后验证码还真显示了。 试分析了一下原因,可能是因为BOM会产生一个空行的输出。导致生成验证码的时候会产生错误,所以不能显示。 批量去除BOM的方法:将以下代码保存为PHP文件,通过浏览器进行访问即可。 //remove the utf-8 boms //by magicbug at gmail dot com if (isset($_GET['dir'])){ //要去除的文件目录,无参数则为文件当前目录。 $basedir=$_GET['dir']; }else{ $basedir = ‘.’; } $auto = 1; checkdir($basedir); function checkdir($basedir){ if ($dh = opendir($basedir)) { while (($file = readdir($dh)) !== false) { if ($file != ‘.’ && $file != ‘..’){ if (!is_dir($basedir.”/”.$file)) { echo “filename: $basedir/ $file “.checkBOM(“$basedir/$file”).” }else{ $dirname = $basedir.”/”. $file; checkdir($dirname); } } } closedir($dh); function checkBOM ($filename) { global $auto; $contents = file_get_contents($filename); $charset[1] = substr($contents,1); $charset[2] = substr($contents,1,宋体; font-size: 16px; line-height: 26px;">$charset[3] = substr($contents,2,宋体; font-size: 16px; line-height: 26px;">if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) { if ($auto == 1) { $rest = substr($contents,3); rewrite ($filename,$rest); return (“automatically removed. } else { return (“else return (“BOM Not Found.”); function rewrite ($filename,$data) { $filenum = fopen($filename,“w”); flock($filenum,LOCK_EX); fwrite($filenum,$data); fclose($filenum); ?> (编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|