From 4d0b8626c12f7703c184d1b05170286b26e0e177 Mon Sep 17 00:00:00 2001 From: Phyks Date: Fri, 24 Jan 2014 01:02:21 +0100 Subject: [PATCH] Added pseudo handling + few improvements --- index.php | 79 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/index.php b/index.php index 0bd09ff..83dd2e0 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,10 @@ (int) $_POST['start'], "end"=>(int) $_POST['end'], "min"=>$min, "sec"=>$sec); + $data[] = array("date"=>time(), "start"=>(int) $_POST['start'], "end"=>(int) $_POST['end'], "min"=>$min, "sec"=>$sec, "pseudo"=>$pseudo); - $last_data = end($data); + // TODO : Upload + taille max de l'upload - if($min != $last_data['min'] || $sec != $last_data['sec'] || $_POST['start'] != $last_data['start'] || $_POST['end'] != $last_data['end']) { + 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)))); } } @@ -86,9 +99,9 @@ $liste_stations = unserialize(gzinflate(base64_decode(file_get_contents('data/stations')))); ?>

Ajouter un trajet

-
+

- $station) { echo ""; @@ -97,7 +110,7 @@

- $station) { echo ""; @@ -106,21 +119,43 @@

min s

-

+

+

+

+ + +

-

Derniers trajets ajoutés

+

RésultatsDerniers trajets ajoutés

+ + max(count($data) - 11, 0); $i--) { - echo ""; + 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); + + foreach($data as $result) { + echo ""; + } + } + else { + for($i = count($data) - 1; $i >= max(count($data) - 10, 0); $i--) { + echo ""; + } } ?>
Date Départ Arrivée TempsPseudo
".htmlspecialchars($liste_stations[$data[$i]['start']]['name'])."".htmlspecialchars($liste_stations[$data[$i]['end']]['name'])."".(int) $data[$i]['min']."min ".(int) $data[$i]['sec']."s
".date('d/m/Y à H:i', $result['date'])."".htmlspecialchars($liste_stations[$result['start']]['name'])."".htmlspecialchars($liste_stations[$result['end']]['name'])."".(int) $result['min']."min ".(int) $result['sec']."s".htmlspecialchars($result['pseudo'])."
".date('d/m/Y à H:i', $data[$i]['date'])."".htmlspecialchars($liste_stations[$data[$i]['start']]['name'])."".htmlspecialchars($liste_stations[$data[$i]['end']]['name'])."".(int) $data[$i]['min']."min ".(int) $data[$i]['sec']."s".htmlspecialchars($data[$i]['pseudo'])."
@@ -132,6 +167,30 @@ +

Recherche de trajets

+
+

+ +

+

+ +

+

+ +

+