Forum Moderators: coopster

Message Too Old, No Replies

Creating an FTP Account

with PHP?

         

ahmedtheking

1:05 pm on Dec 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Has anyone got an idea how to create an FTP account through PHP and assign a user to a group and quota? Also, does PHP work with a server's FTP quota, if, for example, the file was uploaded via a HTML form?

mcavic

2:53 pm on Dec 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP can't create an FTP account by itself, but you can use system() or popen() to run external commands.

And no, the FTP quota won't be obeyed if users are uploading via HTML forms, because that's not an FTP transfer.

You can set filesystem quotas that will always be obeyed, but those quotes will be per local user, not per Web visitor.

ahmedtheking

5:58 pm on Dec 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, any idea on how it can be done via bash (or tcsh, I mean through exec())?

Would the quotas be respected if I used FTP to locally put a file from a HTML form?

mcavic

7:55 pm on Dec 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How you create and configure users depends on your Linux distribution and your FTP server.

if I used FTP to locally put a file from a HTML form?

Yes, but that sounds silly. Why not just implement your own quotes via PHP?

ahmedtheking

10:17 am on Dec 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not on Linux, but OS X. How'd you do quotas via PHP?

Angelis

10:34 am on Dec 27, 2006 (gmt 0)

10+ Year Member



You would have to check the filesize being uploaded and then check how much space is available through the HTML form if you where doing it that way. It would be the same for a PHP upload, you would have to use the exec() or system() function, it shouldnt matter if the server is OSX as its based on BSD Unix (I think) so the commands should still work.

ahmedtheking

10:53 am on Dec 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See I had the idea of managing the files via a DB where it would track the file sizes as you suggested. And yeah Mac should be able to handle bash commands. However, I don't think that the 'DB with PHP Quota' system I've built and the FTP System Quota can work together. This is where I have a nice big problem. I'm having trouble getting them to link to each other. That's why I thought I'd try to use FTP via PHP (yes, supoer long and a bit lame) so that it would conform with the FTP System's Quota

Angelis

12:00 pm on Dec 27, 2006 (gmt 0)

10+ Year Member



If you assign a different directory to each user then you can just check the directory size with a bash command the same as you would do if you where uploading the files.

If you are using a database to store the files then as long as you know which user the files belong to then it shouldnt be a problem to tott up the amount of space they have used.

There are a few different ways you can do it, its just the tracking of whos file is whos that could be the problem, unless you store the filenames and the username who it belongs to in the database and just have a standard storage area.

Lots to think about, shouldnt be too difficult to get it working though.