I'm trying to log into my ftp and delete all files in the anonymous account.
But it keeps failing !!
Any ideas ?? The username is anonymous and the password is BLANK.
$fp = fsockopen ("$ip_address", 21, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "user anonymous\n");
echo fgets($fp,1024);
fputs ($fp, "pass \n");
echo fgets ($fp,1024);
fputs ($fp, "prompt \n");
echo fgets ($fp,1024);
fputs ($fp, "mdelete *.gz\n");
echo fgets ($fp,1024);
fclose ($fp);
}
ftp from a terminal or command prompt works fine and I can disable the prompt and run mdelete *
Alternatively this works but VERY slow:
function EmptyDir($dir) {
$handle=opendir($dir);
while (($file = readdir($handle))!==false) {
@unlink($dir.'/'.$file);
}
closedir($handle);
}
EmptyDir("ftp://$ip_address");
Any Ideas ???
Thanks 🙂