From bd86b9cc65b3b2004204a82cabd08c53aba156dd Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 27 Nov 2015 17:13:07 +0100 Subject: [PATCH 01/18] rewriteRules --- .htaccess | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.htaccess b/.htaccess index efe2226..4f2d56e 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,15 @@ php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on + +#rewriterules +#urlrewritting +RewriteEngine On +RewriteBase / +RewriteRule ^v/([A-Za-z0-9]*)-([a-Z]{2})$ index.php?arena=$1&lang=$2 [L] +RewriteRule ^v/([A-Za-z0-9]*)$ index.php?arena=$1 [L] +RewriteRule ^v/-([a-Z]{2})$ index.php?lang=$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^([A-Za-z0-9]*)$ index.php?page=$1 [L] +RewriteRule ^index.php$ index.php/ [L] From e2987ed71c26c4f8fb9a3eeeacec414961b8a2b6 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 27 Nov 2015 17:18:12 +0100 Subject: [PATCH 02/18] xd_check --- src/functions.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/functions.php b/src/functions.php index b73107c..cc316b8 100644 --- a/src/functions.php +++ b/src/functions.php @@ -11,6 +11,50 @@ function get_arenas_list(){ } return $arenas; } +function rand_str($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'){ + + $chars_length = (strlen($chars) - 1); + $string = $chars{rand(0, $chars_length)}; + + for ($i = 1; $i < $length; $i = strlen($string)){ + $r = $chars{rand(0, $chars_length)}; + if ($r != $string{$i - 1}) $string .= $r; + } + return $string; +} +function xd_check_input($id=1){ + /* + *On génére un hash aléatoire qui sera + *ajouté aux formulaires, afin d'ajouter + *une vérification supplémentaire + *lors du traitement de ce dernier + */ + /* + * le parametre $id permet de selectionner le type de retour + * 0=> un input type hidden sans id + * 1=> un input type hidden avec id + * 2=> juste la valeur + */ + if(!isset($_SESSION['xd_check'])){ + //le générer + $_SESSION['xd_check']=rand_str(25); + } + switch($id){ + case 0: + return ""; + break; + case 1: + return ""; + break; + case 2: + return $_SESSION['xd_check']; + break; + default: + return ""; + break; + } +} + function get_language_array(){ /* * Choisir la langue de l'utilisateur From 2f3da7731a3a12d9c335ccbb4e9aab081b0d7a05 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 18:59:04 +0100 Subject: [PATCH 03/18] p --- html/index.php | 36 +++++++++++++++++++++++++++++++++--- lang/en.php | 3 ++- lang/fr.php | 3 ++- src/functions.php | 8 -------- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/html/index.php b/html/index.php index 242fece..af46480 100644 --- a/html/index.php +++ b/html/index.php @@ -18,9 +18,28 @@ require_once("../src/functions.php"); $arenas=get_arenas_list(); $lang=get_language_array(); + + +if(isset($_GET['arena'])){ + //check if arena is list + $currentArena = false; + foreach($arenas as $arena){ + if($arena['id'] == $GET['arena']){ + $currentArena = $GET['arena']; + break; + } + } + if(!$currentArena){ + error("Wrong parameter"); + die; + } +}else{ + $currentArena = ""; +} + + //form submitting -if (isset($_POST['xd_check'])) -{ +if (isset($_POST['xd_check'])){ //vérifier le numero de formulaire if (($_SESSION['xd_check']!=$_POST['xd_check']) AND ($_POST['xd_check'] !="")){ erreur ('Something wrong has appen'); @@ -51,7 +70,18 @@ if (isset($_POST['xd_check']))
- + +
+ Accueil"; + break; + default: + include ("../src/arenas/".$currentArena."/public.php"); + break; + } + ?>
diff --git a/src/arenas/Battleship/public.php b/src/arenas/Battleship/public.php new file mode 100644 index 0000000..61aa218 --- /dev/null +++ b/src/arenas/Battleship/public.php @@ -0,0 +1 @@ +

Battle ship

\ No newline at end of file diff --git a/src/arenas/tictactoe/public.php b/src/arenas/tictactoe/public.php new file mode 100644 index 0000000..020f14a --- /dev/null +++ b/src/arenas/tictactoe/public.php @@ -0,0 +1 @@ +

tic tac toe

\ No newline at end of file From 58ee185239c8b5472f7e1287e420e29778303735 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 27 Nov 2015 21:12:33 +0100 Subject: [PATCH 05/18] fix rewrite rules --- .htaccess | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.htaccess b/.htaccess index 4f2d56e..13aec07 100644 --- a/.htaccess +++ b/.htaccess @@ -6,10 +6,9 @@ php_flag html_errors on #urlrewritting RewriteEngine On RewriteBase / -RewriteRule ^v/([A-Za-z0-9]*)-([a-Z]{2})$ index.php?arena=$1&lang=$2 [L] -RewriteRule ^v/([A-Za-z0-9]*)$ index.php?arena=$1 [L] -RewriteRule ^v/-([a-Z]{2})$ index.php?lang=$1 [L] +RewriteRule ^/([a-zA-Z]*)-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] +RewriteRule ^/([a-zA-Z]*)$ index\.php?arena=$1 [L] +RewriteRule ^/-([a-z]{2})$ index.php?lang=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^([A-Za-z0-9]*)$ index.php?page=$1 [L] RewriteRule ^index.php$ index.php/ [L] From e93eb34832ebd5f12af2e27d05fd3e42dcceb0e2 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:08:58 +0100 Subject: [PATCH 06/18] fix --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 18acb36..778c41c 100644 --- a/html/index.php +++ b/html/index.php @@ -46,7 +46,7 @@ if (isset($_POST['xd_check'])){ die; } //call the good act.php - if($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){ + if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php")))){ require_once("../src/arenas/".$currentArena."/act.php"); }else{ require_once("../src/arenas/".$currentArena."/act.php"); From d285ef4626aa9b4cccbb7e671495366ab3e56af0 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:10:43 +0100 Subject: [PATCH 07/18] fix () --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 778c41c..9b5a0b8 100644 --- a/html/index.php +++ b/html/index.php @@ -46,7 +46,7 @@ if (isset($_POST['xd_check'])){ die; } //call the good act.php - if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php")))){ + if(($currentArena <> "") && (file_exists("../src/arenas/".$currentArena."/act.php"))){ require_once("../src/arenas/".$currentArena."/act.php"); }else{ require_once("../src/arenas/".$currentArena."/act.php"); From 16b59cb35ae6e0eca8a31208e78642554b68c53f Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:11:22 +0100 Subject: [PATCH 08/18] fix if --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 9b5a0b8..ec274b6 100644 --- a/html/index.php +++ b/html/index.php @@ -83,7 +83,7 @@ if (isset($_POST['xd_check'])){ } ?>

Date: Fri, 27 Nov 2015 22:13:37 +0100 Subject: [PATCH 09/18] switch --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index ec274b6..34665ff 100644 --- a/html/index.php +++ b/html/index.php @@ -92,7 +92,7 @@ if (isset($_POST['xd_check'])){
Accueil

"; break; From 1eb7d3a2c684806dadd7e1cbf3dd8ac437c4aa27 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:15:36 +0100 Subject: [PATCH 10/18] rewrite --- .htaccess | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.htaccess b/.htaccess index 13aec07..1743a97 100644 --- a/.htaccess +++ b/.htaccess @@ -8,7 +8,7 @@ RewriteEngine On RewriteBase / RewriteRule ^/([a-zA-Z]*)-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] RewriteRule ^/([a-zA-Z]*)$ index\.php?arena=$1 [L] -RewriteRule ^/-([a-z]{2})$ index.php?lang=$1 [L] +RewriteRule ^/-([a-z]{2})$ index\.php?lang=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^index.php$ index.php/ [L] +RewriteRule ^index.php$ index.php/ [L] \ No newline at end of file From 66e7650ae6c742543706c996c571f44b194d8a46 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Fri, 27 Nov 2015 22:19:28 +0100 Subject: [PATCH 11/18] fix .htaccess --- .htaccess | 11 ----------- html/.htaccess | 8 ++++++++ 2 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 html/.htaccess diff --git a/.htaccess b/.htaccess index 1743a97..efe2226 100644 --- a/.htaccess +++ b/.htaccess @@ -1,14 +1,3 @@ php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on - -#rewriterules -#urlrewritting -RewriteEngine On -RewriteBase / -RewriteRule ^/([a-zA-Z]*)-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] -RewriteRule ^/([a-zA-Z]*)$ index\.php?arena=$1 [L] -RewriteRule ^/-([a-z]{2})$ index\.php?lang=$1 [L] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^index.php$ index.php/ [L] \ No newline at end of file diff --git a/html/.htaccess b/html/.htaccess new file mode 100644 index 0000000..a560f4c --- /dev/null +++ b/html/.htaccess @@ -0,0 +1,8 @@ +RewriteEngine On +RewriteBase / +RewriteRule ^([a-zA-Z]*)-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] +RewriteRule ^([a-zA-Z]*)$ index\.php?arena=$1 [L] +RewriteRule ^-([a-z]{2})$ index\.php?lang=$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^index.php$ index.php/ [L] From 1f457dd4c422175f65d557dccdc0282c95820ab4 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:25:57 +0100 Subject: [PATCH 12/18] error function --- html/index.php | 6 +++--- src/functions.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/html/index.php b/html/index.php index 34665ff..4c655f0 100644 --- a/html/index.php +++ b/html/index.php @@ -24,13 +24,13 @@ if(isset($_GET['arena'])){ //check if arena is list $currentArena = false; foreach($arenas as $arena){ - if($arena['id'] == $GET['arena']){ - $currentArena = $GET['arena']; + if($arena['id'] == $_GET['arena']){ + $currentArena = $_GET['arena']; break; } } if(!$currentArena){ - error("Wrong parameter"); + error(404,"Wrong parameter"); die; } }else{ diff --git a/src/functions.php b/src/functions.php index 41f4d66..c3bf99c 100644 --- a/src/functions.php +++ b/src/functions.php @@ -79,4 +79,17 @@ function get_language_array(){ include (__DIR__."/../lang/".$language.".php"); return $lang; +} +function error($code,$message){ + switch($error){ + case 404: + header("HTTP/1.0 404 Not Found"); + echo 'Page Not found

'.$message.'

'; + die; + default: + + die; + break; + } + } \ No newline at end of file From 7424f57bc37b4c193f040b80a928686a52249046 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:27:02 +0100 Subject: [PATCH 13/18] fix --- src/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.php b/src/functions.php index c3bf99c..2bae4b2 100644 --- a/src/functions.php +++ b/src/functions.php @@ -81,7 +81,7 @@ function get_language_array(){ return $lang; } function error($code,$message){ - switch($error){ + switch($code){ case 404: header("HTTP/1.0 404 Not Found"); echo 'Page Not found

'.$message.'

'; From a8f016f72873ab7dbe833f9aee1b27d6ac8b34d4 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:29:37 +0100 Subject: [PATCH 14/18] fix tilte --- html/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 4c655f0..6683c23 100644 --- a/html/index.php +++ b/html/index.php @@ -26,6 +26,7 @@ if(isset($_GET['arena'])){ foreach($arenas as $arena){ if($arena['id'] == $_GET['arena']){ $currentArena = $_GET['arena']; + $currentArenaArr=$arena; break; } } @@ -87,7 +88,7 @@ if (isset($_POST['xd_check'])){ echo $lang['SITE_NAME']; }else{ - echo $arenas['current']['title']; + echo $currentArenaArr['title']; } ?>
From cf6c459a0273cf10342491eb64ec20ddd2c76876 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:36:04 +0100 Subject: [PATCH 15/18] fix regex --- html/.htaccess | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/.htaccess b/html/.htaccess index a560f4c..dd8169d 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -1,7 +1,7 @@ RewriteEngine On RewriteBase / -RewriteRule ^([a-zA-Z]*)-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] -RewriteRule ^([a-zA-Z]*)$ index\.php?arena=$1 [L] +RewriteRule ^([a-zA-Z]{1,})-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] +RewriteRule ^([a-zA-Z]{1,})$ index\.php?arena=$1 [L] RewriteRule ^-([a-z]{2})$ index\.php?lang=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d From 3cfde5ee79c3d5b3f61843ab0c8bc22716c3bde8 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:41:56 +0100 Subject: [PATCH 16/18] fix regex --- html/.htaccess | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/.htaccess b/html/.htaccess index dd8169d..8d5ca60 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -2,7 +2,7 @@ RewriteEngine On RewriteBase / RewriteRule ^([a-zA-Z]{1,})-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] RewriteRule ^([a-zA-Z]{1,})$ index\.php?arena=$1 [L] -RewriteRule ^-([a-z]{2})$ index\.php?lang=$1 [L] +RewriteRule ^/-([a-z]{2})$ index\.php?lang=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^index.php$ index.php/ [L] +RewriteRule ^index.php$ index.php/ [L] \ No newline at end of file From fe3a2ecf75567a65858d4b73f537cd4851bdbca7 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:43:14 +0100 Subject: [PATCH 17/18] fix typo --- src/arenas_lists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arenas_lists.php b/src/arenas_lists.php index 71b4e4e..99a99df 100644 --- a/src/arenas_lists.php +++ b/src/arenas_lists.php @@ -7,7 +7,7 @@ $arenas=array( ), array( 'id' => "Battleship", - 'url' => "/battleship", + 'url' => "/Battleship", 'title' => "bataille Navale" ) From 2d25cc79b1c92789a2d138fb93a32e67864a6392 Mon Sep 17 00:00:00 2001 From: gnieark Date: Fri, 27 Nov 2015 22:45:14 +0100 Subject: [PATCH 18/18] fix --- html/.htaccess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/.htaccess b/html/.htaccess index 8d5ca60..9caecf4 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -2,7 +2,7 @@ RewriteEngine On RewriteBase / RewriteRule ^([a-zA-Z]{1,})-([a-z]{2})$ index\.php?arena=$1&lang=$2 [L] RewriteRule ^([a-zA-Z]{1,})$ index\.php?arena=$1 [L] -RewriteRule ^/-([a-z]{2})$ index\.php?lang=$1 [L] +RewriteRule ^-([a-z]{2})$ index\.php?lang=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index.php$ index.php/ [L] \ No newline at end of file