/* this php script produce a js-file with the global com.unitedCoders object. There are more functions in the geo.js (included directly)! Copyright 2009 by Christian Harms from http://united-coders.com/ free usage if a link is set to the website! */ var com = com||{}; com.unitedCoders = com.unitedCoders||{}; 0); //read the content $ret = array(); for($i = 0; $i array() ); $ip = $_SERVER['REMOTE_ADDR']; $ipData = readUrls(array("http://ipinfodb.com/ip_query.php?output=json&ip=".$ip, "http://api.hostip.info/get_html.php?position=true&ip=".$ip) ); //parse xml-response for iplocationtools, no encoding header, utf-8 comes in the xml if (substr($ipData[0],0,1)=='{') { $json = json_decode($ipData[0]); } else { $json = ''; } if ($json && $json->{'City'}) { //Aod the geo data to the result set array_push($result["ll"], array("name" => "ipinfodb", "country" => $json->{'CountryName'}, "city" => $json->{'City'}, "long" => floatval($json->{'Longitude'}), "lat" => floatval($json->{'Latitude'}))); } //parse via regex for hostip if (preg_match("/Country:\s+(.*?)\(\w+\)\nCity:\s+(.*?)\nLatitude: (\d+\.\d+)\nLongitude: (\d+\.\d+)/", $ipData[1], $ma)==1) { array_push($result['ll'], array( 'name' => 'hostip', 'country' => $ma[1], 'city' => $ma[2], 'long' => floatval($ma[4]), 'lat' => floatval($ma[3]))); }; echo "com.unitedCoders.geo =".json_encode($result).";\n"; ?> //Include the other javascript ip2gep APIs directly. document.write(''); document.write(''); ');"; } ?> //Include the additional functions... document.write('');