News → What’s Your IP?
February 18th, 2012 by iceflatline
I’ve added a Your IP tab at the top of the site that will bring you to a page that displays your current IP address as well as some other http connection-related information. A geeky little task I’ve been meaning to do for awhile now. Here’s the code I hacked together for it. As always, please report any problems you encounter with it, and any suggestions you may have for ways to improve the code and/or experience.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<style type="text/css" media="screen">
* {
margin:0;
padding:0;
}
body {
background-color:#00000;
}
h1 {
font-family: 'Trebuchet MS','Lucida Grande',Verdana,Arial,Sans-Serif;
font-size: 65px;
margin-top: 35px;
text-align: center;
margin-bottom: 35px;
color: #006699;
}
h2 {
font-family: 'Trebuchet MS','Lucida Grande',Verdana,Arial,Sans-Serif;
font-size: 19px;
text-align: left;
color: #929280;
}
ul {
font-size: 19px;
margin-top: 20px;
margin-bottom:35px;
margin-left: 15px;
color: #929280;
}
li {
font-family: 'Trebuchet MS','Lucida Grande',Verdana,Arial,Sans-Serif;
margin-top: 10px;
}
li span {
font-family: 'Trebuchet MS','Lucida Grande',Verdana,Arial,Sans-Serif;
font-size: 16px/1;
color: #ccc;
}
</style>
<body>
<div>
<?php
$IP = $_SERVER["REMOTE_ADDR"];
$host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
?>
<h1><?php echo $IP; ?></h1>
</div>
<div>
<h2>More info</h2>
</div>
<div>
<ul>
<?php
echo '<li><strong>Remote Port:</strong> <span>'.$_SERVER["REMOTE_PORT"].'</span></li>';
echo '<li><strong>Request Method:</strong> <span>'.$_SERVER["REQUEST_METHOD"].'</span></li>';
echo '<li><strong>Server Protocol:</strong> <span>'.$_SERVER["SERVER_PROTOCOL"].'</span></li>';
echo '<li><strong>Host:</strong> <span>'.$host.'</span></li>';
echo '<li><strong>User Agent:</strong> <span>'.$_SERVER["HTTP_USER_AGENT"].'</span></li>';
?>
</ul>
</div>
</body>
</html>
Tags: code, Networking, news