<?php <br />
if (isset($_GET['dir'])){ //设置文件目录 <br>
$basedir=$_GET['dir']; <br>
}else{ <br>
$basedir = '.'; <br>
} <br>
$auto = 1; <br>
checkdir($basedir); <br>
function checkdir($basedir){ <br>
if ($dh = opendir($basedir)) { <br>
while (($file = readdir($dh)) !== false) { <br>
if ($file != '.' && $file != '..'){ <br>
if (!is_dir($basedir."/".$file)) { <br>
echo "filename: $basedir/$file ".checkBOM("$basedir/$file")." <br>"; <br>
}else{ <br>
$dirname = $basedir."/".$file; <br>
checkdir($dirname); <br>
} <br>
} <br>
} <br>
closedir($dh); <br>
} <br>
} <br>
function checkBOM ($filename) { <br>
global $auto; <br>
$contents = file_get_contents($filename); <br>
$charset[1] = substr($contents, 0, 1); <br>
$charset[2] = substr($contents, 1, 1); <br>
$charset[3] = substr($contents, 2, 1); <br>
if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) { <br>
if ($auto == 1) { <br>
$rest = substr($contents, 3); <br>
rewrite ($filename, $rest); <br>
return ("<font>BOM found, automatically removed._<a>http://www.k686.com</a></font>"); <br>
} else { <br>
return ("<font>BOM found.</font>"); <br>
} <br>
} <br>
else return ("BOM Not Found."); <br>
} <br>
function rewrite ($filename, $data) { <br>
$filenum = fopen($filename, "w"); <br>
flock($filenum, LOCK_EX); <br>
fwrite($filenum, $data); <br>
fclose($filenum); <br>
} <br>
?>
AD:真正免费,域名+虚机+企业邮箱=0元