2         @define('CONST_ConnectionBucket_PageType', 'Reverse');
 
   4         require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
 
   5         require_once(CONST_BasePath.'/lib/init-website.php');
 
   6         require_once(CONST_BasePath.'/lib/log.php');
 
   7         require_once(CONST_BasePath.'/lib/PlaceLookup.php');
 
   9         if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
 
  11                 $fLoadAvg = getLoadAverage();
 
  12                 if ($fLoadAvg > 2) sleep(60);
 
  13                 if ($fLoadAvg > 4) sleep(120);
 
  16                         userError("Bulk User: Temporary block due to high server load");
 
  22         ini_set('memory_limit', '200M');
 
  25         $sOutputFormat = 'xml';
 
  26         if (isset($_GET['format']) && ($_GET['format'] == 'xml' || $_GET['format'] == 'json'))
 
  28                 $sOutputFormat = $_GET['format'];
 
  32         $aLangPrefOrder = getPreferredLanguages();
 
  34         $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
  36         $aSearchResults = array();
 
  37         $aCleanedQueryParts = array();
 
  38         if (isset($_GET['osm_ids']))
 
  40                 $oPlaceLookup = new PlaceLookup($oDB);
 
  41                 $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
 
  42                 $oPlaceLookup->setIncludeAddressDetails(getParamBool('addressdetails', true));
 
  43                 $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
 
  44                 $oPlaceLookup->setIncludeNameDetails(getParamBool('namedetails', false));
 
  46                 $aOsmIds = explode(',', $_GET['osm_ids']);
 
  48                 if ( count($aOsmIds) > CONST_Places_Max_ID_count ) 
 
  50                         userError('Bulk User: Only ' . CONST_Places_Max_ID_count . " ids are allowed in one request.");
 
  54                 foreach ($aOsmIds AS $sItem) 
 
  57                         if (empty($sItem)) continue;
 
  60                         $iId = (int) substr($sItem, 1);
 
  61                         if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
 
  63                                 $aCleanedQueryParts[] = $sType . $iId;
 
  64                                 $oPlaceLookup->setOSMID($sType, $iId);
 
  65                                 $oPlace = $oPlaceLookup->lookup();
 
  67                                         // we want to use the search-* output templates, so we need to fill
 
  68                                         // $aSearchResults and slightly change the (reverse search) oPlace
 
  71                                         unset($oResult['aAddress']);
 
  72                                         if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
 
  73                                         unset($oResult['langaddress']);
 
  74                                         $oResult['name'] = $oPlace['langaddress'];
 
  75                                         $aSearchResults[] = $oResult;
 
  82         if (CONST_Debug) exit;
 
  84         $sXmlRootTag = 'lookupresults';
 
  85         $sQuery = join(',',$aCleanedQueryParts);
 
  86         // we initialize these to avoid warnings in our logfile
 
  89         $aExcludePlaceIDs = [];
 
  92         include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');