Files
2020-01-27 08:56:08 +01:00

60 lines
1.5 KiB
PHP

<?php
include_once(realpath(dirname(__FILE__)) . "/Magasin.class.php");
?>
<?php
function convert($chaine){
$avant = "àáâãäåòóôõöøèéêëçìíîïùúûüÿñÁÂÀÅÃÄÇÉÊÈËÓÔÒØÕÖÚÛÙÜ";
$apres = "aaaaaaooooooeeeeciiiiuuuuynaaaaaaceeeeoooooouuuu";
$chaine = strtolower($chaine);
$chaine = strtr($chaine, $avant, $apres);
return $chaine;
}
$key = new Variable();
$key->charger("cle_google_map");
$rec = file_get_contents("http://maps.google.fr/maps/geo?q=". $_GET['cp']."&output=csv&key=" . $key->valeur);
$coord = explode(",", $rec);
$lat = $coord[2] ;
$lon = $coord[3];
$magasin = new Magasin();
$query = "select * from $magasin->table where cp=\"" . $_GET['cp'] . "\"";
$resul = mysql_query($query, $magasin->link);
header("Content-type: text/xml");
echo'<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<markers>';
while($row = mysql_fetch_object($resul)){
$row->adresse = convert($row->adresse);
$row->nom = convert($row->nom);
if(! $row->lat){
$row->lat = $lat;
$row->lon = $lon;
}
echo '<marker ';
echo 'nom="' . $row->nom . '" ';
echo 'adresse="' . $row->adresse . '" ';
echo 'cp="'. $row->cp . '" ';
echo 'ville="' . $row->ville . '" ';
echo 'tel="' . $row->tel . '" ';
echo 'fax="' . $row->tel . '" ';
echo 'lat="' . $row->lat . '" ';
echo 'lng="' . $row->lon . '" ';
echo '/>';
}
echo '</markers>';
?>