Passed
Push — 1.0.0-dev ( c78053...5f99ee )
by nguereza
14:45
created
core/classes/Module.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
     */
26 26
    
27
-	class Module{
27
+	class Module {
28 28
 		
29 29
 		/**
30 30
 		 * list of loaded module
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		private static function getLogger(){
46
-			if(self::$logger == null){
47
-				self::$logger[0] =& class_loader('Log', 'classes');
45
+		private static function getLogger() {
46
+			if (self::$logger == null) {
47
+				self::$logger[0] = & class_loader('Log', 'classes');
48 48
 				self::$logger[0]->setLogger('Library::Module');
49 49
 			}
50 50
 			return self::$logger[0];
@@ -53,27 +53,27 @@  discard block
 block discarded – undo
53 53
 		/**
54 54
 		 * Initialise the module list by scanning the directory MODULE_PATH
55 55
 		 */
56
-		public function init(){
56
+		public function init() {
57 57
 			$logger = self::getLogger();
58 58
 			$logger->debug('Check if the application contains the modules ...');
59 59
 			$moduleDir = opendir(MODULE_PATH);
60
-			if(is_resource($moduleDir)){
61
-				while(($module = readdir($moduleDir)) !== false){
62
-					if($module != '.' && $module != '..'  && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){
60
+			if (is_resource($moduleDir)) {
61
+				while (($module = readdir($moduleDir)) !== false) {
62
+					if ($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) {
63 63
 						self::$list[] = $module;
64 64
 					}
65
-					else{
66
-						$logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name');
65
+					else {
66
+						$logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name');
67 67
 					}
68 68
 				}
69 69
 				closedir($moduleDir);
70 70
 			}
71 71
 			ksort(self::$list);
72 72
 			
73
-			if(self::hasModule()){
73
+			if (self::hasModule()) {
74 74
 				$logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']');
75 75
 			}
76
-			else{
76
+			else {
77 77
 				$logger->info('The application contains no module skipping');
78 78
 			}
79 79
 		}
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 		 * Get the list of the custom autoload configuration from module if exists
83 83
 		 * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values
84 84
 		 */
85
-		public static function getModulesAutoloadConfig(){
85
+		public static function getModulesAutoloadConfig() {
86 86
 			$logger = self::getLogger();
87
-			if(! self::hasModule()){
87
+			if (!self::hasModule()) {
88 88
 				$logger->info('No module was loaded skipping.');
89 89
 				return false;
90 90
 			}
@@ -97,27 +97,27 @@  discard block
 block discarded – undo
97 97
 			
98 98
 			foreach (self::$list as $module) {
99 99
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php';
100
-				if(file_exists($file)){
100
+				if (file_exists($file)) {
101 101
 					require_once $file;
102
-					if(! empty($autoload) && is_array($autoload)){
102
+					if (!empty($autoload) && is_array($autoload)) {
103 103
 						//libraries autoload
104
-						if(! empty($autoload['libraries']) && is_array($autoload['libraries'])){
104
+						if (!empty($autoload['libraries']) && is_array($autoload['libraries'])) {
105 105
 							$autoloads['libraries'] = array_merge($autoloads['libraries'], $autoload['libraries']);
106 106
 						}
107 107
 						//config autoload
108
-						if(! empty($autoload['config']) && is_array($autoload['config'])){
108
+						if (!empty($autoload['config']) && is_array($autoload['config'])) {
109 109
 							$autoloads['config'] = array_merge($autoloads['config'], $autoload['config']);
110 110
 						}
111 111
 						//models autoload
112
-						if(! empty($autoload['models']) && is_array($autoload['models'])){
112
+						if (!empty($autoload['models']) && is_array($autoload['models'])) {
113 113
 							$autoloads['models'] = array_merge($autoloads['models'], $autoload['models']);
114 114
 						}
115 115
 						//functions autoload
116
-						if(! empty($autoload['functions']) && is_array($autoload['functions'])){
116
+						if (!empty($autoload['functions']) && is_array($autoload['functions'])) {
117 117
 							$autoloads['functions'] = array_merge($autoloads['functions'], $autoload['functions']);
118 118
 						}
119 119
 						//languages autoload
120
-						if(! empty($autoload['languages']) && is_array($autoload['languages'])){
120
+						if (!empty($autoload['languages']) && is_array($autoload['languages'])) {
121 121
 							$autoloads['languages'] = array_merge($autoloads['languages'], $autoload['languages']);
122 122
 						}
123 123
 						unset($autoload);
@@ -131,23 +131,23 @@  discard block
 block discarded – undo
131 131
 		 * Get the list of the custom routes configuration from module if exists
132 132
 		 * @return array|boolean the routes list or false if no module contains the routes configuration
133 133
 		 */
134
-		public static function getModulesRoutes(){
134
+		public static function getModulesRoutes() {
135 135
 			$logger = self::getLogger();
136
-			if(! self::hasModule()){
136
+			if (!self::hasModule()) {
137 137
 				$logger->info('No module was loaded skipping.');
138 138
 				return false;
139 139
 			}
140 140
 			$routes = array();
141 141
 			foreach (self::$list as $module) {
142 142
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php';
143
-				if(file_exists($file)){
143
+				if (file_exists($file)) {
144 144
 					require_once $file;
145
-					if(! empty($route) && is_array($route)){
145
+					if (!empty($route) && is_array($route)) {
146 146
 						$routes = array_merge($routes, $route);
147 147
 						unset($route);
148 148
 					}
149
-					else{
150
-						show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']');
149
+					else {
150
+						show_error('No routing configuration found in [' . $file . '] for module [' . $module . ']');
151 151
 					}
152 152
 				}
153 153
 			}
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
 		 * @param  string $module  the module name
162 162
 		 * @return boolean|string  false or null if no module have this controller, path the full path of the controller
163 163
 		 */
164
-		public static function findControllerFullPath($class, $module = null){
164
+		public static function findControllerFullPath($class, $module = null) {
165 165
 			$logger = self::getLogger();
166
-			if(! self::hasModule()){
166
+			if (!self::hasModule()) {
167 167
 				$logger->info('No module was loaded skiping.');
168 168
 				return false;
169 169
 			}
170 170
 			$class = str_ireplace('.php', '', $class);
171 171
 			$class = ucfirst($class);
172
-			$classFile = $class.'.php';
173
-			$logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...');
172
+			$classFile = $class . '.php';
173
+			$logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...');
174 174
 			$filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile;
175
-			if(file_exists($filePath)){
176
-				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
175
+			if (file_exists($filePath)) {
176
+				$logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
177 177
 				return $filePath;
178 178
 			}
179
-			else{
180
-				$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
179
+			else {
180
+				$logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']');
181 181
 				return false;
182 182
 			}
183 183
 		}
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 		 * @param string $module the module name
189 189
 		 * @return boolean|string  false or null if no module have this model, return the full path of this model
190 190
 		 */
191
-		public static function findModelFullPath($class, $module = null){
191
+		public static function findModelFullPath($class, $module = null) {
192 192
 			$logger = self::getLogger();
193
-			if(! self::hasModule()){
193
+			if (!self::hasModule()) {
194 194
 				$logger->info('No module was loaded skiping.');
195 195
 				return false;
196 196
 			}
197 197
 			$class = str_ireplace('.php', '', $class);
198 198
 			$class = ucfirst($class);
199
-			$classFile = $class.'.php';
200
-			$logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...');
199
+			$classFile = $class . '.php';
200
+			$logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...');
201 201
 			$filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile;
202
-			if(file_exists($filePath)){
203
-				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
202
+			if (file_exists($filePath)) {
203
+				$logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
204 204
 				return $filePath;
205 205
 			}
206
-			else{
207
-				$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
206
+			else {
207
+				$logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']');
208 208
 				return false;
209 209
 			}
210 210
 		}
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 		 * @param string $module the module name
216 216
 		 * @return boolean|string  false or null if no module have this configuration,  return the full path of this configuration
217 217
 		 */
218
-		public static function findConfigFullPath($configuration, $module = null){
218
+		public static function findConfigFullPath($configuration, $module = null) {
219 219
 			$logger = self::getLogger();
220
-			if(! self::hasModule()){
220
+			if (!self::hasModule()) {
221 221
 				$logger->info('No module was loaded skiping.');
222 222
 				return false;
223 223
 			}
224 224
 			$configuration = str_ireplace('.php', '', $configuration);
225
-			$file = $configuration.'.php';
226
-			$logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...');
225
+			$file = $configuration . '.php';
226
+			$logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...');
227 227
 			$filePath = MODULE_PATH . $module . DS . 'config' . DS . $file;
228
-			if(file_exists($filePath)){
229
-				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
228
+			if (file_exists($filePath)) {
229
+				$logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']');
230 230
 				return $filePath;
231 231
 			}
232
-			else{
233
-				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
232
+			else {
233
+				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']');
234 234
 				return false;
235 235
 			}
236 236
 		}
@@ -241,23 +241,23 @@  discard block
 block discarded – undo
241 241
 		 * @param string $module the module name
242 242
 		 * @return boolean|string  false or null if no module have this helper,  return the full path of this helper
243 243
 		 */
244
-		public static function findFunctionFullPath($helper, $module = null){
244
+		public static function findFunctionFullPath($helper, $module = null) {
245 245
 			$logger = self::getLogger();
246
-			if(! self::hasModule()){
246
+			if (!self::hasModule()) {
247 247
 				$logger->info('No module was loaded skiping.');
248 248
 				return false;
249 249
 			}
250 250
 			$helper = str_ireplace('.php', '', $helper);
251 251
 			$helper = str_ireplace('function_', '', $helper);
252
-			$file = 'function_'.$helper.'.php';
253
-			$logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...');
252
+			$file = 'function_' . $helper . '.php';
253
+			$logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...');
254 254
 			$filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file;
255
-			if(file_exists($filePath)){
256
-				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
255
+			if (file_exists($filePath)) {
256
+				$logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']');
257 257
 				return $filePath;
258 258
 			}
259
-			else{
260
-				$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
259
+			else {
260
+				$logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']');
261 261
 				return false;
262 262
 			}
263 263
 		}
@@ -269,22 +269,22 @@  discard block
 block discarded – undo
269 269
 		 * @param string $module the module name
270 270
 		 * @return boolean|string  false or null if no module have this library,  return the full path of this library
271 271
 		 */
272
-		public static function findLibraryFullPath($class, $module = null){
272
+		public static function findLibraryFullPath($class, $module = null) {
273 273
 			$logger = self::getLogger();
274
-			if(! self::hasModule()){
274
+			if (!self::hasModule()) {
275 275
 				$logger->info('No module was loaded skiping.');
276 276
 				return false;
277 277
 			}
278 278
 			$class = str_ireplace('.php', '', $class);
279
-			$file = $class.'.php';
280
-			$logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...');
279
+			$file = $class . '.php';
280
+			$logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...');
281 281
 			$filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file;
282
-			if(file_exists($filePath)){
283
-				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
282
+			if (file_exists($filePath)) {
283
+				$logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
284 284
 				return $filePath;
285 285
 			}
286
-			else{
287
-				$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
286
+			else {
287
+				$logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']');
288 288
 				return false;
289 289
 			}
290 290
 		}
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 		 * @param string $module the module name to check
297 297
 		 * @return boolean|string  false or null if no module have this view, path the full path of the view
298 298
 		 */
299
-		public static function findViewFullPath($view, $module = null){
299
+		public static function findViewFullPath($view, $module = null) {
300 300
 			$logger = self::getLogger();
301
-			if(! self::hasModule()){
301
+			if (!self::hasModule()) {
302 302
 				$logger->info('No module was loaded skiping.');
303 303
 				return false;
304 304
 			}
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
 			$view = trim($view, '/\\');
307 307
 			$view = str_ireplace('/', DS, $view);
308 308
 			$viewFile = $view . '.php';
309
-			$logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...');
309
+			$logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...');
310 310
 			$filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile;
311
-			if(file_exists($filePath)){
312
-				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
311
+			if (file_exists($filePath)) {
312
+				$logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']');
313 313
 				return $filePath;
314 314
 			}
315
-			else{
316
-				$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
315
+			else {
316
+				$logger->info('View [' . $view . '] does not exist in the module [' . $module . ']');
317 317
 				return false;
318 318
 			}
319 319
 		}
@@ -325,23 +325,23 @@  discard block
 block discarded – undo
325 325
 		 * @param string $appLang the application language like 'en', 'fr'
326 326
 		 * @return boolean|string  false or null if no module have this language,  return the full path of this language
327 327
 		 */
328
-		public static function findLanguageFullPath($language, $module = null, $appLang){
328
+		public static function findLanguageFullPath($language, $module = null, $appLang) {
329 329
 			$logger = self::getLogger();
330
-			if(! self::hasModule()){
330
+			if (!self::hasModule()) {
331 331
 				$logger->info('No module was loaded skiping.');
332 332
 				return false;
333 333
 			}
334 334
 			$language = str_ireplace('.php', '', $language);
335 335
 			$language = str_ireplace('lang_', '', $language);
336
-			$file = 'lang_'.$language.'.php';
337
-			$logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...');
336
+			$file = 'lang_' . $language . '.php';
337
+			$logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...');
338 338
 			$filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file;
339
-			if(file_exists($filePath)){
340
-				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
339
+			if (file_exists($filePath)) {
340
+				$logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']');
341 341
 				return $filePath;
342 342
 			}
343
-			else{
344
-				$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
343
+			else {
344
+				$logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']');
345 345
 				return false;
346 346
 			}
347 347
 		}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		 * Get the list of module loaded
351 351
 		 * @return array the module list
352 352
 		 */
353
-		public static function getModuleList(){
353
+		public static function getModuleList() {
354 354
 			return self::$list;
355 355
 		}
356 356
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		 * Check if the application has an module
359 359
 		 * @return boolean
360 360
 		 */
361
-		public static function hasModule(){
361
+		public static function hasModule() {
362 362
 			return !empty(self::$list);
363 363
 		}
364 364
 
Please login to merge, or discard this patch.
core/libraries/Upload.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     *    @package FileUpload
38 38
     *    @version 1.5
39 39
     */
40
-    class Upload{
40
+    class Upload {
41 41
 
42 42
         /**
43 43
         *   Version
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         *    @version    1.0
70 70
         *    @var        array
71 71
         */
72
-        private $file_array    = array();
72
+        private $file_array = array();
73 73
 
74 74
         /**
75 75
         *    If the file you are trying to upload already exists it will
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         *    @version    1.0
120 120
         *    @var        float
121 121
         */
122
-        private $max_file_size= 0.0;
122
+        private $max_file_size = 0.0;
123 123
 
124 124
         /**
125 125
         *    List of allowed mime types
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
         *    @return    object
218 218
         *    @method    object    __construct
219 219
         */
220
-        public function __construct(){
221
-            $this->logger =& class_loader('Log', 'classes');
220
+        public function __construct() {
221
+            $this->logger = & class_loader('Log', 'classes');
222 222
             $this->logger->setLogger('Library::Upload');
223 223
 
224 224
             Loader::lang('file_upload');
225
-            $obj =& get_instance();
225
+            $obj = & get_instance();
226 226
 
227 227
             $this->error_messages = array(
228 228
                 'upload_err_ini_size' => $obj->lang->get('fu_upload_err_ini_size'),
@@ -239,15 +239,15 @@  discard block
 block discarded – undo
239 239
             );
240 240
 
241 241
             $this->file = array(
242
-                'status'                =>    false,    // True: success upload
243
-                'mime'                  =>    '',       // Empty string
244
-                'filename'              =>    '',       // Empty string
245
-                'original'              =>    '',       // Empty string
246
-                'size'                  =>    0,        // 0 Bytes
247
-                'sizeFormated'          =>    '0B',     // 0 Bytes
248
-                'destination'           =>    './',     // Default: ./
249
-                'allowed_mime_types'    =>    array(),  // Allowed mime types
250
-                'error'                 =>    null,        // File error
242
+                'status'                =>    false, // True: success upload
243
+                'mime'                  =>    '', // Empty string
244
+                'filename'              =>    '', // Empty string
245
+                'original'              =>    '', // Empty string
246
+                'size'                  =>    0, // 0 Bytes
247
+                'sizeFormated'          =>    '0B', // 0 Bytes
248
+                'destination'           =>    './', // Default: ./
249
+                'allowed_mime_types'    =>    array(), // Allowed mime types
250
+                'error'                 =>    null, // File error
251 251
             );
252 252
 
253 253
             // Change dir to current dir
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             } elseif (isset($HTTP_POST_FILES) && is_array($HTTP_POST_FILES)) {
260 260
                 $this->file_array = $HTTP_POST_FILES;
261 261
             }
262
-            $this->logger->info('The upload file information are : ' .stringfy_vars($this->file_array));
262
+            $this->logger->info('The upload file information are : ' . stringfy_vars($this->file_array));
263 263
         }
264 264
         /**
265 265
         *    Set input.
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         */
276 276
         public function setInput($input)
277 277
         {
278
-            if (!empty($input) && (is_string($input) || is_numeric($input) )) {
278
+            if (!empty($input) && (is_string($input) || is_numeric($input))) {
279 279
                 $this->input = $input;
280 280
             }
281 281
             return $this;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         */
312 312
         public function setAutoFilename()
313 313
         {
314
-            $this->filename = sha1(mt_rand(1, 9999).uniqid());
314
+            $this->filename = sha1(mt_rand(1, 9999) . uniqid());
315 315
             $this->filename .= time();
316 316
             return $this;
317 317
         }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
                 $php_size = $this->sizeInBytes((int) ini_get('upload_max_filesize'));
333 333
                 // Calculate difference
334 334
                 if ($php_size < $file_size) {
335
-                    $this->logger->warning('The upload max file size you set [' .$file_size. '] is greather than the PHP configuration for upload max file size [' .$php_size. ']');
335
+                    $this->logger->warning('The upload max file size you set [' . $file_size . '] is greather than the PHP configuration for upload max file size [' . $php_size . ']');
336 336
                 }
337 337
                 $this->max_file_size = $file_size;
338 338
             }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         public function setAllowedMimeTypes(array $mimes)
351 351
         {
352 352
             if (count($mimes) > 0) {
353
-                array_map(array($this , 'setAllowMimeType'), $mimes);
353
+                array_map(array($this, 'setAllowMimeType'), $mimes);
354 354
             }
355 355
             return $this;
356 356
         }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
         {
416 416
             if (!empty($name) && is_string($name)) {
417 417
                 if (array_key_exists($name, $this->mime_helping)) {
418
-                    return $this->setAllowedMimeTypes($this->mime_helping[ $name ]);
418
+                    return $this->setAllowedMimeTypes($this->mime_helping[$name]);
419 419
                 }
420 420
             }
421 421
             return $this;
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
         */
435 435
         public function setUploadFunction($function)
436 436
         {
437
-            if (!empty($function) && (is_array($function) || is_string($function) )) {
438
-                if (is_callable( $function)) {
437
+            if (!empty($function) && (is_array($function) || is_string($function))) {
438
+                if (is_callable($function)) {
439 439
                     $this->upload_function = $function;
440 440
                 }
441 441
             }
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
                         $this->destination_directory = $destination_directory;
481 481
                         chdir($destination_directory);
482 482
                     }
483
-                    else{
484
-                        $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']');
483
+                    else {
484
+                        $this->logger->warning('Can not create the upload directory [' . $destination_directory . ']');
485 485
                     }
486 486
                 }
487 487
             }
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         public function isFilename($filename)
532 532
         {
533 533
             $filename = basename($filename);
534
-            return (!empty($filename) && (is_string( $filename) || is_numeric($filename)));
534
+            return (!empty($filename) && (is_string($filename) || is_numeric($filename)));
535 535
         }
536 536
         /**
537 537
         *    Validate mime type with allowed mime types,
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
         */
574 574
         public function isDirpath($path)
575 575
         {
576
-            if (!empty( $path) && (is_string( $path) || is_numeric($path) )) {
576
+            if (!empty($path) && (is_string($path) || is_numeric($path))) {
577 577
                 if (DIRECTORY_SEPARATOR == '/') {
578
-                    return (preg_match( '/^[^*?"<>|:]*$/' , $path) == 1 );
578
+                    return (preg_match('/^[^*?"<>|:]*$/', $path) == 1);
579 579
                 } else {
580
-                    return (preg_match( "/^[^*?\"<>|:]*$/" , substr($path,2) ) == 1);
580
+                    return (preg_match("/^[^*?\"<>|:]*$/", substr($path, 2)) == 1);
581 581
                 }
582 582
             }
583 583
             return false;
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
         */
606 606
         public function getInfo()
607 607
         {
608
-            return (object)$this->file;
608
+            return (object) $this->file;
609 609
         }
610 610
 
611 611
 
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
          * Check if the file is uploaded
614 614
          * @return boolean
615 615
          */
616
-        public function isUploaded(){
616
+        public function isUploaded() {
617 617
             return isset($this->file_array[$this->input])
618 618
             && is_uploaded_file($this->file_array[$this->input]['tmp_name']);
619 619
         }
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
          * Check if file upload has error
623 623
          * @return boolean
624 624
          */
625
-        protected function uploadHasError(){
625
+        protected function uploadHasError() {
626 626
             //check if file upload is  allowed in the configuration
627
-            if(! ini_get('file_uploads')){
627
+            if (!ini_get('file_uploads')) {
628 628
                 $this->setError($this->error_messages['file_uploads']);
629 629
                 return true;
630 630
             }
631 631
 
632 632
              //check for php upload error
633
-            if(is_numeric($this->file['error']) && $this->file['error'] > 0){
633
+            if (is_numeric($this->file['error']) && $this->file['error'] > 0) {
634 634
                 $this->setError($this->getPhpUploadErrorMessageByCode($this->file['error']));
635 635
                 return true;
636 636
             }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
         *    @return    boolean
666 666
         *    @method    boolean    save
667 667
         */
668
-        public function save(){
668
+        public function save() {
669 669
             if (count($this->file_array) > 0) {
670 670
                 if (array_key_exists($this->input, $this->file_array)) {
671 671
                     // set original filename if not have a new name
672 672
                     if (empty($this->filename)) {
673 673
                         $this->filename = $this->file_array[$this->input]['name'];
674 674
                     }
675
-                    else{
675
+                    else {
676 676
                         // Replace %s for extension in filename
677 677
                         // Before: /[\w\d]*(.[\d\w]+)$/i
678 678
                         // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu
@@ -696,15 +696,15 @@  discard block
 block discarded – undo
696 696
                     $this->file['filename']     = $this->filename;
697 697
                     $this->file['error']        = $this->file_array[$this->input]['error'];
698 698
 
699
-                    $this->logger->info('The upload file information to process is : ' .stringfy_vars($this->file));
699
+                    $this->logger->info('The upload file information to process is : ' . stringfy_vars($this->file));
700 700
 
701 701
                     $error = $this->uploadHasError();
702
-                    if($error){
702
+                    if ($error) {
703 703
                         return false;
704 704
                     }
705 705
                     // Execute input callback
706
-                    if (!empty( $this->callbacks['input'])) {
707
-                        call_user_func($this->callbacks['input'], (object)$this->file);
706
+                    if (!empty($this->callbacks['input'])) {
707
+                        call_user_func($this->callbacks['input'], (object) $this->file);
708 708
                     }
709 709
                    
710 710
 
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
                     );
717 717
 
718 718
                     // Execute output callback
719
-                    if (!empty( $this->callbacks['output'])) {
720
-                        call_user_func($this->callbacks['output'], (object)$this->file);
719
+                    if (!empty($this->callbacks['output'])) {
720
+                        call_user_func($this->callbacks['output'], (object) $this->file);
721 721
                     }
722 722
                     return $this->file['status'];
723 723
                 }
@@ -736,10 +736,10 @@  discard block
 block discarded – undo
736 736
         */
737 737
         public function sizeFormat($size, $precision = 2)
738 738
         {
739
-            if($size > 0){
739
+            if ($size > 0) {
740 740
                 $base       = log($size) / log(1024);
741 741
                 $suffixes   = array('B', 'K', 'M', 'G', 'T');
742
-                return round(pow(1024, $base - floor($base)), $precision) . ( isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : '');
742
+                return round(pow(1024, $base - floor($base)), $precision) . (isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : '');
743 743
             }
744 744
             return null;
745 745
         }
@@ -763,14 +763,14 @@  discard block
 block discarded – undo
763 763
             if (array_key_exists('unit', $matches)) {
764 764
                 $unit = strtoupper($matches['unit']);
765 765
             }
766
-            return (floatval($matches['size']) * pow(1024, $units[$unit]) ) ;
766
+            return (floatval($matches['size']) * pow(1024, $units[$unit]));
767 767
         }
768 768
 
769 769
         /**
770 770
          * Get the upload error message
771 771
          * @return string
772 772
          */
773
-        public function getError(){
773
+        public function getError() {
774 774
             return $this->error;
775 775
         }
776 776
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
          * Set the upload error message
779 779
          * @param string $message the upload error message to set
780 780
          */
781
-        public function setError($message){
781
+        public function setError($message) {
782 782
             $this->logger->info('The file upload got error : ' . $message);
783 783
             $this->error = $message;
784 784
         }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
          * @param  int $code the error code
789 789
          * @return string the error message
790 790
          */
791
-        private function getPhpUploadErrorMessageByCode($code){
791
+        private function getPhpUploadErrorMessageByCode($code) {
792 792
             $codeMessageMaps = array(
793 793
                 1 => $this->error_messages['upload_err_ini_size'],
794 794
                 2 => $this->error_messages['upload_err_form_size'],
Please login to merge, or discard this patch.
core/common.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 		//put the first letter of class to upper case 
54 54
 		$class = ucfirst($class);
55 55
 		static $classes = array();
56
-		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
56
+		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') {
57 57
 			return $classes[$class];
58 58
 		}
59 59
 		$found = false;
60 60
 		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
61 61
 			$file = $path . $dir . '/' . $class . '.php';
62
-			if (file_exists($file)){
63
-				if (class_exists($class, false) === false){
62
+			if (file_exists($file)) {
63
+				if (class_exists($class, false) === false) {
64 64
 					require_once $file;
65 65
 				}
66 66
 				//already found
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				break;
69 69
 			}
70 70
 		}
71
-		if (! $found){
71
+		if (!$found) {
72 72
 			//can't use show_error() at this time because some dependencies not yet loaded
73 73
 			set_http_status_header(503);
74 74
 			echo 'Cannot find the class [' . $class . ']';
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		/*
79 79
 		   TODO use the best method to get the Log instance
80 80
 		 */
81
-		if ($class == 'Log'){
81
+		if ($class == 'Log') {
82 82
 			//can't use the instruction like "return new Log()" 
83 83
 			//because we need return the reference instance of the loaded class.
84 84
 			$log = new Log();
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	function & class_loaded($class = null){
104 104
 		static $list = array();
105
-		if ($class !== null){
105
+		if ($class !== null) {
106 106
 			$list[strtolower($class)] = $class;
107 107
 		}
108 108
 		return $list;
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	function & load_configurations(array $overwrite_values = array()){
119 119
 		static $config;
120
-		if (empty($config)){
120
+		if (empty($config)) {
121 121
 			$file = CONFIG_PATH . 'config.php';
122 122
 			$found = false;
123
-			if (file_exists($file)){
123
+			if (file_exists($file)) {
124 124
 				require_once $file;
125 125
 				$found = true;
126 126
 			}
127
-			if (! $found){
127
+			if (!$found) {
128 128
 				set_http_status_header(503);
129 129
 				echo 'Unable to find the configuration file [' . $file . ']';
130 130
 				die();
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 * 
145 145
 	 * @return mixed          the config value
146 146
 	 */
147
-	function get_config($key, $default = null){
147
+	function get_config($key, $default = null) {
148 148
 		static $cfg;
149
-		if (empty($cfg)){
149
+		if (empty($cfg)) {
150 150
 			$cfg[0] = & load_configurations();
151 151
 		}
152 152
 		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	 * 
161 161
 	 * @codeCoverageIgnore
162 162
 	 */
163
-	function save_to_log($level, $message, $logger = null){
164
-		$log =& class_loader('Log', 'classes');
165
-		if ($logger){
163
+	function save_to_log($level, $message, $logger = null) {
164
+		$log = & class_loader('Log', 'classes');
165
+		if ($logger) {
166 166
 			$log->setLogger($logger);
167 167
 		}
168 168
 		$log->writeLog($message, $level);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	 * 
176 176
 	 * @codeCoverageIgnore
177 177
 	 */
178
-	function set_http_status_header($code = 200, $text = null){
179
-		if (!is_int($code) || $code < 0 ){
178
+	function set_http_status_header($code = 200, $text = null) {
179
+		if (!is_int($code) || $code < 0) {
180 180
 			show_error('HTTP status code must be an integer');
181 181
 		}
182
-		if (empty($text)){
182
+		if (empty($text)) {
183 183
 			$code = abs($code);
184 184
 			$http_status = array(
185 185
 								100 => 'Continue',
@@ -228,18 +228,18 @@  discard block
 block discarded – undo
228 228
 								504 => 'Gateway Timeout',
229 229
 								505 => 'HTTP Version Not Supported',
230 230
 							);
231
-			if (isset($http_status[$code])){
231
+			if (isset($http_status[$code])) {
232 232
 				$text = $http_status[$code];
233 233
 			}
234
-			else{
234
+			else {
235 235
 				show_error('No HTTP status text found for your code please check it.');
236 236
 			}
237 237
 		}
238 238
 		
239
-		if (strpos(php_sapi_name(), 'cgi') === 0){
239
+		if (strpos(php_sapi_name(), 'cgi') === 0) {
240 240
 			header('Status: ' . $code . ' ' . $text, TRUE);
241 241
 		}
242
-		else{
242
+		else {
243 243
 			$proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
244 244
 			header($proto . ' ' . $code . ' ' . $text, TRUE, $code);
245 245
 		}
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 	 *  
255 255
 	 *  @codeCoverageIgnore
256 256
 	 */
257
-	function show_error($msg, $title = 'error', $logging = true){
257
+	function show_error($msg, $title = 'error', $logging = true) {
258 258
 		$title = strtoupper($title);
259 259
 		$data = array();
260 260
 		$data['error'] = $msg;
261 261
 		$data['title'] = $title;
262
-		if ($logging){
263
-			save_to_log('error', '['.$title.'] '.strip_tags($msg), 'GLOBAL::ERROR');
262
+		if ($logging) {
263
+			save_to_log('error', '[' . $title . '] ' . strip_tags($msg), 'GLOBAL::ERROR');
264 264
 		}
265 265
 		$response = & class_loader('Response', 'classes');
266 266
 		$response->sendError($data);
@@ -274,18 +274,18 @@  discard block
 block discarded – undo
274 274
 	 *  
275 275
 	 *  @return boolean true if the web server uses the https protocol, false if not.
276 276
 	 */
277
-	function is_https(){
277
+	function is_https() {
278 278
 		/*
279 279
 		* some servers pass the "HTTPS" parameter in the server variable,
280 280
 		* if is the case, check if the value is "on", "true", "1".
281 281
 		*/
282
-		if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){
282
+		if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
283 283
 			return true;
284 284
 		}
285
-		else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
285
+		else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
286 286
 			return true;
287 287
 		}
288
-		else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
288
+		else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
289 289
 			return true;
290 290
 		}
291 291
 		return false;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 *  
301 301
 	 *  @return boolean true if is a valid URL address or false.
302 302
 	 */
303
-	function is_url($url){
303
+	function is_url($url) {
304 304
 		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url) == 1;
305 305
 	}
306 306
 	
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	 *  @param string $controllerClass the controller class name to be loaded
311 311
 	 *  @codeCoverageIgnore
312 312
 	 */
313
-	function autoload_controller($controllerClass){
314
-		if (file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')){
313
+	function autoload_controller($controllerClass) {
314
+		if (file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')) {
315 315
 			require_once $path;
316 316
 		}
317 317
 	}
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 *  
326 326
 	 *  @return boolean
327 327
 	 */
328
-	function php_exception_handler($ex){
329
-		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
330
-			show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
328
+	function php_exception_handler($ex) {
329
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) {
330
+			show_error('An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
331 331
 		}
332
-		else{
332
+		else {
333 333
 			save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception');
334 334
 		}
335 335
 		return true;
@@ -346,16 +346,16 @@  discard block
 block discarded – undo
346 346
 	 *  
347 347
 	 *  @return boolean	
348 348
 	 */
349
-	function php_error_handler($errno , $errstr, $errfile , $errline){
349
+	function php_error_handler($errno, $errstr, $errfile, $errline) {
350 350
 		$isError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errno) === $errno);
351
-		if ($isError){
351
+		if ($isError) {
352 352
 			set_http_status_header(500);
353 353
 		}
354
-		if (! (error_reporting() & $errno)) {
354
+		if (!(error_reporting() & $errno)) {
355 355
 			save_to_log('error', 'An error is occurred in the file ' . $errfile . ' at line ' . $errline . ' raison : ' . $errstr, 'PHP ERROR');
356 356
 			return;
357 357
 		}
358
-		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
358
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) {
359 359
 			$errorType = 'error';
360 360
 			switch ($errno) {
361 361
 				case E_USER_ERROR:
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 					$errorType = 'error';
372 372
 					break;
373 373
 			}
374
-			show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline .'</b> raison : ' . $errstr, 'PHP ' . $errorType);
374
+			show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline . '</b> raison : ' . $errstr, 'PHP ' . $errorType);
375 375
 		}
376
-		if ($isError){
376
+		if ($isError) {
377 377
 			die();
378 378
 		}
379 379
 		return true;
@@ -383,10 +383,10 @@  discard block
 block discarded – undo
383 383
 	 * This function is used to run in shutdown situation of the script
384 384
 	 * @codeCoverageIgnore
385 385
 	 */
386
-	function php_shudown_handler(){
386
+	function php_shudown_handler() {
387 387
 		$lastError = error_get_last();
388 388
 		if (isset($lastError) &&
389
-			($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))){
389
+			($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) {
390 390
 			php_error_handler($lastError['type'], $lastError['message'], $lastError['file'], $lastError['line']);
391 391
 		}
392 392
 	}
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
 	 *   
405 405
 	 *  @return string string of the HTML attribute.
406 406
 	 */
407
-	function attributes_to_string(array $attributes){
407
+	function attributes_to_string(array $attributes) {
408 408
 		$str = ' ';
409 409
 		//we check that the array passed as an argument is not empty.
410
-		if (! empty($attributes)){
411
-			foreach($attributes as $key => $value){
410
+		if (!empty($attributes)) {
411
+			foreach ($attributes as $key => $value) {
412 412
 				$key = trim(htmlspecialchars($key));
413 413
 				$value = trim(htmlspecialchars($value));
414 414
 				/*
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 				* 	$attr = array('placeholder' => 'I am a "puple"')
419 419
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
420 420
 				 */
421
-				if ($value && strpos('"', $value) !== false){
421
+				if ($value && strpos('"', $value) !== false) {
422 422
 					$value = addslashes($value);
423 423
 				}
424
-				$str .= $key.' = "'.$value.'" ';
424
+				$str .= $key . ' = "' . $value . '" ';
425 425
 			}
426 426
 		}
427 427
 		//remove the space after using rtrim()
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	*
438 438
 	* @return string the stringfy value
439 439
 	*/
440
-	function stringfy_vars($var){
440
+	function stringfy_vars($var) {
441 441
 		return print_r($var, true);
442 442
 	}
443 443
 
@@ -448,18 +448,18 @@  discard block
 block discarded – undo
448 448
 	 * 
449 449
 	 * @return mixed   the sanitize value
450 450
 	 */
451
-	function clean_input($str){
452
-		if (is_array($str)){
451
+	function clean_input($str) {
452
+		if (is_array($str)) {
453 453
 			$str = array_map('clean_input', $str);
454 454
 		}
455
-		else if (is_object($str)){
455
+		else if (is_object($str)) {
456 456
 			$obj = $str;
457 457
 			foreach ($str as $var => $value) {
458 458
 				$obj->$var = clean_input($value);
459 459
 			}
460 460
 			$str = $obj;
461 461
 		}
462
-		else{
462
+		else {
463 463
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
464 464
 		}
465 465
 		return $str;
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 	 * 
478 478
 	 * @return string the string with the hidden part.
479 479
 	 */
480
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
480
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
481 481
 		//get the string length
482 482
 		$len = strlen($str);
483 483
 		//if str is empty
484
-		if ($len <= 0){
484
+		if ($len <= 0) {
485 485
 			return str_repeat($hiddenChar, 6);
486 486
 		}
487 487
 		//if the length is less than startCount and endCount
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 		//or startCount is negative or endCount is negative
490 490
 		//return the full string hidden
491 491
 		
492
-		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
492
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
493 493
 			return str_repeat($hiddenChar, $len);
494 494
 		}
495 495
 		//the start non hidden string
496 496
 		$startNonHiddenStr = substr($str, 0, $startCount);
497 497
 		//the end non hidden string
498 498
 		$endNonHiddenStr = null;
499
-		if ($endCount > 0){
499
+		if ($endCount > 0) {
500 500
 			$endNonHiddenStr = substr($str, - $endCount);
501 501
 		}
502 502
 		//the hidden string
@@ -509,31 +509,31 @@  discard block
 block discarded – undo
509 509
 	 * This function is used to set the initial session config regarding the configuration
510 510
 	 * @codeCoverageIgnore
511 511
 	 */
512
-	function set_session_config(){
512
+	function set_session_config() {
513 513
 		//$_SESSION is not available on cli mode 
514
-		if (! IS_CLI){
515
-			$logger =& class_loader('Log', 'classes');
514
+		if (!IS_CLI) {
515
+			$logger = & class_loader('Log', 'classes');
516 516
 			$logger->setLogger('PHPSession');
517 517
 			//set session params
518 518
 			$sessionHandler = get_config('session_handler', 'files'); //the default is to store in the files
519 519
 			$sessionName = get_config('session_name');
520
-			if ($sessionName){
520
+			if ($sessionName) {
521 521
 				session_name($sessionName);
522 522
 			}
523 523
 			$logger->info('Session handler: ' . $sessionHandler);
524 524
 			$logger->info('Session name: ' . $sessionName);
525 525
 
526
-			if ($sessionHandler == 'files'){
526
+			if ($sessionHandler == 'files') {
527 527
 				$sessionSavePath = get_config('session_save_path');
528
-				if ($sessionSavePath){
529
-					if (! is_dir($sessionSavePath)){
528
+				if ($sessionSavePath) {
529
+					if (!is_dir($sessionSavePath)) {
530 530
 						mkdir($sessionSavePath, 1773);
531 531
 					}
532 532
 					session_save_path($sessionSavePath);
533 533
 					$logger->info('Session save path: ' . $sessionSavePath);
534 534
 				}
535 535
 			}
536
-			else if ($sessionHandler == 'database'){
536
+			else if ($sessionHandler == 'database') {
537 537
 				//load database session handle library
538 538
 				//Model
539 539
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 				//Database Session handler Model
542 542
 				require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php';
543 543
 
544
-				$DBS =& class_loader('DBSessionHandler', 'classes');
544
+				$DBS = & class_loader('DBSessionHandler', 'classes');
545 545
 				session_set_save_handler($DBS, true);
546 546
 				$logger->info('session save path: ' . get_config('session_save_path'));
547 547
 			}
548
-			else{
548
+			else {
549 549
 				show_error('Invalid session handler configuration');
550 550
 			}
551 551
 			$lifetime = get_config('session_cookie_lifetime', 0);
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 			$logger->info('Session lifetime: ' . $lifetime);
569 569
 			$logger->info('Session cookie path: ' . $path);
570 570
 			$logger->info('Session domain: ' . $domain);
571
-			$logger->info('Session is secure: ' . ($secure ? 'TRUE':'FALSE'));
571
+			$logger->info('Session is secure: ' . ($secure ? 'TRUE' : 'FALSE'));
572 572
 			
573
-			if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()){
573
+			if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()) {
574 574
 				$logger->info('Session not yet start, start it now');
575 575
 				session_start();
576 576
 			}
Please login to merge, or discard this patch.