@@ -249,8 +249,7 @@ |
||
249 | 249 | ini_set('display_errors', 0); |
250 | 250 | if (version_compare(PHP_VERSION, '5.3', '>=')) { |
251 | 251 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); |
252 | - } |
|
253 | - else { |
|
252 | + } else { |
|
254 | 253 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); |
255 | 254 | } |
256 | 255 | break; |
@@ -48,16 +48,14 @@ discard block |
||
48 | 48 | require_once CONFIG_PATH . 'config_pagination.php'; |
49 | 49 | if (empty($config) || !is_array($config)) { |
50 | 50 | show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php'); |
51 | - } |
|
52 | - else { |
|
51 | + } else { |
|
53 | 52 | $config = array_merge($config, $overwriteConfig); |
54 | 53 | $this->config = $config; |
55 | 54 | //put it gobally |
56 | 55 | Config::setAll($config); |
57 | 56 | unset($config); |
58 | 57 | } |
59 | - } |
|
60 | - else { |
|
58 | + } else { |
|
61 | 59 | show_error('Unable to find the pagination configuration file'); |
62 | 60 | } |
63 | 61 | } |
@@ -177,11 +175,9 @@ discard block |
||
177 | 175 | $navbar = null; |
178 | 176 | if ($currentPageNumber == 1) { |
179 | 177 | $navbar .= $this->buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber); |
180 | - } |
|
181 | - else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) { |
|
178 | + } else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) { |
|
182 | 179 | $navbar .= $this->buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber); |
183 | - } |
|
184 | - else if ($currentPageNumber == $numberOfPage) { |
|
180 | + } else if ($currentPageNumber == $numberOfPage) { |
|
185 | 181 | $navbar .= $this->buildPaginationLinkForLastPage($begin, $end, $currentPageNumber); |
186 | 182 | } |
187 | 183 | $navbar = $this->config['pagination_open'] . $navbar . $this->config['pagination_close']; |
@@ -222,16 +222,14 @@ discard block |
||
222 | 222 | ); |
223 | 223 | if (isset($http_status[$code])) { |
224 | 224 | $text = $http_status[$code]; |
225 | - } |
|
226 | - else { |
|
225 | + } else { |
|
227 | 226 | show_error('No HTTP status text found for your code please check it.'); |
228 | 227 | } |
229 | 228 | } |
230 | 229 | |
231 | 230 | if (strpos(php_sapi_name(), 'cgi') === 0) { |
232 | 231 | header('Status: ' . $code . ' ' . $text, TRUE); |
233 | - } |
|
234 | - else { |
|
232 | + } else { |
|
235 | 233 | $proto = 'HTTP/1.1'; |
236 | 234 | if (isset($_SERVER['SERVER_PROTOCOL'])) { |
237 | 235 | $proto = $_SERVER['SERVER_PROTOCOL']; |
@@ -323,8 +321,7 @@ discard block |
||
323 | 321 | function php_exception_handler($ex) { |
324 | 322 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) { |
325 | 323 | show_error('An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
326 | - } |
|
327 | - else { |
|
324 | + } else { |
|
328 | 325 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
329 | 326 | } |
330 | 327 | return true; |
@@ -440,15 +437,13 @@ discard block |
||
440 | 437 | function clean_input($str) { |
441 | 438 | if (is_array($str)) { |
442 | 439 | $str = array_map('clean_input', $str); |
443 | - } |
|
444 | - else if (is_object($str)) { |
|
440 | + } else if (is_object($str)) { |
|
445 | 441 | $obj = $str; |
446 | 442 | foreach ($str as $var => $value) { |
447 | 443 | $obj->$var = clean_input($value); |
448 | 444 | } |
449 | 445 | $str = $obj; |
450 | - } |
|
451 | - else { |
|
446 | + } else { |
|
452 | 447 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
453 | 448 | } |
454 | 449 | return $str; |
@@ -521,8 +516,7 @@ discard block |
||
521 | 516 | session_save_path($sessionSavePath); |
522 | 517 | $logger->info('Session save path: ' . $sessionSavePath); |
523 | 518 | } |
524 | - } |
|
525 | - else if ($sessionHandler == 'database') { |
|
519 | + } else if ($sessionHandler == 'database') { |
|
526 | 520 | //load database session handle library |
527 | 521 | //Database Session handler Model |
528 | 522 | require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php'; |
@@ -530,8 +524,7 @@ discard block |
||
530 | 524 | $DBS = & class_loader('DBSessionHandler', 'classes'); |
531 | 525 | session_set_save_handler($DBS, true); |
532 | 526 | $logger->info('session save path: ' . get_config('session_save_path')); |
533 | - } |
|
534 | - else { |
|
527 | + } else { |
|
535 | 528 | show_error('Invalid session handler configuration'); |
536 | 529 | } |
537 | 530 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -264,8 +264,7 @@ discard block |
||
264 | 264 | $this->trigger('after_create', $insert_id); |
265 | 265 | //if the table doesn't have the auto increment field or sequence, the value of 0 will be returned |
266 | 266 | return !$insert_id ? true : $insert_id; |
267 | - } |
|
268 | - else |
|
267 | + } else |
|
269 | 268 | { |
270 | 269 | return FALSE; |
271 | 270 | } |
@@ -383,8 +382,7 @@ discard block |
||
383 | 382 | { |
384 | 383 | $this->getQueryBuilder()->from($this->_table); |
385 | 384 | $result = $this->_database->update(array($this->soft_delete_key => TRUE)); |
386 | - } |
|
387 | - else |
|
385 | + } else |
|
388 | 386 | { |
389 | 387 | $this->getQueryBuilder()->from($this->_table); |
390 | 388 | $result = $this->_database->delete(); |
@@ -407,8 +405,7 @@ discard block |
||
407 | 405 | { |
408 | 406 | $this->getQueryBuilder()->from($this->_table); |
409 | 407 | $result = $this->_database->update(array($this->soft_delete_key => TRUE)); |
410 | - } |
|
411 | - else |
|
408 | + } else |
|
412 | 409 | { |
413 | 410 | $this->getQueryBuilder()->from($this->_table); |
414 | 411 | $result = $this->_database->delete(); |
@@ -429,8 +426,7 @@ discard block |
||
429 | 426 | { |
430 | 427 | $this->getQueryBuilder()->from($this->_table); |
431 | 428 | $result = $this->_database->update(array($this->soft_delete_key => TRUE)); |
432 | - } |
|
433 | - else |
|
429 | + } else |
|
434 | 430 | { |
435 | 431 | $this->getQueryBuilder()->from($this->_table); |
436 | 432 | $result = $this->_database->delete(); |
@@ -242,8 +242,7 @@ discard block |
||
242 | 242 | //if the application is running in CLI mode use the first argument |
243 | 243 | else if (IS_CLI && isset($_SERVER['argv'][1])) { |
244 | 244 | $routeUri = $_SERVER['argv'][1]; |
245 | - } |
|
246 | - else if (isset($_SERVER['REQUEST_URI'])) { |
|
245 | + } else if (isset($_SERVER['REQUEST_URI'])) { |
|
247 | 246 | $routeUri = $_SERVER['REQUEST_URI']; |
248 | 247 | } |
249 | 248 | $this->logger->debug('Check if URL suffix is enabled in the configuration'); |
@@ -339,15 +338,13 @@ discard block |
||
339 | 338 | if (!class_exists($controller, false)) { |
340 | 339 | $e404 = true; |
341 | 340 | $this->logger->warning('The controller file [' . $classFilePath . '] exists but does not contain the class [' . $controller . ']'); |
342 | - } |
|
343 | - else { |
|
341 | + } else { |
|
344 | 342 | $controllerInstance = new $controller(); |
345 | 343 | $controllerMethod = $this->getMethod(); |
346 | 344 | if (!method_exists($controllerInstance, $controllerMethod)) { |
347 | 345 | $e404 = true; |
348 | 346 | $this->logger->warning('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
349 | - } |
|
350 | - else { |
|
347 | + } else { |
|
351 | 348 | $this->logger->info('Routing data is set correctly now GO!'); |
352 | 349 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->args); |
353 | 350 | //render the final page to user |
@@ -355,8 +352,7 @@ discard block |
||
355 | 352 | get_instance()->response->renderFinalPage(); |
356 | 353 | } |
357 | 354 | } |
358 | - } |
|
359 | - else { |
|
355 | + } else { |
|
360 | 356 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
361 | 357 | $e404 = true; |
362 | 358 | } |
@@ -462,8 +458,7 @@ discard block |
||
462 | 458 | $this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']'); |
463 | 459 | $this->module = $moduleControllerMethod[0]; |
464 | 460 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
465 | - } |
|
466 | - else { |
|
461 | + } else { |
|
467 | 462 | $this->logger->info('The current request does not use the module'); |
468 | 463 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
469 | 464 | } |
@@ -519,8 +514,7 @@ discard block |
||
519 | 514 | } |
520 | 515 | //args |
521 | 516 | $this->args = $segment; |
522 | - } |
|
523 | - else { |
|
517 | + } else { |
|
524 | 518 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
525 | 519 | if (in_array($segment[0], $modules)) { |
526 | 520 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
@@ -534,8 +528,7 @@ discard block |
||
534 | 528 | if (!$path) { |
535 | 529 | $this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller'); |
536 | 530 | $this->controller = $this->module; |
537 | - } |
|
538 | - else { |
|
531 | + } else { |
|
539 | 532 | $this->controllerPath = $path; |
540 | 533 | array_shift($segment); |
541 | 534 | } |
@@ -547,8 +540,7 @@ discard block |
||
547 | 540 | } |
548 | 541 | //the remaining is for args |
549 | 542 | $this->args = $segment; |
550 | - } |
|
551 | - else { |
|
543 | + } else { |
|
552 | 544 | $this->logger->info('The current request information is not found in the module list'); |
553 | 545 | //controller |
554 | 546 | if (isset($segment[0])) { |
@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | // Unlinking when the file was expired |
83 | 83 | unlink($filePath); |
84 | 84 | return false; |
85 | - } |
|
86 | - else { |
|
85 | + } else { |
|
87 | 86 | $this->logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']'); |
88 | 87 | return $data['data']; |
89 | 88 | } |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | $this->logger->error('Can not write cache data into file [' . $filePath . '] for the key [' . $key . '], return false'); |
121 | 120 | fclose($handle); |
122 | 121 | return false; |
123 | - } |
|
124 | - else { |
|
122 | + } else { |
|
125 | 123 | $this->logger->info('Cache data saved into file [' . $filePath . '] for the key [' . $key . ']'); |
126 | 124 | fclose($handle); |
127 | 125 | chmod($filePath, 0640); |
@@ -143,8 +141,7 @@ discard block |
||
143 | 141 | if (!file_exists($filePath)) { |
144 | 142 | $this->logger->info('This cache file does not exists skipping'); |
145 | 143 | return false; |
146 | - } |
|
147 | - else { |
|
144 | + } else { |
|
148 | 145 | $this->logger->info('Found cache file [' . $filePath . '] remove it'); |
149 | 146 | unlink($filePath); |
150 | 147 | return true; |
@@ -197,8 +194,7 @@ discard block |
||
197 | 194 | $list = glob(CACHE_PATH . '*.cache'); |
198 | 195 | if (!$list) { |
199 | 196 | $this->logger->info('No cache files were found skipping'); |
200 | - } |
|
201 | - else { |
|
197 | + } else { |
|
202 | 198 | $this->logger->info('Found [' . count($list) . '] cache files to remove if expired'); |
203 | 199 | foreach ($list as $file) { |
204 | 200 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -206,12 +202,10 @@ discard block |
||
206 | 202 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
207 | 203 | if (!$data) { |
208 | 204 | $this->logger->warning('Can not unserialize the cache data for file [' . $file . ']'); |
209 | - } |
|
210 | - else if (time() > $data['expire']) { |
|
205 | + } else if (time() > $data['expire']) { |
|
211 | 206 | $this->logger->info('The cache data for file [' . $file . '] already expired remove it'); |
212 | 207 | unlink($file); |
213 | - } |
|
214 | - else { |
|
208 | + } else { |
|
215 | 209 | $this->logger->info('The cache data for file [' . $file . '] not yet expired skip it'); |
216 | 210 | } |
217 | 211 | } |
@@ -226,8 +220,7 @@ discard block |
||
226 | 220 | $list = glob(CACHE_PATH . '*.cache'); |
227 | 221 | if (!$list) { |
228 | 222 | $this->logger->info('No cache files were found skipping'); |
229 | - } |
|
230 | - else { |
|
223 | + } else { |
|
231 | 224 | $this->logger->info('Found [' . count($list) . '] cache files to remove'); |
232 | 225 | foreach ($list as $file) { |
233 | 226 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -254,8 +247,7 @@ discard block |
||
254 | 247 | |
255 | 248 | $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE'); |
256 | 249 | $this->compressCacheData = false; |
257 | - } |
|
258 | - else { |
|
250 | + } else { |
|
259 | 251 | $this->compressCacheData = $status; |
260 | 252 | } |
261 | 253 | return $this; |
@@ -47,8 +47,7 @@ discard block |
||
47 | 47 | if ($success === false) { |
48 | 48 | $this->logger->info('No cache found for the key [' . $key . '], return false'); |
49 | 49 | return false; |
50 | - } |
|
51 | - else { |
|
50 | + } else { |
|
52 | 51 | $cacheInfo = $this->_getCacheInfo($key); |
53 | 52 | $expire = time(); |
54 | 53 | if ($cacheInfo) { |
@@ -74,8 +73,7 @@ discard block |
||
74 | 73 | if ($result === false) { |
75 | 74 | $this->logger->error('Can not write cache data for the key [' . $key . '], return false'); |
76 | 75 | return false; |
77 | - } |
|
78 | - else { |
|
76 | + } else { |
|
79 | 77 | $this->logger->info('Cache data saved for the key [' . $key . ']'); |
80 | 78 | return true; |
81 | 79 | } |
@@ -94,8 +92,7 @@ discard block |
||
94 | 92 | if ($cacheInfo === false) { |
95 | 93 | $this->logger->info('This cache data does not exists skipping'); |
96 | 94 | return false; |
97 | - } |
|
98 | - else { |
|
95 | + } else { |
|
99 | 96 | $this->logger->info('Found cache data for the key [' . $key . '] remove it'); |
100 | 97 | return apc_delete($key) === true; |
101 | 98 | } |
@@ -119,8 +116,7 @@ discard block |
||
119 | 116 | 'ttl' => $cacheInfos['ttl'] |
120 | 117 | ); |
121 | 118 | return $data; |
122 | - } |
|
123 | - else { |
|
119 | + } else { |
|
124 | 120 | $this->logger->info('This cache does not exists skipping'); |
125 | 121 | return false; |
126 | 122 | } |
@@ -144,8 +140,7 @@ discard block |
||
144 | 140 | if (empty($cacheInfos['cache_list'])) { |
145 | 141 | $this->logger->info('No cache data were found skipping'); |
146 | 142 | return false; |
147 | - } |
|
148 | - else { |
|
143 | + } else { |
|
149 | 144 | $this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove'); |
150 | 145 | return apc_clear_cache('user'); |
151 | 146 | } |