@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | if (!headers_sent()) { |
| 46 | 46 | // TODO include this headers in Template class output method |
| 47 | 47 | header('Access-Control-Allow-Credentials: true'); |
| 48 | - header('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
| 48 | + header('Access-Control-Allow-Origin: '.Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
| 49 | 49 | header('Vary: Origin'); |
| 50 | 50 | header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD'); |
| 51 | - header('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders())); |
|
| 51 | + header('Access-Control-Allow-Headers: '.implode(', ', self::getCorsHeaders())); |
|
| 52 | 52 | } |
| 53 | 53 | if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) { |
| 54 | 54 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return $ip; |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - } else { |
|
| 81 | + }else { |
|
| 82 | 82 | if (self::validateIpAddress($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 83 | 83 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 84 | 84 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $dump = ''; |
| 121 | 121 | try { |
| 122 | 122 | $dump = $this->tpl->render($tpl, $vars); |
| 123 | - } catch (\Exception $e) { |
|
| 123 | + }catch (\Exception $e) { |
|
| 124 | 124 | Logger::log($e->getMessage(), LOG_ERR); |
| 125 | 125 | } |
| 126 | 126 | return $dump; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | public function regenerateTemplates() |
| 148 | 148 | { |
| 149 | 149 | $this->generateTemplatesCache(); |
| 150 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 150 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 151 | 151 | $translations = []; |
| 152 | 152 | if (is_array($domains)) { |
| 153 | 153 | $translations = $this->parsePathTranslations($domains); |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | // force compilation |
| 173 | 173 | if ($file->isFile()) { |
| 174 | 174 | try { |
| 175 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
| 176 | - } catch (\Exception $e) { |
|
| 175 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
| 176 | + }catch (\Exception $e) { |
|
| 177 | 177 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | private function loadDomains() |
| 255 | 255 | { |
| 256 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 256 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 257 | 257 | if (null !== $domains) { |
| 258 | 258 | foreach ($domains as $domain => $paths) { |
| 259 | 259 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $loader = new FilesystemLoader(GeneratorHelper::getTemplatePath()); |
| 270 | 270 | $this->tpl = new Environment($loader, array( |
| 271 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
| 271 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
| 272 | 272 | 'debug' => (bool)$this->debug, |
| 273 | 273 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
| 274 | 274 | )); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function getAdmins() |
| 66 | 66 | { |
| 67 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
| 67 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | if (!empty($user) && !empty($admins[$user])) { |
| 91 | 91 | $auth = $admins[$user]['hash']; |
| 92 | - $this->authorized = ($auth === sha1($user . $pass)); |
|
| 92 | + $this->authorized = ($auth === sha1($user.$pass)); |
|
| 93 | 93 | if ($this->authorized) { |
| 94 | 94 | $this->updateAdmin($user, $admins[$user]['profile']); |
| 95 | 95 | ResponseHelper::setCookieHeaders([ |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | ]); |
| 103 | 103 | $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}")); |
| 104 | 104 | } |
| 105 | - } else { |
|
| 105 | + }else { |
|
| 106 | 106 | $this->admin = null; |
| 107 | 107 | $this->setSessionKey(self::ADMIN_ID_TOKEN, null); |
| 108 | 108 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function hasSessionKey($key) { |
| 33 | 33 | $exists = false; |
| 34 | - if(array_key_exists($key, $this->session)) { |
|
| 34 | + if (array_key_exists($key, $this->session)) { |
|
| 35 | 35 | $exists = true; |
| 36 | 36 | } |
| 37 | 37 | return $exists; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | session_start(); |
| 57 | 57 | } |
| 58 | 58 | // Fix for phpunits |
| 59 | - if(!isset($_SESSION)) { |
|
| 59 | + if (!isset($_SESSION)) { |
|
| 60 | 60 | $_SESSION = []; |
| 61 | 61 | } |
| 62 | 62 | $this->session = null === $_SESSION ? [] : $_SESSION; |
@@ -86,11 +86,11 @@ |
||
| 86 | 86 | public static function save($user) |
| 87 | 87 | { |
| 88 | 88 | $saved = true; |
| 89 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 90 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 89 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 90 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 91 | 91 | $admins[$user['username']]['profile'] = $user['profile']; |
| 92 | 92 | |
| 93 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 93 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 94 | 94 | return $saved; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | */ |
| 70 | 70 | public function swaggerUi($domain) |
| 71 | 71 | { |
| 72 | - if(!Router::getInstance()->domainExists($domain)) { |
|
| 72 | + if (!Router::getInstance()->domainExists($domain)) { |
|
| 73 | 73 | throw new RouterException('Domains is empty'); |
| 74 | 74 | } |
| 75 | 75 | return $this->render('swagger.html.twig', [ |
@@ -38,9 +38,9 @@ |
||
| 38 | 38 | if (self::isTest()) { |
| 39 | 39 | throw new UserAuthException(); |
| 40 | 40 | } |
| 41 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 41 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 42 | 42 | return AdminServices::getInstance()->setAdminHeaders(); |
| 43 | - } else { |
|
| 43 | + }else { |
|
| 44 | 44 | return UserController::showAdminManager(); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | Logger::log('Configuration saved successful'); |
| 66 | 66 | Security::getInstance()->setFlash("callback_message", t("Usuario agregado correctamente")); |
| 67 | 67 | Security::getInstance()->setFlash("callback_route", Router::getInstance()->getRoute("admin", true)); |
| 68 | - } else { |
|
| 68 | + }else { |
|
| 69 | 69 | throw new ConfigException(t('Error al guardar los administradores, prueba a cambiar los permisos')); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | if ($this->isAdmin()) { |
| 101 | 101 | $this->redirect('admin'); |
| 102 | - } else { |
|
| 102 | + }else { |
|
| 103 | 103 | return Admin::staticAdminLogon(); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | Logger::log('Adding debug headers to render response'); |
| 77 | 77 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
| 78 | 78 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 79 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
| 80 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
| 81 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
| 79 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
| 80 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
| 81 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | return $vars; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public static function httpNotFound(Exception $exception = NULL, $isJson = false) |
| 95 | 95 | { |
| 96 | - if(self::isTest()) { |
|
| 96 | + if (self::isTest()) { |
|
| 97 | 97 | return 404; |
| 98 | 98 | } |
| 99 | 99 | Inspector::stats('[Router] Throw not found exception', Inspector::SCOPE_DEBUG); |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $notFoundRoute = Config::getParam('route.404'); |
| 111 | - if(null !== $notFoundRoute) { |
|
| 111 | + if (null !== $notFoundRoute) { |
|
| 112 | 112 | Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true)); |
| 113 | - } else { |
|
| 113 | + }else { |
|
| 114 | 114 | return $template->render('error.html.twig', array( |
| 115 | 115 | 'exception' => $exception, |
| 116 | 116 | 'trace' => $exception->getTraceAsString(), |