Administration

Error: You must enter a name for this location

"; $error = 1; } if ($address == '') { $msg .= "

Error: You must enter an address / state

"; $error = 1; } if ($county == '') { $msg .= "

Error: You must enter a county / state

"; $error = 1; } ######################################Main Geocoders##################################### ###############################United States of America################################## if ($country == 'us') { //Google $apiURL = "http://maps.google.com/maps/geo?q=$address,$town,$county,$postcode,$country&key=$gkey&output=xml"; $addressData = file_get_contents($apiURL); $coordinates = split('[,]',between("", "", $addressData)); $lat = $coordinates[1]; $long = $coordinates[0]; //Backup (Yahoo) if (!$lat && !$long) { //Yahoo chokes if it encounters 2 , symbols in a row, so we have to hand feed it the address. if ($street) {$addr .= "$street";} if ($town) {$addr .= ",$town";} if ($county) {$addr .= ",$county";} if ($postcode) {$addr .= ",$postcode";} if ($country) {$addr .= ",$country";} $apiURL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location=$addr"; $addressData = file_get_contents($apiURL); $lat = between("", "", $addressData); $long = between("", "", $addressData); } //Backup (LocalSearchMaps) if (!$lat && !$long) { $apiURL = "http://geo.localsearchmaps.com/?street=$address&city=$town&state=$county&zip=$postcode&country=$country&cb=coordinates"; $addressData = file_get_contents($apiURL); $coordinates = between('coordinates(', ');', $addressData); $coordinates = split('[,]', $coordinates); $lat = $coordinates[0]; $long = $coordinates[1]; } //Backup (geocoder.us) Just zipcodes OR addresses, not both. Also quite slow. if (!$lat && !$long) { if ($postcode) { $apiURL = "http://rpc.geocoder.us/service/csv?postcode=$postcode"; } else { $apiURL = "http://rpc.geocoder.us/service/csv?address=$address,$town,$county"; } $addressData = file_get_contents($apiURL); $coordinates = split('[,]', $addressData); $lat = $coordinates[0]; $long = $coordinates[1]; } } #######################################Canada############################################ elseif ($country == 'ca') { //geocoder.ca $address = "$street,$town,$county,$postcode,$country"; $address = trim(str_replace(' ', '+', $address)); $apiURL = "http://geocoder.ca/?locate=$address&town=$town&prov=$county&postal=$postcode&geoit=XML"; $addressData = file_get_contents($apiURL); $lat = between("", "", $addressData); $long = between("", "", $addressData); //Backup (LocalSearchMaps) if (!$lat && !$long) { $apiURL = "http://geo.localsearchmaps.com/?street=$address&city=$town&state=$county&country=$country&zip=$postcode&cb=coordinates"; $addressData = file_get_contents($apiURL); $coordinates = between('coordinates(', ');', $addressData); $coordinates = split('[,]', $coordinates); $lat = $coordinates[0]; $long = $coordinates[1]; } //Backup (Google) It is not very good with canada believe it or not. if (!$lat && !$long) { $apiURL = "http://maps.google.com/maps/geo?q=$address,$town,$county,$postcode,$country&key=$gkey&output=xml"; $addressData = file_get_contents($apiURL); $coordinates = split('[,]',between("", "", $addressData)); $lat = $coordinates[1]; $long = $coordinates[0]; } //Backup (Yahoo) if (!$lat && !$long) { //Yahoo chokes if it encounters 2 , symbols in a row, so we have to hand feed it the address. if ($street) {$addr .= "$street";} if ($town) {$addr .= ",$town";} if ($county) {$addr .= ",$county";} if ($postcode) {$addr .= ",$postcode";} if ($country) {$addr .= ",$country";} $apiURL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location=$addr"; echo $addressData = file_get_contents($apiURL); $lat = between("", "", $addressData); $long = between("", "", $addressData); } } ####################################United Kingdom####################################### // {{{ class LongLat /** * Longitude-Latitude utilities * * This function will include the static functions (collection of methods) * that are going to be used to help with the longitude and latitude coords. * * @version 0.1.0 * @license LGPL-CC * @copyright 1line * */ // {{{ class LongLat /** * Longitude-Latitude utilities * * This function will include the static functions (collection of methods) * that are going to be used to help with the longitude and latitude coords. * * @version 0.1.0 * @license LGPL-CC * @copyright 1line * */ class Util_LongLat { // {{{ public static function getCoord /** * Get Coords * * This function retrieves the coords of a givent url. * * @param string $type The type, either longitude or latitude * @param string $content The content of the page to parse. * @return string The value of the parsed content. */ function getCoord($type = 'latitude', $content) { switch (strtolower($type)) { case 'longitude': case 'latitude': $type = (string)$type; } preg_match("/
(.*[^>])<\/dd>/", $content, $values, PREG_OFFSET_CAPTURE); if (is_array($values) && isset($values[1][0])) { preg_match("/\((.*[^\)])\)/", $values[1][0], $lastvalues, PREG_OFFSET_CAPTURE); if (is_array($lastvalues) && isset($lastvalues[1][0])) { return (string)$lastvalues[1][0]; } } return 'none'; } // }}} } // }}} $lat = ''; $long = ''; if (strtolower((string)$county) == 'uk') { $content = file_get_contents("http://www.multimap.com/map/browse.cgi?client=public&search_result=&db=pc&keepicon=true&lang=&pc=$postcode&advanced=&client[equal%20tongue]ublic&addr2=&quicksearch=$postcode&addr3=&addr1="); $lat = Util_LongLat::getCoord('latitude', $content); $long = Util_LongLat::getCoord('longitude', $content); } ####################################Australia############################################ if ($country == 'au') { //Google if (!$lat && !$long) { $apiURL = "http://maps.google.com/maps/geo?q=$address,$town,$county,$postcode,$country&key=$gkey&output=xml"; $addressData = file_get_contents($apiURL); $coordinates = split('[,]',between("", "", $addressData)); $lat = $coordinates[1]; $long = $coordinates[0]; } } ####################################New Zealand########################################## if ($country == 'nz') { //Google if (!$lat && !$long) { $apiURL = "http://maps.google.com/maps/geo?q=$address,$town,$county,$postcode,$country&key=$gkey&output=xml"; $addressData = file_get_contents($apiURL); $coordinates = split('[,]',between("", "", $addressData)); $lat = $coordinates[1]; $long = $coordinates[0]; } } ####################################International######################################## //If there is no long/lat yet, we assume it's international and attempt to find it based on just the //town and country. //Yahoo if (!$lat && !$long) { //Yahoo chokes if it encounters 2 , symbols in a row, so we have to hand feed it the address. if ($town) {$addr .= "$town";} if ($country) {$addr .= ",$country";} $apiURL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location=$addr"; $addressData = file_get_contents($apiURL); $lat = between("", "", $addressData); $long = between("", "", $addressData); } //LocalSearchMaps (Backup) if (!$long && !$lat) { $apiURL = "http://geo.localsearchmaps.com/?street=$address&city=$town&state=$county&country=$country&zip=$postcode&cb=coordinates"; //$addressData = file_get_contents($apiURL); $coordinates = between('coordinates(', ');', $addressData); $coordinates = split('[,]', $coordinates); $lat = $coordinates[0]; $long = $coordinates[1]; } if (!$error) { insert_location($name, $desc, $address, $town, $county, $postcode, $country, $phone, $lat, $long, $link); echo "

Complete: Location has been successfully added to the database.

"; echo "\n"; } if ($error) { echo "$msg"; } } if($messages) { displayErrors($messages); } $filename = '../config.php'; $dir = "../install"; if (is_writable($filename)) { echo '

Attention: config.php is writable, for security reasons please set file permissions to 0644 or click here

'; } else { echo ""; } if (file_exists($dir)) { echo '

Attention: install directory still exsists, please DELETE this directory as this is a security risk.

'; } else { echo ""; } ?>

Add Locations

To add a new office, shop or whatever address you want on the maping system simply enter the details below.

Name:
Description:
Address:
Town / City:
County / State:
Post Code / Zip:
Phone:
Country: