76 lines
1.6 KiB
PHP
76 lines
1.6 KiB
PHP
<?php
|
|
class Mappy
|
|
{
|
|
protected $login = 'scoresdecisions';
|
|
protected $password = 'g1nq3iKv';
|
|
|
|
protected $villes = array(
|
|
'BORDEAUX',
|
|
'CAEN' ,
|
|
'CANNES',
|
|
'GRENOBLE',
|
|
'LA BAULE',
|
|
'LILLE',
|
|
'LYON',
|
|
'MARSEILLE',
|
|
'MONTPELLIER',
|
|
'NANCY',
|
|
'NANTES',
|
|
'NICE',
|
|
'RENNES',
|
|
'STRASBOURG',
|
|
'TOULOUSE',
|
|
'ASNIERES-SUR-SEINE',
|
|
'BOULOGNE-BILLANCOURT',
|
|
'COURBEVOIE',
|
|
'ISSY-LES-MOULINEAUX',
|
|
'LEVALLOIS-PERRET',
|
|
'MONTROUGE',
|
|
'NANTERRE',
|
|
'NEUILLY-SUR-SEINE',
|
|
'RUEIL-MALMAISON',
|
|
'SEVRES',
|
|
'VERSAILLES',
|
|
'PARIS'
|
|
);
|
|
|
|
public function getToken()
|
|
{
|
|
$ACCESSOR_URL = 'http://axe.mappy.com/1v1/';
|
|
$timestamp = time();
|
|
$hash = md5($this->login."@".$this->password."@".$timestamp);
|
|
$preToken = $this->login."@".$timestamp."@".$hash;
|
|
$urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . urlencode($_SERVER["REMOTE_ADDR"]);
|
|
$fh = @fopen($urlGetToken, 'rb');
|
|
|
|
if ($fh == false) return false;
|
|
$token = '';
|
|
while (!feof($fh))$token .= fread($fh, 8192);
|
|
fclose($fh);
|
|
return ($token);
|
|
}
|
|
|
|
protected function cleanAdress($ville)
|
|
{
|
|
$ville = ' '.trim(preg_replace('/([0-9]|ARRONDISSEMENT|_)/i', ' ', $ville)).' ';
|
|
$ville = trim(strtr($ville, array(' EME ' => '', ' ER ' => '')));
|
|
return (ucwords(strtolower($ville)));
|
|
}
|
|
|
|
public function villeCouverte($ville)
|
|
{
|
|
$ville = $this->cleanAdress($ville);
|
|
/*if (in_array(strtoupper($ville),$this->villes)){
|
|
return true;
|
|
}*/
|
|
return false;
|
|
}
|
|
|
|
public function getJs()
|
|
{
|
|
$token = $this->getToken();
|
|
$href = 'http://axe.mappy.com/1v1/init/get.aspx?auth='.$token.'&version=2.16&solution=ajax';
|
|
return $href;
|
|
}
|
|
|
|
} |