使用 PHP 和 JavaScript 跟踪用户

发布于 2024-12-15 07:32:41 字数 1741 浏览 2 评论 0原文

我是否错过了您可以记录以跟踪访问者的任何明显的事情(使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤芳又自赏 2024-12-22 07:32:41

有很多可用的地理定位数据库。如果您想免费,也有一些免费数据库,其更新频率低于付费数据库,例如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文