使用 PHP 和 JavaScript 跟踪用户
我是否错过了您可以记录以跟踪访问者的任何明显的事情(使用 PHP 和 JavaScript)?
- 我可以获得计算机名称吗?
- 我能拿到国家吗?
- 能拿到城市吗?
- 邮政编码?
- 可以从某些浏览器收集任何其他信息吗?
PHP 文档:
<script>
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);?>
<?php echo "document.write('The IP-adress: ' + " . "'" . $ip . "'" . " + '<br>');";?>
<?php echo "document.write('The host address: ' + " . "'" . $hostaddress . "'" . " + '<br>');";?>
document.write('The date: ' + new Date() + '<br>');
document.write('Get the entire URL of the current page: ' + location.href + '<br>');
document.write('This document was last modified on:' + document.lastModified + '<br>'); // good to know wich version of the page they have
if (document.referrer != ''){
document.write('The referrer of this document is: ' + document.referrer + '<br>')
}
else{
document.write('The is no referrer.<br>')
}
document.write('Number of URLs in history list: ' + history.length + '<br>')
// I know it doesn't allways return the right browser info, but it gives a good clue.
document.write("Browser name: " + navigator.appName + '<br>');
document.write("Browser version info: " + navigator.appVersion + '<br>');
document.write("Platform: " + navigator.platform + '<br>');
document.write("User-agent header sent: " + navigator.userAgent + '<br>');
document.write("Language of user: " + navigator.userLanguage);
document.write("Total Height: " + screen.height + '<br>');
document.write("Total Width: " + screen.width + '<br>');
document.write("Cookie: " + document.cookie + '<br>');
</script>
Have I missed any obvious things that you can log to keep track on your visitors (using PHP and JavaScript)?
- Can I get computer name?
- Can I get the country?
- Can I get the city?
- Postal code?
- Any other information that can be collected from certain browsers?
PHP DOCUMENT :
<script>
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);?>
<?php echo "document.write('The IP-adress: ' + " . "'" . $ip . "'" . " + '<br>');";?>
<?php echo "document.write('The host address: ' + " . "'" . $hostaddress . "'" . " + '<br>');";?>
document.write('The date: ' + new Date() + '<br>');
document.write('Get the entire URL of the current page: ' + location.href + '<br>');
document.write('This document was last modified on:' + document.lastModified + '<br>'); // good to know wich version of the page they have
if (document.referrer != ''){
document.write('The referrer of this document is: ' + document.referrer + '<br>')
}
else{
document.write('The is no referrer.<br>')
}
document.write('Number of URLs in history list: ' + history.length + '<br>')
// I know it doesn't allways return the right browser info, but it gives a good clue.
document.write("Browser name: " + navigator.appName + '<br>');
document.write("Browser version info: " + navigator.appVersion + '<br>');
document.write("Platform: " + navigator.platform + '<br>');
document.write("User-agent header sent: " + navigator.userAgent + '<br>');
document.write("Language of user: " + navigator.userLanguage);
document.write("Total Height: " + screen.height + '<br>');
document.write("Total Width: " + screen.width + '<br>');
document.write("Cookie: " + document.cookie + '<br>');
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多可用的地理定位数据库。如果您想免费,也有一些免费数据库,其更新频率低于付费数据库,例如 MaxMind GeoLite< /a>.
如需了解更多 Google IP 地理位置。
There are a lot of geolocation databases available. If you wish to go free there are some free databases too with less frequent updates than their paid counterparts, e.g. MaxMind GeoLite.
For more Google for IP geolocation.