php框架

 首页 > php框架 > ThinkPHP > thinkphp 验证码不现实多半是bom惹的祸 - Thinkphp

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

分享到:
【字体:
导读:
          thinkphp 验证码不现实多半是bom惹的祸,下面是驱除bom的代码:?phpif(isset($_GET[ 39;dir 39;])){ 设置文件目录$basedir=$_GET[ 39;d...

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

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

  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. ?>  
分享到:
关于ThinKPhP验证码,“图像因其本身有错...
关于ThinKPhP验证码,“图像因其本身有错无法显示”的错误 鉴于自己的经验,如果说“浏览器显示“图像XXX因其本身有错无法显示”,可尽量去掉文中空格”. 但是,现在的问题是把代码中所有空格都去掉了还是不能显示检验图片(深度google,大部分的解决方案也是将文件前的空格回车一切都删掉以防...
ThinkPHP的模板引擎如何才能达到最棒的效...
ThinkPHP的模板引擎如何才能达到最棒的效率 默认情况下ThinkPHP框架系统默认使用的模板引擎是内置模板引擎,内置模板引擎支持模板文件中采用php原生态代码和模板标签的混合使用. ThinkPHP官方开发文档说,这种默认的内置模板引擎的性能是高效的,但还不是最佳的,要使模板引擎的性能达到最佳效...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……