Next Previous Contents

6. Using the software

We now have two more php programs that can be used, one is countryhtaccess.php and the other is iptocountry.php. Let's check out iptocountry.php first and get familiar with it. This will help to understand what takes place when we run the countryhtaccess.php program.

Just as with the setup program, point your browser:

...and then click on "IP to Country".

You'll get a page showing a brief help message along with a text box and a clickable button. Enter an IP address into the text box and then click on "Get IP Info".

A page will appear that will display the address you entered along with a version of the address in a long decimal format. The long decimal format is basically the four ip address bytes multiplied out to the full 32-bit number they represent. For most purposes, you can ignore the long decimal results, but they are included in case you have a need for them. I use them for manually looking through the database files and comparing ranges of addresses.

Also displayed is the range of ip addresses that your request matches up with along with the country that this range belongs to. Then below this are two columns of info. In the left column are 6 ranges of ip addresses listed that appear numerically ahead of your request. Likewise, in the column to the right are 6 ranges of ip addresses listed that appear numerically after your request. You can use this information when you wish to find larger blocks of ip addresses than just the one that matches your request.

When you use this program, you'll notice that sometimes it provides a response quite rapidly while other times, it seems to take longer. The difference is due to the ip address you are requesting info on. Some ranges are broken up real badly with very small chunks distributed here and there. When the program encounters those ranges, there is a tremendous amount of data to search through and calculate. But even on a fairly slow server, the wait isn't bad, it's just that you will notice a difference depending on the address you enter.

Play with this program and get used to it. You'll find it's very handy and really helps when you want to find the info you need.

6.1 Sharing the IPToCountry utility with others

Keep in mind that you don't want to send a link of the IPToCountry program to your friends, because it is in your country2 directory. However, you can easily make this handy program available for public use if you copy it to another directory. You can then publish a link on your web site that points to it. Here's what you'll need to do:

Create a new directory to use. It's best to put this into its own directory because it needs a copy of all the database files and you don't really want those cluttering up any of our other directories. Copy the following from your country2 directory into this new directory:

iptocountry.php countries.php 0.php - 255.php (all 256 files)

Now, do a simple edit to the iptocountry.php file to eliminate the "Main Menu" button. Load up iptocountry.php into a text editor and find the following 3 lines:

<form method="POST" action="menu.php">
<input type=submit  value="Main Menu" name="mainmenu">

Delete those 3 lines and save the file into the new directory you created. Now you have a version of this handy utility that you can share with others.

Next Previous Contents