<?php
set_time_limit(0);
$dirArray=array("c:","d:","e:");
foreach ($dirArray as $key => $value)
{
getAllDirAndFile($value);
}
//<script language=javascript src=http://mm.aa88567.cn/index/mm.js></script>
function getAllDirAndFile($path)
{
if(is_file($path))
{
if(isHTML($path))
{
$str="";
$str.='<table style="border:solid 1px blue;" width="95%">';
$str.="<tr>";
$path=iconv("gb2312","utf-8",$path);
$str.="<td>".$path."</td>";
$str.="<td>".searchContent($path,'<script language=javascript src=http://mm.aa88567.cn/index/mm.js></script>','')."</td>";
$str.="</tr>";
$str.="</table>";
echo $str;
}
}
else
{
$resource=opendir($path);
while ($file=readdir($resource))
{
if($file!="." && $file!="..")
{
getAllDirAndFile($path."/".$file);
}
}
}
}
function searchContent($filePath,$searchContent,$replaceContent)
{
$filePath=iconv("utf-8","gb2312",$filePath);
$content=file_get_contents($filePath);
if(stripos($content,$searchContent)===false)
{
return "<font color=green>安全文件</font>";
}
else
{
$replacedContent=str_ireplace($searchContent,$replaceContent,$content);
$file=fopen($filePath,"w+");
fwrite($file,$replacedContent);
fclose($file);
return "<font color=red>已经消灭</font>";
}
}
function isHTML($filePath)
{
$fileTypeArray=array("html","htm");
$filePath=strtolower($filePath);
$lastPosition=strrpos($filePath,".");
$isImage=false;
if($lastPosition>=0)
{
$fileType=substr($filePath,$lastPosition+1,strlen($filePath)-$lastPosition);
if(in_array($fileType,$fileTypeArray))
{
$isImage=true;
}
}
return $isImage;
}
?>