2010-11-01 18:46:28 +03:00
|
|
|
<?php
|
2012-12-09 01:39:24 +04:00
|
|
|
@define('CONST_ConnectionBucket_PageType', 'Reverse');
|
|
|
|
|
2011-02-02 15:01:26 +03:00
|
|
|
require_once(dirname(dirname(__FILE__)).'/lib/init-website.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/log.php');
|
2013-08-27 20:21:20 +04:00
|
|
|
require_once(CONST_BasePath.'/lib/PlaceLookup.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
|
2010-11-01 18:46:28 +03:00
|
|
|
|
2013-04-13 00:45:24 +04:00
|
|
|
if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
|
|
|
|
{
|
|
|
|
$fLoadAvg = getLoadAverage();
|
|
|
|
if ($fLoadAvg > 2) sleep(60);
|
|
|
|
if ($fLoadAvg > 4) sleep(120);
|
|
|
|
if ($fLoadAvg > 6)
|
|
|
|
{
|
|
|
|
echo "Bulk User: Temporary block due to high server load\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$oDB =& getDB();
|
|
|
|
ini_set('memory_limit', '200M');
|
|
|
|
|
|
|
|
// Format for output
|
|
|
|
$sOutputFormat = 'xml';
|
|
|
|
if (isset($_GET['format']) && ($_GET['format'] == 'xml' || $_GET['format'] == 'json' || $_GET['format'] == 'jsonv2'))
|
|
|
|
{
|
|
|
|
$sOutputFormat = $_GET['format'];
|
|
|
|
}
|
2010-11-01 18:46:28 +03:00
|
|
|
|
2011-03-18 12:52:16 +03:00
|
|
|
// Show address breakdown
|
|
|
|
$bShowAddressDetails = true;
|
|
|
|
if (isset($_GET['addressdetails'])) $bShowAddressDetails = (bool)$_GET['addressdetails'];
|
|
|
|
|
2013-04-13 00:45:24 +04:00
|
|
|
// Preferred language
|
|
|
|
$aLangPrefOrder = getPreferredLanguages();
|
2010-11-01 18:46:28 +03:00
|
|
|
|
|
|
|
$hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
|
|
|
|
2013-04-13 00:45:24 +04:00
|
|
|
if (isset($_GET['osm_type']) && isset($_GET['osm_id']) && (int)$_GET['osm_id'] && ($_GET['osm_type'] == 'N' || $_GET['osm_type'] == 'W' || $_GET['osm_type'] == 'R'))
|
|
|
|
{
|
2013-08-27 20:21:20 +04:00
|
|
|
$oPlaceLookup = new PlaceLookup($oDB);
|
|
|
|
$oPlaceLookup->setLanguagePreference($aLangPrefOrder);
|
|
|
|
$oPlaceLookup->setIncludeAddressDetails($bShowAddressDetails);
|
|
|
|
$oPlaceLookup->setOSMID($_GET['osm_type'], $_GET['osm_id']);
|
2010-11-01 18:46:28 +03:00
|
|
|
|
2013-08-27 20:21:20 +04:00
|
|
|
$aPlace = $oPlaceLookup->lookup();
|
2011-02-02 15:01:26 +03:00
|
|
|
|
2013-08-27 20:21:20 +04:00
|
|
|
//if (!$iPlaceID) $sError = 'OSM ID Not Found';
|
2010-11-01 18:46:28 +03:00
|
|
|
}
|
2013-08-27 20:21:20 +04:00
|
|
|
else
|
2010-11-01 18:46:28 +03:00
|
|
|
{
|
2013-08-27 20:21:20 +04:00
|
|
|
$oReverseGeocode = new ReverseGeocode($oDB);
|
|
|
|
$oReverseGeocode->setLanguagePreference($aLangPrefOrder);
|
|
|
|
$oReverseGeocode->setIncludeAddressDetails($bShowAddressDetails);
|
2010-11-01 18:46:28 +03:00
|
|
|
|
2013-08-27 20:21:20 +04:00
|
|
|
$oReverseGeocode->setLatLon($_GET['lat'], $_GET['lon']);
|
|
|
|
$oReverseGeocode->setZoom(@$_GET['zoom']);
|
2011-02-02 15:01:26 +03:00
|
|
|
|
2013-08-27 20:21:20 +04:00
|
|
|
$aPlace = $oReverseGeocode->lookup();
|
2010-11-01 18:46:28 +03:00
|
|
|
}
|
2013-02-07 22:39:33 +04:00
|
|
|
|
|
|
|
if (CONST_Debug) exit;
|
|
|
|
|
2011-02-02 15:01:26 +03:00
|
|
|
include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
|