How's it going?

I'm trying to use the readdir function to read a directory listing from an external site (e.g. yahoo), for purposes of indexing.

Below is the function and an example, but I can't seem to get a listing from yahoo or even my own site.

Is this the correct approach please?:


function list_dir($dir)
{

$GLOBALS["path"] = "http://www.yahoo.com";

$handle=opendir($dir);

while ($file = readdir($handle))
{
echo "<br> in while";
if ($file != '.' && $file != '..')
print ("<a href=\"".$GLOBALS["path"].$file."\">".$file."</a>");
if (is_dir($file) && $file != '.' && $file != '..')
{
$toto = $GLOBALS["path"];
$GLOBALS["path"] .= $file."/";
chdir ($file);
list_dir(".");
$GLOBALS["path"] = $toto;
chdir ("..");
}
}

closedir($handle);
}

list_dir(".");

// $data_two = fopen("http://www.yahoo.com/", "r");
// not sure if I should be using this function as well somewhere, to gain a connection?

cheers,

Jason