Test Failed
Push — 1.0.0-dev ( 92a7f9...7e13dc )
by nguereza
04:45
created
core/functions/function_user_agent.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,17 +55,13 @@
 block discarded – undo
55 55
 
56 56
 			if (isset($_SERVER["HTTP_CLIENT_IP"])) {
57 57
 				$ip = $_SERVER["HTTP_CLIENT_IP"];
58
-			}
59
-			else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
58
+			} else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
60 59
 				$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
61
-			} 
62
-			else if (isset($_SERVER["HTTP_X_FORWARDED"])) {
60
+			} else if (isset($_SERVER["HTTP_X_FORWARDED"])) {
63 61
 				$ip = $_SERVER["HTTP_X_FORWARDED"];
64
-			} 
65
-			else if (isset($_SERVER["HTTP_FORWARDED_FOR"])) {
62
+			} else if (isset($_SERVER["HTTP_FORWARDED_FOR"])) {
66 63
 				$ip = $_SERVER["HTTP_FORWARDED_FOR"];
67
-			} 
68
-			else if (isset($_SERVER["HTTP_FORWARDED"])) {
64
+			} else if (isset($_SERVER["HTTP_FORWARDED"])) {
69 65
 				$ip = $_SERVER["HTTP_FORWARDED"];
70 66
 			} 
71 67
 
Please login to merge, or discard this patch.
core/common.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -224,16 +224,14 @@  discard block
 block discarded – undo
224 224
 							);
225 225
 			if(isset($http_status[$code])){
226 226
 				$text = $http_status[$code];
227
-			}
228
-			else{
227
+			} else{
229 228
 				show_error('No HTTP status text found for your code please check it.');
230 229
 			}
231 230
 		}
232 231
 		
233 232
 		if(strpos(php_sapi_name(), 'cgi') === 0){
234 233
 			header('Status: ' . $code . ' ' . $text, TRUE);
235
-		}
236
-		else{
234
+		} else{
237 235
 			$proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
238 236
 			header($proto . ' ' . $code . ' ' . $text, TRUE, $code);
239 237
 		}
@@ -271,11 +269,9 @@  discard block
 block discarded – undo
271 269
 		*/
272 270
 		if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){
273 271
 			return true;
274
-		}
275
-		else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
272
+		} else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
276 273
 			return true;
277
-		}
278
-		else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
274
+		} else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
279 275
 			return true;
280 276
 		}
281 277
 		return false;
@@ -313,8 +309,7 @@  discard block
 block discarded – undo
313 309
 	function php_exception_handler($ex){
314 310
 		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
315 311
 			show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
316
-		}
317
-		else{
312
+		} else{
318 313
 			save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception');
319 314
 		}
320 315
 		exit(1);
@@ -431,15 +426,13 @@  discard block
 block discarded – undo
431 426
 	function clean_input($str){
432 427
 		if(is_array($str)){
433 428
 			$str = array_map('clean_input', $str);
434
-		}
435
-		else if(is_object($str)){
429
+		} else if(is_object($str)){
436 430
 			$obj = $str;
437 431
 			foreach ($str as $var => $value) {
438 432
 				$obj->$var = clean_input($value);
439 433
 			}
440 434
 			$str = $obj;
441
-		}
442
-		else{
435
+		} else{
443 436
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
444 437
 		}
445 438
 		return $str;
@@ -510,8 +503,7 @@  discard block
 block discarded – undo
510 503
 					session_save_path($sessionSavePath);
511 504
 					$logger->info('Session save path: ' . $sessionSavePath);
512 505
 				}
513
-			}
514
-			else if($sessionHandler == 'database'){
506
+			} else if($sessionHandler == 'database'){
515 507
 				//load database session handle library
516 508
 				//Model
517 509
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
@@ -522,8 +514,7 @@  discard block
 block discarded – undo
522 514
 				$DBS =& class_loader('DBSessionHandler', 'classes');
523 515
 				session_set_save_handler($DBS, true);
524 516
 				$logger->info('session save path: ' . get_config('session_save_path'));
525
-			}
526
-			else{
517
+			} else{
527 518
 				show_error('Invalid session handler configuration');
528 519
 			}
529 520
 			$lifetime = get_config('session_cookie_lifetime', 0);
Please login to merge, or discard this patch.
tests/include/autoloader.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@
 block discarded – undo
42 42
 		if(isset($classesMap[$class])){
43 43
 			if(file_exists($classesMap[$class])){
44 44
 				include_once $classesMap[$class];
45
-			}
46
-			else{
45
+			} else{
47 46
 				echo 'File for class ' . $class . ' not found';
48 47
 			}
49 48
 		}
Please login to merge, or discard this patch.
tests/include/common.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,15 +178,13 @@
 block discarded – undo
178 178
 	function clean_input($str){
179 179
 		if(is_array($str)){
180 180
 			$str = array_map('clean_input', $str);
181
-		}
182
-		else if(is_object($str)){
181
+		} else if(is_object($str)){
183 182
 			$obj = $str;
184 183
 			foreach ($str as $var => $value) {
185 184
 				$obj->$var = clean_input($value);
186 185
 			}
187 186
 			$str = $obj;
188
-		}
189
-		else{
187
+		} else{
190 188
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
191 189
 		}
192 190
 		return $str;
Please login to merge, or discard this patch.
core/classes/DBSessionHandler.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,8 +87,7 @@  discard block
 block discarded – undo
87 87
 	         */
88 88
 	        if(is_object($logger)){
89 89
 	          $this->setLogger($logger);
90
-	        }
91
-	        else{
90
+	        } else{
92 91
 	            $this->logger =& class_loader('Log', 'classes');
93 92
 	            $this->logger->setLogger('Library::DBSessionHandler');
94 93
 	        }
@@ -197,8 +196,7 @@  discard block
 block discarded – undo
197 196
 			if($this->getLoader()){
198 197
 				$this->getLoader()->functions('user_agent'); 
199 198
 				$this->getLoader()->library('Browser'); 
200
-			}
201
-			else{
199
+			} else{
202 200
             	Loader::functions('user_agent');
203 201
             	Loader::library('Browser');
204 202
             }
@@ -237,8 +235,7 @@  discard block
 block discarded – undo
237 235
 			if($this->getLoader()){
238 236
 				$this->getLoader()->functions('user_agent'); 
239 237
 				$this->getLoader()->library('Browser'); 
240
-			}
241
-			else{
238
+			} else{
242 239
             	Loader::functions('user_agent');
243 240
             	Loader::library('Browser');
244 241
             }
@@ -264,8 +261,7 @@  discard block
 block discarded – undo
264 261
 				//update
265 262
 				unset($params[$columns['sid']]);
266 263
 				$instance->update($sid, $params);
267
-			}
268
-			else{
264
+			} else{
269 265
 				$this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now');
270 266
 				$instance->insert($params);
271 267
 			}
Please login to merge, or discard this patch.
core/classes/model/Model.php 1 patch
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -143,8 +143,7 @@  discard block
 block discarded – undo
143 143
         public function __construct(Database $db = null){
144 144
             if(is_object($db)){
145 145
                 $this->setDatabaseInstance($db);
146
-            }
147
-            else{
146
+            } else{
148 147
                 $obj = & get_instance();
149 148
         		if(isset($obj->database) && is_object($obj->database)){
150 149
                     /**
@@ -256,8 +255,7 @@  discard block
 block discarded – undo
256 255
                 $insert_id = $this->_database->insertId();
257 256
                 $this->trigger('after_create', $insert_id);
258 257
                 return $insert_id;
259
-            }
260
-            else
258
+            } else
261 259
             {
262 260
                 return FALSE;
263 261
             }
@@ -294,8 +292,7 @@  discard block
 block discarded – undo
294 292
                                    ->update($data, $escape);
295 293
                 $this->trigger('after_update', array($data, $result));
296 294
                 return $result;
297
-            }
298
-            else
295
+            } else
299 296
             {
300 297
                 return FALSE;
301 298
             }
@@ -318,8 +315,7 @@  discard block
 block discarded – undo
318 315
                                    ->update($data, $escape);
319 316
                 $this->trigger('after_update', array($data, $result));
320 317
                 return $result;
321
-            }
322
-            else
318
+            } else
323 319
             {
324 320
                 return FALSE;
325 321
             }
@@ -336,8 +332,7 @@  discard block
 block discarded – undo
336 332
                 if(is_array($args[1])){
337 333
                     $data = array_pop($args);
338 334
                 }
339
-            }
340
-            else if(count($args) == 3){
335
+            } else if(count($args) == 3){
341 336
                 if(is_array($args[2])){
342 337
                     $data = array_pop($args);
343 338
                 }
@@ -349,8 +344,7 @@  discard block
 block discarded – undo
349 344
                 $result = $this->_database->from($this->_table)->update($data);
350 345
                 $this->trigger('after_update', array($data, $result));
351 346
                 return $result;
352
-            }
353
-            else
347
+            } else
354 348
             {
355 349
                 return FALSE;
356 350
             }
@@ -377,8 +371,7 @@  discard block
 block discarded – undo
377 371
             if ($this->soft_delete)
378 372
             {
379 373
                 $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
380
-            }
381
-            else
374
+            } else
382 375
             {
383 376
                 $result = $this->_database->from($this->_table)->delete();
384 377
             }
@@ -398,8 +391,7 @@  discard block
 block discarded – undo
398 391
             if ($this->soft_delete)
399 392
             {
400 393
                 $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
401
-            }
402
-            else
394
+            } else
403 395
             {
404 396
                 $result = $this->_database->from($this->_table)->delete();
405 397
             }
@@ -417,8 +409,7 @@  discard block
 block discarded – undo
417 409
             if ($this->soft_delete)
418 410
             {
419 411
                 $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE ));
420
-            }
421
-            else
412
+            } else
422 413
             {
423 414
                 $result = $this->_database->from($this->_table)->delete();
424 415
             }
@@ -463,8 +454,7 @@  discard block
 block discarded – undo
463 454
                 {
464 455
                     $relationship = $value;
465 456
                     $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' );
466
-                }
467
-                else
457
+                } else
468 458
                 {
469 459
                     $relationship = $key;
470 460
                     $options = $value;
@@ -474,15 +464,13 @@  discard block
 block discarded – undo
474 464
                 {
475 465
                     if(is_object($this->loaderInstance)){
476 466
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
477
-                    }
478
-                    else{
467
+                    } else{
479 468
                         Loader::model($options['model'], $relationship . '_model');    
480 469
                     }
481 470
                     if (is_object($row))
482 471
                     {
483 472
                         $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']});
484
-                    }
485
-                    else
473
+                    } else
486 474
                     {
487 475
                         $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]);
488 476
                     }
@@ -495,8 +483,7 @@  discard block
 block discarded – undo
495 483
                 {
496 484
                     $relationship = $value;
497 485
                     $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' );
498
-                }
499
-                else
486
+                } else
500 487
                 {
501 488
                     $relationship = $key;
502 489
                     $options = $value;
@@ -506,15 +493,13 @@  discard block
 block discarded – undo
506 493
                 {
507 494
                     if(is_object($this->loaderInstance)){
508 495
                         $this->loaderInstance->model($options['model'], $relationship . '_model');
509
-                    }
510
-                    else{
496
+                    } else{
511 497
                         Loader::model($options['model'], $relationship . '_model');    
512 498
                     }
513 499
                     if (is_object($row))
514 500
                     {
515 501
                         $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key});
516
-                    }
517
-                    else
502
+                    } else
518 503
                     {
519 504
                         $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]);
520 505
                     }
@@ -536,8 +521,7 @@  discard block
 block discarded – undo
536 521
             if(count($args) == 2)
537 522
             {
538 523
                 list($key, $value) = $args;
539
-            }
540
-            else
524
+            } else
541 525
             {
542 526
                 $key = $this->primary_key;
543 527
                 $value = $args[0];
@@ -685,8 +669,7 @@  discard block
 block discarded – undo
685 669
             if (is_object($row))
686 670
             {
687 671
                 $row->created_at = date('Y-m-d H:i:s');
688
-            }
689
-            else
672
+            } else
690 673
             {
691 674
                 $row['created_at'] = date('Y-m-d H:i:s');
692 675
             }
@@ -699,8 +682,7 @@  discard block
 block discarded – undo
699 682
             if (is_object($row))
700 683
             {
701 684
                 $row->updated_at = date('Y-m-d H:i:s');
702
-            }
703
-            else
685
+            } else
704 686
             {
705 687
                 $row['updated_at'] = date('Y-m-d H:i:s');
706 688
             }
@@ -727,8 +709,7 @@  discard block
 block discarded – undo
727 709
                 if (is_array($row))
728 710
                 {
729 711
                     $row[$column] = unserialize($row[$column]);
730
-                }
731
-                else
712
+                } else
732 713
                 {
733 714
                     $row->$column = unserialize($row->$column);
734 715
                 }
@@ -748,8 +729,7 @@  discard block
 block discarded – undo
748 729
 					if(isset($row->$attr)){
749 730
 						unset($row->$attr);
750 731
 					}
751
-                }
752
-                else
732
+                } else
753 733
                 {
754 734
 					if(isset($row[$attr])){
755 735
 						unset($row[$attr]);
@@ -828,8 +808,7 @@  discard block
 block discarded – undo
828 808
                 {
829 809
                     $this->_database->orderBy($key, $value);
830 810
                 }
831
-            }
832
-            else
811
+            } else
833 812
             {
834 813
                 $this->_database->orderBy($criteria, $order);
835 814
             }
@@ -887,8 +866,7 @@  discard block
 block discarded – undo
887 866
                 $fv = null;
888 867
                 if(is_object($this->formValidationInstance)){
889 868
                     $fv = $this->formValidationInstance;
890
-                }
891
-                else{
869
+                } else{
892 870
                     Loader::library('FormValidation');
893 871
                     $fv = $this->formvalidation;
894 872
                     $this->setFormValidation($fv);
@@ -901,17 +879,14 @@  discard block
 block discarded – undo
901 879
                     if ($fv->run())
902 880
                     {
903 881
                         return $data;
904
-                    }
905
-                    else
882
+                    } else
906 883
                     {
907 884
                         return FALSE;
908 885
                     }
909
-                }
910
-                else {
886
+                } else {
911 887
                     return $data;
912 888
                 }
913
-            }
914
-            else
889
+            } else
915 890
             {
916 891
                 return $data;
917 892
             }
@@ -930,46 +905,38 @@  discard block
 block discarded – undo
930 905
                     if (is_array($filter))
931 906
                     {
932 907
                         $this->_database->in($field, $filter);
933
-                    }
934
-                    else
908
+                    } else
935 909
                     {
936 910
                         if (is_int($field))
937 911
                         {
938 912
                             $this->_database->where($filter);
939
-                        }
940
-                        else
913
+                        } else
941 914
                         {
942 915
                             $this->_database->where($field, $filter);
943 916
                         }
944 917
                     }
945 918
                 }
946
-            }
947
-            else if (count($params) == 1)
919
+            } else if (count($params) == 1)
948 920
             {
949 921
                 $this->_database->where($params[0]);
950
-            }
951
-        	else if(count($params) == 2)
922
+            } else if(count($params) == 2)
952 923
     		{
953 924
                 if (is_array($params[1]))
954 925
                 {
955 926
                     $this->_database->in($params[0], $params[1]);
956
-                }
957
-                else
927
+                } else
958 928
                 {
959 929
                     $this->_database->where($params[0], $params[1]);
960 930
                 }
961
-    		}
962
-    		else if(count($params) == 3)
931
+    		} else if(count($params) == 3)
963 932
     		{
964 933
     			$this->_database->where($params[0], $params[1], $params[2]);
965
-    		}
966
-            else
934
+    		} else
967 935
             {
968 936
                 if (is_array($params[1]))
969 937
                 {
970 938
                     $this->_database->in($params[0], $params[1]);
971
-                }
972
-                else
939
+                } else
973 940
                 {
974 941
                     $this->_database->where($params[0], $params[1]);
975 942
                 }
Please login to merge, or discard this patch.
core/classes/Loader.php 1 patch
Braces   +18 added lines, -36 removed lines patch added patch discarded remove patch
@@ -148,8 +148,7 @@  discard block
 block discarded – undo
148 148
 					if(isset($path[1])){
149 149
 						$instance = strtolower($path[1]);
150 150
 					}
151
-				}
152
-				else{
151
+				} else{
153 152
 					$instance = strtolower($class);
154 153
 				}
155 154
 			}
@@ -169,8 +168,7 @@  discard block
 block discarded – undo
169 168
 					$searchModuleName = $path[0];
170 169
 					$class = ucfirst($path[1]);
171 170
 				}
172
-			}
173
-			else{
171
+			} else{
174 172
 				$class = ucfirst($class);
175 173
 			}
176 174
 
@@ -181,8 +179,7 @@  discard block
 block discarded – undo
181 179
 			if($moduleModelFilePath){
182 180
 				$logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it');
183 181
 				$classFilePath = $moduleModelFilePath;
184
-			}
185
-			else{
182
+			} else{
186 183
 				$logger->info('Cannot find model [' . $class . '] from modules using the default location');
187 184
 			}
188 185
 			$logger->info('The model file path to be loaded is [' . $classFilePath . ']');
@@ -194,12 +191,10 @@  discard block
 block discarded – undo
194 191
 					$obj->{$instance} = $c;
195 192
 					static::$loaded[$instance] = $class;
196 193
 					$logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.');
197
-				}
198
-				else{
194
+				} else{
199 195
 					show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']');
200 196
 				}
201
-			}
202
-			else{
197
+			} else{
203 198
 				show_error('Unable to find the model [' . $class . ']');
204 199
 			}
205 200
 		}
@@ -227,8 +222,7 @@  discard block
 block discarded – undo
227 222
 					if(isset($path[1])){
228 223
 						$instance = strtolower($path[1]);
229 224
 					}
230
-				}
231
-				else{
225
+				} else{
232 226
 					$instance = strtolower($class);
233 227
 				}
234 228
 			}
@@ -254,8 +248,7 @@  discard block
 block discarded – undo
254 248
 				$libraryFilePath = CORE_LIBRARY_PATH . $file;
255 249
 				$class = ucfirst($class);
256 250
 				$logger->info('This library is a system library');
257
-			}
258
-			else{
251
+			} else{
259 252
 				$logger->info('This library is not a system library');	
260 253
 				//first check if this library is in the module
261 254
 				$logger->debug('Checking library [' . $class . '] from module list ...');
@@ -267,8 +260,7 @@  discard block
 block discarded – undo
267 260
 						$searchModuleName = $path[0];
268 261
 						$class = ucfirst($path[1]);
269 262
 					}
270
-				}
271
-				else{
263
+				} else{
272 264
 					$class = ucfirst($class);
273 265
 				}
274 266
 				if(! $searchModuleName && !empty($obj->moduleName)){
@@ -278,8 +270,7 @@  discard block
 block discarded – undo
278 270
 				if($moduleLibraryPath){
279 271
 					$logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it');
280 272
 					$libraryFilePath = $moduleLibraryPath;
281
-				}
282
-				else{
273
+				} else{
283 274
 					$logger->info('Cannot find library [' . $class . '] from modules using the default location');
284 275
 				}
285 276
 			}
@@ -303,12 +294,10 @@  discard block
 block discarded – undo
303 294
 					$obj->{$instance} = $c;
304 295
 					static::$loaded[$instance] = $class;
305 296
 					$logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.');
306
-				}
307
-				else{
297
+				} else{
308 298
 					show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class);
309 299
 				}
310
-			}
311
-			else{
300
+			} else{
312 301
 				show_error('Unable to find library class [' . $class . ']');
313 302
 			}
314 303
 		}
@@ -352,8 +341,7 @@  discard block
 block discarded – undo
352 341
 			if($moduleFunctionPath){
353 342
 				$logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it');
354 343
 				$functionFilePath = $moduleFunctionPath;
355
-			}
356
-			else{
344
+			} else{
357 345
 				$logger->info('Cannot find helper [' . $function . '] from modules using the default location');
358 346
 			}
359 347
 			if(! $functionFilePath){
@@ -372,8 +360,7 @@  discard block
 block discarded – undo
372 360
 				require_once $functionFilePath;
373 361
 				static::$loaded['function_' . $function] = $functionFilePath;
374 362
 				$logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.');
375
-			}
376
-			else{
363
+			} else{
377 364
 				show_error('Unable to find helper file [' . $file . ']');
378 365
 			}
379 366
 		}
@@ -417,8 +404,7 @@  discard block
 block discarded – undo
417 404
 			if($moduleConfigPath){
418 405
 				$logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it');
419 406
 				$configFilePath = $moduleConfigPath;
420
-			}
421
-			else{
407
+			} else{
422 408
 				$logger->info('Cannot find config [' . $filename . '] from modules using the default location');
423 409
 			}
424 410
 			$logger->info('The config file path to be loaded is [' . $configFilePath . ']');
@@ -426,12 +412,10 @@  discard block
 block discarded – undo
426 412
 				require_once $configFilePath;
427 413
 				if(! empty($config) && is_array($config)){
428 414
 					Config::setAll($config);
429
-				}
430
-				else{
415
+				} else{
431 416
 					show_error('No configuration found in ['. $configFilePath . ']');
432 417
 				}
433
-			}
434
-			else{
418
+			} else{
435 419
 				show_error('Unable to find config file ['. $configFilePath . ']');
436 420
 			}
437 421
 			static::$loaded['config_' . $filename] = $configFilePath;
@@ -489,8 +473,7 @@  discard block
 block discarded – undo
489 473
 			if($moduleLanguagePath){
490 474
 				$logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it');
491 475
 				$languageFilePath = $moduleLanguagePath;
492
-			}
493
-			else{
476
+			} else{
494 477
 				$logger->info('Cannot find language [' . $language . '] from modules using the default location');
495 478
 			}
496 479
 			if(! $languageFilePath){
@@ -517,8 +500,7 @@  discard block
 block discarded – undo
517 500
 				}
518 501
 				static::$loaded['lang_' . $language] = $languageFilePath;
519 502
 				$logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.');
520
-			}
521
-			else{
503
+			} else{
522 504
 				show_error('Unable to find language file [' . $file . ']');
523 505
 			}
524 506
 		}
Please login to merge, or discard this patch.
core/classes/Database.php 1 patch
Braces   +42 added lines, -84 removed lines patch added patch discarded remove patch
@@ -188,8 +188,7 @@  discard block
 block discarded – undo
188 188
          */
189 189
         if(is_object($logger)){
190 190
           $this->logger = $logger;
191
-        }
192
-        else{
191
+        } else{
193 192
             $this->logger =& class_loader('Log', 'classes');
194 193
             $this->logger->setLogger('Library::Database');
195 194
         }
@@ -251,14 +250,12 @@  discard block
 block discarded – undo
251 250
             $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'");
252 251
             $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
253 252
             return true;
254
-          }
255
-          catch (PDOException $e){
253
+          } catch (PDOException $e){
256 254
             $this->logger->fatal($e->getMessage());
257 255
             show_error('Cannot connect to Database.');
258 256
             return false;
259 257
           }
260
-      }
261
-      else{
258
+      } else{
262 259
         show_error('Database configuration is not set.');
263 260
         return false;
264 261
       }
@@ -276,8 +273,7 @@  discard block
 block discarded – undo
276 273
           $froms .= $this->prefix . $key . ', ';
277 274
         }
278 275
         $this->from = rtrim($froms, ', ');
279
-      }
280
-      else{
276
+      } else{
281 277
         $this->from = $this->prefix . $table;
282 278
       }
283 279
       return $this;
@@ -383,8 +379,7 @@  discard block
 block discarded – undo
383 379
       }
384 380
       if (is_null($this->join)){
385 381
         $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
386
-      }
387
-      else{
382
+      } else{
388 383
         $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
389 384
       }
390 385
       return $this;
@@ -455,12 +450,10 @@  discard block
 block discarded – undo
455 450
         foreach($field as $f){
456 451
         	$this->whereIsNull($f, $andOr);
457 452
         }
458
-      }
459
-      else{
453
+      } else{
460 454
         if (! $this->where){
461 455
           $this->where = $field.' IS NULL ';
462
-        }
463
-        else{
456
+        } else{
464 457
             $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NULL ';
465 458
           }
466 459
       }
@@ -478,12 +471,10 @@  discard block
 block discarded – undo
478 471
         foreach($field as $f){
479 472
           $this->whereIsNotNull($f, $andOr);
480 473
         }
481
-      }
482
-      else{
474
+      } else{
483 475
         if (! $this->where){
484 476
           $this->where = $field.' IS NOT NULL ';
485
-        }
486
-        else{
477
+        } else{
487 478
             $this->where = $this->where . ' '.$andOr.' ' . $field.' IS NOT NULL ';
488 479
           }
489 480
       }
@@ -510,8 +501,7 @@  discard block
 block discarded – undo
510 501
           $_where[] = $type . $column . '=' . ($escape ? $this->escape($data) : $data);
511 502
         }
512 503
         $where = implode(' '.$andOr.' ', $_where);
513
-      }
514
-      else{
504
+      } else{
515 505
         if(is_array($op)){
516 506
           $x = explode('?', $where);
517 507
           $w = '';
@@ -524,14 +514,12 @@  discard block
 block discarded – undo
524 514
             }
525 515
           }
526 516
           $where = $w;
527
-        }
528
-        else if (! in_array((string)$op, $this->operatorList)){
517
+        } else if (! in_array((string)$op, $this->operatorList)){
529 518
           if(is_null($op)){
530 519
             $op = '';
531 520
           }
532 521
         	$where = $type . $where . ' = ' . ($escape ? $this->escape($op) : $op);
533
-        }
534
-        else{
522
+        } else{
535 523
           if(is_null($val)){
536 524
             $val = '';
537 525
           }
@@ -540,12 +528,10 @@  discard block
 block discarded – undo
540 528
       }
541 529
       if (is_null($this->where)){
542 530
         $this->where = $where;
543
-      }
544
-      else{
531
+      } else{
545 532
         if(substr($this->where, -1) == '('){
546 533
           $this->where = $this->where . ' ' . $where;
547
-        }
548
-        else{
534
+        } else{
549 535
           $this->where = $this->where . ' '.$andOr.' ' . $where;
550 536
         }
551 537
       }
@@ -589,12 +575,10 @@  discard block
 block discarded – undo
589 575
     public function groupStart($type = '', $andOr = ' AND'){
590 576
       if (is_null($this->where)){
591 577
         $this->where = $type . ' (';
592
-      }
593
-      else{
578
+      } else{
594 579
           if(substr($this->where, -1) == '('){
595 580
             $this->where .= $type . ' (';
596
-          }
597
-          else{
581
+          } else{
598 582
           	$this->where .= $andOr . ' ' . $type . ' (';
599 583
           }
600 584
       }
@@ -658,12 +642,10 @@  discard block
 block discarded – undo
658 642
         $keys = implode(', ', $_keys);
659 643
         if (is_null($this->where)){
660 644
           $this->where = $field . ' ' . $type . 'IN (' . $keys . ')';
661
-        }
662
-        else{
645
+        } else{
663 646
           if(substr($this->where, -1) == '('){
664 647
             $this->where = $this->where . ' ' . $field . ' '.$type.'IN (' . $keys . ')';
665
-          }
666
-          else{
648
+          } else{
667 649
             $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' '.$type.'IN (' . $keys . ')';
668 650
           }
669 651
         }
@@ -717,12 +699,10 @@  discard block
 block discarded – undo
717 699
       }
718 700
       if (is_null($this->where)){
719 701
       	$this->where = $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
720
-      }
721
-      else{
702
+      } else{
722 703
         if(substr($this->where, -1) == '('){
723 704
           $this->where = $this->where . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
724
-        }
725
-        else{
705
+        } else{
726 706
           $this->where = $this->where . ' ' . $andOr . ' ' . $field . ' ' . $type . 'BETWEEN ' . ($escape ? $this->escape($value1) : $value1) . ' AND ' . ($escape ? $this->escape($value2) : $value2);
727 707
         }
728 708
       }
@@ -772,12 +752,10 @@  discard block
 block discarded – undo
772 752
       $like = $escape ? $this->escape($data) : $data;
773 753
       if (is_null($this->where)){
774 754
         $this->where = $field . ' ' . $type . 'LIKE ' . $like;
775
-      }
776
-      else{
755
+      } else{
777 756
         if(substr($this->where, -1) == '('){
778 757
           $this->where = $this->where . ' ' . $field . ' ' . $type . 'LIKE ' . $like;
779
-        }
780
-        else{
758
+        } else{
781 759
           $this->where = $this->where . ' '.$andOr.' ' . $field . ' ' . $type . 'LIKE ' . $like;
782 760
         }
783 761
       }
@@ -824,8 +802,7 @@  discard block
 block discarded – undo
824 802
       }
825 803
       if (! is_null($limitEnd)){
826 804
         $this->limit = $limit . ', ' . $limitEnd;
827
-      }
828
-      else{
805
+      } else{
829 806
         $this->limit = $limit;
830 807
       }
831 808
       return $this;
@@ -840,12 +817,10 @@  discard block
 block discarded – undo
840 817
     public function orderBy($orderBy, $orderDir = ' ASC'){
841 818
       if (! is_null($orderDir)){
842 819
         $this->orderBy = ! $this->orderBy ? ($orderBy . ' ' . strtoupper($orderDir)) : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir);
843
-      }
844
-      else{
820
+      } else{
845 821
         if(stristr($orderBy, ' ') || $orderBy == 'rand()'){
846 822
           $this->orderBy = ! $this->orderBy ? $orderBy : $this->orderBy . ', ' . $orderBy;
847
-        }
848
-        else{
823
+        } else{
849 824
           $this->orderBy = ! $this->orderBy ? ($orderBy . ' ASC') : $this->orderBy . ', ' . ($orderBy . ' ASC');
850 825
         }
851 826
       }
@@ -860,8 +835,7 @@  discard block
 block discarded – undo
860 835
     public function groupBy($field){
861 836
       if(is_array($field)){
862 837
         $this->groupBy = implode(', ', $field);
863
-      }
864
-      else{
838
+      } else{
865 839
         $this->groupBy = $field;
866 840
       }
867 841
       return $this;
@@ -888,14 +862,12 @@  discard block
 block discarded – undo
888 862
   	      }
889 863
       	}
890 864
         $this->having = $w;
891
-      }
892
-      else if (! in_array($op, $this->operatorList)){
865
+      } else if (! in_array($op, $this->operatorList)){
893 866
         if(is_null($op)){
894 867
           $op = '';
895 868
         }
896 869
         $this->having = $field . ' > ' . ($escape ? $this->escape($op) : $op);
897
-      }
898
-      else{
870
+      } else{
899 871
         if(is_null($val)){
900 872
           $val = '';
901 873
         }
@@ -940,8 +912,7 @@  discard block
 block discarded – undo
940 912
       $query = $this->getAll(true);
941 913
       if($returnSQLQueryOrResultType === true){
942 914
         return $query;
943
-      }
944
-      else{
915
+      } else{
945 916
         return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) );
946 917
       }
947 918
     }
@@ -980,8 +951,7 @@  discard block
 block discarded – undo
980 951
 	  
981 952
 	  if($returnSQLQueryOrResultType === true){
982 953
     	return $query;
983
-      }
984
-      else{
954
+      } else{
985 955
     	return $this->query($query, true, (($returnSQLQueryOrResultType == 'array') ? true : false) );
986 956
       }
987 957
     }
@@ -999,8 +969,7 @@  discard block
 block discarded – undo
999 969
         $columns = array_keys($this->getData());
1000 970
         $column = implode(',', $columns);
1001 971
         $val = implode(', ', $this->getData());
1002
-      }
1003
-      else{
972
+      } else{
1004 973
         $columns = array_keys($data);
1005 974
         $column = implode(',', $columns);
1006 975
         $val = implode(', ', ($escape ? array_map(array($this, 'escape'), $data) : $data));
@@ -1015,8 +984,7 @@  discard block
 block discarded – undo
1015 984
         }
1016 985
         $this->insertId = $this->pdo->lastInsertId();
1017 986
         return $this->insertId();
1018
-      }
1019
-      else{
987
+      } else{
1020 988
 		  return false;
1021 989
       }
1022 990
     }
@@ -1034,8 +1002,7 @@  discard block
 block discarded – undo
1034 1002
         foreach ($this->getData() as $column => $val){
1035 1003
           $values[] = $column . ' = ' . $val;
1036 1004
         }
1037
-      }
1038
-      else{
1005
+      } else{
1039 1006
         foreach ($data as $column => $val){
1040 1007
           $values[] = $column . '=' . ($escape ? $this->escape($val) : $val);
1041 1008
         }
@@ -1129,14 +1096,12 @@  discard block
 block discarded – undo
1129 1096
         $cacheKey = md5($query . $all . $array);
1130 1097
         if(is_object($this->cacheInstance)){
1131 1098
           $cacheInstance = $this->cacheInstance;
1132
-        }
1133
-        else{
1099
+        } else{
1134 1100
           $obj = & get_instance();
1135 1101
           $cacheInstance = $obj->cache;  
1136 1102
         }
1137 1103
         $cacheContent = $cacheInstance->get($cacheKey);        
1138
-      }
1139
-      else{
1104
+      } else{
1140 1105
 		  $this->logger->info('The cache is not enabled for this query or is not the SELECT query, get the result directly from real database');
1141 1106
       }
1142 1107
 
@@ -1150,8 +1115,7 @@  discard block
 block discarded – undo
1150 1115
         $bench = null;
1151 1116
         if(is_object($this->benchmarkInstance)){
1152 1117
           $bench = $this->benchmarkInstance;
1153
-        }
1154
-        else{
1118
+        } else{
1155 1119
           $obj = & get_instance();
1156 1120
           $bench = $obj->benchmark;  
1157 1121
         }
@@ -1169,15 +1133,13 @@  discard block
 block discarded – undo
1169 1133
             //if need return all result like list of record
1170 1134
             if ($all){
1171 1135
     				    $this->result = ($array == false) ? $sqlQuery->fetchAll(PDO::FETCH_OBJ) : $sqlQuery->fetchAll(PDO::FETCH_ASSOC);
1172
-    		    }
1173
-            else{
1136
+    		    } else{
1174 1137
 				        $this->result = ($array == false) ? $sqlQuery->fetch(PDO::FETCH_OBJ) : $sqlQuery->fetch(PDO::FETCH_ASSOC);
1175 1138
             }
1176 1139
             //Sqlite and pgsql always return 0 when using rowCount()
1177 1140
             if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1178 1141
               $this->numRows = count($this->result);  
1179
-            }
1180
-            else{
1142
+            } else{
1181 1143
               $this->numRows = $sqlQuery->rowCount(); 
1182 1144
             }
1183 1145
 
@@ -1185,23 +1147,20 @@  discard block
 block discarded – undo
1185 1147
               $this->logger->info('Save the result for query [' .$this->query. '] into cache for future use');
1186 1148
               $cacheInstance->set($cacheKey, $this->result, $cacheExpire);
1187 1149
           }
1188
-        }
1189
-        else{
1150
+        } else{
1190 1151
           $error = $this->pdo->errorInfo();
1191 1152
           $this->error = isset($error[2]) ? $error[2] : '';
1192 1153
           $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error));
1193 1154
           $this->error();
1194 1155
         }
1195
-      }
1196
-      else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){
1156
+      } else if ((! $cacheContent && !$sqlSELECTQuery) || ($cacheContent && !$sqlSELECTQuery)){
1197 1157
     		$queryStr = $this->pdo->query($this->query);
1198 1158
     		if($queryStr){
1199 1159
           //Sqlite and pgsql always return 0 when using rowCount()
1200 1160
           if(in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1201 1161
             $this->result = 1; //to test the result for the query like UPDATE, INSERT, DELETE
1202 1162
             $this->numRows = 1;  
1203
-          }
1204
-          else{
1163
+          } else{
1205 1164
               $this->result = $queryStr->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE
1206 1165
               $this->numRows = $queryStr->rowCount(); 
1207 1166
           }
@@ -1212,8 +1171,7 @@  discard block
 block discarded – undo
1212 1171
           $this->logger->fatal('The database query execution got error: ' . stringfy_vars($error));
1213 1172
           $this->error();
1214 1173
         }
1215
-      }
1216
-      else{
1174
+      } else{
1217 1175
         $this->logger->info('The result for query [' .$this->query. '] already cached use it');
1218 1176
         $this->result = $cacheContent;
1219 1177
 	     	$this->numRows = count($this->result);
Please login to merge, or discard this patch.
core/classes/Config.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,15 +78,13 @@  discard block
 block discarded – undo
78 78
 					//check if the server is running under IPv6
79 79
 					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){
80 80
 						$baseUrl = '['.$_SERVER['SERVER_ADDR'].']';
81
-					}
82
-					else{
81
+					} else{
83 82
 						$baseUrl = $_SERVER['SERVER_ADDR'];
84 83
 					}
85 84
 					$port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && ! is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https()) ) ? ':' . $_SERVER['SERVER_PORT'] : '');
86 85
 					$baseUrl = (is_https() ? 'https' : 'http').'://' . $baseUrl . $port
87 86
 						. substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
88
-				}
89
-				else{
87
+				} else{
90 88
 					$logger->warning('Can not determine the application base URL automatically, use http://localhost as default');
91 89
 					$baseUrl = 'http://localhost/';
92 90
 				}
@@ -151,8 +149,7 @@  discard block
 block discarded – undo
151 149
 				$logger->info('Delete config item ['.$item.']');
152 150
 				unset(self::$config[$item]);
153 151
 				return true;
154
-			}
155
-			else{
152
+			} else{
156 153
 				$logger->warning('Config item ['.$item.'] to be deleted does not exists');
157 154
 				return false;
158 155
 			}
Please login to merge, or discard this patch.