Solved

Login script

Posted on 2006-07-14
5
203 Views
Last Modified: 2008-03-17
Hi guys,

i have this ftp login script on my website. It works just fine. One little problem is that when I enter @ in either name or password it doesn't work. Any ideas?

<?php
$ftp_server = "server.com";
$ftp_user = $_REQUEST['log'];
$ftp_pass = $_REQUEST['pass'];

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Error!");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
   header("Location: ftp://".$ftp_user.":".$ftp_pass."@".$ftp_server);
} else {
   include "error_ftp.htm";
}

// close the connection
ftp_close($conn_id);
?>

0
Comment
Question by:RealSnaD
  • 2
  • 2
5 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 250 total points
ID: 17111760
use urlencode on $ftp_user and $ftp_pass
0
 
LVL 14

Expert Comment

by:ThG
ID: 17111780
it cannot work obviously, because the browser mismatches the "@" in the login for the host part of the URI.

some providers that require the "@" in the login name sometimes accepts a "+" also.. using str_replace("@", "+", $ftp_user); might help.
0
 
LVL 14

Expert Comment

by:ThG
ID: 17111793
well... snoyes_jw's idea ain't bad at all! good point.
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 17111865
I'd say perfect point. It worked. Funny thing is that in Firefox after redirect the url address is ftp://server.com, whereas in IE it becomes ftp://X@server.com. Where X = whatever was after @ in password :)
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 17111876
So basically, if user's password starts with @ the rest of it will be shown in the address bar :) Anyways, who cares. Thank you guys.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now