diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8fce603
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+data/
diff --git a/README.md b/README.md
index 87d5715..a1002d7 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,5 @@ DefiVelib
=========
A website to compare travel times in Velib at Paris.
+
+Currently working on…
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..9556c37
--- /dev/null
+++ b/index.php
@@ -0,0 +1,137 @@
+(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))));
+ }
+ }
+?>
+
+
+
+
+
+
+ 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
+
+
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é.
+
+
+