FTP login via PHP
Moderator: General Moderators
FTP login via PHP
Hi.
I have not been able to find any examples on this, so I hope one of you can help.
I'm looking for a way to "post" a username & password contained in PHP-variables to a ftp-adress, thus sending the user to the ftp-folder without the password being revealed.
I do not have access to CURL-functions, so I think I would need "fsockopen".
Can anyone help me out, here?
Thanks, in advance.
Mads Christensen, DK
I have not been able to find any examples on this, so I hope one of you can help.
I'm looking for a way to "post" a username & password contained in PHP-variables to a ftp-adress, thus sending the user to the ftp-folder without the password being revealed.
I do not have access to CURL-functions, so I think I would need "fsockopen".
Can anyone help me out, here?
Thanks, in advance.
Mads Christensen, DK
here is a little snippet of a script that i use
Code: Select all
// make sure we have time enough to execute this script - 20 * 60 seconds
set_time_limit(1200);
// get the fileslist that we have downloaded already
$local = filesInDirectory($local_path);
// get the fileslist available on the ftp server
$ftp = ftp_connect($settings['ftp_host']);
ftp_login($ftp, $settings['ftp_user'], $settings['ftp_pass']);
$remote = ftp_nlist($ftp, ".");
// get the remote files we don't have locally
foreach($remote as $file)
{
if (!in_array($file, $local))
{
// we don't have the file, thus download it
ftp_get($ftp, $local_path . $file, $file, FTP_BINARY);
...
}
}I am creating a system where different users have their own individual folders which they can gain access to via FTP.
There are more features in the system so under all circumstances the user has already logged in to a site where he has access to the different features.
Therefore, I think it would be userfriendly if the user could access his FTP-folder by clicking a link. I could, of course, make the link ftp://user:pass@ftp.host.dk - I wish, however, that his password is not revealed at any time.
The user should have access to his folder with all opportunites of reading, writing and executing.
That is basically what I want to do. I will now see if the function you mentioned is what I need. Thank you for your quick reply, your help is appreciated.
Mads
There are more features in the system so under all circumstances the user has already logged in to a site where he has access to the different features.
Therefore, I think it would be userfriendly if the user could access his FTP-folder by clicking a link. I could, of course, make the link ftp://user:pass@ftp.host.dk - I wish, however, that his password is not revealed at any time.
The user should have access to his folder with all opportunites of reading, writing and executing.
That is basically what I want to do. I will now see if the function you mentioned is what I need. Thank you for your quick reply, your help is appreciated.
Mads
Last edited by MadsC on Wed May 04, 2005 7:57 am, edited 1 time in total.
Just comment that out and pray your script doesn't require more than 30 seconds or so...MadsC wrote: Warning: set_time_limit(): Cannot set time limit in safe mode
Well, you could write your own using the glob function. I could post the function in this forum, but it seems useless, because it performs some soap requests...MadsC wrote: Fatal error: Call to undefined function: filesindirectory()
Okay. But since I have no knowledge on that area, at first I would like to know if it is what I need. To me it looks like a script that downloads a row of files, but I just want to link to the ftp-folder.
Formerly, I had an upload-system with a view over the user's files. FTP is better, I think, since you control the same way as in ordinary folders and you can handle multiple files. Furthermore, filesizes are not restricted by the browser's timelimit when uploading.
Formerly, I had an upload-system with a view over the user's files. FTP is better, I think, since you control the same way as in ordinary folders and you can handle multiple files. Furthermore, filesizes are not restricted by the browser's timelimit when uploading.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
I don't think the OP needs the FTP functions....
If i understand well, he needs a filemanager that works on the webserver. So, if he uses that, he is bound to the limitations of php etc...
If provides ftp access, he should give his users access rights to do this. And the users would need an ftp client. Well, he could write an ftp client in php (or search one, there are some nice out there) but that would restrict him again to the limitations of php etc...
If i understand well, he needs a filemanager that works on the webserver. So, if he uses that, he is bound to the limitations of php etc...
If provides ftp access, he should give his users access rights to do this. And the users would need an ftp client. Well, he could write an ftp client in php (or search one, there are some nice out there) but that would restrict him again to the limitations of php etc...
As far as I understand "glob", the use of it is for opening folders, returning and handling the files within - through PHP.
But as you say, tim - PHP restricts the handling of the files.
So therefore it would be optimal with FTP.
What I want PHP to do is merely to link to the FTP-location:
If I go to ftp://user@host.dk a dialog will request my password before I access the folder. But since the session already contains this password, it would be great if PHP posted or somehow enclosed the password to the FTP-location, so the password request is not needed.
If I am completly off the track, please tell me.
But as you say, tim - PHP restricts the handling of the files.
So therefore it would be optimal with FTP.
What I want PHP to do is merely to link to the FTP-location:
If I go to ftp://user@host.dk a dialog will request my password before I access the folder. But since the session already contains this password, it would be great if PHP posted or somehow enclosed the password to the FTP-location, so the password request is not needed.
> If the user is referred to the ftp://... -location, does he then need a FTP-client. Normally, don't the browser just view the folder as a local folder?If provides ftp access, he should give his users access rights to do this. And the users would need an ftp client. Well, he could write an ftp client in php (or search one, there are some nice out there) but that would restrict him again to the limitations of php etc...
If I am completly off the track, please tell me.
That is because most browsers have a built-in ftp functionality.MadsC wrote: > If the user is referred to the ftp://... -location, does he then need a FTP-client. Normally, don't the browser just view the folder as a local folder?
If you know the password, you could redirect them like:
Code: Select all
header("Location: ftp://{$user}:{$password}@server/{$user}");Yes...
As I mentioned in my former post, I will not use the ftp://user:pass-thing, since I do not want the password to be revealed at any time.
I just wondered if somebody here knew a way to send the password by posting it or something, but maybe it isn't possible.
Thanks for your interrest, anyways.
As I mentioned in my former post, I will not use the ftp://user:pass-thing, since I do not want the password to be revealed at any time.
I just wondered if somebody here knew a way to send the password by posting it or something, but maybe it isn't possible.
Thanks for your interrest, anyways.