简体   繁体   English

PHP获取用户信息

[英]PHP get user information

I made a website with a login script.我用登录脚本制作了一个网站。 Now there is some guy that makes false logins all the time.现在有一些人一直在进行虚假登录。 For example usernames like 'lfdjgh' and email addresses like jkgfhkjghf@dkhfkgh.com.例如,像“lfdjgh”这样的用户名和像 jkgfhkjghf@dkhfkgh.com 这样的电子邮件地址。 I want to find out where this person is located etc.我想知道这个人在哪里等等。

Is there a way to find some detailed information about that user?有没有办法找到有关该用户的一些详细信息? Computer-name, Ip address, location, etc?计算机名称、IP 地址、位置等?

Thanks谢谢

I agree with that the other answers have said, you can use the values passed with $_SERVER to help avoid this.我同意其他答案所说的,您可以使用$_SERVER传递的值来帮助避免这种情况。

Along with adding a CAPTCHA to your page, you can also add the IP address to your database, grabbed with $_SERVER['REMOTE_ADDR'] and compare known spam IP's to new registrations, and check if its a known spammer.除了将验证码添加到您的页面之外,您还可以将 IP 地址添加到您的数据库中,使用$_SERVER['REMOTE_ADDR']获取并将已知的垃圾邮件 IP 与新注册进行比较,并检查它是否是已知的垃圾邮件发送者。 Its what I do, and I don't have much spam at all (:这就是我所做的,而且我根本没有太多垃圾邮件(:

Happy hunting!狩猎愉快!

run this php code to see what you can get运行这个 php 代码,看看你能得到什么

echo '<pre>';
echo print_r($_SERVER);
echo '</pre>';

Getting $_SERVER['REMOTE_ADDR'] as in the accepted answer is too simplistic.在接受的答案中获取 $_SERVER['REMOTE_ADDR'] 太简单了。

The currently accepted method is目前接受的方法是

if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}

Copied from Tim Kennedy's answer in Stackoverflow Post复制自 Tim Kennedy 在Stackoverflow Post中的回答

You can get the user's IP using the $_SERVER variables, and store it when they submit the form.您可以使用$_SERVER变量获取用户的 IP,并在他们提交表单时存储它。 Then you could use a service to geographically locate the computer, like this one .然后,您可以使用一项服务来对计算机进行地理定位,例如这个

You can use certain values in $_SERVER to find out more about the attacker.您可以使用$_SERVER中的某些值来了解有关攻击者的更多信息。 In most cases $_SERVER['REMOTE_ADDR'] will contain the user's IP address.在大多数情况下$_SERVER['REMOTE_ADDR']将包含用户的 IP 地址。 Be aware though that there is no guarantee that this value is correct and there still might be some kind of proxy involved.请注意,虽然不能保证此值是正确的,但仍可能涉及某种代理。 The best way probably would be to use some kind of captcha to prevent bots from using your signup form.最好的方法可能是使用某种验证码来防止机器人使用您的注册表单。 Because that's most likely the reason.因为这很可能是原因。

you can use $_SERVER['REMOTE_ADDR'] to get the users IP-Adress (hopefully*) and then use a site like http://ip-lookup.net/ to get the broad location of taht address.您可以使用$_SERVER['REMOTE_ADDR']获取用户 IP 地址(希望*),然后使用http://ip-lookup.net/之类的站点获取 taht 地址的大致位置。

*there could be some kind of router/proxy/whatever in use together with other users (like in a students' hostel, for example) where you would only get the ip-adress of that device, so you can't identify a unique user. *可能有某种路由器/代理/与其他用户一起使用的任何东西(例如在学生宿舍中),您只能获得该设备的 IP 地址,因此您无法识别唯一的用户。

i think the simplest way to track them is only to store the location and IP-address when some one make registration as well as when he/she login in your application from there location..its also safe and good practice for any admin;我认为跟踪它们的最简单方法是仅在某人进行注册以及他/她从该位置登录您的应用程序时存储位置和 IP 地址。对于任何管理员来说,这也是安全和良好的做法; this entry will make you good tracked application for fake as well as real users too...此条目将使您也可以很好地跟踪虚假用户和真实用户的应用程序...

I think this facility provided by Google analytic also..they are provided all the details of the user hit on your applications with time/ipaddress/location etc...我认为谷歌分析也提供了这个工具......他们提供了用户点击您的应用程序的所有详细信息,包括时间/IP地址/位置等......

But if the entry are just some kind of fake entry from the script only, then its batter to put captcha in your site..但是,如果该条目只是脚本中的某种虚假条目,那么将验证码放入您的网站的击球手..

ALL THE BEST..:)一切顺利..:)

Thanks.谢谢。

You cannot (really) find out where the user is located (if it is what I suspect it is).您无法(真的)找出用户所在的位置(如果我怀疑它是)。

It's probably some hacker (/ script kiddy) / spambot.这可能是一些黑客(/脚本小子)/垃圾邮件机器人。

You can try to change your input field's names to break the automated process of filling the formfields.您可以尝试更改输入字段的名称以中断填写表单字段的自动化过程。

You can use the $_SERVER superglobal to find out the ip of the user.您可以使用$_SERVER超全局来找出用户的 ip。

You could suspend the ip address for some time also you could add a captcha to the form.您可以暂停 IP 地址一段时间,也可以在表单中添加验证码。

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

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