I have a function that is supposed to return "good" or "bad" if FTP credentials are working or not. Problem is:
1. It takes a rather long time and sometimes times out or something, causing it to break my page.
2. If it produces any sort of error, it displays the full error rather than the ones I created.
Is there a better way to do this, especially if I wanted to do like 20 on the same page?
1. It takes a rather long time and sometimes times out or something, causing it to break my page.
2. If it produces any sort of error, it displays the full error rather than the ones I created.
Code:
function checkFTP($ftp_server, $ftp_user, $ftp_pass){
if(strstr($ftp_server,"http")){
$ftp_server = str_replace("[URL unfurl="true"]http://","",$ftp_server);[/URL]
$ftp_server = str_replace("[URL unfurl="true"]https://","",$ftp_server);[/URL]
}
if(strstr($ftp_server,"[URL unfurl="true"]www.")){[/URL]
$ftp_server = str_replace("[URL unfurl="true"]www.","",$ftp_server);[/URL]
}
$ftp_conn = ftp_connect($ftp_server) or die('<span class="bad"><strong>Negative</strong> - bad host/domain name</span>');
if(!ftp_login($ftp_conn, $ftp_user, $ftp_pass)){
echo '<span class="bad"><strong>Negative</strong> - invalid login credentials</span>';
die();
} else {
echo '<span class="good">Affirmative</span>';
}
ftp_close($ftp_conn);
}