Info and sample code here:
http://phpweby.com/software/ip2country