Completed
Push — 2.2 ( f4c653...5ece81 )
by Vermeulen
02:18
created
src/fonctions/global.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
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)) //Au cas où la valeur à vérifier soit un array (peut arriver avec les POST)
38 38
     {
39
-        foreach($string as $key => $val)
39
+        foreach ($string as $key => $val)
40 40
         {
41 41
             //Dans le cas où après si $key est modifié, alors la valeur pour 
42 42
             //la clé non sécurisé existerais toujours et la sécurisation 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 
56 56
     // On regarde si le type de string est un nombre entier (int)
57
-    if(ctype_digit($string))
57
+    if (ctype_digit($string))
58 58
     {
59 59
         $string = intval($string);
60 60
         return $string;
@@ -67,17 +67,17 @@  discard block
 block discarded – undo
67 67
     //commenté car problème de notice si php < 5.4
68 68
     //if(defined(ENT_HTML401)) {$optHtmlentities .= ' | '.ENT_HTML401;} //à partir de php5.4
69 69
 
70
-    if($html === false)
70
+    if ($html === false)
71 71
     {
72 72
         $string = htmlentities($string, $optHtmlentities, 'UTF-8');
73 73
     }
74 74
 
75
-    if(function_exists('DB_protect'))
75
+    if (function_exists('DB_protect'))
76 76
     {
77 77
         $string = DB_protect($string);
78 78
     }
79 79
 
80
-    if($null_cslashe === false)
80
+    if ($null_cslashe === false)
81 81
     {
82 82
         $string = addcslashes($string, '%_');
83 83
     }
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function post($key, $default = null, $html = false)
133 133
 {
134
-    if(!isset($_POST[$key]))
134
+    if (!isset($_POST[$key]))
135 135
     {
136 136
         return $default;
137 137
     }
138 138
 
139 139
     $post = $_POST[$key];
140 140
 
141
-    if(is_string($post))
141
+    if (is_string($post))
142 142
     {
143 143
         $post = trim($post);
144 144
     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  */
157 157
 function get($key, $default = null)
158 158
 {
159
-    if(!isset($_GET[$key]))
159
+    if (!isset($_GET[$key]))
160 160
     {
161 161
         return $default;
162 162
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function ErrorView($num, $cleanCache = true)
186 186
 {
187
-    if($cleanCache)
187
+    if ($cleanCache)
188 188
     {
189 189
         ob_clean(); //On efface tout ce qui a pu être mis dans le buffer pour l'affichage
190 190
     }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     global $request, $path;
193 193
 
194 194
     //Envoi du status http
195
-    if(function_exists('http_response_code')) //php >= 5.4
195
+    if (function_exists('http_response_code')) //php >= 5.4
196 196
     {
197 197
         http_response_code($num);
198 198
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         header(':', true, $num);
202 202
     }
203 203
 
204
-    if(file_exists(path_controllers.'erreurs/'.$num.'.php'))
204
+    if (file_exists(path_controllers.'erreurs/'.$num.'.php'))
205 205
     {
206 206
         require_once(path_controllers.'erreurs/'.$num.'.php');
207 207
     }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
  */
228 228
 function logfile($file, $txt, $date = true)
229 229
 {
230
-    if($date === true)
230
+    if ($date === true)
231 231
     {
232 232
         $date    = new \BFW\Date();
233 233
         $dateTxt = $date->getJour()
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     {
245 245
         file_put_contents($file, rtrim($txt)."\n", FILE_APPEND);
246 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
     }
@@ -259,39 +259,39 @@  discard block
 block discarded – undo
259 259
  */
260 260
 function verifTypeData($vars)
261 261
 {
262
-    if(!is_array($vars))
262
+    if (!is_array($vars))
263 263
     {
264 264
         return false;
265 265
     }
266 266
 
267
-    foreach($vars as $var)
267
+    foreach ($vars as $var)
268 268
     {
269
-        if(!is_array($var))
269
+        if (!is_array($var))
270 270
         {
271 271
             return false;
272 272
         }
273 273
 
274
-        if(!(!empty($var['type']) && isset($var['data'])))
274
+        if (!(!empty($var['type']) && isset($var['data'])))
275 275
         {
276 276
             return false;
277 277
         }
278 278
 
279
-        if($var['type'] == 'int')
279
+        if ($var['type'] == 'int')
280 280
         {
281 281
             $var['type'] = 'integer';
282 282
         }
283 283
 
284
-        if($var['type'] == 'float')
284
+        if ($var['type'] == 'float')
285 285
         {
286 286
             $var['type'] = 'double';
287 287
         }
288 288
 
289
-        if(!is_string($var['type']))
289
+        if (!is_string($var['type']))
290 290
         {
291 291
             return false;
292 292
         }
293 293
 
294
-        if(gettype($var['data']) != $var['type'])
294
+        if (gettype($var['data']) != $var['type'])
295 295
         {
296 296
             return false;
297 297
         }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 {
310 310
     global $BFWKernel;
311 311
 
312
-    if(!(isset($BFWKernel) && is_object($BFWKernel) && get_class($BFWKernel) == 'BFW\Kernel'))
312
+    if (!(isset($BFWKernel) && is_object($BFWKernel) && get_class($BFWKernel) == 'BFW\Kernel'))
313 313
     {
314 314
         $BFWKernel = new \BFW\Kernel;
315 315
     }
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
  */
327 327
 function is_session_started()
328 328
 {
329
-    if(php_sapi_name() === 'cli')
329
+    if (php_sapi_name() === 'cli')
330 330
     {
331 331
         return false;
332 332
     }
333 333
 
334
-    if(PHP_VERSION_ID >= 50400) //PHP >= 5.4.0
334
+    if (PHP_VERSION_ID >= 50400) //PHP >= 5.4.0
335 335
     {
336
-        if(session_status() === PHP_SESSION_ACTIVE)
336
+        if (session_status() === PHP_SESSION_ACTIVE)
337 337
         {
338 338
             return true;
339 339
         }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         return false;
342 342
     }
343 343
 
344
-    if(session_id() !== '')
344
+    if (session_id() !== '')
345 345
     {
346 346
         return true;
347 347
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/BFW_init.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,13 +159,11 @@
 block discarded – undo
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']))
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 ob_start(); //Tamporisation du tampon de sortie html. Permet que le code html ne sorte qu'à la fin et non petit à petit (permet d'utiliser les fonctions changeant les headers ou cookie à n'importe quel moment par exemple)
9 9
 
10 10
 //Définition des chemins d'accès
11
-if(!isset($rootPath))
11
+if (!isset($rootPath))
12 12
 {
13
-    if(!isset($myVendorName))
13
+    if (!isset($myVendorName))
14 14
     {
15 15
         $myVendorName = 'vendor';
16 16
     }
@@ -20,41 +20,41 @@  discard block
 block discarded – undo
20 20
 
21 21
 //Issue #69 : Ce n'est pas à htmlentities de forcer le charset.
22 22
 //Possibilité de demander à ne pas le redéfinir
23
-if(!isset($notDefineDefaultCharset))
23
+if (!isset($notDefineDefaultCharset))
24 24
 {
25 25
     $notDefineDefaultCharset = false;
26 26
 }
27 27
 
28
-if($notDefineDefaultCharset === false)
28
+if ($notDefineDefaultCharset === false)
29 29
 {
30 30
     ini_set('default_charset', 'UTF-8');
31 31
 }
32 32
 
33 33
 //Fichier de config
34
-if(!isset($forceConfig) || (isset($forceConfig) && $forceConfig == false))
34
+if (!isset($forceConfig) || (isset($forceConfig) && $forceConfig == false))
35 35
 {
36 36
     require_once($rootPath.'configs/bfw_config.php');
37 37
 }
38 38
 //Fichier de config
39 39
 
40
-if((isset($noSession) && $noSession == false) || !isset($noSession))
40
+if ((isset($noSession) && $noSession == false) || !isset($noSession))
41 41
 { 
42 42
     session_set_cookie_params(0); //permet de detruire le cookie de session si le navigateur quitte
43 43
     session_start(); //Ouverture des sessions
44 44
 }
45 45
 
46 46
 //Class Loader
47
-if(!isset($loader))
47
+if (!isset($loader))
48 48
 {
49 49
     $loader = require($rootPath.'vendor/autoload.php');
50 50
     $loaderAddPsr4 = 'addPsr4';
51 51
 }
52 52
 
53
-if(!isset($loaderAddPsr4)) {$loaderAddPsr4 = 'addNamespace';} //Default of PSR4 library
53
+if (!isset($loaderAddPsr4)) {$loaderAddPsr4 = 'addNamespace'; } //Default of PSR4 library
54 54
 
55 55
 $loader->$loaderAddPsr4('controller\\', $rootPath.'controllers/');
56
-$loader->$loaderAddPsr4('modules\\',    $rootPath.'modules/');
57
-$loader->$loaderAddPsr4('modeles\\',    $rootPath.'modeles/');
56
+$loader->$loaderAddPsr4('modules\\', $rootPath.'modules/');
57
+$loader->$loaderAddPsr4('modeles\\', $rootPath.'modeles/');
58 58
 //Class Loader
59 59
 
60 60
 //Instancie la classe Kernel
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 $modulesToLoad = array();
74 74
 
75 75
 //SQL
76
-if($bd_enabled)
76
+if ($bd_enabled)
77 77
 {
78 78
     $modulesToLoad['bd'] = array('name' => $bd_module, 'action' => 'load');
79 79
 }
@@ -84,32 +84,32 @@  discard block
 block discarded – undo
84 84
 //Controller
85 85
 $modulesToLoad['ctr'] = array('name' => $ctr_module, 'action' => 'test');
86 86
 
87
-foreach($modulesToLoad as $key => $moduleLoad)
87
+foreach ($modulesToLoad as $key => $moduleLoad)
88 88
 {
89
-    if(!empty($moduleLoad['name']))
89
+    if (!empty($moduleLoad['name']))
90 90
     {
91 91
         $pathToModule = $rootPath.'modules/'.$moduleLoad['name'];
92
-        if(empty($pathToModule))
92
+        if (empty($pathToModule))
93 93
         {
94 94
             continue;
95 95
         }
96 96
         
97
-        if(is_link($pathToModule))
97
+        if (is_link($pathToModule))
98 98
         {
99 99
             $pathToModule = readlink($pathToModule);
100 100
             
101
-            if(file_exists($pathToModule.'/bfw_modules_info.php'))
101
+            if (file_exists($pathToModule.'/bfw_modules_info.php'))
102 102
             {
103 103
                 require_once($pathToModule.'/bfw_modules_info.php');
104 104
                 
105
-                if(!empty($modulePath))
105
+                if (!empty($modulePath))
106 106
                 {
107 107
                     $pathToModule .= '/'.$modulePath;
108 108
                 }
109 109
             }
110 110
         }
111 111
         
112
-        if(!file_exists($pathToModule.'/kernel_init.php'))
112
+        if (!file_exists($pathToModule.'/kernel_init.php'))
113 113
         {
114 114
             define('kernelModuleLoad_'.$key.'_test', false);
115 115
             throw new \Exception('Module '.$moduleLoad['name'].' not found.');
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
         define('kernelModuleLoad_'.$key.'_test', true);
119 119
         define('kernelModuleLoad_'.$key.'_path', $pathToModule.'/kernel_init.php');
120 120
         
121
-        if($moduleLoad['action'] == 'load')
121
+        if ($moduleLoad['action'] == 'load')
122 122
         {
123 123
             require_once($pathToModule.'/kernel_init.php');
124 124
         }
125 125
     }
126 126
     
127
-    if(!defined('kernelModuleLoad_'.$key.'_test'))
127
+    if (!defined('kernelModuleLoad_'.$key.'_test'))
128 128
     {
129 129
         define('kernelModuleLoad_'.$key.'_test', false);
130 130
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
 //Serveur memcache (permet de stocker des infos direct sur la ram avec ou sans limite dans le temps)
135 135
 $Memcache = null;
136
-if($memcache_enabled === true)
136
+if ($memcache_enabled === true)
137 137
 {
138 138
     $Memcache = new BFW\Ram($memcache_host, $memcache_port);
139 139
 }
@@ -157,30 +157,30 @@  discard block
 block discarded – undo
157 157
  */
158 158
 define('modulesLoadTime_EndInit', 'endInit');
159 159
 
160
-if(file_exists($rootPath.'modules'))
160
+if (file_exists($rootPath.'modules'))
161 161
 {
162 162
     $dir = opendir($rootPath.'modules');
163 163
     $dir_arr = array('.', '..', '.htaccess');
164 164
     
165
-    while(false !== ($moduleName = readdir($dir)))
165
+    while (false !== ($moduleName = readdir($dir)))
166 166
     {
167 167
         $path = $rootPath.'modules/'.$moduleName;
168
-        if(is_link($path)) {$path = readlink($path);}
168
+        if (is_link($path)) {$path = readlink($path); }
169 169
         
170 170
         //Si le fichier existe, on inclus le fichier principal du module
171
-        if(file_exists($path.'/module.json'))
171
+        if (file_exists($path.'/module.json'))
172 172
         {
173 173
             $Modules->newFromJson($path);
174 174
         }
175
-        elseif(file_exists($path.'/'.$moduleName.'.php'))
175
+        elseif (file_exists($path.'/'.$moduleName.'.php'))
176 176
         {
177 177
             require_once($path.'/'.$moduleName.'.php');
178 178
             $Modules->addPath($moduleName, $path);
179 179
         }
180
-        else {continue;}
180
+        else {continue; }
181 181
         
182 182
         $moduleInfos = $Modules->getModuleInfos($moduleName);
183
-        if(!file_exists($path.'/'.$moduleInfos['runFile']))
183
+        if (!file_exists($path.'/'.$moduleInfos['runFile']))
184 184
         {
185 185
             $Modules->loaded($moduleName);
186 186
         }
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 }
191 191
 
192 192
 $modulesToLoad = $Modules->listToLoad(modulesLoadTime_Module);
193
-if(is_array($modulesToLoad) && count($modulesToLoad) > 0)
193
+if (is_array($modulesToLoad) && count($modulesToLoad) > 0)
194 194
 {
195
-    foreach($modulesToLoad as $moduleToLoad)
195
+    foreach ($modulesToLoad as $moduleToLoad)
196 196
     {
197 197
         $infos = $Modules->getModuleInfos($moduleToLoad);
198 198
         $path = $infos['path'];
199 199
         
200
-        if(file_exists($path.'/'.$infos['runFile']))
200
+        if (file_exists($path.'/'.$infos['runFile']))
201 201
         {
202 202
             $Modules->loaded($moduleToLoad);
203 203
             require_once($path.'/'.$infos['runFile']);
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 
213 213
 //Chargement des modules
214 214
 $modulesToLoad = $Modules->listToLoad(modulesLoadTime_Visiteur);
215
-if(is_array($modulesToLoad) && count($modulesToLoad) > 0)
215
+if (is_array($modulesToLoad) && count($modulesToLoad) > 0)
216 216
 {
217
-    foreach($modulesToLoad as $moduleToLoad)
217
+    foreach ($modulesToLoad as $moduleToLoad)
218 218
     {
219 219
         $infos = $Modules->getModuleInfos($moduleToLoad);
220 220
         $path = $infos['path'];
221 221
         
222
-        if(file_exists($path.'/'.$infos['runFile']))
222
+        if (file_exists($path.'/'.$infos['runFile']))
223 223
         {
224 224
             $Modules->loaded($moduleToLoad);
225 225
             require_once($path.'/'.$infos['runFile']);
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
 
263 263
 //Chargement des modules
264 264
 $modulesToLoad = $Modules->listToLoad(modulesLoadTime_EndInit);
265
-if(is_array($modulesToLoad) && count($modulesToLoad) > 0)
265
+if (is_array($modulesToLoad) && count($modulesToLoad) > 0)
266 266
 {
267
-    foreach($modulesToLoad as $moduleToLoad)
267
+    foreach ($modulesToLoad as $moduleToLoad)
268 268
     {
269 269
         $infos = $Modules->getModuleInfos($moduleToLoad);
270 270
         $path = $infos['path'];
271 271
         
272
-        if(file_exists($path.'/'.$infos['runFile']))
272
+        if (file_exists($path.'/'.$infos['runFile']))
273 273
         {
274 274
             $Modules->loaded($moduleToLoad);
275 275
             require_once($path.'/'.$infos['runFile']);
Please login to merge, or discard this patch.