Hi,
PHP offers very good functions to manipulate local system directories. However, I'd like to manipulate
remote directories. In other word, for example,
http://www.geocities.com/said_fox/ "said_fox" is regarded as a remote directory. I want to know
How can I know the number of its files. There are so many programs that able to do this functionality,
such as httrack webcopier, frontpage, etc.
The following code, That I have coded, do this functionality so well, but locally:
<?
//Check if the form submited or not
if($_REQUEST['term'])
{//It is submited
//So start search
$dir = "./"; //the current diretory
$dh = opendir($dir);
$found = 0;
$c = 0;
while($fn = readdir($dh) !== false)
{
$c ++;
}
rewinddir($dh);
for ($i = 0; $i < $c; $i++)
{
$fn = readdir($dh);
$mfh = $dir.$fn;
if (is_dir($mfh)) continue 1;
$fh = fopen($mfh,"r");
$data = fread($fh,filesize($mfh));// or die ("Couldnot able read ".$mfh);
if(strpos($data,$_REQUEST['term'])){
echo "<a href=\"".$dir.$fn."\">".$fn."</a><br>";
$found++;
}
fclose($fh);
}
closedir($dh);
echo "<hr>".$found." File(s) were found from ".$c;
echo " <a href=\"".$_SERVER['PHP_SELF']."\">TRY AGAIN</a>";
}
else
{//Draw the form
?>
<form action="<?=$_SERVER['PHP_SELF']?>">
Insert The Search Term<input type="text" name="term">
<input type="submit">
</form>
<?}
?>
So How Can I do the same but remotely!?