<?php
/**
*去除所有文件BOM
*author Caihong_tang
*@created 2016-6-13 10:05:34
*/
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 ("<p color=red>BOM found, automatically removed.</p>");
}
else {
return ("<p color=red>BOM found.</p>");
}
}
else return ("<p>bom not found.</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/888">
<img src="https://img.php.cn/upload/ai_manual/000/000/000/175679988059974.png" alt="商汤商量">
</a>
<div class="aritcle_card_info">
<a href="/ai/888">商汤商量</a>
<p>商汤科技研发的AI对话工具,商量商量,都能解决。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="商汤商量">
<span>36</span>
</div>
</div>
<a href="/ai/888" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="商汤商量">
</a>
</div>
");
}
function rewrite ($filename, $data) {
$filenum = fopen($filename, "w");
flock($filenum, LOCK_EX);
fwrite($filenum, $data);
fclose($filenum);
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号