--- /dev/null
+<?php
+function locateIp($ip){
+ $d = file_get_contents("http://www.ipinfodb.com/ip_query.php?ip=$ip&output=xml");
+
+ //Use backup server if cannot make a connection
+ if (!$d){
+ $backup = file_get_contents("http://backup.ipinfodb.com/ip_query.php?ip=$ip&output=xml");
+ $answer = new SimpleXMLElement($backup);
+ if (!$backup) return false; // Failed to open connection
+ }else{
+ $answer = new SimpleXMLElement($d);
+ }
+
+ $country_code = $answer->CountryCode;
+ $country_name = $answer->CountryName;
+ $region_name = $answer->RegionName;
+ $city = $answer->City;
+ $zippostalcode = $answer->ZipPostalCode;
+ $latitude = $answer->Latitude;
+ $longitude = $answer->Longitude;
+ $timezone = $answer->Timezone;
+ $gmtoffset = $answer->Gmtoffset;
+ $dstoffset = $answer->Dstoffset;
+
+ //Return the data as an array
+ return array('ip' => $ip, 'country_code' => $country_code, 'country_name' => $country_name, 'region_name' => $region_name, 'city' => $city, 'zippostalcode' => $zippostalcode, 'latitude' => $latitude, 'longitude' => $longitude, 'timezone' => $timezone, 'gmtoffset' => $gmtoffset, 'dstoffset' => $dstoffset);
+}
+
+function isCorrectContinentCode ($continentCode, $country_code) {
+ $path = "../manual/".$continentCode."/".$country_code."/".$country_code.".conf" ;
+ if ( file_exists ($path) ) return $continentCode ;
+ return false ;
+}
+
+function findContinent($country_code){
+
+ $continentCode = "eu" ;
+ if ( isCorrectContinentCode ($continentCode, $country_code) ) return $continentCode ;
+
+ $continentCode = "as" ;
+ if ( isCorrectContinentCode ($continentCode, $country_code) ) return $continentCode ;
+
+ $continentCode = "af" ;
+ if ( isCorrectContinentCode ($continentCode, $country_code) ) return $continentCode ;
+
+ $continentCode = "sa" ;
+ if ( isCorrectContinentCode ($continentCode, $country_code) ) return $continentCode ;
+
+ $continentCode = "oc" ;
+ if ( isCorrectContinentCode ($continentCode, $country_code) ) return $continentCode ;
+
+ $continentCode = "na" ;
+ if ( isCorrectContinentCode ($continentCode, $country_code) ) return $continentCode ;
+
+ return false ;
+
+}
+
+$ip = $_SERVER['REMOTE_ADDR'];
+$ip_data = locateIp($ip);
+
+if ($ip_data == false ) {
+ $fileName = "../manual/manual.conf" ;
+} else {
+ $continent = findContinent ( $country_code ) ;
+
+ if ($continent == false ) {
+ $fileName = "../manual/manual.conf" ;
+ } else {
+ $fileName = "../manual/".$continent."/".$country_code."/".$country_code.".conf" ;
+ }
+}
+
+/*
+echo "conf file is [".$fileName."]" ;
+
+echo "IP : " . $ip_data['ip'] . "\n";
+echo "Country code : " . $ip_data['country_code'] . "\n";
+echo "Country name : " . $ip_data['country_name'] . "\n";
+echo "Region name : " . $ip_data['region_name'] . "\n";
+echo "City : " . $ip_data['city'] . "\n";
+echo "Zip/postal code : " . $ip_data['zippostalcode'] . "\n";
+echo "Latitude : " . $ip_data['latitude'] . "\n";
+echo "Longitude : " . $ip_data['longitude'] . "\n";
+echo "Timezone : " . $ip_data['timezone'] . "\n";
+echo "GmtOffset : " . $ip_data['gmtoffset'] . "\n";
+echo "DstOffset : " . $ip_data['dstoffset'] . "\n";
+*/
+
+// echo "##################################\n" ;
+echo file_get_contents ($fileName);
+// echo "##################################\n" ;
+
+?>