IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

Ftp Script Problems - Authentication Failure


beeseven
no avatar
Privileged Member
*********
Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



Post #1 post Mar 5 2005, 02:12 AM
I uploaded the code as a text file because it's pretty big:
http://beeseven.trap17.com/ftp.txt
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.
Go to the top of the page
+Quote Post
mobious
no avatar
Advanced Member
*******
Group: Members
Posts: 113
Joined: 14-January 05
From: Philippines
Member No.: 3,271



Post #2 post Mar 5 2005, 09:57 AM
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:

CODE
if (!ftp_login($ftpcon1, $username1, $password1)) }
   print "Could not login to remote host</BODY></HTML>";
}
Go to the top of the page
+Quote Post
stevey
no avatar
Advanced Member
*******
Group: Members
Posts: 119
Joined: 12-July 04
From: london
Member No.: 85



Post #3 post Mar 5 2005, 10:09 AM
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.
Go to the top of the page
+Quote Post
mobious
no avatar
Advanced Member
*******
Group: Members
Posts: 113
Joined: 14-January 05
From: Philippines
Member No.: 3,271



Post #4 post Mar 5 2005, 10:23 AM
QUOTE(stevey @ Mar 5 2005, 06:09 PM)
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.
[right][snapback]56414[/snapback][/right]


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.

CODE
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";
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No new   16 willmark 506 23rd October 2009 - 01:48 PM
Last post by: TheDarkHacker
No New Posts   5 Shibbeh 16,082 20th August 2004 - 10:04 PM
Last post by: ill
No New Posts   0 OpaQue 17,185 9th September 2004 - 08:40 AM
Last post by: OpaQue
No New Posts 4 zip_mc 13,284 22nd September 2009 - 10:26 AM
Last post by: akira550
No New Posts   4 stevey 10,207 16th August 2004 - 07:17 PM
Last post by: pr3dr49
No New Posts   9 shadowx 3,229 12th October 2009 - 07:12 PM
Last post by: manish-mohania
No New Posts   4 xmae 9,137 24th August 2006 - 03:21 PM
Last post by: juice
No New Posts   7 football123213 15,572 20th August 2004 - 12:25 AM
Last post by: ill
No new   15 -prodigy- 14,132 27th February 2005 - 10:22 PM
Last post by: alexia
No New Posts   2 -Pandemonium- 12,055 22nd August 2004 - 04:25 AM
Last post by: -Pandemonium-
No New Posts   8 -Pandemonium- 9,303 25th August 2004 - 04:00 PM
Last post by: -Pandemonium-
No New Posts   6 winflowers 9,043 11th September 2004 - 09:14 PM
Last post by: MSTR
No New Posts 4 spawn_syxx9 8,325 22nd September 2009 - 03:45 PM
Last post by: jlhaslip
No New Posts   0 Raptrex 7,103 6th September 2004 - 11:19 PM
Last post by: Raptrex
No New Posts   11 dozen 10,440 13th September 2004 - 07:26 PM
Last post by: melkonianarg


 



RSS Open Discussion Time is now: 8th November 2009 - 05:50 PM

Web Hosting Powered by ComputingHost.com.