@@ -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,21 +69,21 @@ discard block |
||
69 | 69 | { |
70 | 70 | $path = explode("/", $string); |
71 | 71 | $originalFilename = end($path); |
72 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
72 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
73 | 73 | $debug = Config::getParam('debug'); |
74 | 74 | $cache = Config::getParam('cache.var'); |
75 | - $cache = $cache ? '.' . $cache : ''; |
|
75 | + $cache = $cache ? '.'.$cache : ''; |
|
76 | 76 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
77 | 77 | $mime = finfo_file($finfo, $filenamePath); |
78 | 78 | $extension = explode(".", $string); |
79 | 79 | $extension = end($extension); |
80 | - $file = "/" . substr(md5($string), 0, 8) . "." . $extension; |
|
80 | + $file = "/".substr(md5($string), 0, 8).".".$extension; |
|
81 | 81 | finfo_close($finfo); |
82 | 82 | if (preg_match('/\.css$/i', $string)) { |
83 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
83 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
84 | 84 | $htmlBase = "css"; |
85 | 85 | } elseif (preg_match('/\.js$/i', $string)) { |
86 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
86 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
87 | 87 | $htmlBase = "js"; |
88 | 88 | } elseif (preg_match("/image/i", $mime)) { |
89 | 89 | $htmlBase = "img"; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $file = $name; |
99 | 99 | } |
100 | 100 | if ($debug) { |
101 | - $file = str_replace("." . $extension, "_" . $originalFilename, $file); |
|
101 | + $file = str_replace(".".$extension, "_".$originalFilename, $file); |
|
102 | 102 | } |
103 | - $filePath = $htmlBase . $file; |
|
103 | + $filePath = $htmlBase.$file; |
|
104 | 104 | |
105 | 105 | return array($base, $htmlBase, $filePath); |
106 | 106 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | GeneratorHelper::createDir(dirname($path)); |
117 | 117 | if ("" !== $content && false === file_put_contents($path, $content)) { |
118 | - throw new ConfigException(t('No se tienen permisos para escribir en ' . $path)); |
|
118 | + throw new ConfigException(t('No se tienen permisos para escribir en '.$path)); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -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(), |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | { |
25 | 25 | Inspector::stats('[RouterHelper] Getting class to call for executing the request action', Inspector::SCOPE_DEBUG); |
26 | 26 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
27 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
27 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
28 | 28 | $reflectionClass = new ReflectionClass($actionClass); |
29 | 29 | if ($reflectionClass->hasMethod('getInstance')) { |
30 | 30 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
31 | - } else { |
|
31 | + }else { |
|
32 | 32 | $class = new $actionClass; |
33 | 33 | } |
34 | 34 | return $class; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public static function extractComponents($route, $pattern) |
63 | 63 | { |
64 | 64 | Inspector::stats('[RouterHelper] Extracting parts for the request to execute', Inspector::SCOPE_DEBUG); |
65 | - if(Config::getParam('allow.double.slashes', true)) { |
|
65 | + if (Config::getParam('allow.double.slashes', true)) { |
|
66 | 66 | $route = preg_replace("/\/\//", '/', $route); |
67 | 67 | } |
68 | 68 | $url = parse_url($route); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $expr = preg_quote($expr, '/'); |
121 | 121 | $expr = str_replace('###', '(.*)', $expr); |
122 | 122 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
123 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
123 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
124 | 124 | return $matched; |
125 | 125 | } |
126 | 126 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public static function extractDomainInfo(ReflectionClass $class, $domain) |
133 | 133 | { |
134 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
134 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
135 | 135 | $templatesPath = 'templates'; |
136 | 136 | $publicPath = 'public'; |
137 | 137 | $modelsPath = 'models'; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | $modelsPath = ucfirst($modelsPath); |
142 | 142 | } |
143 | 143 | if ($class->hasConstant('TPL')) { |
144 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
144 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
145 | 145 | } |
146 | 146 | return [ |
147 | 147 | 'base' => $path, |
148 | - 'template' => $path . $templatesPath, |
|
149 | - 'model' => $path . $modelsPath, |
|
150 | - 'public' => $path . $publicPath, |
|
148 | + 'template' => $path.$templatesPath, |
|
149 | + 'model' => $path.$modelsPath, |
|
150 | + 'public' => $path.$publicPath, |
|
151 | 151 | ]; |
152 | 152 | } |
153 | 153 | |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | foreach ($parameters as $param) { |
169 | 169 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
170 | 170 | $params[$param->getName()] = $param->getDefaultValue(); |
171 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
171 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
172 | 172 | } elseif (!$param->isOptional()) { |
173 | 173 | $requirements[] = $param->getName(); |
174 | 174 | } |
175 | 175 | } |
176 | - } else { |
|
176 | + }else { |
|
177 | 177 | $default = $regex; |
178 | 178 | } |
179 | 179 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $httpMethod = AnnotationHelper::extractReflectionHttpMethod($docComments); |
204 | 204 | $icon = AnnotationHelper::extractDocIcon($docComments); |
205 | 205 | $label = AnnotationHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
206 | - $route = $httpMethod . "#|#" . $regex; |
|
206 | + $route = $httpMethod."#|#".$regex; |
|
207 | 207 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
208 | 208 | $info = [ |
209 | 209 | 'method' => $method->getName(), |