@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | if(!is_object($subject)) |
| 40 | 40 | { |
| 41 | 41 | throw new Exception('Le paramètre $subject doit être un objet.'); |
| 42 | - } |
|
| 43 | - elseif(is_object($subject) && get_class($subject) != '\SplSubject') |
|
| 42 | + } elseif(is_object($subject) && get_class($subject) != '\SplSubject') |
|
| 44 | 43 | { |
| 45 | 44 | throw new Exception('Le paramètre $subject doit être un objet de type \SplSubject.'); |
| 46 | 45 | } |
@@ -66,14 +65,12 @@ discard block |
||
| 66 | 65 | $preg_match = preg_match('^'.$regex.'::'.$regex.'\('.$regex2.'\);$', $action, $match); |
| 67 | 66 | $class = $match[1]; |
| 68 | 67 | $args = $match[3]; |
| 69 | - } |
|
| 70 | - elseif(strpos($action, '->') !== false) |
|
| 68 | + } elseif(strpos($action, '->') !== false) |
|
| 71 | 69 | { |
| 72 | 70 | $preg_match = preg_match('^'.$regex.'::'.$regex.'\('.$regex2.'\);$', $action, $match); |
| 73 | 71 | $class = $match[1]; |
| 74 | 72 | $args = $match[3]; |
| 75 | - } |
|
| 76 | - else |
|
| 73 | + } else |
|
| 77 | 74 | { |
| 78 | 75 | $preg_match = preg_match('^'.$regex.'\('.$regex2.'\);$', $action, $match); |
| 79 | 76 | $args = $match[2]; |
@@ -98,8 +95,7 @@ discard block |
||
| 98 | 95 | try |
| 99 | 96 | { |
| 100 | 97 | eval($action); |
| 101 | - } |
|
| 102 | - catch(\Exception $e) |
|
| 98 | + } catch(\Exception $e) |
|
| 103 | 99 | { |
| 104 | 100 | echo $e->getMessage(); |
| 105 | 101 | } |
@@ -298,8 +298,7 @@ |
||
| 298 | 298 | if($this->proxy != NULL) |
| 299 | 299 | { |
| 300 | 300 | $this->ip = $this->proxy; |
| 301 | - } |
|
| 302 | - elseif(isset($_SERVER['REMOTE_ADDR'])) |
|
| 301 | + } elseif(isset($_SERVER['REMOTE_ADDR'])) |
|
| 303 | 302 | { |
| 304 | 303 | $this->ip = $_SERVER['REMOTE_ADDR']; |
| 305 | 304 | } |
@@ -119,8 +119,7 @@ discard block |
||
| 119 | 119 | if(!is_null($this->notify_action)) |
| 120 | 120 | { |
| 121 | 121 | $this->notifyObserver($this->notify_action); |
| 122 | - } |
|
| 123 | - else |
|
| 122 | + } else |
|
| 124 | 123 | { |
| 125 | 124 | foreach($this->observers as $observer) |
| 126 | 125 | { |
@@ -140,13 +139,14 @@ discard block |
||
| 140 | 139 | { |
| 141 | 140 | $this->debug = $debug; |
| 142 | 141 | |
| 143 | - if($debug) //Affiche toutes les erreurs de php |
|
| 142 | + if($debug) { |
|
| 143 | + //Affiche toutes les erreurs de php |
|
| 144 | 144 | { |
| 145 | 145 | error_reporting(E_ALL); |
| 146 | + } |
|
| 146 | 147 | ini_set('display_errors', 'On'); |
| 147 | 148 | ini_set('html_errors', true); |
| 148 | - } |
|
| 149 | - else //Affiche aucune erreur (prod) |
|
| 149 | + } else //Affiche aucune erreur (prod) |
|
| 150 | 150 | { |
| 151 | 151 | error_reporting(0); |
| 152 | 152 | } |
@@ -34,7 +34,8 @@ discard block |
||
| 34 | 34 | (peut être génant sur un nom de variable dans le cas par exemple de $_POST['coucou'] ou $_POST['cou_cou'] pour l'exemple au-dessus) |
| 35 | 35 | */ |
| 36 | 36 | |
| 37 | - if(is_array($string)) //Au cas où la valeur à vérifier soit un array (peut arriver avec les POST) |
|
| 37 | + if(is_array($string)) { |
|
| 38 | + //Au cas où la valeur à vérifier soit un array (peut arriver avec les POST) |
|
| 38 | 39 | { |
| 39 | 40 | foreach($string as $key => $val) |
| 40 | 41 | { |
@@ -42,6 +43,7 @@ discard block |
||
| 42 | 43 | //la clé non sécurisé existerais toujours et la sécurisation |
| 43 | 44 | //ne servirais à rien. |
| 44 | 45 | unset($string[$key]); |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | $key = secure($key, true, $null_cslashe); |
| 47 | 49 | $val = secure($val, $html, $null_cslashe); |
@@ -192,11 +194,12 @@ discard block |
||
| 192 | 194 | global $request, $path; |
| 193 | 195 | |
| 194 | 196 | //Envoi du status http |
| 195 | - if(function_exists('http_response_code')) //php >= 5.4 |
|
| 197 | + if(function_exists('http_response_code')) { |
|
| 198 | + //php >= 5.4 |
|
| 196 | 199 | { |
| 197 | 200 | http_response_code($num); |
| 198 | 201 | } |
| 199 | - else //php < 5.4 |
|
| 202 | + } else //php < 5.4 |
|
| 200 | 203 | { |
| 201 | 204 | header(':', true, $num); |
| 202 | 205 | } |
@@ -204,12 +207,10 @@ discard block |
||
| 204 | 207 | if(file_exists(path_controllers.'erreurs/'.$num.'.php')) |
| 205 | 208 | { |
| 206 | 209 | require_once(path_controllers.'erreurs/'.$num.'.php'); |
| 207 | - } |
|
| 208 | - elseif (file_exists(path_controllers.'erreurs.php')) |
|
| 210 | + } elseif (file_exists(path_controllers.'erreurs.php')) |
|
| 209 | 211 | { |
| 210 | 212 | require_once(path_controllers.'erreurs.php'); |
| 211 | - } |
|
| 212 | - else |
|
| 213 | + } else |
|
| 213 | 214 | { |
| 214 | 215 | echo 'Erreur '.$num; |
| 215 | 216 | } |
@@ -243,8 +244,7 @@ discard block |
||
| 243 | 244 | try |
| 244 | 245 | { |
| 245 | 246 | file_put_contents($file, rtrim($txt)."\n", FILE_APPEND); |
| 246 | - } |
|
| 247 | - catch(\Exception $e) |
|
| 247 | + } catch(\Exception $e) |
|
| 248 | 248 | { |
| 249 | 249 | echo '<br/>Impossible d\'écrire dans le fichier : '.$file.'<br/>'; |
| 250 | 250 | } |
@@ -331,11 +331,13 @@ discard block |
||
| 331 | 331 | return false; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if(PHP_VERSION_ID >= 50400) //PHP >= 5.4.0 |
|
| 334 | + if(PHP_VERSION_ID >= 50400) { |
|
| 335 | + //PHP >= 5.4.0 |
|
| 335 | 336 | { |
| 336 | 337 | if(session_status() === PHP_SESSION_ACTIVE) |
| 337 | 338 | { |
| 338 | 339 | return true; |
| 340 | + } |
|
| 339 | 341 | } |
| 340 | 342 | |
| 341 | 343 | return false; |
@@ -99,67 +99,52 @@ discard block |
||
| 99 | 99 | if($color == 'black') |
| 100 | 100 | { |
| 101 | 101 | return 30; |
| 102 | - } |
|
| 103 | - elseif($color == 'red') |
|
| 102 | + } elseif($color == 'red') |
|
| 104 | 103 | { |
| 105 | 104 | return 31; |
| 106 | - } |
|
| 107 | - elseif($color == 'green') |
|
| 105 | + } elseif($color == 'green') |
|
| 108 | 106 | { |
| 109 | 107 | return 32; |
| 110 | - } |
|
| 111 | - elseif($color == 'yellow') |
|
| 108 | + } elseif($color == 'yellow') |
|
| 112 | 109 | { |
| 113 | 110 | return 33; |
| 114 | - } |
|
| 115 | - elseif($color == 'blue') |
|
| 111 | + } elseif($color == 'blue') |
|
| 116 | 112 | { |
| 117 | 113 | return 34; |
| 118 | - } |
|
| 119 | - elseif($color == 'magenta') |
|
| 114 | + } elseif($color == 'magenta') |
|
| 120 | 115 | { |
| 121 | 116 | return 35; |
| 122 | - } |
|
| 123 | - elseif($color == 'cyan') |
|
| 117 | + } elseif($color == 'cyan') |
|
| 124 | 118 | { |
| 125 | 119 | return 36; |
| 126 | - } |
|
| 127 | - elseif($color == 'white') |
|
| 120 | + } elseif($color == 'white') |
|
| 128 | 121 | { |
| 129 | 122 | return 37; |
| 130 | 123 | } |
| 131 | - } |
|
| 132 | - elseif($type == 'bg') |
|
| 124 | + } elseif($type == 'bg') |
|
| 133 | 125 | { |
| 134 | 126 | if($color == 'black') |
| 135 | 127 | { |
| 136 | 128 | return 40; |
| 137 | - } |
|
| 138 | - elseif($color == 'red') |
|
| 129 | + } elseif($color == 'red') |
|
| 139 | 130 | { |
| 140 | 131 | return 41; |
| 141 | - } |
|
| 142 | - elseif($color == 'green') |
|
| 132 | + } elseif($color == 'green') |
|
| 143 | 133 | { |
| 144 | 134 | return 42; |
| 145 | - } |
|
| 146 | - elseif($color == 'yellow') |
|
| 135 | + } elseif($color == 'yellow') |
|
| 147 | 136 | { |
| 148 | 137 | return 43; |
| 149 | - } |
|
| 150 | - elseif($color == 'blue') |
|
| 138 | + } elseif($color == 'blue') |
|
| 151 | 139 | { |
| 152 | 140 | return 44; |
| 153 | - } |
|
| 154 | - elseif($color == 'magenta') |
|
| 141 | + } elseif($color == 'magenta') |
|
| 155 | 142 | { |
| 156 | 143 | return 45; |
| 157 | - } |
|
| 158 | - elseif($color == 'cyan') |
|
| 144 | + } elseif($color == 'cyan') |
|
| 159 | 145 | { |
| 160 | 146 | return 46; |
| 161 | - } |
|
| 162 | - elseif($color == 'white') |
|
| 147 | + } elseif($color == 'white') |
|
| 163 | 148 | { |
| 164 | 149 | return 47; |
| 165 | 150 | } |
@@ -176,36 +161,28 @@ discard block |
||
| 176 | 161 | if($style == 'normal') |
| 177 | 162 | { |
| 178 | 163 | return 0; |
| 179 | - } |
|
| 180 | - elseif($style == 'bold') |
|
| 164 | + } elseif($style == 'bold') |
|
| 181 | 165 | { |
| 182 | 166 | return 1; |
| 183 | - } |
|
| 184 | - elseif($style == 'not-bold') |
|
| 167 | + } elseif($style == 'not-bold') |
|
| 185 | 168 | { |
| 186 | 169 | return 21; |
| 187 | - } |
|
| 188 | - elseif($style == 'underline') |
|
| 170 | + } elseif($style == 'underline') |
|
| 189 | 171 | { |
| 190 | 172 | return 4; |
| 191 | - } |
|
| 192 | - elseif($style == 'not-underline') |
|
| 173 | + } elseif($style == 'not-underline') |
|
| 193 | 174 | { |
| 194 | 175 | return 24; |
| 195 | - } |
|
| 196 | - elseif($style == 'blink') |
|
| 176 | + } elseif($style == 'blink') |
|
| 197 | 177 | { |
| 198 | 178 | return 5; |
| 199 | - } |
|
| 200 | - elseif($style == 'not-blink') |
|
| 179 | + } elseif($style == 'not-blink') |
|
| 201 | 180 | { |
| 202 | 181 | return 25; |
| 203 | - } |
|
| 204 | - elseif($style == 'reverse') |
|
| 182 | + } elseif($style == 'reverse') |
|
| 205 | 183 | { |
| 206 | 184 | return 7; |
| 207 | - } |
|
| 208 | - elseif($style == 'not-reverse') |
|
| 185 | + } elseif($style == 'not-reverse') |
|
| 209 | 186 | { |
| 210 | 187 | return 27; |
| 211 | 188 | } |
@@ -78,21 +78,23 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $pathFile = ''; |
| 80 | 80 | |
| 81 | - if(file_exists($rootPath.'web/'.$file)) //Un fichier mit dans /web |
|
| 81 | + if(file_exists($rootPath.'web/'.$file)) { |
|
| 82 | + //Un fichier mit dans /web |
|
| 82 | 83 | { |
| 83 | 84 | $pathFile = $rootPath.'web'; |
| 84 | 85 | } |
| 85 | - elseif(strpos($request, '/modules/') !== false) //Un fichier non php mit dans un modules. |
|
| 86 | + } elseif(strpos($request, '/modules/') !== false) { |
|
| 87 | + //Un fichier non php mit dans un modules. |
|
| 86 | 88 | { |
| 87 | 89 | $modulePos = strpos($request, '/modules/') + 9; |
| 90 | + } |
|
| 88 | 91 | $moduleName = substr($request, $modulePos, (strpos($request, '/', $modulePos) - $modulePos)); |
| 89 | 92 | |
| 90 | 93 | if(!file_exists('modules/'.$moduleName.'/externe.php')) |
| 91 | 94 | { |
| 92 | 95 | $error = 403; |
| 93 | 96 | } |
| 94 | - } |
|
| 95 | - else |
|
| 97 | + } else |
|
| 96 | 98 | { |
| 97 | 99 | $error = 404; |
| 98 | 100 | } |
@@ -102,12 +104,10 @@ discard block |
||
| 102 | 104 | if($ext == 'css') |
| 103 | 105 | { |
| 104 | 106 | header('Content-type: text/css'); |
| 105 | - } |
|
| 106 | - elseif($ext == 'js') |
|
| 107 | + } elseif($ext == 'js') |
|
| 107 | 108 | { |
| 108 | 109 | header('Content-type: text/javascript'); |
| 109 | - } |
|
| 110 | - else |
|
| 110 | + } else |
|
| 111 | 111 | { |
| 112 | 112 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 113 | 113 | header('Content-type: '.finfo_file($finfo, $pathFile.$file)); |
@@ -116,8 +116,7 @@ discard block |
||
| 116 | 116 | echo file_get_contents($pathFile.$file); |
| 117 | 117 | exit; |
| 118 | 118 | } |
| 119 | - } |
|
| 120 | - elseif(substr($ext, 0, 3) == 'php' && !is_null($ext)) |
|
| 119 | + } elseif(substr($ext, 0, 3) == 'php' && !is_null($ext)) |
|
| 121 | 120 | { |
| 122 | 121 | $modulePos = strpos($request, '/modules/') + 9; |
| 123 | 122 | $moduleName = substr($request, $modulePos, (strpos($request, '/', $modulePos) - $modulePos)); |
@@ -130,13 +129,11 @@ discard block |
||
| 130 | 129 | if(in_array($afterModuleName, $moduleExterneAuthorized)) |
| 131 | 130 | { |
| 132 | 131 | require_once($rootPath.$request); |
| 133 | - } |
|
| 134 | - else |
|
| 132 | + } else |
|
| 135 | 133 | { |
| 136 | 134 | $error = 403; |
| 137 | 135 | } |
| 138 | - } |
|
| 139 | - else |
|
| 136 | + } else |
|
| 140 | 137 | { |
| 141 | 138 | $error = 404; |
| 142 | 139 | } |
@@ -159,13 +159,11 @@ |
||
| 159 | 159 | if(file_exists($path.'/module.json')) |
| 160 | 160 | { |
| 161 | 161 | $Modules->newFromJson($path); |
| 162 | - } |
|
| 163 | - elseif(file_exists($path.'/'.$moduleName.'.php')) |
|
| 162 | + } elseif(file_exists($path.'/'.$moduleName.'.php')) |
|
| 164 | 163 | { |
| 165 | 164 | require_once($path.'/'.$moduleName.'.php'); |
| 166 | 165 | $Modules->addPath($moduleName, $path); |
| 167 | - } |
|
| 168 | - else {continue;} |
|
| 166 | + } else {continue;} |
|
| 169 | 167 | |
| 170 | 168 | $moduleInfos = $Modules->getModuleInfos($moduleName); |
| 171 | 169 | if(!file_exists($path.'/'.$moduleInfos['runFile'])) |
@@ -44,22 +44,13 @@ discard block |
||
| 44 | 44 | $err_severity == E_COMPILE_ERROR || |
| 45 | 45 | $err_severity == E_RECOVERABLE_ERROR |
| 46 | 46 | ) |
| 47 | - {$erreurType = 'Fatal';} |
|
| 48 | - |
|
| 49 | - elseif( |
|
| 47 | + {$erreurType = 'Fatal';} elseif( |
|
| 50 | 48 | $err_severity == E_WARNING || |
| 51 | 49 | $err_severity == E_CORE_WARNING || |
| 52 | 50 | $err_severity == E_USER_WARNING || |
| 53 | 51 | $err_severity == E_COMPILE_WARNING |
| 54 | 52 | ) |
| 55 | - {$erreurType = 'Fatal';} |
|
| 56 | - |
|
| 57 | - elseif($err_severity == E_PARSE) {$erreurType = 'Parse';} |
|
| 58 | - elseif($err_severity == E_NOTICE || $err_severity == E_USER_NOTICE) {$erreurType = 'Notice';} |
|
| 59 | - elseif($err_severity == E_STRICT) {$erreurType = 'Strict';} |
|
| 60 | - elseif($err_severity == E_RECOVERABLE_ERROR) {$erreurType = '/';} |
|
| 61 | - elseif($err_severity == E_DEPRECATED || $err_severity == E_USER_DEPRECATED) {$erreurType = 'Deprecated';} |
|
| 62 | - else {$erreurType = 'Unknow';} |
|
| 53 | + {$erreurType = 'Fatal';} elseif($err_severity == E_PARSE) {$erreurType = 'Parse';} elseif($err_severity == E_NOTICE || $err_severity == E_USER_NOTICE) {$erreurType = 'Notice';} elseif($err_severity == E_STRICT) {$erreurType = 'Strict';} elseif($err_severity == E_RECOVERABLE_ERROR) {$erreurType = '/';} elseif($err_severity == E_DEPRECATED || $err_severity == E_USER_DEPRECATED) {$erreurType = 'Deprecated';} else {$erreurType = 'Unknow';} |
|
| 63 | 54 | |
| 64 | 55 | global $errorRender; |
| 65 | 56 | $errorRender($erreurType, $err_msg, $err_file, $err_line, debug_backtrace()); |
@@ -103,9 +94,7 @@ discard block |
||
| 103 | 94 | { |
| 104 | 95 | if($iArgs > 0) {echo ', ';} |
| 105 | 96 | |
| 106 | - if(is_array($args) || is_object($args)) {echo gettype($args);} |
|
| 107 | - elseif(is_null($args)) {echo 'null';} |
|
| 108 | - else {echo htmlentities($args);} |
|
| 97 | + if(is_array($args) || is_object($args)) {echo gettype($args);} elseif(is_null($args)) {echo 'null';} else {echo htmlentities($args);} |
|
| 109 | 98 | } |
| 110 | 99 | |
| 111 | 100 | echo ')'; |
@@ -424,41 +424,38 @@ |
||
| 424 | 424 | { |
| 425 | 425 | $aff_date = 'Maintenant'; |
| 426 | 426 | $aff_heure = ''; |
| 427 | - } |
|
| 428 | - elseif($diffAnnee == 0 && $diffMois == 0 && ($diffJour == 0 || ($diffJour == 1 && $diffHeure <= 2))) |
|
| 427 | + } elseif($diffAnnee == 0 && $diffMois == 0 && ($diffJour == 0 || ($diffJour == 1 && $diffHeure <= 2))) |
|
| 429 | 428 | { |
| 430 | 429 | $aff_date = 'Il y a '; //On commence par déclaré le début de l'affichage |
| 431 | 430 | |
| 432 | - if($diffJour > 1) //Dans le cas de 23h -> $heure_diff = -1 |
|
| 431 | + if($diffJour > 1) { |
|
| 432 | + //Dans le cas de 23h -> $heure_diff = -1 |
|
| 433 | 433 | { |
| 434 | - $h = 24+$diffHeure; //24 + (-1) |
|
| 435 | - $aff_date .= $h.'h'; |
|
| 434 | + $h = 24+$diffHeure; |
|
| 436 | 435 | } |
| 437 | - else |
|
| 436 | + //24 + (-1) |
|
| 437 | + $aff_date .= $h.'h'; |
|
| 438 | + } else |
|
| 438 | 439 | { |
| 439 | 440 | if($diffHeure > 0) |
| 440 | 441 | { |
| 441 | 442 | $aff_date .= $diffHeure.'h'; |
| 442 | - } |
|
| 443 | - elseif($diffHeure <= 0 && $diffMinute > 0) |
|
| 443 | + } elseif($diffHeure <= 0 && $diffMinute > 0) |
|
| 444 | 444 | { |
| 445 | 445 | $aff_date .= $diffMinute.'min'; |
| 446 | - } |
|
| 447 | - else |
|
| 446 | + } else |
|
| 448 | 447 | { |
| 449 | 448 | $aff_date .= $diffSeconde.'s'; |
| 450 | 449 | } |
| 451 | 450 | } |
| 452 | 451 | |
| 453 | 452 | $aff_heure = ''; #Partie prévu pour l'affichage |
| 454 | - } |
|
| 455 | - elseif($diffInvert == 0 && $diffAnnee == 0 && $diffMois == 0 && (($diffJour == 1 && $diffHeure > 2) || ($diffJour == 0 && $diffHeure == 0))) |
|
| 453 | + } elseif($diffInvert == 0 && $diffAnnee == 0 && $diffMois == 0 && (($diffJour == 1 && $diffHeure > 2) || ($diffJour == 0 && $diffHeure == 0))) |
|
| 456 | 454 | { |
| 457 | 455 | //C'était hier |
| 458 | 456 | $aff_date = 'Hier'; #On affiche donc en première partie "hier" |
| 459 | 457 | $aff_heure = ' à '.$heure.':'.$minute; #et en seconde partie, l'heure et les minutes |
| 460 | - } |
|
| 461 | - else |
|
| 458 | + } else |
|
| 462 | 459 | { |
| 463 | 460 | //Sinon et bien c'était il y a plus de 48h, et on affiche la date au format habituel |
| 464 | 461 | $aff_date = 'Le '.$jour.'/'.$mois; //D'abord le jour et le mois |