thinkphp验证码不现实多半是bom惹的祸

thinkphp 验证码不现实多半是bom惹的祸,下面是驱除bom的代码:

链接:https://pan.baidu.com/s/1v5gm7n0L7TGyejCmQrMh2g 提取码:x2p5

免费分享,但是X度限制严重,如若链接失效点击链接或搜索加群 群号518475424

    1. if (isset($_GET['dir'])){ //设置文件目录  
    2. $basedir=$_GET['dir'];  
    3. }else{  
    4. $basedir = '.';  
    5. }  
    6. $auto = 1;  
    7. checkdir($basedir);  
    8. function checkdir($basedir){  
    9. if ($dh = opendir($basedir)) {  
    10.   while (($file = readdir($dh)) !== false) {  
    11.    if ($file != '.' && $file != '..'){  
    12.     if (!is_dir($basedir."/".$file)) {  
    13.      echo "filename: $basedir/$file ".checkBOM("$basedir/$file").
      ";  
    14.     }else{  
    15.      $dirname = $basedir."/".$file;  
    16.      checkdir($dirname);  
    17.     }  
    18.    }  
    19.   }  
    20. closedir($dh);  
    21. }  
    22. }  
    23. function checkBOM ($filename) {  
    24. global $auto;  
    25. $contents = file_get_contents($filename);  
    26. $charset[1] = substr($contents, 0, 1);  
    27. $charset[2] = substr($contents, 1, 1);  
    28. $charset[3] = substr($contents, 2, 1);  
    29. if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {  
    30.   if ($auto == 1) {  
    31.    $rest = substr($contents, 3);  
    32.    rewrite ($filename, $rest);  
    33.    return ("BOM found, automatically removed._http://www.phpfensi.com");  
    34.   } else {  
    35.    return ("BOM found.");  
    36.   }  
    37. }  
    38. else return ("BOM Not Found.");  
    39. }  
    40. function rewrite ($filename, $data) {  
    41. $filenum = fopen($filename, "w");  
    42. flock($filenum, LOCK_EX);  
    43. fwrite($filenum, $data);  
    44. fclose($filenum);  
    45. }  
    46. ?> 
原文地址:https://www.cnblogs.com/it-3327/p/11734965.html