From 3a5c1ee9ad3d5030e4adf535b7f6a5cb9ea5aed7 Mon Sep 17 00:00:00 2001 From: Clecle Date: Wed, 11 Nov 2015 08:05:51 +0100 Subject: [PATCH] =?UTF-8?q?=C2=90corps=20de=20la=20fonction=20checkParam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/security.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/manager/security.php b/manager/security.php index 3eea68b..1a9bbb4 100755 --- a/manager/security.php +++ b/manager/security.php @@ -153,7 +153,7 @@ /* [1] Vérification de l'intégrité des tableaux =============================================================================*/ $areArrays = is_array($tabVar) && is_array($tabForm); // si ce sont bien des tabeaux - $areNEmpty = $areArrays && count($tabVar) > 0 && count($tabVar) > 0; // si ils ne sont pas vides + $areNEmpty = $areArrays && count($tabVar) > 0 && count($tabForm) > 0; // si ils ne sont pas vides $haveEqLen = $areNEmpty && count($tabVar) == count($tabForm); // si ils ont la même taille if( !$haveEqLen ) // si toutes les conditions ne sont pas vérifiées @@ -164,10 +164,29 @@ =============================================================================*/ $checker = true; // on définit le checker à VRAI + // Vérification des types + // pour chaque variable - foreach ($tabVar as $type => $value){ + foreach ($tabVar as $type => $tabVal){ + foreach($tabVal as $variable) { // <--- Gestion des tableaux de valeurs ??? + $checker = ($type == gettype($variable)); + if($checker == false) + return (" variable : ".(String)$variable." non conforme, type attendu : ".(String)$type." type reçu :".gettype($variable)); + } } + // Vérification des formats + + foreach($tabForm as $format => $tabVal) { + foreach ($tabVal as $variable) { // <--- Gestion des tableaux de valeurs ??? + $checker = preg_match($format,$variable); + if($checker == false) + return (" variable : ".$variable." non conforme, format attendu : ".(String)$format." format reçu :".(String)$variable); + } + } + + return $checker; + } ?> \ No newline at end of file