Jump to content
xisto Community
Sign in to follow this  
beeseven

Ftp Script Problems - Authentication Failure

Recommended Posts

I uploaded the code as a text file because it's pretty big:

http://forums.xisto.com/no_longer_exists/

As I said it can't login. I get this error:

Warning: ftp_login(): Authentication failed, sorry in /home/beeseven/public_html/ftp.php on line 45

I think it might have something to do with character encoding, but I'm not sure. If you think it is, what kind of encoding would work as if I typed it directly? I tried putting it in the file, but then I got the missing required fields error.

Share this post


Link to post
Share on other sites

it's just what was displayed. just check your username and password. you should also change how you write your code for logging in. use this:

if (!ftp_login($ftpcon1, $username1, $password1)) }    print "Could not login to remote host</BODY></HTML>";}

Share this post


Link to post
Share on other sites

you should also chekc your ftp server most of the ftp connections that fail in my scripts are usually as a result of a failure in the ftp server.

Share this post


Link to post
Share on other sites

you should also chekc your ftp server most of the ftp connections that fail in my scripts are usually as a result of a failure in the ftp server.

56414[/snapback]


yes that's the common problem. but imo, it's his username and password. the warning came from ftp_login() which is after ftp_connect(). so he successfuly connected to his server but cannot login due to wrong username or password. it may be because it is using ftp through proxy authentication. ftp_login() has no support for it but i found a script for it.

 

function ftp_parse_response($response, &$errstr) {   if(!is_array($response)) {       $errstr    = 'Parameter \$response must be an array';        return false;   }          foreach($response as $r) {       $code    = substr(trim($r),0,3);       if(!is_numeric($code)) {           $errstr    = "$code is not a valid FTP code",$code);       }                  if($code > 400) {           $errstr    = $r;           return false;       }   }          return true;}$user = "user";$pass = "password";$host = "ftp.example.com";$proxyuser = "proxyuser";$proxypass = "proxypass";$proxyhost = "ftp.proxy.com";$conn_id = ftp_connect($proxyhost);if(!$conn_id) {   die("cannot connect to proxy");}$commands  = array(   "USER ".$user."@".$host." ".$proxyuser,   "PASS ".$pass,   "PASS ".$proxypass);foreach($commands as $c) {   $ret    = ftp_raw($conn_id,$c);   //you can write your own ftp_parse_response func that    //use an array of string as input   if(!ftp_parse_response($ret,$errstr)) {       ftp_close($conn_id);       die("cannot login to $host");   }}echo "ok, now connected";

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.