Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (46 sloc) 1.358 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<?php
/*
Placefinder Explorer by Christian Heilmann
http://isithackday.com/hacks/geo/placefinder/
Copyright (c)2010 Christian Heilmann
Code licensed under the BSD License:
http://wait-till-i.com/license.txt
*/
header('Content-type: text/javascript');
$appid = 'YD-bs4vWJU_JXrmPwSfQ8yStcfWoDA5n51J';
echo 'placefinder.datain("';
$latlon = $_GET['latlon'];
$url='http://where.yahooapis.com/geocode?q='.$latlon.'&gflags=ACR&flags=QRGSTXP&appid='.$appid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$data = unserialize($output);
$found = false;
if($data['ResultSet']['Result'][0]){
  $set = $data['ResultSet']['Result'][0];
  echo '<ul>';
  foreach(array_keys($set) as $s){
    if($set[$s]!=''){
      if(!$found && strpos($s,'line') !== false){
        $found = true;
        $name = $set[$s];
      }
      if(is_array($set[$s])){
        echo '<li><span>'.ucfirst($s).': </span><ul>';
        foreach(array_keys($set[$s]) as $x){
          if($set[$s][$x]!=''){
            echo '<li><span>'.ucfirst($x).': </span>'.$set[$s][$x].'</li>';
          }
        }
        echo '</ul></li>';
      } else {
        echo '<li><span>'.ucfirst($s).': </span>'.$set[$s].'</li>';
      }
    }
  }
  echo '</ul>';
}
echo '","'.$latlon.'","'.$name.'")';
?>
Something went wrong with that request. Please try again.