Collecting user info with PHP and Javascript
I wrote a PHP/Javascript webpage to find user info. Take a look and tell me what else I should add.
The script on my server: http://www.irongeek.com/browserinfo.php
Source:
PHP Code:
<HTML>
<BODY>
<TITLE>Irongeek's Browser Information Page</TITLE>
<? include ("http://irongeek.com/header.htm"); ?>
<B>Irongeek's Browser Information Page</B><P>
Here is some of the information your browser currently puts out.<P>
<B>Info obtained by PHP on the server:</B><P>
<TABLE cellpadding="5" width="65%" align="center">
<?
table_print ("IP",$_SERVER['REMOTE_ADDR']);
$hostname=gethostbyaddr($_SERVER['REMOTE_ADDR']);
table_print ("Hostname",$hostname);
table_print ("Operating System",find_os());
table_print ("Entire User Agent String",$_SERVER['HTTP_USER_AGENT']);
table_print ("Referrer",$_SERVER['HTTP_REFERER']);
table_print ("Remote Client Port:",$_SERVER['REMOTE_PORT']);
?>
</TABLE>
<B>Info obtained by JavaScript on the client:</B><P>
<script language="javascript" type="text/javascript">
<!--
document.write('<TABLE cellpadding="5" width="65%" align="center">');
JSTable_print("Java Enabled",navigator.javaEnabled());
//JSTable_print("IP", java.net.InetAddress.getLocalHost().getHostAddress());
JSTable_print("Browser",navigator.appName);
JSTable_print("Browser Version",navigator.appVersion);
JSTable_print("Platform",navigator.platform);
JSTable_print("CPU Class",navigator.cpuClass);
var tp="";
if (navigator.appName=="Netscape"){
var tdes="Plugins";
for (i in navigator.plugins)
{
if (tp!=navigator.plugins[i].name){
JSTable_print(tdes,navigator.plugins[i].name);
tdes="";
}
tp=navigator.plugins[i].name;
}
}
JSTable_print("System Language",navigator.systemLanguage);
JSTable_print("Resolution",screen.width+"x"+screen.height);
JSTable_print("Color Depth",screen.colorDepth);
JSTable_print("Referrer",document.referrer);
document.write("</TABLE>");
function JSTable_print(description,value)
{
document.write('<TR><TD><FONT color="#990099">' + description + '</FONT></TD><TD>' + value + '</TD></TR>');
}
// -->
</script>
<? //PHP Functions
function table_print($description, $value){
echo '<TR><TD><FONT color="#990099">'.$description.'</FONT></TD><TD>'.$value.'</TD></TR>';
}
function find_os()
{
$browserarray=explode("; ",$_SERVER['HTTP_USER_AGENT']);
$os= $browserarray[2];
return $os;
}
function find_browser()
{
$browserarray=explode("; ",$_SERVER['HTTP_USER_AGENT']);
if ($browserarray[1]=="U"){
$browser = $browserarray[4];
}else {
$browser = $browserarray[1];
}
return $browser;
}
?>
<? include ("http://irongeek.com/footer.php"); ?>
</BODY>
</HTML>