This document is a general grouping of internet related items and covers issues like internet protocols as well as useful tips scripts.
1. Using the IP Addresses database for IP Address Lookup
For high-load Geotargeting or IP Address Lookups, a feed of the IP Address database should be used to perserve bandwidth.
A. A Simple GET
There is an HTTP oriented API for locating and Geocoding IP addresses. If the http
get doesn't include an "?ip=a.b.c.d" parameter, then the ip address of
the calling maching is substituted. If the &position=true parameter is
present at the end of the URL, then latitude and longitude are also returned.
Both HTML and XML formats are supplied.
a. Locate country for ip address of sending host
bash $ links -dump http://api.hostip.info/country.php
PL
b. Locate country for specific ip address
bash $ links -dump http://api.hostip.info/country.php?ip=12.215.42.19
US
c. Country and city for sending host
bash $ links -dump http://api.hostip.info/get_html.php
Country: RZECZPOSPOLITA POLSKA (PL)
City: Warsaw
d. Country and city for specific ip
bash $ links -dump http://api.hostip.info/get_html.php?ip=12.215.42.19
Country: UNITED STATES (US)
City: Sugar Grove, IL
e. Country, city, lat+long of sending host
bash $ links -dump http://api.hostip.info/get_html.php?position=true
Country: RZECZPOSPOLITA POLSKA (PL)
City: Warsaw
Latitude: 52.2333
f. Country, city, lat+long for specific ip
bash $ links -dump http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
Country: UNITED STATES (US)
City: Sugar Grove, IL
Latitude: 41.7696
Longitude: -88.4588
g. xml outout of #f
bash $ links -dump http://api.hostip.info/?ip=12.215.42.19
[use the URL above for an example - XML too long to paste below]
B. Country Flag
The following HTML can be used to get a country flag for a given ip address. The database
is significantly more accurate (it ought to be 100%) for countries than for cities.
B.1 Flag of visitor's location:
<A HREF="http://www.hostip.info">
<IMG SRC="http://api.hostip.info/flag.php" BORDER="0" ALT="IP Address Lookup">
</A>
B.2 Flag of any IP address:
<A HREF="http://www.hostip.info">
<IMG SRC="http://api.hostip.info/flag.php?ip=12.215.42.19" ALT="IP Address Lookup">
</A>
C. Embedded Applet
The following is designed to be embedded within another HTML page using the OBJECT tag. This
reproduces the zoom-in applet, (or an explanatory message with a link to fix, if the IP address
lookup is unknown). Which means you can embed the applet in your own site without needing to have
the local database and map data (which runs to a few gigabytes...)
All you need do is include the OBJECT block below in your HTML. Note, you can also add "?ip=aaa.bbb.ccc.ddd" to the frame.html url below to map a specific IP address.
<OBJECT DATA='http://www.hostip.info/map/frame.html' TYPE='text/html' BORDER=0 WIDTH=610 HEIGHT=330 HSPACE=0 VSPACE=0> </OBJECT>
2.