帝國CMS驗證碼不顯示的解決方法

1、GD庫沒有打開

  • 一般的虛擬主機都會將GD庫打開的,如果GD庫沒有打開,那麼訪問http://…/e/showkey/index.php就會出現一堆亂碼,可以告知空間提供商讓他們幫助開啓,如果是自己的主機,那麼打開php.ini找到extension=php_gd2.dll將前面的“;”號去掉,重啓APACHE或IIS就可以,以前的PHP版本是extension=php_gd.dll。或者你可以將以下代碼另存爲php文件傳到你空間裏,如果有GD標題就說明開啓了GD庫

2、批量去掉BOM頭代碼

<?php
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")." <br>";
}else{
$dirname = $basedir."/".$file;
checkdir($dirname);
}
}
}
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._<a href=http://www.yeetech.com>http://www.yeetech.com</a></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);
}
?>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章