Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling FTP access using PHP :-S 1

Status
Not open for further replies.

ElectronikBean

Programmer
Oct 10, 2002
24
0
0
GB
Hello all,

I am a complete newbie to PHP, I am used to coding in VB.

I have been told the following from my host provider after I requested the functionality of creating / managing ftp logon accounts.

"Thank you very much for your mail dated Mai 29, 2003

You can do this using PHP functions which allow you setup ftp on your
site. Unfortunaltely, I am unable to give you further assistance on the
matter. I suggest that you consult books, websites on the matter."

- so here I am.

The site is hosted on a linux server - which I know little (sad yes - I do plan to get into 'real' Operating Systems one day).

I discoverd the following morsel on fooassociates.com

$ftpStream = ftp_connect("my.ftp.server");
$loginResult = ftp_login($ftpStream, "username", "password");
if ($loginResult) {
print "Login Successful!";
}
ftp_quit($ftpStream);

yet I am still unsure that I am going in the right direction for this. Do I use write a bit of code like this into an executeable directory like a cgi?

It just does not make sense to me that I can access the whole site using the master ftp access, yet ftp creation/management for other users is a matter of scripting? :S

If you know how this is done, please help!
DataJag.
 
What you are asking is a bit more complicated than it would seem at first glance.

The code snipped you've quoted is the code necessary for PHP to connect to an FTP server -- this does not manage FTP user account data.

The problem is providing a source against which user credentials can be compared for authentication. FTP servers on unix-like OSes can use the user directory as this source, but I doubt your service provider is going to allow you to create user accounts at the system level.

Most FTP servers on unix-like OSes also have the functionality for authenticating user credentials against other sources, such as LDAP servers or database servers.

In your specific case, you have two problems: What is the authentication source where you can add users? How do you manage that data source through PHP?

The answer to both questions is, unfortunately, "Insufficient data for a meaingful answer."

The first step is contacting your hosting provider again and spell out very carefully what it is you are trying to do. (Make sure, too, that what you're wanting to do is something your hosting provider is going to allow you to do, too.) Find out the data sources against which his FTP server will authenticate user credentials.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Thanks for the tip - and for redirecting me onto the correct path. It can be difficult to find your way when your left groping around in the dark!

What the support person was saying did not make a lot of sense as - like you say, they did not even tell me the correct details. It makes sense that an "administrator" like logon account would be needed to log on to create the user's ftp accounts - or some other means.

Thanks again,

DataJag :)



 
You're not quite following me -- you're probably thinking Win32-centric.

On Win32, every user credential is stored in the user directory. On unix-like OSes, applications are often written which use both the user directory and additional sources for user credential authentication.

It may very well be that your hosting provider has set up such a mechanism -- for example, configuring their FTP server to authentication user credentials against either of the system user directory or a specific table in a database. In this case, you would not need to be any kind of administrator in a system-level sense -- just a user with access to change the data in one table database.


Want the best answers? Ask the best questions: TANSTAAFL!
 
(To sleipnir214 )

Yes you are right, I was not on the right track, but after viewing my own post last night, I re-read your comments. It is only natural for me to think Win32, as that is all I have been used to for a long time...

So, to reiterate, Unix family OSs use a user directory or a database table to store usernames, passwords the rights to what ever resource or folder.

What I then need to do is update that table/folder somehow to add a user... and give them permissions etc..

Thanks again sleipnir214 - your a star!

:)

I reckon that they think that I want to do this automatically, or have a web page that creates users etc...

OooooKaay... back to the support dept... :mad:

I have just activated a MySQl database with the service - and I will also checkout the tables...

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top