@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace PSFS\base; |
| 3 | 3 | |
| 4 | -use PSFS\base\types\helpers\RequestHelper; |
|
| 5 | 4 | use PSFS\base\types\helpers\ResponseHelper; |
| 6 | 5 | use PSFS\base\types\traits\SecureTrait; |
| 7 | 6 | use PSFS\base\types\traits\SingletonTrait; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | session_start(); |
| 76 | 76 | } |
| 77 | 77 | // Fix for phpunits |
| 78 | - if(!isset($_SESSION)) { |
|
| 78 | + if (!isset($_SESSION)) { |
|
| 79 | 79 | $_SESSION = []; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $saved = true; |
| 137 | 137 | try { |
| 138 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 139 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 138 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 139 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 140 | 140 | $admins[$user['username']]['profile'] = $user['profile']; |
| 141 | 141 | |
| 142 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 143 | - } catch(\Exception $e) { |
|
| 142 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 143 | + }catch (\Exception $e) { |
|
| 144 | 144 | Logger::log($e->getMessage(), LOG_ERR); |
| 145 | 145 | $saved = false; |
| 146 | 146 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function getAdmins() |
| 179 | 179 | { |
| 180 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
| 180 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | if (!empty($user) && !empty($admins[$user])) { |
| 207 | 207 | $auth = $admins[$user]['hash']; |
| 208 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
| 208 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
| 209 | 209 | if ($this->authorized) { |
| 210 | 210 | $this->admin = array( |
| 211 | 211 | 'alias' => $user, |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | ] |
| 222 | 222 | ]); |
| 223 | 223 | } |
| 224 | - } else { |
|
| 224 | + }else { |
|
| 225 | 225 | $this->admin = null; |
| 226 | 226 | $this->setSessionKey(self::ADMIN_ID_TOKEN, null); |
| 227 | 227 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public static function header($name, $default = null) |
| 114 | 114 | { |
| 115 | - return self::getInstance()->getHeader($name, $default); |
|
| 115 | + return self::getInstance()->getHeader($name, $default); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | $header = null; |
| 126 | 126 | if ($this->hasHeader($name)) { |
| 127 | 127 | $header = $this->header[$name]; |
| 128 | - } else if(array_key_exists('h_' . strtolower($name), $this->query)) { |
|
| 129 | - $header = $this->query['h_' . strtolower($name)]; |
|
| 128 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
| 129 | + $header = $this->query['h_'.strtolower($name)]; |
|
| 130 | 130 | } |
| 131 | 131 | return $header ?: $default; |
| 132 | 132 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
| 226 | 226 | ob_start(); |
| 227 | - header('Location: ' . $url); |
|
| 227 | + header('Location: '.$url); |
|
| 228 | 228 | ob_end_clean(); |
| 229 | 229 | Security::getInstance()->updateSession(); |
| 230 | 230 | exit(_("Redireccionando...")); |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $url = $this->getServerName(); |
| 270 | 270 | $protocol = $protocol ? $this->getProtocol() : ''; |
| 271 | - if (!empty($protocol)) $url = $protocol . $url; |
|
| 271 | + if (!empty($protocol)) $url = $protocol.$url; |
|
| 272 | 272 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
| 273 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
| 273 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
| 274 | 274 | } |
| 275 | 275 | return $url; |
| 276 | 276 | } |
@@ -222,7 +222,9 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function redirect($url = null) |
| 224 | 224 | { |
| 225 | - if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
|
| 225 | + if (null === $url) { |
|
| 226 | + $url = $this->getServer('HTTP_ORIGIN'); |
|
| 227 | + } |
|
| 226 | 228 | ob_start(); |
| 227 | 229 | header('Location: ' . $url); |
| 228 | 230 | ob_end_clean(); |
@@ -268,7 +270,9 @@ discard block |
||
| 268 | 270 | { |
| 269 | 271 | $url = $this->getServerName(); |
| 270 | 272 | $protocol = $protocol ? $this->getProtocol() : ''; |
| 271 | - if (!empty($protocol)) $url = $protocol . $url; |
|
| 273 | + if (!empty($protocol)) { |
|
| 274 | + $url = $protocol . $url; |
|
| 275 | + } |
|
| 272 | 276 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
| 273 | 277 | $url .= ':' . $this->getServer('SERVER_PORT'); |
| 274 | 278 | } |