@@ -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(), |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | { |
| 51 | 51 | $this->generateSlugs(); |
| 52 | 52 | GeneratorHelper::createDir(CONFIG_DIR); |
| 53 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', [$this->routing, $this->getSlugs()], Cache::JSON, TRUE); |
|
| 53 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', [$this->routing, $this->getSlugs()], Cache::JSON, TRUE); |
|
| 54 | 54 | |
| 55 | 55 | return $this; |
| 56 | 56 | } |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $filePath = ''; |
| 45 | 45 | if (!file_exists($filePath)) { |
| 46 | - $filePath = BASE_DIR . $string; |
|
| 46 | + $filePath = BASE_DIR.$string; |
|
| 47 | 47 | } |
| 48 | 48 | $filenamePath = AssetsHelper::findDomainPath($string, $filePath); |
| 49 | 49 | |
| 50 | 50 | $filePath = self::processAsset($string, $name, $return, $filenamePath); |
| 51 | 51 | $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
| 52 | - $returnPath = empty($name) ? $basePath . '/' . $filePath : $name; |
|
| 52 | + $returnPath = empty($name) ? $basePath.'/'.$filePath : $name; |
|
| 53 | 53 | return $return ? $returnPath : ''; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $router = Router::getInstance(); |
| 67 | 67 | try { |
| 68 | 68 | return $router->getRoute($path, $absolute, $params); |
| 69 | - } catch (\Exception $e) { |
|
| 69 | + }catch (\Exception $e) { |
|
| 70 | 70 | return $router->getRoute('', $absolute, $params); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | $data = file_get_contents($filenamePath); |
| 215 | 215 | if (!empty($name)) { |
| 216 | - file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
| 217 | - } else { |
|
| 218 | - file_put_contents($base . $filePath, $data); |
|
| 216 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
| 217 | + }else { |
|
| 218 | + file_put_contents($base.$filePath, $data); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | if (file_exists($filenamePath)) { |
| 235 | 235 | list($base, $htmlBase, $filePath) = AssetsHelper::calculateAssetPath($string, $name, $return, $filenamePath); |
| 236 | 236 | //Creamos el directorio si no existe |
| 237 | - GeneratorHelper::createDir($base . $htmlBase); |
|
| 237 | + GeneratorHelper::createDir($base.$htmlBase); |
|
| 238 | 238 | //Si se ha modificado |
| 239 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) { |
|
| 239 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) { |
|
| 240 | 240 | if ($htmlBase === 'css') { |
| 241 | 241 | self::processCssLines($filenamePath); |
| 242 | 242 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | 'attachments' => [ |
| 31 | 31 | [ |
| 32 | 32 | "author_name" => $request->getRootUrl(true), |
| 33 | - "text" => $file . ($line !== '' ? ' [' . $line . ']' : ''), |
|
| 33 | + "text" => $file.($line !== '' ? ' ['.$line.']' : ''), |
|
| 34 | 34 | "color" => Config::getParam('debug', true) ? 'warning' : "danger", |
| 35 | 35 | "title" => $message, |
| 36 | 36 | 'fallback' => 'PSFS Error notifier', |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public static function header($name, $default = null) |
| 124 | 124 | { |
| 125 | - return self::getInstance()->getHeader($name, $default); |
|
| 125 | + return self::getInstance()->getHeader($name, $default); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | $header = null; |
| 136 | 136 | if ($this->hasHeader($name)) { |
| 137 | 137 | $header = $this->header[$name]; |
| 138 | - } else if(array_key_exists('h_' . strtolower($name), $this->query)) { |
|
| 139 | - $header = $this->query['h_' . strtolower($name)]; |
|
| 140 | - } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 141 | - $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name))); |
|
| 138 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
| 139 | + $header = $this->query['h_'.strtolower($name)]; |
|
| 140 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 141 | + $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name))); |
|
| 142 | 142 | } |
| 143 | 143 | return $header ?: $default; |
| 144 | 144 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $url = $this->getServer('HTTP_ORIGIN'); |
| 243 | 243 | } |
| 244 | 244 | ob_start(); |
| 245 | - header('Location: ' . $url); |
|
| 245 | + header('Location: '.$url); |
|
| 246 | 246 | ob_end_clean(); |
| 247 | 247 | Security::getInstance()->updateSession(); |
| 248 | 248 | exit(t('Redirect...')); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | $url = $this->getServerName(); |
| 259 | 259 | $protocol = $hasProtocol ? $this->getProtocol() : ''; |
| 260 | 260 | if (!empty($protocol)) { |
| 261 | - $url = $protocol . $url; |
|
| 261 | + $url = $protocol.$url; |
|
| 262 | 262 | } |
| 263 | 263 | $url = $this->checkServerPort($url); |
| 264 | 264 | return $url; |
@@ -272,15 +272,15 @@ discard block |
||
| 272 | 272 | { |
| 273 | 273 | $port = (integer)$this->getServer('SERVER_PORT'); |
| 274 | 274 | $host = $this->getServer('HTTP_HOST'); |
| 275 | - if(!empty($host)) { |
|
| 275 | + if (!empty($host)) { |
|
| 276 | 276 | $parts = explode(':', $host); |
| 277 | 277 | $hostPort = (integer)end($parts); |
| 278 | - if($hostPort !== $port && count($parts) > 1) { |
|
| 278 | + if ($hostPort !== $port && count($parts) > 1) { |
|
| 279 | 279 | $port = $hostPort; |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | if (!in_array($port, [80, 443], true)) { |
| 283 | - $url .= ':' . $port; |
|
| 283 | + $url .= ':'.$port; |
|
| 284 | 284 | } |
| 285 | 285 | return $url; |
| 286 | 286 | } |
@@ -143,14 +143,14 @@ |
||
| 143 | 143 | return $header ?: $default; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * @param string $language |
|
| 148 | - * @return void |
|
| 149 | - */ |
|
| 150 | - public static function setLanguageHeader(string $language) |
|
| 151 | - { |
|
| 152 | - self::getInstance()->header['X-API-LANG'] = $language; |
|
| 153 | - } |
|
| 146 | + /** |
|
| 147 | + * @param string $language |
|
| 148 | + * @return void |
|
| 149 | + */ |
|
| 150 | + public static function setLanguageHeader(string $language) |
|
| 151 | + { |
|
| 152 | + self::getInstance()->header['X-API-LANG'] = $language; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * Método que devuelve la url solicitada |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!defined('LOG_DIR')) { |
| 21 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 22 | - define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 21 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 22 | + define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $args = func_get_args(); |
| 59 | 59 | list($logger, $debug, $path) = $this->setup($args); |
| 60 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'ab+'); |
|
| 60 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'ab+'); |
|
| 61 | 61 | if (false !== $this->stream && is_resource($this->stream)) { |
| 62 | 62 | $this->addPushLogger($logger, $debug); |
| 63 | - } else { |
|
| 63 | + }else { |
|
| 64 | 64 | throw new ConfigException(t('Error creating logger')); |
| 65 | 65 | } |
| 66 | 66 | $this->logLevel = strtoupper(Config::getParam('log.level', 'NOTICE')); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | private function createLoggerPath() |
| 142 | 142 | { |
| 143 | 143 | $logger = $this->setLoggerName(); |
| 144 | - $path = Config::getParam('default.log.path',LOG_DIR) . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
| 144 | + $path = Config::getParam('default.log.path', LOG_DIR).DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
| 145 | 145 | GeneratorHelper::createDir($path); |
| 146 | 146 | return $path; |
| 147 | 147 | } |
@@ -34,20 +34,20 @@ |
||
| 34 | 34 | $scripts = $this->getNode("scripts"); |
| 35 | 35 | |
| 36 | 36 | //Creamos el parser |
| 37 | - $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\'' . $this->type . '\')') |
|
| 37 | + $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\''.$this->type.'\')') |
|
| 38 | 38 | ->raw(";\n"); |
| 39 | 39 | |
| 40 | 40 | //Asociamos el hash |
| 41 | - $compiler->write('$parser->setHash(\'' . $this->hash . '\')') |
|
| 41 | + $compiler->write('$parser->setHash(\''.$this->hash.'\')') |
|
| 42 | 42 | ->raw(";\n"); |
| 43 | 43 | |
| 44 | 44 | //Inicializamos SRI |
| 45 | - $compiler->write('$parser->init(\'' . $this->type . '\')') |
|
| 45 | + $compiler->write('$parser->init(\''.$this->type.'\')') |
|
| 46 | 46 | ->raw(";\n"); |
| 47 | 47 | |
| 48 | 48 | //Asociamos los ficheros |
| 49 | 49 | foreach ($scripts->getAttribute("value") as $value) { |
| 50 | - $compiler->write('$parser->addFile(\'' . $value . '\')')->raw(";\n"); |
|
| 50 | + $compiler->write('$parser->addFile(\''.$value.'\')')->raw(";\n"); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | //Procesamos los ficheros |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | use PSFS\base\types\helpers\GeneratorHelper; |
| 14 | 14 | use PSFS\base\types\helpers\Inspector; |
| 15 | 15 | |
| 16 | -defined('CSS_SRI_FILENAME') or define('CSS_SRI_FILENAME', CACHE_DIR . DIRECTORY_SEPARATOR . 'css.sri.json'); |
|
| 17 | -defined('JS_SRI_FILENAME') or define('JS_SRI_FILENAME', CACHE_DIR . DIRECTORY_SEPARATOR . 'js.sri.json'); |
|
| 16 | +defined('CSS_SRI_FILENAME') or define('CSS_SRI_FILENAME', CACHE_DIR.DIRECTORY_SEPARATOR.'css.sri.json'); |
|
| 17 | +defined('JS_SRI_FILENAME') or define('JS_SRI_FILENAME', CACHE_DIR.DIRECTORY_SEPARATOR.'js.sri.json'); |
|
| 18 | 18 | /** |
| 19 | 19 | * Class AssetsParser |
| 20 | 20 | * @package PSFS\base\extension |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** @var Cache $cache */ |
| 67 | 67 | $cache = Cache::getInstance(); |
| 68 | 68 | $this->sri = $cache->getDataFromFile($this->sriFilename, Cache::JSON, true); |
| 69 | - if(empty($this->sri)) { |
|
| 69 | + if (empty($this->sri)) { |
|
| 70 | 70 | $this->sri = []; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function __construct($type = 'js') |
| 80 | 80 | { |
| 81 | 81 | $this->type = $type; |
| 82 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 82 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 83 | 83 | $this->domains = Template::getDomains(true); |
| 84 | 84 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
| 85 | 85 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function addFile($filename) |
| 94 | 94 | { |
| 95 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
| 95 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
| 96 | 96 | $this->files[] = $filename; |
| 97 | 97 | } elseif (!empty($this->domains)) { |
| 98 | 98 | foreach ($this->domains as $domain => $paths) { |
| 99 | 99 | $domainFilename = str_replace($domain, $paths["public"], $filename); |
| 100 | - if (file_exists($domainFilename) && preg_match('/\.' . $this->type . '$/i', $domainFilename)) { |
|
| 100 | + if (file_exists($domainFilename) && preg_match('/\.'.$this->type.'$/i', $domainFilename)) { |
|
| 101 | 101 | $this->files[] = $domainFilename; |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | public function setHash($hash) |
| 115 | 115 | { |
| 116 | 116 | $cache = Config::getParam('cache.var', ''); |
| 117 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
| 117 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
| 118 | 118 | return $this; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $sourceFile = explode("?", $sourceFile); |
| 178 | 178 | $sourceFile = $sourceFile[0]; |
| 179 | 179 | } |
| 180 | - $orig = realpath(dirname($filenamePath) . DIRECTORY_SEPARATOR . $sourceFile); |
|
| 180 | + $orig = realpath(dirname($filenamePath).DIRECTORY_SEPARATOR.$sourceFile); |
|
| 181 | 181 | return $orig; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -194,15 +194,15 @@ discard block |
||
| 194 | 194 | if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) { |
| 195 | 195 | foreach ($urls as $source) { |
| 196 | 196 | $orig = self::calculateResourcePathname($filenamePath, $source); |
| 197 | - if(!empty($orig)) { |
|
| 197 | + if (!empty($orig)) { |
|
| 198 | 198 | $orig_part = preg_split("/Public/i", $orig); |
| 199 | - $dest = WEB_DIR . $orig_part[1]; |
|
| 199 | + $dest = WEB_DIR.$orig_part[1]; |
|
| 200 | 200 | GeneratorHelper::createDir(dirname($dest)); |
| 201 | 201 | if (@copy($orig, $dest) === false) { |
| 202 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
| 202 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
| 203 | 203 | } |
| 204 | - } else { |
|
| 205 | - Logger::log($filenamePath . ' has an empty origin with the url ' . $source, LOG_WARNING); |
|
| 204 | + }else { |
|
| 205 | + Logger::log($filenamePath.' has an empty origin with the url '.$source, LOG_WARNING); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | * @throws \PSFS\base\exception\GeneratorException |
| 216 | 216 | */ |
| 217 | 217 | protected function getSriHash($hash, $type = 'js') { |
| 218 | - if(array_key_exists($hash, $this->sri)) { |
|
| 218 | + if (array_key_exists($hash, $this->sri)) { |
|
| 219 | 219 | $sriHash = $this->sri[$hash]; |
| 220 | - } else { |
|
| 221 | - Inspector::stats('[SRITrait] Generating SRI for ' . $hash, Inspector::SCOPE_DEBUG); |
|
| 222 | - $filename = WEB_DIR . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $hash . '.' . $type; |
|
| 220 | + }else { |
|
| 221 | + Inspector::stats('[SRITrait] Generating SRI for '.$hash, Inspector::SCOPE_DEBUG); |
|
| 222 | + $filename = WEB_DIR.DIRECTORY_SEPARATOR.$type.DIRECTORY_SEPARATOR.$hash.'.'.$type; |
|
| 223 | 223 | $sriHash = base64_encode(hash("sha384", file_get_contents($filename), true)); |
| 224 | 224 | $this->sri[$hash] = $sriHash; |
| 225 | 225 | Cache::getInstance()->storeData($this->sriFilename, $this->sri, Cache::JSON, true); |