简体   繁体   English

我可以在服务器上获取FTP上传的IP地址吗?

[英]Can I get the IP address for a FTP upload at the server?

I provide a public FTP account for people to upload files into a temporary folder. 我提供了一个公共FTP帐户,供人们将文件上传到临时文件夹中。 An AJAX interface shows fresh files, then users can tag and move the file into a different folder. AJAX界面显示了新文件,然后用户可以标记文件并将其移动到其他文件夹中。

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. 单个FTP帐户是不可选项。

Is there a way to connect the logged-in user and the FTP-upload by IP address? 有没有办法通过IP地址连接登录用户和FTP上传文件? Can I find out the uploader IP for any given file using PHP? 我可以使用PHP找出任何给定文件的上传者IP吗?

Is there a way to connect the logged-in user and the FTP-upload by IP address? 有没有办法通过IP地址连接登录用户和FTP上传文件? Can I find out the uploader IP for any given file using PHP? 我可以使用PHP找出任何给定文件的上传者IP吗?

You can't easily find the IP address data for previous FTP uploads if you didn't capture it at the time. 如果您当时没有捕获,则无法轻松找到先前FTP上传的IP地址数据。 Going forward you could certainly record this BUT: 展望未来,您当然可以录制以下内容:

1) only if your FTP server permits it 1)仅在您的FTP服务器允许的情况下

2) it'll probably write it to the log which you'll need to parse then compare with the actual files (not trivial) 2)可能会将其写入您需要解析的日志中,然后与实际文件进行比较(不琐碎)

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. 3)基本方法有缺陷-除非您仅让用户通过局域网连接,否则不需要FTP连接的客户端地址与HTTP连接的客户端地址相同。 (eg HTTP connection might go through a proxy, FTP connection direct). (例如,HTTP连接可能通过代理,FTP连接直接)。

A slightly better approach would be to use usernames rather than IP addresses (although you still have problems 1 and 2 to contend with). 稍微好一点的方法是使用用户名而不是IP地址(尽管您仍然要解决问题1和2)。

Better yet, scrap the FTP and do the uploads using HTTP. 更好的是,废弃FTP并使用HTTP进行上传。

C. C。

Do it with PHP, you are showing it on the web right? 使用PHP进行操作,您可以在网上看到它吗?

Make a New Table on you mysql or other db! 在您的mysql或其他数据库上创建新表! 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. 他们每次发送文件时,如果需要以后将路径,ip,Web用户名(如果有的话)和md5sum保存到DB上的新表中,那么在列出时,您只需在DB上搜索路径并打印用户名或IP ...当他们删除时,删除具有该路径的行,当他们移动时,更改该行的路径。 It's simple :) 这很简单 :)

;) ;)

EDIT: Sorry for my english, i hope you understand it... 编辑:对不起,我的英语,我希望你能理解...

One of the following is possible: 可能是以下之一:

  • Change your FTP server to save the filename and IP address to a database or file. 更改您的FTP服务器以将文件名和IP地址保存到数据库或文件中。
  • Go through the FTP server logs (which supposedly contain IP addresses and filenames) and store this information in a database periodically. 浏览FTP服务器日志(可能包含IP地址和文件名),并将此信息定期存储在数据库中。
  • Let users upload files through HTTP. 让用户通过HTTP上传文件。 In that case you can implement it with PHP and store the IP and filename. 在这种情况下,您可以使用PHP来实现它并存储IP和文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM