#!/usr/bin/python

print "Content-type: text/html"
print

from os import getenv
from socket import gethostbyaddr

print '''<html>
<head>
<title>User Details</title>
<style type="text/css">
<!--
p {font: bold 11px Arial, Helvetica, sans-serif;}
p.text {font: normal 13px Arial, Helvetica, sans-serif;}
a {font: normal 13px Arial, Helvetica, sans-serif; color: #000099;}
.header {background: #000000; color: #ffffff;}
-->
</style>
</head>
<body>
<p>
<table border="1" cellspacing="1" cellpadding="4">
	<tr>
		<td colspan="2" class="header"><p>IP Address / Hostname</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>IP Address:</p></td>
		<td><p class="text">''' + getenv('REMOTE_ADDR', '') + '''</p></td>
	</tr>
	<tr> 
		<td bgcolor="#F3F3F3"><p>Hostname:</p></td>
		<td><p class="text">''' + gethostbyaddr(getenv('REMOTE_ADDR', ''))[0] + '''</p></td>
	</tr>
	<tr>
		<td colspan="2" class="header"><p>Browser/Computer Properties</p></td>
	</tr>
	<tr> 
		<td bgcolor="#F3F3F3"><p>Browser:</p></td>
		<td><p class="text">''' + getenv('HTTP_USER_AGENT', 'not specified') + '''</p></td>
	</tr>
	<script type="text/javascript">
		var days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
		var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
		var now = new Date();
		var day = now.getDay();
		var month = now.getMonth();
		var date = ((now.getDate() < 10) ? "0" : "") + now.getDate();
		var year = (now.getYear() < 1000) ? now.getYear() + 1900 : now.getYear();
		var hours = now.getHours();
		var minutes = now.getMinutes();
		var seconds = now.getSeconds();
		var amORpm = "AM";
		if (hours > 11) amORpm = "PM";
		if (hours > 12) hours -= 12;
		if (hours == 0) hours = 12;
		if (minutes <= 9) minutes = "0" + minutes;
		if (seconds <= 9) seconds = "0" + seconds;
		time = days[day] + ", " + months[month] + " " + date + ", " + year + " - " + hours + ":" + minutes + ":" + seconds + " " + amORpm;
		document.write('<tr><td bgcolor="#F3F3F3"><p>Date and Time:</p></td><td><p class="text">', time, '</p></td></tr>');
		document.write('<tr><td bgcolor="#F3F3F3"><p>Javascript:</p></td><td><p class="text"><font color="#009900">Enabled</font></p></td></tr>');
		if (navigator.cookieEnabled) {
			document.write('<tr><td bgcolor="#F3F3F3"><p>Cookies:</p></td><td><p class="text"><font color="#009900">Enabled</font></p></td></tr>');
		} else {
			document.write('<tr><td bgcolor="#F3F3F3"><p>Cookies:</p></td><td><p class="text"><font color="#990000">Disabled</font></p></td></tr>');	
		}
		if (navigator.javaEnabled()) {
			document.write('<tr><td bgcolor="#F3F3F3"><p>Java:</p></td><td><p class="text"><font color="#009900">Enabled</font></p></td></tr>');
		} else {
			document.write('<tr><td bgcolor="#F3F3F3"><p>Java:</p></td><td><p class="text"><font color="#990000">Disabled</font></p></td></tr>');	
		}
		if (navigator.cpuClass != null) {
			cpu = "CPU Class " + navigator.cpuClass;
		} else if (navigator.oscpu != null) {
			cpu = "OS/CPU " + navigator.oscpu;
		}
		document.write('<tr><td bgcolor="#F3F3F3"><p>CPU Class/Type:</p></td><td><p class="text">', cpu, '</p></td></tr>');
		if (window.screen) {
			cdepth = screen.colorDepth;
		}
		document.write('<tr><td bgcolor="#F3F3F3"><p>Color Depth:</p></td><td><p class="text">', cdepth, '</p></td></tr>');
		document.write('<tr><td bgcolor="#F3F3F3"><p>Screen Size:</p></td><td><p class="text">', screen.width, ' x ', screen.height, '</p></td></tr>');
		if (document.all) {
			wwidth = document.body.offsetWidth + ' (' + ((100 * document.body.offsetWidth)/screen.width).toFixed(1) + '% of ' + screen.width + ')';
		} else if (document.layers) {
			wwidth = document.body.width + ' (' + ((100 * document.body.width)/screen.width).toFixed(1) + '% of ' + screen.width + ')';
		} else if (document.body.clientWidth != null) {
			wwidth = document.body.clientWidth + ' (' + ((100 * document.body.clientWidth)/screen.width).toFixed(1) + '% of ' + screen.width + ')';
		}
		if (document.all) {
			wheight = document.body.offsetHeight + ' (' + ((100 * document.body.offsetHeight)/screen.height).toFixed(1) + '% of ' + screen.height + ')';
		} else if (document.layers) {
			wheight = document.body.height + ' (' + ((100 * document.body.height)/screen.height).toFixed(1) + '% of ' + screen.height + ')';
		} else if (document.body.clientHeight != null) {
			wheight = document.body.clientHeight + ' (' + ((100 * document.body.clientHeight)/screen.height).toFixed(1) + '% of ' + screen.height + ')';
		}
		document.write('<tr><td bgcolor="#F3F3F3"><p>Window Size:</p></td><td><p class="text">', wwidth, ' x ', wheight, '</p></td></tr>');
	</script>
	<noscript><tr><td bgcolor="#F3F3F3"><p>Javascript:</p></td><td><p class="text"><font color="#990000">Disabled</font></p></td></tr></noscript>
	<tr>
		<td colspan="2" class="header"><p>Browser Headers</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Host:</p></td>
		<td><p class="text">''' + getenv('HTTP_HOST', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Accept:</p></td>
		<td><p class="text">''' + getenv('HTTP_ACCEPT', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Accept-Language:</p></td>
		<td><p class="text">''' + getenv('HTTP_ACCEPT_LANGUAGE', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Accept-Encoding:</p></td>
		<td><p class="text">''' + getenv('HTTP_ACCEPT_ENCODING', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Accept-Charset:</p></td>
		<td><p class="text">''' + getenv('HTTP_ACCEPT_CHARSET', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Keep-Alive:</p></td>
		<td><p class="text">''' + getenv('HTTP_KEEP_ALIVE', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Connection:</p></td>
		<td><p class="text">''' + getenv('HTTP_CONNECTION', '') + '''</p></td>
	</tr>
	<tr>
		<td bgcolor="#F3F3F3"><p>Page Referer:</p></td>
		<td><p class="text">''' + (getenv('HTTP_REFERER', '') or 'none') + '''</p></td>
	</tr>
</table>
</p>
</body>
</html>
'''
