(int) $_POST['start'], "end"=>(int) $_POST['end'], "min"=>$min, "sec"=>$sec); $last_data = end($data); if($min != $last_data['min'] || $sec != $last_data['sec'] || $_POST['start'] != $last_data['start'] || $_POST['end'] != $last_data['end']) { file_put_contents('data/data', base64_encode(gzdeflate(serialize($data)))); } } ?> Vélibs à proximité

DéfiVélib

Définition du code de synchronisation.
Vous pouvez désormais mettre à jour la liste des stations en visitant l'adresse suivante (update URL) :
http://" . $_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']."?update=1&code=".$code_synchro."

Il est possible d'automatiser la tâche via une tâche cron. Par exemple (see README) :
* * * * * wget -q -O http://" . $_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']."?update=1&code=".$code_synchro." #Commande de mise a jour des stations de velib

"; } if(!empty($_GET['update']) || !empty($code_synchro)) //If we want to make an update (or first run) { if(empty($code_synchro) && is_file('data/config')) //If not first run, get the synchronisation code from data file { $data = unserialize(gzinflate(base64_decode(file_get_contents('data/config')))); $code_synchro = $data[0]; } if(!empty($_GET['code']) && $_GET['code'] == $code_synchro) //Once we have the code and it is correct { $stations_xml = simplexml_load_file('http://www.velib.paris.fr/service/carto'); $liste_stations = array(); foreach($stations_xml->markers->marker as $station) { $liste_stations[(int) $station['number']] = array('name'=>(string) $station['name'], 'address'=>(string) $station['fullAddress'], 'lat'=>(float) $station['lat'], 'lng'=>(float) $station['lng']); } file_put_contents('data/stations', base64_encode(gzdeflate(serialize($liste_stations)))); echo "

Mise à jour de la liste des stations effectuée avec succès (Update successful).

"; } else { echo "

Mauvais code de vérification (Error : bad synchronisation code). Veuillez réessayer la mise à jour. Se référer au README pour plus d'informations sur la mise à jour.

"; } echo "

Retourner à l'application (Back to index)

"; exit(); } $liste_stations = unserialize(gzinflate(base64_decode(file_get_contents('data/stations')))); ?>

Ajouter un trajet

min s

Derniers trajets ajoutés

"; } ?>
Départ Arrivée Temps
".htmlspecialchars($liste_stations[$trajet['start']]['name'])."".htmlspecialchars($liste_stations[$trajet['end']]['name'])."".(int) $trajet['min']."min ".(int) $trajet['sec']."s

Aucun trajet enregistré.