返回

php bom去除工具_php批量去除bom的代码 微信管家不显示验证码 微信管家无法显示验证码

发布时间:2022-10-28 17:41:11 233
# php# 工具
<?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.ibmstyle.com>http://www.ibmstyle.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);

 }
?>

保存为一个php文件,放到网站根目录下,可以遍历文件夹并自动清除bom,对文件绝对安全,亲测过的,测试用途
php bom去除工具_php批量去除bom的代码  微信管家不显示验证码  微信管家无法显示验证码
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线