Test Setup Failed
Branch 1.0.0-dev (6506b5)
by nguereza
05:54
created
core/common.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 		//put the first letter of class to upper case 
52 52
 		$class = ucfirst($class);
53 53
 		static $classes = array();
54
-		if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
54
+		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') {
55 55
 			return $classes[$class];
56 56
 		}
57 57
 		$found = false;
58 58
 		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
59 59
 			$file = $path . $dir . '/' . $class . '.php';
60
-			if(file_exists($file)){
61
-				if(class_exists($class, false) == false){
60
+			if (file_exists($file)) {
61
+				if (class_exists($class, false) == false) {
62 62
 					require_once $file;
63 63
 				}
64 64
 				//already found
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 				break;
67 67
 			}
68 68
 		}
69
-		if(! $found){
69
+		if (!$found) {
70 70
 			//can't use show_error() at this time because some dependencies not yet loaded
71 71
 			set_http_status_header(503);
72 72
 			echo 'Cannot find the class [' . $class . ']';
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		/*
77 77
 		   TODO use the best method to get the Log instance
78 78
 		 */
79
-		if($class == 'Log'){
79
+		if ($class == 'Log') {
80 80
 			//can't use the instruction like "return new Log()" 
81 81
 			//because we need return the reference instance of the loaded class.
82 82
 			$log = new Log();
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	function & class_loaded($class = null){
100 100
 		static $list = array();
101
-		if($class != null){
101
+		if ($class != null) {
102 102
 			$list[strtolower($class)] = $class;
103 103
 		}
104 104
 		return $list;
@@ -111,22 +111,22 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	function & load_configurations(array $overwrite_values = array()){
113 113
 		static $config;
114
-		if(empty($config)){
114
+		if (empty($config)) {
115 115
 			$file = CONFIG_PATH . 'config.php';
116 116
 			$found = false;
117
-			if(file_exists($file)){
117
+			if (file_exists($file)) {
118 118
 				require_once $file;
119 119
 				$found = true;
120 120
 			}
121
-			if(! $found){
121
+			if (!$found) {
122 122
 				set_http_status_header(503);
123 123
 				echo 'Unable to find the configuration file [' . $file . ']';
124 124
 				exit(1);
125 125
 			}
126 126
 
127
-			if(! isset($config) || !is_array($config)){
127
+			if (!isset($config) || !is_array($config)) {
128 128
 				set_http_status_header(503);
129
-				echo 'No configuration found in file ['  . $file . ']';
129
+				echo 'No configuration found in file [' . $file . ']';
130 130
 				exit(1);
131 131
 			}
132 132
 		}
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 	 * @param  mixed $default the default value to return if can't find the config item in the configuration
143 143
 	 * @return mixed          the config value
144 144
 	 */
145
-	function get_config($key, $default = null){
145
+	function get_config($key, $default = null) {
146 146
 		static $cfg;
147
-		if(empty($cfg)){
147
+		if (empty($cfg)) {
148 148
 			$cfg[0] = & load_configurations();
149 149
 		}
150 150
 		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	 * @param  string $message the log message to be saved
157 157
 	 * @param  string $logger  the logger to use if is set
158 158
 	 */
159
-	function save_to_log($level, $message, $logger = null){
160
-		$log =& class_loader('Log', 'classes');
161
-		if($logger){
159
+	function save_to_log($level, $message, $logger = null) {
160
+		$log = & class_loader('Log', 'classes');
161
+		if ($logger) {
162 162
 			$log->setLogger($logger);
163 163
 		}
164 164
 		$log->writeLog($message, $level);
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param integer $code the HTTP status code
170 170
 	 * @param string  $text the HTTP status text
171 171
 	 */
172
-	function set_http_status_header($code = 200, $text = null){
173
-		if(! $code || !is_numeric($code)){
172
+	function set_http_status_header($code = 200, $text = null) {
173
+		if (!$code || !is_numeric($code)) {
174 174
 			show_error('HTTP status code must be an integer');
175 175
 		}
176
-		if(empty($text)){
176
+		if (empty($text)) {
177 177
 			$code = abs($code);
178 178
 			$http_status = array(
179 179
 								100 => 'Continue',
@@ -222,18 +222,18 @@  discard block
 block discarded – undo
222 222
 								504 => 'Gateway Timeout',
223 223
 								505 => 'HTTP Version Not Supported',
224 224
 							);
225
-			if(isset($http_status[$code])){
225
+			if (isset($http_status[$code])) {
226 226
 				$text = $http_status[$code];
227 227
 			}
228
-			else{
228
+			else {
229 229
 				show_error('No HTTP status text found for your code please check it.');
230 230
 			}
231 231
 		}
232 232
 		
233
-		if(strpos(php_sapi_name(), 'cgi') === 0){
233
+		if (strpos(php_sapi_name(), 'cgi') === 0) {
234 234
 			header('Status: ' . $code . ' ' . $text, TRUE);
235 235
 		}
236
-		else{
236
+		else {
237 237
 			$proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
238 238
 			header($proto . ' ' . $code . ' ' . $text, TRUE, $code);
239 239
 		}
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	 *  @param $title the message title: "error", "info", "warning", etc.
247 247
 	 *  @param $logging either to save error in log
248 248
 	 */
249
-	function show_error($msg, $title = 'error', $logging = true){
249
+	function show_error($msg, $title = 'error', $logging = true) {
250 250
 		$title = strtoupper($title);
251 251
 		$data['error'] = $msg;
252 252
 		$data['title'] = $title;
253
-		if($logging){
254
-			save_to_log('error', '['.$title.'] '.strip_tags($msg), 'GLOBAL::ERROR');
253
+		if ($logging) {
254
+			save_to_log('error', '[' . $title . '] ' . strip_tags($msg), 'GLOBAL::ERROR');
255 255
 		}
256 256
 		$response = & class_loader('Response', 'classes');
257 257
 		$response->sendError($data);
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
 	 *  
265 265
 	 *  @return boolean true if the web server uses the https protocol, false if not.
266 266
 	 */
267
-	function is_https(){
267
+	function is_https() {
268 268
 		/*
269 269
 		* some servers pass the "HTTPS" parameter in the server variable,
270 270
 		* if is the case, check if the value is "on", "true", "1".
271 271
 		*/
272
-		if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){
272
+		if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
273 273
 			return true;
274 274
 		}
275
-		else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
275
+		else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
276 276
 			return true;
277 277
 		}
278
-		else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
278
+		else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
279 279
 			return true;
280 280
 		}
281 281
 		return false;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 *  @param string $url the URL address to check
289 289
 	 *  @return boolean true if is a valid URL address or false.
290 290
 	 */
291
-	function is_url($url){
291
+	function is_url($url) {
292 292
 		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url);
293 293
 	}
294 294
 	
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 *  
298 298
 	 *  @param string $controllerClass the controller class name to be loaded
299 299
 	 */
300
-	function autoload_controller($controllerClass){
301
-		if(file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')){
300
+	function autoload_controller($controllerClass) {
301
+		if (file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')) {
302 302
 			require_once $path;
303 303
 		}
304 304
 	}
@@ -310,11 +310,11 @@  discard block
 block discarded – undo
310 310
 	 *  @param object $ex instance of the "Exception" class or a derived class
311 311
 	 *  @return boolean
312 312
 	 */
313
-	function php_exception_handler($ex){
314
-		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
315
-			show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
313
+	function php_exception_handler($ex) {
314
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) {
315
+			show_error('An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
316 316
 		}
317
-		else{
317
+		else {
318 318
 			save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception');
319 319
 		}
320 320
 		exit(1);
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *  @param array $errcontext the context
332 332
 	 *  @return boolean	
333 333
 	 */
334
-	function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){
334
+	function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) {
335 335
 		$isError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errno) === $errno);
336
-		if($isError){
336
+		if ($isError) {
337 337
 			set_http_status_header(500);
338 338
 		}
339
-		if (! (error_reporting() & $errno)) {
339
+		if (!(error_reporting() & $errno)) {
340 340
 			save_to_log('error', 'An error is occurred in the file ' . $errfile . ' at line ' . $errline . ' raison : ' . $errstr, 'PHP ' . $error_type, 'PHP ERROR');
341 341
 			return;
342 342
 		}
343
-		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
343
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) {
344 344
 			$errorType = 'error';
345 345
 			switch ($errno) {
346 346
 				case E_USER_ERROR:
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 					$errorType = 'error';
357 357
 					break;
358 358
 			}
359
-			show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline .'</b> raison : ' . $errstr, 'PHP ' . $errorType);
359
+			show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline . '</b> raison : ' . $errstr, 'PHP ' . $errorType);
360 360
 		}
361
-		if ($isError){
361
+		if ($isError) {
362 362
 			exit(1);
363 363
 		}
364 364
 		return true;
@@ -367,10 +367,10 @@  discard block
 block discarded – undo
367 367
 	/**
368 368
 	 * This function is used to run in shutdown situation of the script
369 369
 	 */
370
-	function php_shudown_handler(){
370
+	function php_shudown_handler() {
371 371
 		$lastError = error_get_last();
372 372
 		if (isset($lastError) &&
373
-			($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))){
373
+			($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) {
374 374
 			php_error_handler($lastError['type'], $lastError['message'], $lastError['file'], $lastError['line']);
375 375
 		}
376 376
 	}
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	 *  @param $attributes associative array to convert to a string attribute.
388 388
 	 *  @return string string of the HTML attribute.
389 389
 	 */
390
-	function attributes_to_string(array $attributes){
390
+	function attributes_to_string(array $attributes) {
391 391
 		$str = ' ';
392 392
 		//we check that the array passed as an argument is not empty.
393
-		if(! empty($attributes)){
394
-			foreach($attributes as $key => $value){
393
+		if (!empty($attributes)) {
394
+			foreach ($attributes as $key => $value) {
395 395
 				$key = trim(htmlspecialchars($key));
396 396
 				$value = trim(htmlspecialchars($value));
397 397
 				/*
@@ -401,10 +401,10 @@  discard block
 block discarded – undo
401 401
 				* 	$attr = array('placeholder' => 'I am a "puple"')
402 402
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
403 403
 				 */
404
-				if($value && strpos('"', $value) !== false){
404
+				if ($value && strpos('"', $value) !== false) {
405 405
 					$value = addslashes($value);
406 406
 				}
407
-				$str .= $key.' = "'.$value.'" ';
407
+				$str .= $key . ' = "' . $value . '" ';
408 408
 			}
409 409
 		}
410 410
 		//remove the space after using rtrim()
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	*
420 420
 	* @return string the stringfy value
421 421
 	*/
422
-	function stringfy_vars($var){
422
+	function stringfy_vars($var) {
423 423
 		return print_r($var, true);
424 424
 	}
425 425
 
@@ -428,18 +428,18 @@  discard block
 block discarded – undo
428 428
 	 * @param  mixed $str the value to clean
429 429
 	 * @return mixed   the sanitize value
430 430
 	 */
431
-	function clean_input($str){
432
-		if(is_array($str)){
431
+	function clean_input($str) {
432
+		if (is_array($str)) {
433 433
 			$str = array_map('clean_input', $str);
434 434
 		}
435
-		else if(is_object($str)){
435
+		else if (is_object($str)) {
436 436
 			$obj = $str;
437 437
 			foreach ($str as $var => $value) {
438 438
 				$obj->$var = clean_input($value);
439 439
 			}
440 440
 			$str = $obj;
441 441
 		}
442
-		else{
442
+		else {
443 443
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
444 444
 		}
445 445
 		return $str;
@@ -456,11 +456,11 @@  discard block
 block discarded – undo
456 456
 	 *
457 457
 	 * @return string the string with the hidden part.
458 458
 	 */
459
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
459
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
460 460
 		//get the string length
461 461
 		$len = strlen($str);
462 462
 		//if str is empty
463
-		if($len <= 0){
463
+		if ($len <= 0) {
464 464
 			return str_repeat($hiddenChar, 6);
465 465
 		}
466 466
 		//if the length is less than startCount and endCount
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
 		//or startCount is negative or endCount is negative
469 469
 		//return the full string hidden
470 470
 		
471
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
471
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
472 472
 			return str_repeat($hiddenChar, $len);
473 473
 		}
474 474
 		//the start non hidden string
475 475
 		$startNonHiddenStr = substr($str, 0, $startCount);
476 476
 		//the end non hidden string
477 477
 		$endNonHiddenStr = null;
478
-		if($endCount > 0){
478
+		if ($endCount > 0) {
479 479
 			$endNonHiddenStr = substr($str, - $endCount);
480 480
 		}
481 481
 		//the hidden string
@@ -487,31 +487,31 @@  discard block
 block discarded – undo
487 487
 	/**
488 488
 	 * This function is used to set the initial session config regarding the configuration
489 489
 	 */
490
-	function set_session_config(){
490
+	function set_session_config() {
491 491
 		//$_SESSION is not available on cli mode 
492
-		if(! IS_CLI){
493
-			$logger =& class_loader('Log', 'classes');
492
+		if (!IS_CLI) {
493
+			$logger = & class_loader('Log', 'classes');
494 494
 			$logger->setLogger('PHPSession');
495 495
 			//set session params
496 496
 			$sessionHandler = get_config('session_handler', 'files'); //the default is to store in the files
497 497
 			$sessionName = get_config('session_name');
498
-			if($sessionName){
498
+			if ($sessionName) {
499 499
 				session_name($sessionName);
500 500
 			}
501 501
 			$logger->info('Session handler: ' . $sessionHandler);
502 502
 			$logger->info('Session name: ' . $sessionName);
503 503
 
504
-			if($sessionHandler == 'files'){
504
+			if ($sessionHandler == 'files') {
505 505
 				$sessionSavePath = get_config('session_save_path');
506
-				if($sessionSavePath){
507
-					if(! is_dir($sessionSavePath)){
506
+				if ($sessionSavePath) {
507
+					if (!is_dir($sessionSavePath)) {
508 508
 						mkdir($sessionSavePath, 1773);
509 509
 					}
510 510
 					session_save_path($sessionSavePath);
511 511
 					$logger->info('Session save path: ' . $sessionSavePath);
512 512
 				}
513 513
 			}
514
-			else if($sessionHandler == 'database'){
514
+			else if ($sessionHandler == 'database') {
515 515
 				//load database session handle library
516 516
 				//Model
517 517
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
@@ -519,11 +519,11 @@  discard block
 block discarded – undo
519 519
 				//Database Session handler Model
520 520
 				require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php';
521 521
 
522
-				$DBS =& class_loader('DBSessionHandler', 'classes');
522
+				$DBS = & class_loader('DBSessionHandler', 'classes');
523 523
 				session_set_save_handler($DBS, true);
524 524
 				$logger->info('session save path: ' . get_config('session_save_path'));
525 525
 			}
526
-			else{
526
+			else {
527 527
 				show_error('Invalid session handler configuration');
528 528
 			}
529 529
 			$lifetime = get_config('session_cookie_lifetime', 0);
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 			$logger->info('Session lifetime: ' . $lifetime);
547 547
 			$logger->info('Session cookie path: ' . $path);
548 548
 			$logger->info('Session domain: ' . $domain);
549
-			$logger->info('Session is secure: ' . ($secure ? 'TRUE':'FALSE'));
549
+			$logger->info('Session is secure: ' . ($secure ? 'TRUE' : 'FALSE'));
550 550
 			
551
-			if((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()){
551
+			if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()) {
552 552
 				$logger->info('Session not yet start, start it now');
553 553
 				session_start();
554 554
 			}
Please login to merge, or discard this patch.
core/lang/en/lang_form_validation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
  	/**
4 4
  	 * Form validation language message (English) 
5 5
  	 */
6
- 	$lang['fv_required']     		= 'Field %1 is required.';
6
+ 	$lang['fv_required'] = 'Field %1 is required.';
7 7
     $lang['fv_min_length']   		= 'Field %1 must contain at least %2 characters.';
8 8
     $lang['fv_max_length']   		= 'Field %1 must contain at most %2 characters.';
9 9
     $lang['fv_exact_length'] 		= 'Field %1 must contain exactly %2 characters.';
10
-    $lang['fv_less_than'] 		    = 'Field %1 must less than %2.';
10
+    $lang['fv_less_than'] = 'Field %1 must less than %2.';
11 11
     $lang['fv_greater_than'] 		= 'Field %1 must greater than %2.';
12 12
     $lang['fv_matches']      		= 'Field %1 must be identical to field %2.';
13 13
     $lang['fv_valid_email']  		= 'Field %1 must contain a valid E-mail address.';
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     $lang['fv_depends']      		= 'Field %1 depends on field %2 which is not valid.';
17 17
 	$lang['fv_is_unique']	   		= 'The value of field %1 already exists.';
18 18
 	$lang['fv_is_unique_update']	= 'The value of field %1 already exists for another record.';
19
-    $lang['fv_exists']	   			= 'The value of the field %1 does not exist.';
19
+    $lang['fv_exists'] = 'The value of the field %1 does not exist.';
20 20
     $lang['fv_regex']	   			= 'The value of the field %1 does not use the correct format.';
21 21
     $lang['fv_in_list']	   			= 'The value of field %1 must be one of the list (%2).';
22 22
     $lang['fv_numeric']	   			= 'The value of field %1 must be a number.';
Please login to merge, or discard this patch.
core/lang/en/lang_file_upload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
  	$lang['fu_upload_err_ini_size']     = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
7 7
     $lang['fu_upload_err_form_size']   	= 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
8 8
     $lang['fu_upload_err_partial']   	= 'The uploaded file was only partially uploaded.';
9
-    $lang['fu_upload_err_no_file'] 		= 'No file was choosed. Please select one.';
9
+    $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.';
10 10
     $lang['fu_upload_err_no_tmp_dir']   = 'Missing a temporary folder.';
11
-    $lang['fu_upload_err_cant_write'] 	= 'Failed to write file to disk.';
11
+    $lang['fu_upload_err_cant_write'] = 'Failed to write file to disk.';
12 12
     $lang['fu_upload_err_extension']    = 'A PHP extension stopped the file upload.';
13
-    $lang['fu_accept_file_types']  		= 'Filetype not allowed';
13
+    $lang['fu_accept_file_types'] = 'Filetype not allowed';
14 14
     $lang['fu_file_uploads_disabled']   = 'File uploading option is disabled in php.ini';
15 15
     $lang['fu_max_file_size']           = 'The uploaded file size is too big max size is %s';
16 16
     $lang['fu_overwritten_not_allowed'] = 'You don\'t allow overwriting existing file';
Please login to merge, or discard this patch.