Visitor IP and Host Display
Reverse DNS Lookup and Geolocation Code

Links PageDownloadsPeopleVideoGames MenuEducational

Reverse DNS & Geolocation Code for your Web Site
Sample of the Entire Code Set

Your Information

You are visiting from:
IP Address: 54.196.88.85
Host: ec2-54-196-88-85.compute-1.amazonaws.com

Reverse DNS Lookup

Enter IP Address:
Host: ec2-54-196-88-85.compute-1.amazonaws.com
City: Toronto
State: Ontario
Country: Canada
Latitude: 43.6670
Longitude: -79.4170
Time Zone: GMT -05:00

FREE Geolocation Information available for only 20 uses per hour!!!

Introduction and Descriptions

This Code is FREE, and was coded by the owner of Best You Can Get.
There are 3 modules, which work separately or together, depending on your needs.
The information displayed in "Your Information" related to your sites visitors and the "Reverse DNS Lookup", both use DNS Servers to retrieve information, much the way your browser does when you type an address into your Browsers Address Bar.
The "Your Information" and "Reverse DNS" modules DO NOT rely on any "other Web Site" for any information, only DNS Servers are queried, in addition you must have use of PHP on your Web Hosts Server.

The Geolocation Add-On module integrates with the Reverse DNS Lookup Module, and relies on another web site (www.geobytes.com) for it's database information.

When using the FREE Service, Geobytes limits Geolocation queries from your IP Address to 20 per HOUR, unless you pay for their service.
The page associated with the FREE Service used for the creation of this tool is Here.

At the time this web site was created, they offered 10,000 queries for $10
If you decide to pay for un-interrupted service it only costs about 1/10 of a cent per look up. It's pretty cheap!!!
You will have to modify the code yourself to pass your account information with your queries. The sample code uses the 20 FREE queries per Hour.
After your 20 Queries it will display a message to the effect that your Limit has been reached.
At the end of the hour it seems to function normally again.

Complete Code for ALL 3 Modules Together

Get the Code for ALL 3 modules for Your Site Combined

Copy and Paste the Code Below, into your pages code.

See Important instructions below the Code!
<table align=center border="1" width="400">
<tr>
<td bgcolor="#FFFFFF">
<p align="center"><b><font size="4">Your Information</font></b></td>
</tr>
<tr>
<td bgcolor="#CCCCFF">
<!-- Get and Display Remote IP Address -->
<?php
echo "You are visiting from:";
?>
<br>
<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
echo "IP Address: " . $ip;
?>
<br>
<!-- Get Host Name from Remote IP Address Variable $ip -->
<?php
//Gets the Host Name
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo "Host: " . $hostname;
?>
</td>
</tr>
</table>

<!-- Enter IP Address to pass to Host look up (Reverse DNS) Script, using the $rdnsip variable and pass it to this php file name -->

<table align="center" border="1" width="400">
<tr>
<td bgcolor="#FFFFFF">


<p align="center"><b><font size="4">Reverse DNS Lookup</font></b></td>
</tr>
<tr>
<td bgcolor="#CCCCFF">


<FORM ACTION="reversedns.php" METHOD=post><b>Enter IP Address: </b>
<INPUT TYPE=text NAME=rdnsip VALUE="" SIZE=15 maxlength=15><BR>
<INPUT TYPE=submit NAME=Submit VALUE="Lookup">
</FORM>
</td>
</tr>
<!-- Get Host Name by IP Address stored in the $rdns variable -->
<tr>
<td bgcolor="#CCCCFF">

<?php
//Gets the Host Name
error_reporting(E_ALL ^ E_NOTICE);
$rdnsip = $_REQUEST['rdnsip'];
 if ($ip == '') {
$ip = "0.0.0.0";
}
if ($rdnsip == '') {
$rdnsip = $ip;
}
$hostname = gethostbyaddr($rdnsip);
echo "Host: " . $hostname;
?>

</td>
</tr>
</table>

<!-- Geolocation PHP script to Send string including IP Address from $rdns variable to look up and return data -->

<table align="center" border="1" width="400">
<tr>
<td bgcolor="#CCCCFF">


<?php
//tests for associated modules
error_reporting(E_ALL ^ E_NOTICE);
 if ($ip == '') {
$ip = "0.0.0.0";
}
if ($rdnsip == '') {
$rdnsip = $ip;
}
$AddressString = 'http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=' . $rdnsip;
$tags = get_meta_tags($AddressString);
print "City: " . $tags['city']; // city name
?>
<br>
<?php
print "State: " . $tags['region']; // state name
?>
<br>
<?php
print "Country: " . $tags['country']; // country name
?>
<br>
<?php
print "Latitude: " . $tags['latitude']; // Latitude name
?>
<br>
<?php
print "Longitude: " . $tags['longitude']; // Longitude name
?>
<br>
<?php
print "Time Zone: GMT " . $tags['timezone']; // Time Zone name
?>


</td>
</tr>
</table>

Instructions:

Copy and Paste the code above into your pages code.
The file name MUST end in .php not htm or html!!!
The Server hosting your page MUST run PHP!!!

You can paste this code into the code of a normal HTML coded page, but make sure and change the file extension when you save it to .php

There is ONE place YOU MUST EDIT the code, for it to function!
Look for this in the Code you are pasting:

<!-- REPLACE changethisname.php below with the name you are naming THIS PAGE and be sure to use a PHP extension -->
<FORM ACTION="changethisname.php" METHOD=post><b>Enter IP Address: </b>
 

Change <FORM ACTION="changethisname.php" so that changethisname.php is renamed to match the name you give the page you are pasting the code into.

For Example:

If the web page you are adding this to is currently named:

mypage.htm

You would need to edit this line of code

<FORM ACTION="changethisname.php" METHOD=post><b>Enter IP Address: </b>

to look like this

<FORM ACTION="mypage.php" METHOD=post><b>Enter IP Address: </b>

AND SAVE THE PAGE AS

mypage.php

That is ALL the editing necessary to have this code functional on YOUR web page!!!

Of course you can name the page whatever you want, as long as you use a .php file extension, and make sure the name matches in that one line of code!
You can tweak the table colors to match your page, as well, if you have sufficient knowledge of html to do so.
The Tables separate each module, so you can carefully copy from any <table> to </table> section of the code, and end up with the individual modules you desire.

At the time this web site was created, they offered 10,000 queries for $10
You will have to modify the code yourself to pass your account information with your queries. The sample code uses the 20 FREE queries per Hour.

There are NO Warranties, or Guarantees expressed or implied for ANY purpose with this code, it is "as is".
Use at your own risk. If you have any issue with it, your sole course of action is to discontinue using it!
This code is NOT Branded in any way, and I give it freely to whoever has a use for it (public domain) - Enjoy!!!

The "Your Information" Section

Copy and Paste the Code Below, into your pages code.

See Important instructions below the Code!
<table align=center border="1" width="400">
<tr>
<td bgcolor="#FFFFFF">
<p align="center"><b><font size="4">Your Information</font></b></td>
</tr>
<tr>
<td bgcolor="#CCCCFF">
<!-- Get and Display Remote IP Address -->
<?php
echo "You are visiting from:";
?>
<br>
<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
echo "IP Address: " . $ip;
?>
<br>
<!-- Get Host Name from Remote IP Address Variable $ip -->
<?php
//Gets the Host Name
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo "Host: " . $hostname;
?>
</td>
</tr>
</table>

Instructions:

Copy and Paste the code above into your pages code.
The file name MUST end in .php not htm or html!!!
The Server hosting your page MUST run PHP!!!

You can paste this code into the code of a normal HTML coded page, but make sure and change the file extension when you save it to .php

That is ALL the editing necessary to have this code functional on YOUR web page!!!

You can name the page whatever you want, as long as you use a .php file extension!
You can tweak the table colors to match your page, as well, if you have sufficient knowledge of html to do so.
The Tables separate each module, so you can carefully copy from any <table> to </table> section of the code, and end up with the individual modules you desire.

There are NO Warranties, or Guarantees expressed or implied for ANY purpose with this code, it is "as is".
Use at your own risk. If you have any issue with it, your sole course of action is to discontinue using it!
This code is NOT Branded in any way, and I give it freely to whoever has a use for it (public domain) - Enjoy!!!

The "Reverse DNS Lookup" Section

Copy and Paste the Code Below, into your pages code.

See Important instructions below the Code!
<!-- Enter IP Address to pass to Host look up (Reverse DNS) Script, using the $rdnsip variable and pass it to this php file name -->

<table align="center" border="1" width="400">
<tr>
<td bgcolor="#FFFFFF">


<p align="center"><b><font size="4">Reverse DNS Lookup</font></b></td>
</tr>
<tr>
<td bgcolor="#CCCCFF">


<FORM ACTION="reversedns.php" METHOD=post><b>Enter IP Address: </b>
<INPUT TYPE=text NAME=rdnsip VALUE="" SIZE=15 maxlength=15><BR>
<INPUT TYPE=submit NAME=Submit VALUE="Lookup">
</FORM>
</td>
</tr>
<!-- Get Host Name by IP Address stored in the $rdns variable -->
<tr>
<td bgcolor="#CCCCFF">

<?php
//Gets the Host Name
error_reporting(E_ALL ^ E_NOTICE);
$rdnsip = $_REQUEST['rdnsip'];
 if ($ip == '') {
$ip = "0.0.0.0";
}
if ($rdnsip == '') {
$rdnsip = $ip;
}
$hostname = gethostbyaddr($rdnsip);
echo "Host: " . $hostname;
?>

</td>
</tr>
</table>

Instructions:

Copy and Paste the code above into your pages code.
The file name MUST end in .php not htm or html!!!
The Server hosting your page MUST run PHP!!!

You can paste this code into the code of a normal HTML coded page, but make sure and change the file extension when you save it to .php

There is ONE place YOU MUST EDIT the code, for it to function!
Look for this in the Code you are pasting:

<!-- REPLACE changethisname.php below with the name you are naming THIS PAGE and be sure to use a PHP extension -->
<FORM ACTION="changethisname.php" METHOD=post><b>Enter IP Address: </b>
 

Change <FORM ACTION="changethisname.php" so that changethisname.php is renamed to match the name you give the page you are pasting the code into.

For Example:

If the web page you are adding this to is currently named:

mypage.htm

You would need to edit this line of code

<FORM ACTION="changethisname.php" METHOD=post><b>Enter IP Address: </b>

to look like this

<FORM ACTION="mypage.php" METHOD=post><b>Enter IP Address: </b>

AND SAVE THE PAGE AS

mypage.php

That is ALL the editing necessary to have this code functional on YOUR web page!!!

Of course you can name the page whatever you want, as long as you use a .php file extension, and make sure the name matches in that one line of code!
You can tweak the table colors to match your page, as well, if you have sufficient knowledge of html to do so.
The Tables separate each module, so you can carefully copy from any <table> to </table> section of the code, and end up with the individual modules you desire.

There are NO Warranties, or Guarantees expressed or implied for ANY purpose with this code, it is "as is".
Use at your own risk. If you have any issue with it, your sole course of action is to discontinue using it!
This code is NOT Branded in any way, and I give it freely to whoever has a use for it (public domain) - Enjoy!!!

The "Geolocation" Add-On module

Copy and Paste the Code Below, into your pages code.

See Important instructions below the Code!
<!-- Geolocation PHP script to Send string including IP Address from $rdns variable to look up and return data -->

<table align="center" border="1" width="400">
<tr>
<td bgcolor="#CCCCFF">


<?php
//tests for associated modules
error_reporting(E_ALL ^ E_NOTICE);
 if ($ip == '') {
$ip = "0.0.0.0";
}
if ($rdnsip == '') {
$rdnsip = $ip;
}
$AddressString = 'http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=' . $rdnsip;
$tags = get_meta_tags($AddressString);
print "City: " . $tags['city']; // city name
?>
<br>
<?php
print "State: " . $tags['region']; // state name
?>
<br>
<?php
print "Country: " . $tags['country']; // country name
?>
<br>
<?php
print "Latitude: " . $tags['latitude']; // Latitude name
?>
<br>
<?php
print "Longitude: " . $tags['longitude']; // Longitude name
?>
<br>
<?php
print "Time Zone: GMT " . $tags['timezone']; // Time Zone name
?>


</td>
</tr>
</table>

Instructions:

Copy and Paste the code above into your pages code.
The file name MUST end in .php not htm or html!!!
The Server hosting your page MUST run PHP!!!
This Module Requires the "Reverse DNS Lookup" Module or the "Your Information Module!!!
This Module gets its IP Address information for Geolocation from the "Reverse DNS" Module or the "Information Module".

You can paste this code into the code of a normal HTML coded page, but make sure and change the file extension when you save it to .php

That is ALL the editing necessary to have this code functional on YOUR web page!!!

You can name the page whatever you want, as long as you use a .php file extension!
You can tweak the table colors to match your page, as well, if you have sufficient knowledge of html to do so.
The Tables separate each module, so you can carefully copy from any <table> to </table> section of the code, and end up with the individual modules you desire.

The Geolocation Add-On module integrates with the Reverse DNS Lookup Module, and relies on another web site (www.geobytes.com) for it's database information.

When using the FREE Service, Geobytes limits Geolocation queries from your IP Address to 20 per HOUR, unless you pay for their service.
The page associated with the FREE Service used for the creation of this tool is Here.

At the time this web site was created, they offered 10,000 queries for $10
If you decide to pay for un-interrupted service it only costs about 1/10 of a cent per look up. It's pretty cheap!!!
After your 20 Queries it will display a message to the effect that your Limit has been reached.
At the end of the hour it seems to function normally again.

If you acquire paid service, you will have to modify the code yourself to pass your account information with your queries.
The sample code uses the 20 FREE queries per Hour.

There are NO Warranties, or Guarantees expressed or implied for ANY purpose with this code, it is "as is".
Use at your own risk. If you have any issue with it, your sole course of action is to discontinue using it!
This code is NOT Branded in any way, and I give it freely to whoever has a use for it (public domain) - Enjoy!!!

Links PageDownloadsPeopleVideoGames MenuEducational
 Copyright 2008  http://www.bestyoucanget.com All Rights Reserved See Terms of Use