2014-01-23 23:48:59 +01:00
< ? php
2014-01-24 18:07:59 +01:00
session_start ();
2014-01-24 01:02:21 +01:00
date_default_timezone_set ( " Europe/Paris " );
2014-01-24 18:07:59 +01:00
2014-01-24 01:02:21 +01:00
function search ( $array ) {
global $_POST ;
return in_array ( $_POST [ 'start_search' ], $array ) && in_array ( $_POST [ 'end_search' ], $array );
}
2014-01-24 18:55:06 +01:00
// Generates a token against CSRF
// ==============================
function generate_token ( $name = '' ) {
if ( session_id () == '' )
session_start ();
$token = uniqid ( rand (), true );
$_SESSION [ $name . '_token' ] = $token ;
$_SESSION [ $name . '_token_time' ] = time ();
return $token ;
}
// Checks that the anti-CSRF token is correct
// ==========================================
function check_token ( $time , $name = '' ) {
if ( session_id () == '' )
session_start ();
if ( isset ( $_SESSION [ $name . '_token' ]) && isset ( $_SESSION [ $name . '_token_time' ]) && ( isset ( $_POST [ 'token' ]) || isset ( $_GET [ 'token' ]))) {
if ( ! empty ( $_POST [ 'token' ]))
$token = $_POST [ 'token' ];
else
$token = $_GET [ 'token' ];
if ( $_SESSION [ $name . '_token' ] == $token ) {
if ( $_SESSION [ $name . '_token_time' ] >= ( time () - ( int ) $time ))
return true ;
}
}
return false ;
}
2014-01-23 23:48:59 +01:00
if ( is_file ( 'data/data' )) {
$data = unserialize ( gzinflate ( base64_decode ( file_get_contents ( 'data/data' ))));
}
else {
$data = array ();
}
2014-01-24 18:55:06 +01:00
if ( ! empty ( $_GET [ 'suppr' ]) && ! empty ( $_SESSION [ 'admin' ]) && ! empty ( $_GET [ 'token' ])) {
if ( check_token ( 600 , 'defivelib' )) {
unlink ( $data [ $_GET [ 'suppr' ]]);
}
else {
exit ( " Mauvais token, veuillez réessayer. " );
}
2014-01-24 18:07:59 +01:00
}
if ( ! empty ( $_GET [ 'deco' ])) {
session_destroy ();
}
if ( is_file ( 'data/config' )) {
$config = unserialize ( gzinflate ( base64_decode ( file_get_contents ( 'data/config' ))));
if ( ! empty ( $_GET [ 'code' ]) && $_GET [ 'code' ] == $config [ 0 ]) {
$_SESSION [ 'admin' ] = true ;
}
}
2014-01-24 01:02:21 +01:00
$search = false ;
2014-01-24 18:55:06 +01:00
if ( ! empty ( $_POST [ 'start_search' ]) && ! empty ( $_POST [ 'end_search' ]) & ! empty ( $_POST [ 'token' ])) {
if ( check_token ( 600 , 'defivelib' )) {
$search = true ;
$data = array_filter ( $data , " search " );
}
else {
exit ( " Mauvais token, veuillez réessayer. " );
}
2014-01-24 01:02:21 +01:00
}
2014-01-23 23:48:59 +01:00
if (( ! empty ( $_POST [ 'time_min' ]) || ! empty ( $_POST [ 'time_sec' ])) && ! empty ( $_POST [ 'start' ]) && ! empty ( $_POST [ 'end' ])) {
2014-01-24 18:55:06 +01:00
if ( check_token ( 600 , 'defivelib' )) {
$min = ( ! empty ( $_POST [ 'time_min' ])) ? ( int ) $_POST [ 'time_min' ] : 0 ;
$sec = ( ! empty ( $_POST [ 'time_sec' ])) ? ( int ) $_POST [ 'time_sec' ] : 0 ;
$pseudo = ( ! empty ( $_POST [ 'pseudo' ])) ? $_POST [ 'pseudo' ] : " Anonyme " ;
2014-01-23 23:48:59 +01:00
2014-01-24 18:55:06 +01:00
$data [] = array ( " date " => time (), " start " => ( int ) $_POST [ 'start' ], " end " => ( int ) $_POST [ 'end' ], " min " => $min , " sec " => $sec , " pseudo " => $pseudo );
2014-01-23 23:48:59 +01:00
2014-01-24 18:55:06 +01:00
// TODO : Upload + taille max de l'upload
2014-01-23 23:48:59 +01:00
2014-01-24 18:55:06 +01:00
if ( count ( $data ) == 1 || $min != $data [ count ( $data ) - 2 ][ 'min' ] || $sec != $data [ count ( $data ) - 2 ][ 'sec' ] || $_POST [ 'start' ] != $data [ count ( $data ) - 2 ][ 'start' ] || $_POST [ 'end' ] != $data [ count ( $data ) - 2 ][ 'end' ] || $pseudo != $data [ count ( $data ) - 2 ][ 'pseudo' ]) {
file_put_contents ( 'data/data' , base64_encode ( gzdeflate ( serialize ( $data ))));
}
}
else {
exit ( " Mauvais token, veuillez réessayer. " );
2014-01-23 23:48:59 +01:00
}
}
2014-01-24 18:55:06 +01:00
$token = generate_token ( 'defivelib' );
2014-01-23 23:48:59 +01:00
?>
<! DOCTYPE html >
< html lang = " fr " >
< head >
< meta charset = " utf-8 " >
2014-01-24 18:07:59 +01:00
< title > DéfiVélib </ title >
2014-01-23 23:48:59 +01:00
< meta name = " author " content = " phyks " >
2014-01-24 18:30:05 +01:00
< style type = " text/css " media = " screen " >
html , body {
margin : 0 ;
padding : 0 ;
width : 100 % ;
height : 100 % ;
font - family : sans - serif ;
background - color : lightgrey ;
background - image : url ( data : image / png ; base64 , iVBORw0KGgoAAAANSUhEUgAAAIQAAACECAYAAABRRIOnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1 +/ AAAABV0RVh0Q3JlYXRpb24gVGltZQAzLzEyLzEzP / y5FwAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAACAASURBVHicbd1pkiPHkQVgR2KHURyJWu5 / Fx1Ao6E1W7pCoTagYNiBnB / FL + oh2WVGY1cByIzw9flzz8Don //8Z/+nP/2pZrNZXS6X2m639fPPP9d4PK7b7Vbb7bb+/ve/1/F4rNlsVi8vL/XTTz/VZDKp2+1WHx8f9ac//am6rqvxeFyvr6/1l7/8pcbjcXVdV09PT/Xzzz9X13VVVfX+/l6//PJLjcfjOh6P9fHx0X6/XC71/v5e//M//1Oz2axut1u9vr7WL7/8Un5c/3a71WQyqdfX1/rpp59qNpu113/++eeazWbt/j/99FPN5/Maj8ft98ViUdfrtd7f3+sf//hHVVUdj8e239PpVF3XtfVMp9Pq+75eXl7ql19+qfv9XrPZrF2v67q2nr/+9a81Go2qqur5+bn+9re/1fF4rOVyWev1ur1ufX/+859rMpnU8Xis3W5Xf/7zn+t2u9VisWjvv1wutVgsmjyrqt3Pft3vL3/5S5P3y8tL/e1vf6vz+Vzz+bzW63X94x//qMvlUqPR6OHzx+OxRt+/f+/7vq/T6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Aqf729vZQqiaGwCtIYdfrtb1fFNvtdq1K0bugi77va7fbPUQj+sF
}
#main {
width : 50 % ;
min - height : 50 % ;
margin : auto ;
background - color : white ;
text - align : center ;
padding : 1 em ;
- moz - box - sizing : border - box ; - webkit - box - sizing : border - box ; box - sizing : border - box ;
}
#main h1 {
margin : 0 ;
border : 1 px solid black ;
background - color : rgb ( 117 , 170 , 39 );
}
#main h2 {
text - align : left ;
}
#main h1 a {
color : black ;
text - decoration : none ;
font - size : 1.5 em ;
}
table td , th {
padding : 0.5 em ;
border : 1 px solid black ;
}
table th {
background - color : rgba ( 117 , 170 , 39 , 0.4 );
}
table {
border - collapse : collapse ;
margin : auto ;
}
fieldset {
background - color : rgba ( 17 , 78 , 121 , 0.1 );
}
2014-01-24 18:55:06 +01:00
#disclaimer {
font - size : 0.75 em ;
}
#disclaimer p {
text - align : left ;
}
2014-01-24 18:30:05 +01:00
</ style >
2014-01-23 23:48:59 +01:00
</ head >
< body >
< div id = " main " >
< h1 >< a href = " index.php " > DéfiVélib </ a ></ h1 >
< ? php
if ( ! is_dir ( 'data/' )) {
mkdir ( 'data/' );
}
if ( ! is_file ( 'data/config' )) //First run
{
//Define a new synchronisation code
$code_synchro = substr ( sha1 ( rand ( 0 , 30 ) . time () . rand ( 0 , 30 )), 0 , 10 );
file_put_contents ( 'data/config' , base64_encode ( gzdeflate ( serialize ( array ( $code_synchro ))))); //Save it in data/data file
$_GET [ 'code' ] = $code_synchro ;
echo " <p>
Définition du code de synchronisation .< br />
Vous pouvez désormais mettre à jour la liste des stations en visitant l ' adresse suivante ( update URL ) :< br />
< a href = 'http://" . $_SERVER["SERVER_NAME"].$_SERVER[' REQUEST_URI ']."?update=1&code=".$code_synchro."' > http :// " . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] . " ? update = 1 & code = " . $code_synchro . " </ a >
</ p >
< p >
Il est possible d ' automatiser la tâche via une tâche cron . Par exemple ( see README ) :< br />
* * * * * wget - q - O < a href = 'http://" . $_SERVER["SERVER_NAME"].$_SERVER[' REQUEST_URI ']."?update=1&code=".$code_synchro."' > http :// " . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] . " ? update = 1 & code = " . $code_synchro . " </ a > #Commande de mise a jour des stations de velib
</ p > " ;
}
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 " <p>Mise à jour de la liste des stations effectuée avec succès (Update successful).</p> " ;
}
else
{
echo " <p>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.</p> " ;
}
echo " <p><a href='index.php'>Retourner à l'application (Back to index)</a></p></body></html> " ;
exit ();
}
$liste_stations = unserialize ( gzinflate ( base64_decode ( file_get_contents ( 'data/stations' ))));
?>
2014-01-24 18:55:06 +01:00
< div id = " disclaimer " >
< h2 > Disclaimer </ h2 >
< p > Les temps rentrés sur cette page ne sont qu 'indicatifs et sont fournis par les internautes eux-mêmes. Ils peuvent donc ne pas refléter les temps réels de parcours. En particulier, il est important de rappeler que le code de la route s' applique aussi aux vélos et que l 'obtention d' un meilleur temps ne doit pas se faire au détriment du respect du code de la route .</ p >
< p > Le respect des données personnelles étant particulièrement important , ce script ne conserve aucune information particulière si vous ne souhaitez pas en renseigner . Votre adresse IP est néanmoins stockée dans les logs de connexion au serveur , comme pour tout serveur web , conformément à l ' article 6 de la LCEN .</ p >
< p >< a href = " README.md " > Plus d ' informations sur DefiVelib </ a ></ p >
</ div >
2014-01-23 23:48:59 +01:00
< h2 > Ajouter un trajet </ h2 >
2014-01-24 18:30:05 +01:00
< form method = " post " action = " index.php " > <!-- enctype = " multipart/form-data " -->
< fieldset >
< legend > Trajet </ legend >
2014-01-23 23:48:59 +01:00
< p >< label name = " start " > Station de départ : </ label >
2014-01-24 01:02:21 +01:00
< select name = " start " id = " start " >
2014-01-23 23:48:59 +01:00
< ? php
foreach ( $liste_stations as $key => $station ) {
2014-01-24 18:55:06 +01:00
if ( ! empty ( $_POST [ 'start_search' ]) && $_POST [ 'start_search' ] == $key )
$selected = " selected " ;
else
$selected = " " ;
echo " <option value= \" " . $key . " \" " . $selected . " > " . $station [ 'name' ] . " </option> " ;
2014-01-23 23:48:59 +01:00
}
?>
</ select >
</ p >
< p >< label for = " end " > Station d ' arrivée : </ label >
2014-01-24 01:02:21 +01:00
< select name = " end " id = " end " >
2014-01-23 23:48:59 +01:00
< ? php
foreach ( $liste_stations as $key => $station ) {
2014-01-24 18:55:06 +01:00
if ( ! empty ( $_POST [ 'end_search' ]) && $_POST [ 'end_search' ] == $key )
$selected = " selected " ;
else
$selected = " " ;
echo " <option value= \" " . $key . " \" " . $selected . " > " . $station [ 'name' ] . " </option> " ;
2014-01-23 23:48:59 +01:00
}
?>
</ select >
</ p >
< p >< label for = " time_min " > Durée du trajet : </ label >< input type = " int " name = " time_min " id = " time_min " size = " 2 " /> min < input type = " int " name = " time_sec " id = " time_sec " size = " 2 " /> s </ p >
2014-01-24 18:30:05 +01:00
</ fieldset >
< fieldset >
< legend > Informations </ legend >
2014-01-24 01:02:21 +01:00
< p >< label for = " pseudo " > Votre pseudo ( optionnel ) : </ label >< input type = " text " name = " pseudo " id = " pseudo " /></ p >
2014-01-24 18:30:05 +01:00
<!-- < p >< label for = " photo " > Photo du ticket ( ? max ) : </ label >< input type = " file " name = " photo " id = " photo " ></ p >-->
</ fieldset >
2014-01-24 01:02:21 +01:00
< p >
2014-01-24 18:55:06 +01:00
< input type = " submit " value = " Envoyer " />
< input type = " hidden " name = " token " value = " <?php echo $token ; ?> " />
2014-01-24 18:30:05 +01:00
<!-- < input type = " hidden " name = " MAX_FILE_SIZE " value = " 2097152 " >-->
2014-01-24 01:02:21 +01:00
</ p >
2014-01-23 23:48:59 +01:00
</ form >
2014-01-24 01:02:21 +01:00
< h2 >< ? php if ( $search ) { ?> Résultats<?php } else {?>Derniers trajets ajoutés<?php }?></h2>
2014-01-23 23:48:59 +01:00
< ? php
if ( ! empty ( $data )) {
?>
< table >
< tr >
2014-01-24 01:02:21 +01:00
< th > Date </ th >
2014-01-23 23:48:59 +01:00
< th > Départ </ th >
< th > Arrivée </ th >
< th > Temps </ th >
2014-01-24 01:02:21 +01:00
< th > Pseudo </ th >
2014-01-24 18:07:59 +01:00
< ? php
if ( ! empty ( $_SESSION [ 'admin' ])) {
?>
< th > Supprimer </ th >
< ? php
}
?>
2014-01-23 23:48:59 +01:00
</ tr >
< ? php
2014-01-24 01:02:21 +01:00
if ( $search ) {
$min = array ();
$sec = array ();
foreach ( $data as $key => $result ) {
$min [ $key ] = $result [ 'min' ];
$sec [ $key ] = $result [ 'sec' ];
}
array_multisort ( $min , SORT_DESC , $sec , SORT_DESC , $data );
2014-01-24 18:07:59 +01:00
foreach ( $data as $key => $result ) {
if ( ! empty ( $_SESSION [ 'admin' ])) {
2014-01-24 18:55:06 +01:00
$delete = " <td><a href= \" ?suppr= " . $key . " &token= " . $token . " \" >Supprimer</a></td> " ;
2014-01-24 18:07:59 +01:00
}
else {
$delete = " " ;
}
echo " <tr><td> " . date ( 'd/m/Y à H:i' , $result [ 'date' ]) . " </td><td> " . h tmlspecialchars ( $liste_stations [ $result [ 'start' ]][ 'name' ]) . " </td><td> " . htmlspecialchars ( $liste_stations [ $result [ 'end' ]][ 'name' ]) . " </td><td> " . ( int ) $result [ 'min' ] . " min " . ( int ) $result [ 'sec' ] . " s</td><td> " . htmlspecialchars ( $result [ 'pseudo' ]) . " </td> " . $delete . " </tr> " ;
2014-01-24 01:02:21 +01:00
}
}
else {
for ( $i = count ( $data ) - 1 ; $i >= max ( count ( $data ) - 10 , 0 ); $i -- ) {
2014-01-24 18:07:59 +01:00
if ( ! empty ( $_SESSION [ 'admin' ])) {
2014-01-24 18:55:06 +01:00
$delete = " <td><a href= \" ?suppr= " . $i . " &token= " . $token . " \" >Supprimer</a></td> " ;
2014-01-24 18:07:59 +01:00
}
else {
$delete = " " ;
}
echo " <tr><td> " . date ( 'd/m/Y à H:i' , $data [ $i ][ 'date' ]) . " </td><td> " . htmlspecialchars ( $liste_stations [ $data [ $i ][ 'start' ]][ 'name' ]) . " </td><td> " . htmlspecialchars ( $liste_stations [ $data [ $i ][ 'end' ]][ 'name' ]) . " </td><td> " . ( int ) $data [ $i ][ 'min' ] . " min " . ( int ) $data [ $i ][ 'sec' ] . " s</td><td> " . htmlspecialchars ( $data [ $i ][ 'pseudo' ]) . " </td> " . $delete . " </tr> " ;
2014-01-24 01:02:21 +01:00
}
2014-01-23 23:48:59 +01:00
}
?>
</ table >
< ? php
}
else {
?>
< p > Aucun trajet enregistré .</ p >
< ? php
}
?>
2014-01-24 01:02:21 +01:00
< h2 > Recherche de trajets </ h2 >
< form method = " post " action = " index.php " >
2014-01-24 18:30:05 +01:00
< fieldset >
2014-01-24 01:02:21 +01:00
< p >< label name = " start_search " > Station de départ : </ label >
< select name = " start_search " id = " start_search " >
< ? php
foreach ( $liste_stations as $key => $station ) {
2014-01-24 18:07:59 +01:00
if ( ! empty ( $_POST [ 'start_search' ]) && $_POST [ 'start_search' ] == $key )
$selected = " selected " ;
else
$selected = " " ;
echo " <option value= \" " . $key . " \" " . $selected . " > " . $station [ 'name' ] . " </option> " ;
2014-01-24 01:02:21 +01:00
}
?>
</ select >
</ p >
< p >< label for = " end_search " > Station d ' arrivée : </ label >
< select name = " end_search " id = " end_search " >
< ? php
foreach ( $liste_stations as $key => $station ) {
2014-01-24 18:07:59 +01:00
if ( ! empty ( $_POST [ 'end_search' ]) && $_POST [ 'end_search' ] == $key )
$selected = " selected " ;
else
$selected = " " ;
echo " <option value= \" " . $key . " \" " . $selected . " > " . $station [ 'name' ] . " </option> " ;
2014-01-24 01:02:21 +01:00
}
?>
</ select >
</ p >
2014-01-24 18:30:05 +01:00
</ fieldset >
2014-01-24 01:02:21 +01:00
< p >
2014-01-24 18:55:06 +01:00
< input type = " submit " value = " Rechercher " />
< input type = " hidden " name = " token " value = " <?php echo $token ; ?> " />
2014-01-24 01:02:21 +01:00
</ p >
</ form >
2014-01-24 18:07:59 +01:00
< ? php
if ( ! empty ( $_SESSION [ 'admin' ])) {
?>
< p >< a href = " ?deco=1 " > Déconnexion </ a ></ p >
< ? php
}
?>
2014-01-23 23:48:59 +01:00
</ div >
</ body >
</ html >