@@ -31,9 +31,10 @@ |
||
| 31 | 31 | function getallheaders() |
| 32 | 32 | { |
| 33 | 33 | $headers = array(); |
| 34 | - foreach ($_SERVER as $h => $v) |
|
| 35 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
| 34 | + foreach ($_SERVER as $h => $v) { |
|
| 35 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
| 36 | 36 | $headers[$hp[1]] = $v; |
| 37 | + } |
|
| 37 | 38 | return $headers; |
| 38 | 39 | } |
| 39 | 40 | } |
@@ -7,4 +7,4 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | Trait BoostrapTrait {} |
| 9 | 9 | |
| 10 | -require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
|
| 11 | 10 | \ No newline at end of file |
| 11 | +require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php'; |
|
| 12 | 12 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $use /= 1024; |
| 36 | 36 | break; |
| 37 | 37 | case "MBytes": |
| 38 | - $use /= (1024 * 1024); |
|
| 38 | + $use /= (1024*1024); |
|
| 39 | 39 | break; |
| 40 | 40 | case "Bytes": |
| 41 | 41 | default: |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | Logger::log('Added handlers for errors'); |
| 62 | 62 | //Warning & Notice handler |
| 63 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
| 63 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
| 64 | 64 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
| 65 | 65 | return true; |
| 66 | 66 | }, E_ALL | E_STRICT); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | Logger::log('Initializing stats (mem + ts)'); |
| 75 | 75 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
| 76 | 76 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
| 77 | - } else { |
|
| 77 | + }else { |
|
| 78 | 78 | $this->ts = Request::getInstance()->getTs(); |
| 79 | 79 | } |
| 80 | 80 | $this->mem = memory_get_usage(); |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public static function dropInstance() { |
| 36 | 36 | $class = get_called_class(); |
| 37 | - if(isset(self::$instance[$class])) { |
|
| 37 | + if (isset(self::$instance[$class])) { |
|
| 38 | 38 | self::$instance[$class] = null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -69,16 +69,16 @@ |
||
| 69 | 69 | if (!Request::getInstance()->isFile()) { |
| 70 | 70 | return $this->router->execute($this->actualUri); |
| 71 | 71 | } |
| 72 | - } else { |
|
| 72 | + }else { |
|
| 73 | 73 | return ConfigController::getInstance()->config(); |
| 74 | 74 | } |
| 75 | - } catch (AdminCredentialsException $a) { |
|
| 75 | + }catch (AdminCredentialsException $a) { |
|
| 76 | 76 | return UserController::showAdminManager(); |
| 77 | - } catch (SecurityException $s) { |
|
| 77 | + }catch (SecurityException $s) { |
|
| 78 | 78 | return $this->security->notAuthorized($this->actualUri); |
| 79 | - } catch (RouterException $r) { |
|
| 79 | + }catch (RouterException $r) { |
|
| 80 | 80 | return $this->router->httpNotFound($r); |
| 81 | - } catch (\Exception $e) { |
|
| 81 | + }catch (\Exception $e) { |
|
| 82 | 82 | return $this->dumpException($e); |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | class FileHelper { |
| 9 | 9 | /** |
| 10 | - * @param mixed $data |
|
| 10 | + * @param string $data |
|
| 11 | 11 | * @param string $path |
| 12 | 12 | * @return int |
| 13 | 13 | */ |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param string $path |
| 20 | - * @return mixed|bool |
|
| 20 | + * @return string|false |
|
| 21 | 21 | */ |
| 22 | 22 | public static function readFile($path) { |
| 23 | 23 | $data = false; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public static function readFile($path) { |
| 23 | 23 | $data = false; |
| 24 | - if(file_exists($path)) { |
|
| 24 | + if (file_exists($path)) { |
|
| 25 | 25 | $data = file_get_contents($path); |
| 26 | 26 | } |
| 27 | 27 | return $data; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
| 133 | 133 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
| 134 | 134 | ResponseHelper::setCookieHeaders($cookies); |
| 135 | - header('Content-type: ' . $contentType); |
|
| 135 | + header('Content-type: '.$contentType); |
|
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | Logger::log('Start output response'); |
| 149 | 149 | ob_start(); |
| 150 | 150 | $this->setReponseHeaders($contentType, $cookies); |
| 151 | - header('Content-length: ' . strlen($output)); |
|
| 151 | + header('Content-length: '.strlen($output)); |
|
| 152 | 152 | |
| 153 | 153 | $needCache = Cache::needCache(); |
| 154 | 154 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
| 155 | 155 | $cache = Cache::getInstance(); |
| 156 | 156 | Logger::log('Saving output response into cache'); |
| 157 | 157 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
| 158 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
| 159 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
| 158 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
| 159 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
| 160 | 160 | } |
| 161 | 161 | echo $output; |
| 162 | 162 | |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | Logger::log('Close template render'); |
| 175 | 175 | $uri = Request::requestUri(); |
| 176 | 176 | Security::getInstance()->setSessionKey("lastRequest", array( |
| 177 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
| 177 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
| 178 | 178 | "ts" => microtime(true), |
| 179 | 179 | )); |
| 180 | 180 | Security::getInstance()->updateSession(); |
| 181 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
| 181 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
| 182 | 182 | exit; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -216,15 +216,15 @@ discard block |
||
| 216 | 216 | ///////////////////////////////////////////////////////////// |
| 217 | 217 | // Date in the past sets the value to already have been expired. |
| 218 | 218 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
| 219 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 219 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 220 | 220 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 221 | 221 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 222 | 222 | header("Pragma: no-cache"); |
| 223 | 223 | header("Expires: 0"); |
| 224 | 224 | header('Content-Transfer-Encoding: none'); |
| 225 | - header("Content-type: " . $content); |
|
| 226 | - header("Content-length: " . strlen($data)); |
|
| 227 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 225 | + header("Content-type: ".$content); |
|
| 226 | + header("Content-length: ".strlen($data)); |
|
| 227 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 228 | 228 | echo $data; |
| 229 | 229 | ob_flush(); |
| 230 | 230 | ob_end_clean(); |
@@ -202,7 +202,7 @@ |
||
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | 204 | * Método que fuerza la descarga de un fichero |
| 205 | - * @param $data |
|
| 205 | + * @param string $data |
|
| 206 | 206 | * @param string $content |
| 207 | 207 | * @param string $filename |
| 208 | 208 | * @return mixed |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $download = $this->getRequest()->get('download') ?: false; |
| 34 | 34 | |
| 35 | 35 | $module = $this->srv->getModules($domain); |
| 36 | - if(empty($module)) { |
|
| 36 | + if (empty($module)) { |
|
| 37 | 37 | return Router::getInstance()->httpNotFound(null, true); |
| 38 | 38 | } |
| 39 | 39 | switch (strtolower($type)) { |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | ini_restore('max_execution_time'); |
| 54 | 54 | ini_restore('memory_limit'); |
| 55 | 55 | |
| 56 | - if($download && $type === ApiController::SWAGGER_DOC) { |
|
| 56 | + if ($download && $type === ApiController::SWAGGER_DOC) { |
|
| 57 | 57 | return $this->download(\GuzzleHttp\json_encode($doc), 'application/json', 'swagger.json'); |
| 58 | - } elseif($type === ApiController::HTML_DOC) { |
|
| 58 | + } elseif ($type === ApiController::HTML_DOC) { |
|
| 59 | 59 | return $this->render('documentation.html.twig', ["data" => json_encode($doc)]); |
| 60 | - } else { |
|
| 60 | + }else { |
|
| 61 | 61 | return $this->json($doc, 200); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $translations = array(); |
| 25 | 25 | if (file_exists($absoluteTranslationFileName)) { |
| 26 | 26 | @include($absoluteTranslationFileName); |
| 27 | - } else { |
|
| 27 | + }else { |
|
| 28 | 28 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public static function setLocale() { |
| 38 | 38 | $locale = Config::getParam("default.language", 'es_ES'); |
| 39 | - Logger::log('Set locale to project [' . $locale . ']'); |
|
| 39 | + Logger::log('Set locale to project ['.$locale.']'); |
|
| 40 | 40 | // Load translations |
| 41 | - putenv("LC_ALL=" . $locale); |
|
| 41 | + putenv("LC_ALL=".$locale); |
|
| 42 | 42 | setlocale(LC_ALL, $locale); |
| 43 | 43 | // Load the locale path |
| 44 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 45 | - Logger::log('Set locale dir ' . $locale_path); |
|
| 44 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 45 | + Logger::log('Set locale dir '.$locale_path); |
|
| 46 | 46 | GeneratorHelper::createDir($locale_path); |
| 47 | 47 | bindtextdomain('translations', $locale_path); |
| 48 | 48 | textdomain('translations'); |