Hi--
I went into the process of trying to make a ftp connecting script (part of a main project to index the files on ftp servers) because the FTP function didn't seem to work well.
I also installed php5 on my laptop to try a new function (forgot what it was now) but that gave me problems as well...
So... In the below script you can see that I'm trying to login to a ftp server(using sockets):
<?
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
$connection = socket_connect($socket,'localhost',21);
while($new = socket_read($socket,5024))
{
print $data;
flush();
ob_flush();
$data = "$data" . "$new";
if (substr_count($data, '220') > 0) { //If username is asked
socket_write($socket,"USER anonymous");
print "USER anonymous";
flush();
ob_flush();
}
if (substr_count($data, '331') > 0) { //If pass is asked
socket_write($socket,"PASS anonymous");
}
if (substr_count($data, '230') > 0) { /When login complete
socket_write($socket,"LIST"); //Ask for dir listing
}
}
?>
But, I only see the first server reply (code 220), then the script just times out...
But why? 🙁