@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | foreach ($compiledFiles as $file) { |
26 | 26 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
27 | 27 | } |
28 | - } else { |
|
29 | - echo "\t\t<script type='text/javascript' src='" . $baseUrl . "/js/" . $hash . ".js'" . |
|
28 | + }else { |
|
29 | + echo "\t\t<script type='text/javascript' src='".$baseUrl."/js/".$hash.".js'". |
|
30 | 30 | "></script>\n"; |
31 | 31 | } |
32 | 32 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | */ |
43 | 43 | protected function putDebugJs($pathParts, $base, $file, $hash, array &$compiledFiles) |
44 | 44 | { |
45 | - $filePath = $hash . "_" . $pathParts[count($pathParts) - 1]; |
|
46 | - $compiledFiles[] = "/js/" . $filePath; |
|
45 | + $filePath = $hash."_".$pathParts[count($pathParts) - 1]; |
|
46 | + $compiledFiles[] = "/js/".$filePath; |
|
47 | 47 | $data = ""; |
48 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file)) { |
|
48 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file)) { |
|
49 | 49 | $data = file_get_contents($file); |
50 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
50 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
51 | 51 | } |
52 | 52 | return $data; |
53 | 53 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function compileJs(array $files, $basePath, $hash, array &$compiledFiles) |
65 | 65 | { |
66 | - $base = $basePath . "js" . DIRECTORY_SEPARATOR; |
|
66 | + $base = $basePath."js".DIRECTORY_SEPARATOR; |
|
67 | 67 | $debug = Config::getParam('debug'); |
68 | - if ($debug || !file_exists($base . $hash . ".js")) { |
|
68 | + if ($debug || !file_exists($base.$hash.".js")) { |
|
69 | 69 | $data = ''; |
70 | 70 | if (0 < count($files)) { |
71 | 71 | $minifier = new JS(); |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | if (file_exists($file)) { |
75 | 75 | if ($debug) { |
76 | 76 | $data = $this->putDebugJs($pathParts, $base, $file, $hash, $compiledFiles); |
77 | - } elseif (!file_exists($base . $hash . ".js")) { |
|
77 | + } elseif (!file_exists($base.$hash.".js")) { |
|
78 | 78 | $minifier->add($file); |
79 | 79 | //$data = $this->putProductionJs($base, $file, $data); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | 83 | if ($debug) { |
84 | - AssetsHelper::storeContents($base . $hash . ".js", $data); |
|
85 | - } else { |
|
84 | + AssetsHelper::storeContents($base.$hash.".js", $data); |
|
85 | + }else { |
|
86 | 86 | $this->dumpJs($hash, $base, $minifier); |
87 | 87 | } |
88 | 88 | unset($minifier); |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | ini_set('memory_limit', -1); |
104 | 104 | GeneratorHelper::createDir($base); |
105 | 105 | if (Config::getParam('assets.obfuscate', false)) { |
106 | - $minifier->gzip($base . $hash . ".js"); |
|
107 | - } else { |
|
108 | - $minifier->minify($base . $hash . ".js"); |
|
106 | + $minifier->gzip($base.$hash.".js"); |
|
107 | + }else { |
|
108 | + $minifier->minify($base.$hash.".js"); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | protected function compileCss($basePath, $hash) |
33 | 33 | { |
34 | 34 | $debug = Config::getParam('debug'); |
35 | - $base = $basePath . "css" . DIRECTORY_SEPARATOR; |
|
36 | - if ($debug || !file_exists($base . $hash . ".css")) { |
|
35 | + $base = $basePath."css".DIRECTORY_SEPARATOR; |
|
36 | + if ($debug || !file_exists($base.$hash.".css")) { |
|
37 | 37 | $data = ''; |
38 | 38 | if (0 < count($this->files)) { |
39 | 39 | $minifier = new CSS(); |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | } |
43 | 43 | } |
44 | 44 | if ($debug) { |
45 | - AssetsHelper::storeContents($base . $hash . ".css", $data); |
|
46 | - } else { |
|
45 | + AssetsHelper::storeContents($base.$hash.".css", $data); |
|
46 | + }else { |
|
47 | 47 | $minifier = new CSS(); |
48 | 48 | $minifier->add($data); |
49 | 49 | ini_set('max_execution_time', -1); |
50 | 50 | ini_set('memory_limit', -1); |
51 | 51 | GeneratorHelper::createDir($base); |
52 | - $minifier->minify($base . $hash . ".css"); |
|
52 | + $minifier->minify($base.$hash.".css"); |
|
53 | 53 | } |
54 | 54 | unset($minifier); |
55 | 55 | } |
@@ -69,21 +69,21 @@ discard block |
||
69 | 69 | if (file_exists($file)) { |
70 | 70 | $debug = Config::getParam('debug'); |
71 | 71 | $pathParts = explode("/", $file); |
72 | - $filePath = $this->hash . "_" . $pathParts[count($pathParts) - 1]; |
|
73 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($file) || $debug) { |
|
72 | + $filePath = $this->hash."_".$pathParts[count($pathParts) - 1]; |
|
73 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($file) || $debug) { |
|
74 | 74 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
75 | - if (file_exists($base . $hash . ".css") && @unlink($base . $hash . ".css") === false) { |
|
76 | - throw new ConfigException("Can't unlink file " . $base . $hash . ".css"); |
|
75 | + if (file_exists($base.$hash.".css") && @unlink($base.$hash.".css") === false) { |
|
76 | + throw new ConfigException("Can't unlink file ".$base.$hash.".css"); |
|
77 | 77 | } |
78 | 78 | $this->loopCssLines($file); |
79 | 79 | } |
80 | 80 | if ($debug) { |
81 | 81 | $data = file_get_contents($file); |
82 | - AssetsHelper::storeContents($base . $filePath, $data); |
|
83 | - } else { |
|
82 | + AssetsHelper::storeContents($base.$filePath, $data); |
|
83 | + }else { |
|
84 | 84 | $data .= file_get_contents($file); |
85 | 85 | } |
86 | - $this->compiledFiles[] = "/css/" . $filePath; |
|
86 | + $this->compiledFiles[] = "/css/".$filePath; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $data; |
@@ -115,25 +115,25 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function extractCssResources($source, $file) |
117 | 117 | { |
118 | - Inspector::stats('[CssTrait] Start collecting resources from ' . $file, Inspector::SCOPE_DEBUG); |
|
118 | + Inspector::stats('[CssTrait] Start collecting resources from '.$file, Inspector::SCOPE_DEBUG); |
|
119 | 119 | $sourceFile = AssetsHelper::extractSourceFilename($source); |
120 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $sourceFile); |
|
120 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$sourceFile); |
|
121 | 121 | $origPart = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
122 | 122 | try { |
123 | 123 | if (count($source) > 1 && array_key_exists(1, $origPart)) { |
124 | - $dest = $this->path . $origPart[1]; |
|
124 | + $dest = $this->path.$origPart[1]; |
|
125 | 125 | GeneratorHelper::createDir(dirname($dest)); |
126 | 126 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
127 | 127 | if (@copy($orig, $dest) === FALSE) { |
128 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
128 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
129 | 129 | } |
130 | 130 | Logger::log("$orig copiado a $dest", LOG_INFO); |
131 | 131 | } |
132 | 132 | } |
133 | - } catch (\Exception $e) { |
|
133 | + }catch (\Exception $e) { |
|
134 | 134 | Logger::log($e->getMessage(), LOG_ERR); |
135 | 135 | } |
136 | - Inspector::stats('[CssTrait] End collecting resources from ' . $file, Inspector::SCOPE_DEBUG); |
|
136 | + Inspector::stats('[CssTrait] End collecting resources from '.$file, Inspector::SCOPE_DEBUG); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | foreach ($compiledFiles as $file) { |
148 | 148 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
149 | 149 | } |
150 | - } else { |
|
151 | - echo "\t\t<link href='" . $baseUrl . "/css/" . $hash . ".css' rel='stylesheet' " . |
|
150 | + }else { |
|
151 | + echo "\t\t<link href='".$baseUrl."/css/".$hash.".css' rel='stylesheet' ". |
|
152 | 152 | //"crossorigin='anonymous' integrity='sha384-" . $sri . "'>"; |
153 | 153 | "media='screen, print'>"; |
154 | 154 | } |
@@ -46,11 +46,11 @@ |
||
46 | 46 | foreach ($this->fields as $field) { |
47 | 47 | $array['fields'][] = $field->__toArray(); |
48 | 48 | } |
49 | - usort($array['fields'], function ($fieldA, $fieldB) { |
|
49 | + usort($array['fields'], function($fieldA, $fieldB) { |
|
50 | 50 | if ((bool)$fieldA['required'] !== (bool)$fieldB['required']) { |
51 | 51 | if ((bool)$fieldA['required']) { |
52 | 52 | return -1; |
53 | - } else { |
|
53 | + }else { |
|
54 | 54 | return 1; |
55 | 55 | } |
56 | 56 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | { |
64 | 64 | if (preg_match('/^asc$/i', $direction)) { |
65 | 65 | return self::ASC; |
66 | - } else { |
|
66 | + }else { |
|
67 | 67 | return self::DESC; |
68 | 68 | } |
69 | 69 | } |
@@ -79,18 +79,18 @@ |
||
79 | 79 | if (!Request::getInstance()->isFile()) { |
80 | 80 | return $this->router->execute($uri ?: $this->actualUri); |
81 | 81 | } |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | return ConfigController::getInstance()->config(); |
84 | 84 | } |
85 | - } catch (AdminCredentialsException $a) { |
|
85 | + }catch (AdminCredentialsException $a) { |
|
86 | 86 | return UserController::showAdminManager(); |
87 | - } catch (SecurityException $s) { |
|
87 | + }catch (SecurityException $s) { |
|
88 | 88 | return $this->security->notAuthorized($this->actualUri); |
89 | - } catch (RouterException $r) { |
|
89 | + }catch (RouterException $r) { |
|
90 | 90 | return $this->router->httpNotFound($r); |
91 | - } catch (ApiException $a) { |
|
91 | + }catch (ApiException $a) { |
|
92 | 92 | return $this->router->httpNotFound($a, true); |
93 | - } catch (\Exception $e) { |
|
93 | + }catch (\Exception $e) { |
|
94 | 94 | return $this->dumpException($e); |
95 | 95 | } |
96 | 96 | } |
@@ -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 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | { |
60 | 60 | $args = func_get_args(); |
61 | 61 | list($logger, $debug, $path) = $this->setup($args); |
62 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'ab+'); |
|
62 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'ab+'); |
|
63 | 63 | if (false !== $this->stream && is_resource($this->stream)) { |
64 | 64 | $this->addPushLogger($logger, $debug); |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | throw new ConfigException(t('Error creating logger')); |
67 | 67 | } |
68 | 68 | $this->logLevel = strtoupper(Config::getParam('log.level', 'NOTICE')); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | private function createLoggerPath(): string |
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 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | */ |
28 | 28 | public static function dropServerValue(string $key): void |
29 | 29 | { |
30 | - if(array_key_exists($key, $_SERVER)) { |
|
30 | + if (array_key_exists($key, $_SERVER)) { |
|
31 | 31 | unset($_SERVER[$key]); |
32 | 32 | } |
33 | 33 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $use /= 1024; |
41 | 41 | break; |
42 | 42 | case "MBytes": |
43 | - $use /= (1024 * 1024); |
|
43 | + $use /= (1024*1024); |
|
44 | 44 | break; |
45 | 45 | case "Bytes": |
46 | 46 | default: |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | ini_set('display_errors', 1); |
71 | 71 | } |
72 | 72 | //Warning & Notice handler |
73 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
73 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
74 | 74 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
75 | 75 | return true; |
76 | 76 | }, E_ALL | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); |
77 | 77 | |
78 | - register_shutdown_function(function () { |
|
78 | + register_shutdown_function(function() { |
|
79 | 79 | $error = error_get_last() or json_last_error() or preg_last_error() or \DateTime::getLastErrors(); |
80 | 80 | if ($error !== NULL) { |
81 | 81 | $errno = $error["type"]; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | |
91 | 91 | if (self::getTs() > 10 && null !== Config::getParam('log.slack.hook')) { |
92 | 92 | SlackHelper::getInstance()->trace('Slow service endpoint', '', '', [ |
93 | - 'time' => round(self::getTs(), 3) . ' secs', |
|
94 | - 'memory' => round(self::getMem('MBytes'), 3) . ' Mb', |
|
93 | + 'time' => round(self::getTs(), 3).' secs', |
|
94 | + 'memory' => round(self::getMem('MBytes'), 3).' Mb', |
|
95 | 95 | ]); |
96 | 96 | } |
97 | 97 | return false; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | Inspector::stats('[SystemTrait] Initializing stats (mem + ts)'); |
107 | 107 | if (ServerHelper::hasServerValue('REQUEST_TIME_FLOAT')) { |
108 | 108 | $this->ts = (float)ServerHelper::getServerValue('REQUEST_TIME_FLOAT'); |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | $this->ts = PSFS_START_TS; |
111 | 111 | } |
112 | 112 | $this->mem = PSFS_START_MEM; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function init() |
99 | 99 | { |
100 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
100 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
101 | 101 | $this->loadConfigData(); |
102 | 102 | } |
103 | 103 | return $this; |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $finalData = self::saveExtraParams($data); |
213 | 213 | $saved = false; |
214 | 214 | try { |
215 | - $finalData = array_filter($finalData, function ($key, $value) { |
|
215 | + $finalData = array_filter($finalData, function($key, $value) { |
|
216 | 216 | return in_array($key, self::$required, true) || !empty($value); |
217 | 217 | }, ARRAY_FILTER_USE_BOTH); |
218 | - $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
218 | + $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
219 | 219 | self::getInstance()->loadConfigData(); |
220 | 220 | $saved = true; |
221 | - } catch (ConfigException $e) { |
|
221 | + }catch (ConfigException $e) { |
|
222 | 222 | Logger::log($e->getMessage(), LOG_ERR); |
223 | 223 | } |
224 | 224 | return $saved; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function loadConfigData(): void |
252 | 252 | { |
253 | - $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: []; |
|
253 | + $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: []; |
|
254 | 254 | $this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE; |
255 | 255 | if (array_key_exists('cache.var', $this->config)) { |
256 | 256 | Security::getInstance()->setSessionKey('config.cache.var', $this->config['cache.var']); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | public static function getParam($key, $defaultValue = null, $module = null) |
276 | 276 | { |
277 | 277 | if (null !== $module) { |
278 | - return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue)); |
|
278 | + return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue)); |
|
279 | 279 | } |
280 | 280 | $param = self::getInstance()->get($key); |
281 | 281 | return (null !== $param) ? $param : $defaultValue; |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | { |
292 | 292 | $done = true; |
293 | 293 | foreach (self::$cleanable_config_files as $configFile) { |
294 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . $configFile)) { |
|
295 | - if (!unlink(CONFIG_DIR . DIRECTORY_SEPARATOR . $configFile)) { |
|
294 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.$configFile)) { |
|
295 | + if (!unlink(CONFIG_DIR.DIRECTORY_SEPARATOR.$configFile)) { |
|
296 | 296 | $done = false; |
297 | 297 | } |
298 | 298 | } |