views:

37

answers:

3

I provide a public FTP account for people to upload files into a temporary folder. An AJAX interface shows fresh files, then users can tag and move the file into a different folder.

I would like to show every user just the files they uploaded themselves, not all the other ones that might be uploaded at the same time by other people. Individual FTP accounts are no option.

Is there a way to connect the logged-in user and the FTP-upload by IP address? Can I find out the uploader IP for any given file using PHP?

+1  A: 

Do it with PHP, you are showing it on the web right?

Make a New Table on you mysql or other db! Everytime they send a file, save to your new table on DB the path, ip, web username (if any) and md5sum if you need for later, then, when listing, you only have to search the path on the DB and print the username or IP... And when they delete, delete the row with that path, and when they move, change the path of that row. It's simple :)

;)

EDIT: Sorry for my english, i hope you understand it...

CuSS
A: 

One of the following is possible:

  • Change your FTP server to save the filename and IP address to a database or file.
  • Go through the FTP server logs (which supposedly contain IP addresses and filenames) and store this information in a database periodically.
  • Let users upload files through HTTP. In that case you can implement it with PHP and store the IP and filename.
Sjoerd
A: 

Is there a way to connect the logged-in user and the FTP-upload by IP address? Can I find out the uploader IP for any given file using PHP?

You can't easily find the IP address data for previous FTP uploads if you didn't capture it at the time. Going forward you could certainly record this BUT:

1) only if your FTP server permits it

2) it'll probably write it to the log which you'll need to parse then compare with the actual files (not trivial)

3) the fundamental approach is flawed - unless you've only got users connecting via a local area network, there is no requirement that the client address for the FTP connection is the same as the client connection for the HTTP connection. (e.g. HTTP connection might go through a proxy, FTP connection direct).

A slightly better approach would be to use usernames rather than IP addresses (although you still have problems 1 and 2 to contend with).

Better yet, scrap the FTP and do the uploads using HTTP.

C.

symcbean
Thank you, this seems to be a good roundup. I know the concept is not very clean, so it is probably better to change it rather than making a big effort to implement it.
pixelistik