示例#1
0
 } else {
     // Making an API call to Hostip:
     $xml = @unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ipa));
     if ($xml) {
         // Get the city
         $city = $xml['geoplugin_city'];
         // Get the countryname
         $countryName = $xml['geoplugin_countryName'];
         // Get the country code
         $countryAbbrev = $xml['geoplugin_countryCode'];
         // Country Latitude
         $countryLong = $xml['geoplugin_longitude'];
         $countryLat = $xml['geoplugin_latitude'];
     } else {
         // try to get the stuff via xml
         $fxml = @jak_load_xml_from_curl('http://www.geoplugin.net/xml.gp?ip=' . $ipa);
         // Parse the xml
         $xml = simplexml_load_string($fxml);
         // Get the city
         $city = $xml->geoplugin_city;
         // Get the countryname
         $countryName = $xml->geoplugin_countryName;
         // Get the country code
         $countryAbbrev = $xml->geoplugin_countryCode;
         // Country Latitude
         $countryLong = $xml->geoplugin_longitude;
         $countryLat = $xml->geoplugin_latitude;
     }
 }
 // This is a more accurate version but limited to 20 per hour, so if you exceed
 if (!$countryLat) {
示例#2
0
function jak_load_xml_from_url($jakvar)
{
    if ($jakvar) {
        return simplexml_load_string(jak_load_xml_from_curl($jakvar));
    }
}