edainworks.com :: VGR :: remotely testing FTP servers to see if they accept anonymous access.

Code :
//VGR20092003 Création
//
function FTPAcceptsAnonymousLogin($host) {
  $conn_id = @ftp_connect($host,21);
  if ($conn_id) {
    $retval=@ftp_login($conn_id,"anonymous", "user@domain.tld");
    ftp_close($conn_id);
  } else $retval=FALSE;
  return($retval);
} // FTPAcceptsAnonymousLogin($host) Boolean Function

$host='127.0.0.1';
echo "Host '$host' ".((FTPAcceptsAnonymousLogin($host))?'accepts':'does not accept').' anonymous FTP
'; // NO? $host='ftpperso.free.fr'; echo "Host '$host' ".((FTPAcceptsAnonymousLogin($host))?'accepts':'does not accept').' anonymous FTP
'; // NO $host='ftp.free.fr'; echo "Host '$host' ".((FTPAcceptsAnonymousLogin($host))?'accepts':'does not accept').' anonymous FTP
'; // YES
Run :
Host '127.0.0.1' does not accept anonymous FTP
Host 'ftpperso.free.fr' does not accept anonymous FTP
Host 'ftp.free.fr' accepts anonymous FTP

Vincent Graux (VGR) for European Experts Exchange and Edaìn Works  back to list of test scripts
Last update 2020-10-17 12:19:16