@@ -12,10 +12,10 @@ |
||
12 | 12 | { |
13 | 13 | $uri = Request::requestUri(); |
14 | 14 | Security::getInstance()->setSessionKey('lastRequest', array( |
15 | - 'url' => Request::getInstance()->getRootUrl() . $uri, |
|
15 | + 'url' => Request::getInstance()->getRootUrl().$uri, |
|
16 | 16 | 'ts' => microtime(true), |
17 | 17 | 'eta' => microtime(true) - PSFS_START_TS, |
18 | - 'mem' => memory_get_usage() / 1024 / 1024, |
|
18 | + 'mem' => memory_get_usage()/1024/1024, |
|
19 | 19 | )); |
20 | 20 | Security::getInstance()->updateSession(); |
21 | 21 | return EventInterface::EVENT_SUCCESS; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $platform = trim(Config::getInstance()->get('platform.name', 'PSFS')); |
38 | 38 | ResponseHelper::setHeader('HTTP/1.1 401 Unauthorized'); |
39 | - ResponseHelper::setHeader('WWW-Authenticate: Basic Realm="' . $platform . '"'); |
|
39 | + ResponseHelper::setHeader('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
40 | 40 | echo t('Zona restringida'); |
41 | 41 | exit(); |
42 | 42 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $admin['class'] = 'primary'; |
79 | 79 | break; |
80 | 80 | } |
81 | - } else { |
|
81 | + }else { |
|
82 | 82 | $admin['class'] = 'primary'; |
83 | 83 | } |
84 | 84 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->setStatusCode(Template::STATUS_OK); |
128 | 128 | break; |
129 | 129 | default: |
130 | - $this->setStatusCode('HTTP/1.0 ' . ($status ?: 200)); |
|
130 | + $this->setStatusCode('HTTP/1.0 '.($status ?: 200)); |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | return $this; |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | */ |
141 | 141 | private function setResponseHeaders($contentType = 'text/html', array $cookies = array()): void |
142 | 142 | { |
143 | - ResponseHelper::setHeader('X-Powered-By: ' . Config::getParam('poweredBy', 'PSFS')); |
|
143 | + ResponseHelper::setHeader('X-Powered-By: '.Config::getParam('poweredBy', 'PSFS')); |
|
144 | 144 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
145 | 145 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
146 | 146 | ResponseHelper::setCookieHeaders($cookies); |
147 | - ResponseHelper::setHeader('Content-type: ' . $contentType); |
|
147 | + ResponseHelper::setHeader('Content-type: '.$contentType); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | |
@@ -162,16 +162,16 @@ discard block |
||
162 | 162 | Logger::log('Start output response'); |
163 | 163 | ob_start(); |
164 | 164 | $this->setResponseHeaders($contentType, $cookies); |
165 | - ResponseHelper::setHeader('Content-length: ' . strlen($output)); |
|
166 | - ResponseHelper::setHeader('CRC: ' . crc32($output)); |
|
165 | + ResponseHelper::setHeader('Content-length: '.strlen($output)); |
|
166 | + ResponseHelper::setHeader('CRC: '.crc32($output)); |
|
167 | 167 | |
168 | 168 | $needCache = Cache::needCache(); |
169 | 169 | $cache = Cache::getInstance(); |
170 | 170 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
171 | 171 | if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
172 | 172 | Logger::log('Saving output response into cache'); |
173 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
174 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON); |
|
173 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
174 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', headers_list(), Cache::JSON); |
|
175 | 175 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
176 | 176 | $cache->flushCache(); |
177 | 177 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | ob_end_clean(); |
182 | 182 | Logger::log('End output response'); |
183 | 183 | $this->closeRender(); |
184 | - } else { |
|
184 | + }else { |
|
185 | 185 | return $output; |
186 | 186 | } |
187 | 187 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | { |
194 | 194 | Logger::log('Close template render'); |
195 | 195 | EventHelper::handleEvents(EventHelper::EVENT_END_REQUEST); |
196 | - Logger::log('End request: ' . Request::requestUri(), LOG_INFO); |
|
196 | + Logger::log('End request: '.Request::requestUri(), LOG_INFO); |
|
197 | 197 | exit; |
198 | 198 | } |
199 | 199 | |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | ///////////////////////////////////////////////////////////// |
232 | 232 | // Date in the past sets the value to already have been expired. |
233 | 233 | ResponseHelper::setHeader('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); |
234 | - ResponseHelper::setHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
234 | + ResponseHelper::setHeader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
235 | 235 | ResponseHelper::setHeader('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
236 | 236 | ResponseHelper::setHeader('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
237 | 237 | ResponseHelper::setHeader('Pragma: no-cache'); |
238 | 238 | ResponseHelper::setHeader('Expires: 0'); |
239 | 239 | ResponseHelper::setHeader('Content-Transfer-Encoding: binary'); |
240 | - ResponseHelper::setHeader('Content-type: ' . $content); |
|
241 | - ResponseHelper::setHeader('Content-length: ' . strlen($data)); |
|
242 | - ResponseHelper::setHeader('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
240 | + ResponseHelper::setHeader('Content-type: '.$content); |
|
241 | + ResponseHelper::setHeader('Content-length: '.strlen($data)); |
|
242 | + ResponseHelper::setHeader('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
243 | 243 | ResponseHelper::setHeader('Access-Control-Expose-Headers: Filename'); |
244 | - ResponseHelper::setHeader('Filename: ' . $filename); |
|
244 | + ResponseHelper::setHeader('Filename: '.$filename); |
|
245 | 245 | echo $data; |
246 | 246 | ob_flush(); |
247 | 247 | ob_end_clean(); |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | |
14 | 14 | public static function handleEvents(string $eventName, mixed $context = null): void |
15 | 15 | { |
16 | - if(array_key_exists($eventName, self::$events)) { |
|
17 | - foreach(self::$events[$eventName] as $eventClass) { |
|
16 | + if (array_key_exists($eventName, self::$events)) { |
|
17 | + foreach (self::$events[$eventName] as $eventClass) { |
|
18 | 18 | try { |
19 | 19 | $return = (new $eventClass)($context); |
20 | 20 | Logger::log("$eventClass event handled with return $return"); |
21 | - } catch (\Exception $exception) { |
|
22 | - Logger::log("$eventClass event handled with exception:" . $exception->getMessage(), LOG_CRIT); |
|
21 | + }catch (\Exception $exception) { |
|
22 | + Logger::log("$eventClass event handled with exception:".$exception->getMessage(), LOG_CRIT); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public static function addEvent(string $eventName, string $eventClass): void |
29 | 29 | { |
30 | - if(!array_key_exists($eventName, self::$events)) { |
|
30 | + if (!array_key_exists($eventName, self::$events)) { |
|
31 | 31 | self::$events[$eventName] = []; |
32 | 32 | } |
33 | 33 | self::$events[$eventName][] = $eventClass; |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | if (!headers_sent()) { |
51 | 51 | // TODO include this headers in Template class output method |
52 | 52 | ResponseHelper::setHeader('Access-Control-Allow-Credentials: true'); |
53 | - ResponseHelper::setHeader('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
53 | + ResponseHelper::setHeader('Access-Control-Allow-Origin: '.Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
54 | 54 | ResponseHelper::setHeader('Vary: Origin'); |
55 | 55 | ResponseHelper::setHeader('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD'); |
56 | - ResponseHelper::setHeader('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders())); |
|
56 | + ResponseHelper::setHeader('Access-Control-Allow-Headers: '.implode(', ', self::getCorsHeaders())); |
|
57 | 57 | } |
58 | 58 | if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) { |
59 | 59 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | return $ip; |
87 | 87 | } |
88 | 88 | } |
89 | - } else { |
|
89 | + }else { |
|
90 | 90 | if (self::validateIpAddress($xForwardedFor)) { |
91 | 91 | return $xForwardedFor; |
92 | 92 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | // Verifica si la IP está en el rango válido |
127 | 127 | if ($ipNum >= $rangoInicioNum && $ipNum <= $rangoFinNum) { |
128 | 128 | return true; // La IP está en el rango válido |
129 | - } else { |
|
129 | + }else { |
|
130 | 130 | return false; // La IP está fuera del rango válido |
131 | 131 | } |
132 | 132 | } |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | foreach ($data as $key => $value) { |
30 | 30 | try { |
31 | 31 | $realValue = $model->getByName($key); |
32 | - } catch (\Exception $e) { |
|
32 | + }catch (\Exception $e) { |
|
33 | 33 | $realValue = $value; |
34 | 34 | } |
35 | 35 | if (Api::API_MODEL_KEY_FIELD === $key) { |
36 | 36 | $result[$key] = (integer)$realValue; |
37 | - } else { |
|
37 | + }else { |
|
38 | 38 | $result[$key] = $realValue; |
39 | 39 | } |
40 | 40 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return array |
50 | 50 | * @throws \Propel\Runtime\Exception\PropelException |
51 | 51 | */ |
52 | - public static function mapArrayObject($namespace, ColumnMap $modelPk, array $query, array|ActiveRecordInterface $data = []) |
|
52 | + public static function mapArrayObject($namespace, ColumnMap $modelPk, array $query, array | ActiveRecordInterface $data = []) |
|
53 | 53 | { |
54 | 54 | $formatter = new ObjectFormatter(); |
55 | 55 | $formatter->setClass($namespace); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** @var ActiveRecordInterface $obj */ |
68 | 68 | $obj = @$formatter->getAllObjectsFromRow($objData); |
69 | 69 | $result = self::mapResult($obj, $data); |
70 | - if (!preg_match('/' . $modelPk->getPhpName() . '/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
70 | + if (!preg_match('/'.$modelPk->getPhpName().'/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
71 | 71 | unset($result[$modelPk->getPhpName()]); |
72 | 72 | } |
73 | 73 | return $result; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | protected function hydrateOrders() |
40 | 40 | { |
41 | 41 | if (count($this->query)) { |
42 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
42 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
43 | 43 | foreach ($this->query as $key => $value) { |
44 | 44 | if ($key === self::API_ORDER_FIELD) { |
45 | 45 | $orders = json_decode($value, true); |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | */ |
58 | 58 | protected function extractPagination() |
59 | 59 | { |
60 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
60 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
61 | 61 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
62 | 62 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
63 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
63 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
64 | 64 | return array($page, (int)$limit); |
65 | 65 | } |
66 | 66 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param ModelCriteria $query |
70 | 70 | * @throws \PSFS\base\exception\ApiException |
71 | 71 | */ |
72 | - protected function addOrders(ModelCriteria &$query) |
|
72 | + protected function addOrders(ModelCriteria & $query) |
|
73 | 73 | { |
74 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
74 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
75 | 75 | $orderAdded = FALSE; |
76 | 76 | $tableMap = $this->getTableMap(); |
77 | 77 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $orderAdded = TRUE; |
80 | 80 | if ($direction === Order::ASC) { |
81 | 81 | $query->addAscendingOrderByColumn($column->getPhpName()); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | $query->addDescendingOrderByColumn($column->getPhpName()); |
84 | 84 | } |
85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $query->addAscendingOrderByColumn($key); |
91 | 91 | } |
92 | 92 | } |
93 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
93 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param ModelCriteria $query |
100 | 100 | */ |
101 | - protected function addFilters(ModelCriteria &$query) |
|
101 | + protected function addFilters(ModelCriteria & $query) |
|
102 | 102 | { |
103 | 103 | if (count($this->query) > 0) { |
104 | 104 | $tableMap = $this->getTableMap(); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | $this->checkReturnFields($query); |
127 | 127 | if ($limit === -1) { |
128 | 128 | $this->list = $query->find($this->con); |
129 | - } else { |
|
129 | + }else { |
|
130 | 130 | $this->list = $query->paginate($page, $limit, $this->con); |
131 | 131 | } |
132 | - } catch (\Exception $e) { |
|
132 | + }catch (\Exception $e) { |
|
133 | 133 | Logger::log($e->getMessage(), LOG_ERR); |
134 | 134 | } |
135 | 135 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | $header = null; |
138 | 138 | if ($this->hasHeader($name)) { |
139 | 139 | $header = $this->header[$name]; |
140 | - } else if (array_key_exists('h_' . strtolower($name), $this->query)) { |
|
141 | - $header = $this->query['h_' . strtolower($name)]; |
|
142 | - } else if (array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
143 | - $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name))); |
|
140 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
141 | + $header = $this->query['h_'.strtolower($name)]; |
|
142 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
143 | + $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name))); |
|
144 | 144 | } |
145 | 145 | return $header ?: $default; |
146 | 146 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $url = $this->getServer('HTTP_ORIGIN'); |
255 | 255 | } |
256 | 256 | ob_start(); |
257 | - header('Location: ' . $url); |
|
257 | + header('Location: '.$url); |
|
258 | 258 | ob_end_clean(); |
259 | 259 | Security::getInstance()->updateSession(); |
260 | 260 | exit(t('Redirect...')); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $url = $this->getServerName(); |
271 | 271 | $protocol = $hasProtocol ? $this->getProtocol() : '//'; |
272 | 272 | if (!empty($protocol)) { |
273 | - $url = $protocol . $url; |
|
273 | + $url = $protocol.$url; |
|
274 | 274 | } |
275 | 275 | return $this->checkServerPort($url); |
276 | 276 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | } |
293 | 293 | if (!in_array($port, [80, 443], true)) { |
294 | - $url .= ':' . $port; |
|
294 | + $url .= ':'.$port; |
|
295 | 295 | } |
296 | 296 | return $url; |
297 | 297 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | |
47 | 47 | $filePath = $returnPath = ''; |
48 | 48 | if (!file_exists($filePath)) { |
49 | - $filePath = BASE_DIR . $string; |
|
49 | + $filePath = BASE_DIR.$string; |
|
50 | 50 | } |
51 | 51 | $filenamePath = AssetsHelper::findDomainPath($string, $filePath); |
52 | - if(!empty($filenamePath)){ |
|
52 | + if (!empty($filenamePath)) { |
|
53 | 53 | $filePath = self::processAsset($string, $name, $return, $filenamePath); |
54 | 54 | $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl(false)); |
55 | - $returnPath = empty($name) ? $basePath . '/' . $filePath : $name; |
|
55 | + $returnPath = empty($name) ? $basePath.'/'.$filePath : $name; |
|
56 | 56 | } |
57 | 57 | return $return ? $returnPath : ''; |
58 | 58 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $router = Router::getInstance(); |
71 | 71 | try { |
72 | 72 | return $router->getRoute($path, $absolute, $params); |
73 | - } catch (\Exception $e) { |
|
73 | + }catch (\Exception $e) { |
|
74 | 74 | Logger::log($e->getMessage()); |
75 | 75 | return $router->getRoute('', $absolute, $params); |
76 | 76 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $filenamePath = self::extractPathname($path, $domains); |
167 | 167 | // Check if resources has been copied to public folders |
168 | 168 | if (!$debug) { |
169 | - $cacheFilename = Config::getParam('cache.var', '__initial__') . '.file.cache'; |
|
169 | + $cacheFilename = Config::getParam('cache.var', '__initial__').'.file.cache'; |
|
170 | 170 | $cachedFiles = Cache::getInstance()->readFromCache($cacheFilename, |
171 | 171 | 1, fn() => [], Cache::JSON, true) ?: []; |
172 | 172 | // Force the resource copy |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string|array |
189 | 189 | */ |
190 | - private static function extractPathname(string $path, $domains): string|array |
|
190 | + private static function extractPathname(string $path, $domains): string | array |
|
191 | 191 | { |
192 | 192 | $filenamePath = $path; |
193 | 193 | if (!empty($domains) && !file_exists($path)) { |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | * @param string $base |
227 | 227 | * @param string $filePath |
228 | 228 | */ |
229 | - private static function putResourceContent(string|null $name, string $filenamePath, string $base, string $filePath): void |
|
229 | + private static function putResourceContent(string | null $name, string $filenamePath, string $base, string $filePath): void |
|
230 | 230 | { |
231 | 231 | $data = file_get_contents($filenamePath); |
232 | 232 | if (!empty($name)) { |
233 | - file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
234 | - } else { |
|
235 | - file_put_contents($base . $filePath, $data); |
|
233 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
234 | + }else { |
|
235 | + file_put_contents($base.$filePath, $data); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * @return string |
246 | 246 | * @throws GeneratorException |
247 | 247 | */ |
248 | - private static function processAsset(string $string, string|null $name = null, bool $return = true, string $filenamePath = ''): string |
|
248 | + private static function processAsset(string $string, string | null $name = null, bool $return = true, string $filenamePath = ''): string |
|
249 | 249 | { |
250 | 250 | $filePath = $filenamePath; |
251 | 251 | if (file_exists($filenamePath)) { |
252 | 252 | list($base, $htmlBase, $filePath) = AssetsHelper::calculateAssetPath($string, $name, $return, $filenamePath); |
253 | 253 | //Creamos el directorio si no existe |
254 | - GeneratorHelper::createDir($base . $htmlBase); |
|
254 | + GeneratorHelper::createDir($base.$htmlBase); |
|
255 | 255 | //Si se ha modificado |
256 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) { |
|
256 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) { |
|
257 | 257 | if ($htmlBase === 'css') { |
258 | 258 | self::processCssLines($filenamePath); |
259 | 259 | } |