@@ -20,7 +20,7 @@ |
||
| 20 | 20 | protected function connectToServers() |
| 21 | 21 | { |
| 22 | 22 | $addServers = []; |
| 23 | - foreach($this->config['memcached']['server'] as $server) |
|
| 23 | + foreach ($this->config['memcached']['server'] as $server) |
|
| 24 | 24 | { |
| 25 | 25 | $addServers[] = [$server['host'], $server['port']]; |
| 26 | 26 | } |
@@ -20,29 +20,29 @@ discard block |
||
| 20 | 20 | $this->loadAllConfigsFiles(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - protected function searchAllConfigsFiles($dirPath, $pathFromRoot='') |
|
| 23 | + protected function searchAllConfigsFiles($dirPath, $pathFromRoot = '') |
|
| 24 | 24 | { |
| 25 | - if(!file_exists($dirPath)) { |
|
| 25 | + if (!file_exists($dirPath)) { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | $listFiles = array_diff(scandir($dirPath), ['.', '..']); |
| 30 | 30 | |
| 31 | - foreach($listFiles as $file) { |
|
| 31 | + foreach ($listFiles as $file) { |
|
| 32 | 32 | $keyFile = $pathFromRoot.$file; |
| 33 | 33 | $readPath = $dirPath.'/'.$file; |
| 34 | 34 | |
| 35 | - if(is_file($readPath)) { |
|
| 35 | + if (is_file($readPath)) { |
|
| 36 | 36 | $this->configFiles[$keyFile] = $readPath; |
| 37 | 37 | continue; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if(is_link($readPath)) { |
|
| 40 | + if (is_link($readPath)) { |
|
| 41 | 41 | $this->configFiles[$keyFile] = realpath($readPath); |
| 42 | 42 | continue; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(is_dir($readPath)) { |
|
| 45 | + if (is_dir($readPath)) { |
|
| 46 | 46 | $this->searchAllConfigsFiles($readPath, $pathFromRoot.'/'); |
| 47 | 47 | continue; |
| 48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | protected function loadAllConfigsFiles() |
| 53 | 53 | { |
| 54 | - foreach($this->configFiles as $fileKey => $filePath) |
|
| 54 | + foreach ($this->configFiles as $fileKey => $filePath) |
|
| 55 | 55 | { |
| 56 | 56 | $this->loadConfigFile($fileKey, $filePath); |
| 57 | 57 | } |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $fileExtension = pathinfo($filePath, PATHINFO_EXTENSION); |
| 63 | 63 | |
| 64 | - if($fileExtension === 'json') { |
|
| 64 | + if ($fileExtension === 'json') { |
|
| 65 | 65 | $this->loadJsonConfigFile($fileKey, $filePath); |
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if($fileExtension === 'php') { |
|
| 69 | + if ($fileExtension === 'php') { |
|
| 70 | 70 | $this->loadPhpConfigFile($fileKey, $filePath); |
| 71 | 71 | return; |
| 72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $json = file_get_contents($filePath); |
| 80 | 80 | $config = json_decode($json); |
| 81 | 81 | |
| 82 | - if($config === null) { |
|
| 82 | + if ($config === null) { |
|
| 83 | 83 | throw new Exception(json_last_error_msg()); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -91,25 +91,25 @@ discard block |
||
| 91 | 91 | $this->config[$fileKey] = require($filePath); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function getConfig($key, $file=null) |
|
| 94 | + public function getConfig($key, $file = null) |
|
| 95 | 95 | { |
| 96 | 96 | $nbConfigFile = count($this->config); |
| 97 | 97 | |
| 98 | - if($file === null && $nbConfigFile > 1) { |
|
| 98 | + if ($file === null && $nbConfigFile > 1) { |
|
| 99 | 99 | throw new Exception('Please indicate a file for get config '.$key); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if($nbConfigFile === 1) { |
|
| 102 | + if ($nbConfigFile === 1) { |
|
| 103 | 103 | $file = key($this->config); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if(!isset($this->config[$file])) { |
|
| 106 | + if (!isset($this->config[$file])) { |
|
| 107 | 107 | throw new Exception('The file '.$file.' not exist for config '.$key); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $config = &$this->config[$file]; |
| 111 | 111 | |
| 112 | - if(!isset($config[$key])) { |
|
| 112 | + if (!isset($config[$key])) { |
|
| 113 | 113 | throw new Exception('The config key '.$key.' not exist in config'); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | protected function loadConfig() |
| 73 | 73 | { |
| 74 | - if(!file_exists(CONFIG_DIR.$this->pathName)) { |
|
| 74 | + if (!file_exists(CONFIG_DIR.$this->pathName)) { |
|
| 75 | 75 | return; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | protected function loadJsonFile($jsonFilePath) |
| 98 | 98 | { |
| 99 | - if(!file_exists($jsonFilePath)) { |
|
| 99 | + if (!file_exists($jsonFilePath)) { |
|
| 100 | 100 | throw new Exception('File '.$jsonFilePath.' not found.'); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $infos = json_decode(file_get_contents($jsonFilePath)); |
| 104 | - if($infos === null) { |
|
| 104 | + if ($infos === null) { |
|
| 105 | 105 | throw new Exception(json_last_error_msg()); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | $moduleInfos = $this->loadInfos; |
| 114 | 114 | $runnerFile = ''; |
| 115 | 115 | |
| 116 | - if(property_exists($moduleInfos, 'runner')) { |
|
| 116 | + if (property_exists($moduleInfos, 'runner')) { |
|
| 117 | 117 | $runnerFile = (string) $moduleInfos->runner; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if($runnerFile === '') { |
|
| 120 | + if ($runnerFile === '') { |
|
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | .'/'.$runnerFile |
| 127 | 127 | ; |
| 128 | 128 | |
| 129 | - if(!file_exists($runnerFile)) { |
|
| 129 | + if (!file_exists($runnerFile)) { |
|
| 130 | 130 | throw new Exception( |
| 131 | 131 | 'Runner file for module '.$this->pathName.' not found.' |
| 132 | 132 | ); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function getOption($optionKey) |
| 18 | 18 | { |
| 19 | - if(!isset($this->options[$optionKey])) { |
|
| 19 | + if (!isset($this->options[$optionKey])) { |
|
| 20 | 20 | throw new Exception('Option key '.$optionKey.' not exist.'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public static function getInstance() |
| 27 | 27 | { |
| 28 | - if(self::$instance === null) { |
|
| 28 | + if (self::$instance === null) { |
|
| 29 | 29 | self::$instance = new self; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | public function getServerVar($keyName) |
| 66 | 66 | { |
| 67 | - if(!isset($_SERVER[$keyName])) { |
|
| 67 | + if (!isset($_SERVER[$keyName])) { |
|
| 68 | 68 | return ''; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $firstLang = explode(';', $acceptLangs[0]); |
| 93 | 93 | $lang = strtolower($firstLang[0]); |
| 94 | 94 | |
| 95 | - if(strpos($lang, '-') !== false) |
|
| 95 | + if (strpos($lang, '-') !== false) |
|
| 96 | 96 | { |
| 97 | 97 | $minLang = explode('-', $lang); |
| 98 | 98 | $lang = $minLang[0]; |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->ssl = false; |
| 121 | 121 | |
| 122 | - if(!empty($serverHttps) && $serverHttps !== 'off') { |
|
| 122 | + if (!empty($serverHttps) && $serverHttps !== 'off') { |
|
| 123 | 123 | $this->ssl = true; |
| 124 | 124 | } |
| 125 | - elseif(!empty($fwdProto) && $fwdProto === 'https') { |
|
| 125 | + elseif (!empty($fwdProto) && $fwdProto === 'https') { |
|
| 126 | 126 | $this->ssl = true; |
| 127 | 127 | } |
| 128 | - elseif(!empty($fwdSsl) && $fwdSsl === 'on') { |
|
| 128 | + elseif (!empty($fwdSsl) && $fwdSsl === 'on') { |
|
| 129 | 129 | $this->ssl = true; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | $key = array_search($observer, $this->observers, true); |
| 21 | 21 | |
| 22 | - if($key !== false) { |
|
| 22 | + if ($key !== false) { |
|
| 23 | 23 | unset($this->observers[$key]); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function notify($action = '') |
| 30 | 30 | { |
| 31 | - foreach($this->observers as $observer) { |
|
| 31 | + foreach ($this->observers as $observer) { |
|
| 32 | 32 | $observer->update($this, $action); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | ]; |
| 55 | 55 | |
| 56 | 56 | $erreurType = 'Unknown'; |
| 57 | - if(isset($map[$errSeverity])) { |
|
| 57 | + if (isset($map[$errSeverity])) { |
|
| 58 | 58 | $erreurType = $map[$errSeverity]; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $errorRenderFcts = self::errorGetRender(); |
| 62 | - $errorRender = $errorRenderFcts['default']; |
|
| 62 | + $errorRender = $errorRenderFcts['default']; |
|
| 63 | 63 | |
| 64 | - if(PHP_SAPI === 'cli') { |
|
| 64 | + if (PHP_SAPI === 'cli') { |
|
| 65 | 65 | $errorRender = $errorRenderFcts['cli']; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -97,22 +97,22 @@ discard block |
||
| 97 | 97 | <p class="title">Niarf, a error is detected !</p> |
| 98 | 98 | <p class="info">'.$erreurType.' Error : <strong>'.$errMsg.'</strong> in '.$errFile.' at line '.$errLine.'</p> |
| 99 | 99 | <fieldset><pre>'; |
| 100 | - foreach($backtrace as $i => $info) { |
|
| 100 | + foreach ($backtrace as $i => $info) { |
|
| 101 | 101 | echo '#'.$i.' '.$info['function']; |
| 102 | 102 | |
| 103 | - if(isset($info['args']) && count($info['args']) > 0) { |
|
| 103 | + if (isset($info['args']) && count($info['args']) > 0) { |
|
| 104 | 104 | echo '('; |
| 105 | 105 | |
| 106 | - foreach($info['args'] as $iArgs => $args) { |
|
| 107 | - if($iArgs > 0) { |
|
| 106 | + foreach ($info['args'] as $iArgs => $args) { |
|
| 107 | + if ($iArgs > 0) { |
|
| 108 | 108 | echo ', '; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(is_array($args) || is_object($args)) { |
|
| 111 | + if (is_array($args) || is_object($args)) { |
|
| 112 | 112 | echo gettype($args); |
| 113 | 113 | |
| 114 | 114 | } |
| 115 | - elseif(is_null($args)) { |
|
| 115 | + elseif (is_null($args)) { |
|
| 116 | 116 | echo 'null'; |
| 117 | 117 | } |
| 118 | 118 | else { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | echo ')'; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if(isset($info['file'], $info['line'])) { |
|
| 126 | + if (isset($info['file'], $info['line'])) { |
|
| 127 | 127 | echo ' called at ['.$info['file'].' line '.$info['line'].']'; |
| 128 | 128 | } |
| 129 | 129 | echo "\n\n"; |
@@ -8,34 +8,34 @@ |
||
| 8 | 8 | { |
| 9 | 9 | parent::__construct($defaultOption, $options); |
| 10 | 10 | |
| 11 | - if($this->options['rootDir'] === null) { |
|
| 11 | + if ($this->options['rootDir'] === null) { |
|
| 12 | 12 | $this->options['rootDir'] = $this->defineRootDir(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if($this->options['vendorDir'] === null) { |
|
| 15 | + if ($this->options['vendorDir'] === null) { |
|
| 16 | 16 | $this->options['vendorDir'] = $this->defineVendorDir(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - $rootDirPosLastLetter = strlen($this->options['rootDir'])-1; |
|
| 20 | - $vendorDirPosLastLetter = strlen($this->options['vendorDir'])-1; |
|
| 19 | + $rootDirPosLastLetter = strlen($this->options['rootDir']) - 1; |
|
| 20 | + $vendorDirPosLastLetter = strlen($this->options['vendorDir']) - 1; |
|
| 21 | 21 | |
| 22 | - if($this->options['rootDir'][$rootDirPosLastLetter] !== '/') { |
|
| 22 | + if ($this->options['rootDir'][$rootDirPosLastLetter] !== '/') { |
|
| 23 | 23 | $this->options['rootDir'] .= '/'; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - if($this->options['vendorDir'][$vendorDirPosLastLetter] !== '/') { |
|
| 26 | + if ($this->options['vendorDir'][$vendorDirPosLastLetter] !== '/') { |
|
| 27 | 27 | $this->options['vendorDir'] .= '/'; |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | protected function defineVendorDir() |
| 32 | 32 | { |
| 33 | - if(PHP_VERSION_ID >= 70000) { |
|
| 33 | + if (PHP_VERSION_ID >= 70000) { |
|
| 34 | 34 | return dirname(__FILE__, 5).'/'; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $rootDir = __FILE__; |
| 38 | - for($i=1; $i<=5; $i++) { |
|
| 38 | + for ($i = 1; $i <= 5; $i++) { |
|
| 39 | 39 | $rootDir = dirname($rootDir); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | global $_SESSION; |
| 40 | 40 | |
| 41 | - if(!isset($_SESSION['token'])) { |
|
| 41 | + if (!isset($_SESSION['token'])) { |
|
| 42 | 42 | throw new Exception('no token found'); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(!isset($_SESSION['token'][$this->formId])) { |
|
| 45 | + if (!isset($_SESSION['token'][$this->formId])) { |
|
| 46 | 46 | throw new Exception('no token found for form id '.$this->formId); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public function createToken() |
| 53 | 53 | { |
| 54 | - if(is_null($this->idForm)) { |
|
| 54 | + if (is_null($this->idForm)) { |
|
| 55 | 55 | throw new Exception('Form id is undefined.'); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return $token; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function checkToken($tokenToCheck, $timeExp=15) |
|
| 69 | + public function checkToken($tokenToCheck, $timeExp = 15) |
|
| 70 | 70 | { |
| 71 | 71 | //Throw Exception |
| 72 | 72 | $tokenInfos = $this->getToken(); |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | $token = $tokenInfos->token; |
| 75 | 75 | $dateCreate = $tokenInfos->date; |
| 76 | 76 | |
| 77 | - if($token !== $tokenToCheck) { |
|
| 77 | + if ($token !== $tokenToCheck) { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $limitDate = new DateTime; |
| 82 | 82 | $limitDate->modify('-'.(int) $timeExp.' minutes'); |
| 83 | 83 | |
| 84 | - if($dateCreate < $limitDate) { |
|
| 84 | + if ($dateCreate < $limitDate) { |
|
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | 87 | |