使用PHP和JavaScript跟踪用户

时间:2011-11-13 23:54:23

标签: php javascript ip tracking visitor

我是否遗漏了您可以登录以跟踪访问者的任何显而易见的事情(使用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>

1 个答案:

答案 0 :(得分:1)

有许多可用的地理位置数据库。如果您希望免费获得一些免费数据库,其更新频率低于其付费对应数据库,例如: MaxMind GeoLite

了解IP geolocation的更多Google。