<?
$file_list=$_GET['file_list'];
$file_to_check=$_GET['file_to_check'];
$refering_file_list=array();
$list_of_files=file($file_list);
for($count=0;$count<count($list_of_files);$count++)
{
$current_directory=$_SERVER["DOCUMENT_ROOT"].'/';
$name=trim(str_replace('http://'.$_SERVER['SERVER_NAME'].'/',$current_directory,$list_of_files[$count]));
$file_contents = "";
if ($handle = @fopen($name,'r',true)) {
while (!feof($handle))
{
$part = fread($handle, 1024);
$file_contents .= $part;
//if (eregi("</head>", $part)) break;
}
$file_name=substr($file_to_check,strrpos($file_to_check,'/')+1);
if(strpos($file_contents,$file_name))$refering_file_list[]=$list_of_files[$count];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bottom</title>
</head>
<body>
<?
if(isset($_GET['file_list']))
{
echo '<h3>List of referring files</h3><br/>';
for($count=0;$count<count($refering_file_list);$count++)
{
echo("<a href='".$refering_file_list[$count]."'>$refering_file_list[$count]</a><br/>");
}
}
?>
</body>
</html>
|