关于ThinkCMF后台验证码不显示

最近小凯在群里看到好多同学们遇到一个头疼的问题,程序在本地调试好了之后上传服务器,后台的验证码就会不显示,今天三群的  【江苏  冰点零度 php】 同学遇到了这个问题。

开始小凯以为是GB库出来问题 因为之前有个同学利用万网的空间 没有打开GB库 导致了不显示。

 

【常州-Qy-电脑】同学解答了这个问题 这里需要一个附件 

代码如下

<?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.</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);  
}  
?>

把此代码命名为xiaokai.php 上传到根目录打开http://你的网址/xiaokai.php,然后刷新后台即可恢复正常

posted @ 2019-07-24 10:02  诩小贝  阅读(720)  评论(0编辑  收藏  举报
Copyright ©2016 诩小贝   联系QQ:980823367