<?php/* detects and clears bom*/if (Isset ($_get[' dir ')) {$basedir =$_get[' dir '];} else{$basedir = '. ';} $auto = 1;checkdir ($basedir), function Checkdir ($basedir) {if ($dh = Opendir ($basedir)) {while ($file = Readdir ($d h))!== false) {if ($file! = '. ' && $file! = ' ... ') {if (!is_dir ($basedir. ") /". $file)" {echo "filename: $basedir/$file". Checkbom ("$basedir/$file"). "<br>"; }else{$dirname = $basedir. " /". $file; Checkdir ($dirname); }}}//end while Closedir ($DH); }//end if ($dh}//end functionfunction 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.</font>"; }else{return ("<font Color=red>bom found.</font>"); }} else return ("BOM not Found.");} End Functionfunction Rewrite ($filename, $data) {$filenum = fopen ($filename, "w"); Flock ($filenum, LOCK_EX); Fwrite ($filenum, $data); Fclose ($filenum);} End Function?>
Check php files for PHP functions that contain BOMs