2         header("content-type: text/xml; charset=UTF-8");
\r 
   3         header("Access-Control-Allow-Origin: *");
\r 
   6         echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
\r 
   9         echo "<reversegeocode";
\r 
  10         echo " timestamp='".date(DATE_RFC822)."'";
\r 
  11         echo " attribution='Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.'";
\r 
  12         echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
\r 
  15         if (!sizeof($aPlace))
\r 
  18                         echo "<error>$sError</error>";
\r 
  20                         echo "<error>Unable to geocode</error>";
\r 
  25                 if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
\r 
  26                 if ($aPlace['osm_type'] && $aPlace['osm_id']) echo ' osm_type="'.($aPlace['osm_type']=='N'?'node':($aPlace['osm_type']=='W'?'way':'relation')).'"'.' osm_id="'.$aPlace['osm_id'].'"';
\r 
  27                 if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
\r 
  28                 echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
\r 
  30                 echo "<addressparts>";
\r 
  31                 foreach($aAddress as $sKey => $sValue)
\r 
  33                         $sKey = str_replace(' ','_',$sKey);
\r 
  35                         echo htmlspecialchars($sValue);
\r 
  38                 echo "</addressparts>";
\r 
  41         echo "</reversegeocode>";
\r