@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | /** |
| 618 | 618 | * Método que extrae los parámetros de una función |
| 619 | 619 | * |
| 620 | - * @param array $sr |
|
| 620 | + * @param string[] $sr |
|
| 621 | 621 | * @param \ReflectionMethod $method |
| 622 | 622 | * |
| 623 | 623 | * @return array |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | * |
| 671 | 671 | * @param string $docComments |
| 672 | 672 | * |
| 673 | - * @return bool |
|
| 673 | + * @return string |
|
| 674 | 674 | */ |
| 675 | 675 | private function extractReflectionCacheability($docComments) |
| 676 | 676 | { |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function init() |
| 61 | 61 | { |
| 62 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
| 62 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
| 63 | 63 | $this->hydrateRouting(); |
| 64 | 64 | $this->simpatize(); |
| 65 | - } else { |
|
| 66 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
| 67 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
| 65 | + }else { |
|
| 66 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
| 67 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | "success" => FALSE, |
| 85 | 85 | "error" => $e->getMessage(), |
| 86 | 86 | )), 'application/json'); |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | if (NULL === $e) { |
| 89 | 89 | Logger::log('Not found page throwed without previus exception'); |
| 90 | 90 | $e = new \Exception(_('Page not found'), 404); |
@@ -125,24 +125,24 @@ discard block |
||
| 125 | 125 | $this->checkRestrictedAccess($route); |
| 126 | 126 | //Search action and execute |
| 127 | 127 | return $this->searchAction($route); |
| 128 | - } catch (AccessDeniedException $e) { |
|
| 128 | + }catch (AccessDeniedException $e) { |
|
| 129 | 129 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
| 130 | 130 | if ('login' === Config::getInstance()->get('admin_login')) { |
| 131 | 131 | return $this->redirectLogin($route); |
| 132 | - } else { |
|
| 132 | + }else { |
|
| 133 | 133 | return $this->sentAuthHeader(); |
| 134 | 134 | } |
| 135 | - } catch (RouterException $r) { |
|
| 135 | + }catch (RouterException $r) { |
|
| 136 | 136 | if (FALSE !== preg_match('/\/$/', $route)) { |
| 137 | 137 | if (preg_match('/admin/', $route)) { |
| 138 | 138 | $default = Config::getInstance()->get('admin_action'); |
| 139 | - } else { |
|
| 139 | + }else { |
|
| 140 | 140 | $default = Config::getInstance()->get('home_action'); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $this->execute($this->getRoute($default)); |
| 144 | 144 | } |
| 145 | - } catch (\Exception $e) { |
|
| 145 | + }catch (\Exception $e) { |
|
| 146 | 146 | Logger::log($e->getMessage(), LOG_ERR); |
| 147 | 147 | throw $e; |
| 148 | 148 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $class = $this->getClassToCall($action); |
| 220 | 220 | try { |
| 221 | 221 | return $this->executeCachedRoute($route, $action, $class, $get); |
| 222 | - } catch (\Exception $e) { |
|
| 222 | + }catch (\Exception $e) { |
|
| 223 | 223 | Logger::log($e->getMessage(), LOG_ERR); |
| 224 | 224 | throw new RouterException($e->getMessage(), 404, $e); |
| 225 | 225 | } |
@@ -309,13 +309,13 @@ discard block |
||
| 309 | 309 | if (file_exists($modules)) { |
| 310 | 310 | $this->routing = $this->inspectDir($modules, "", $this->routing); |
| 311 | 311 | } |
| 312 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
| 312 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
| 313 | 313 | $home = Config::getInstance()->get('home_action'); |
| 314 | 314 | if (NULL !== $home || $home !== '') { |
| 315 | 315 | $home_params = NULL; |
| 316 | 316 | foreach ($this->routing as $pattern => $params) { |
| 317 | 317 | list($method, $route) = $this->extractHttpRoute($pattern); |
| 318 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
| 318 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
| 319 | 319 | $home_params = $params; |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
| 341 | 341 | foreach ($files as $file) { |
| 342 | 342 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
| 343 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
| 343 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
| 344 | 344 | } |
| 345 | 345 | $this->finder = new Finder(); |
| 346 | 346 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $httpMethod = $this->extractReflectionHttpMethod($docComments); |
| 382 | 382 | $visible = $this->extractReflectionVisibility($docComments); |
| 383 | 383 | $expiration = $this->extractReflectionCacheability($docComments); |
| 384 | - $routing[$httpMethod . "#|#" . $regex] = array( |
|
| 384 | + $routing[$httpMethod."#|#".$regex] = array( |
|
| 385 | 385 | "class" => $namespace, |
| 386 | 386 | "method" => $method->getName(), |
| 387 | 387 | "params" => $params, |
@@ -411,9 +411,9 @@ discard block |
||
| 411 | 411 | { |
| 412 | 412 | //Calculamos los dominios para las plantillas |
| 413 | 413 | if ($class->hasConstant("DOMAIN")) { |
| 414 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
| 415 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 416 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 414 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
| 415 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 416 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 417 | 417 | $tpl_path = "templates"; |
| 418 | 418 | $public_path = "public"; |
| 419 | 419 | $model_path = "models"; |
@@ -423,12 +423,12 @@ discard block |
||
| 423 | 423 | $model_path = ucfirst($model_path); |
| 424 | 424 | } |
| 425 | 425 | if ($class->hasConstant("TPL")) { |
| 426 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
| 426 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
| 427 | 427 | } |
| 428 | 428 | $this->domains[$domain] = array( |
| 429 | - "template" => $path . $tpl_path, |
|
| 430 | - "model" => $path . $model_path, |
|
| 431 | - "public" => $path . $public_path, |
|
| 429 | + "template" => $path.$tpl_path, |
|
| 430 | + "model" => $path.$model_path, |
|
| 431 | + "public" => $path.$public_path, |
|
| 432 | 432 | ); |
| 433 | 433 | } |
| 434 | 434 | |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | public function simpatize() |
| 443 | 443 | { |
| 444 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
| 445 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
| 444 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
| 445 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
| 446 | 446 | $this->generateSlugs($absoluteTranslationFileName); |
| 447 | 447 | Config::createDir(CONFIG_DIR); |
| 448 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 448 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 449 | 449 | |
| 450 | 450 | return $this; |
| 451 | 451 | } |
@@ -496,16 +496,16 @@ discard block |
||
| 496 | 496 | public function getRoute($slug = '', $absolute = FALSE, $params = NULL) |
| 497 | 497 | { |
| 498 | 498 | if (strlen($slug) === 0) { |
| 499 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
| 499 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
| 500 | 500 | } |
| 501 | 501 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
| 502 | 502 | throw new RouterException(_("No existe la ruta especificada")); |
| 503 | 503 | } |
| 504 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
| 504 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
| 505 | 505 | if (!empty($params)) foreach ($params as $key => $value) { |
| 506 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
| 506 | + $url = str_replace("{".$key."}", $value, $url); |
|
| 507 | 507 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
| 508 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
| 508 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | if (preg_match('/^\/admin(\/|$)/', $routePattern)) { |
| 524 | 524 | if (preg_match('/^PSFS/', $params["class"])) { |
| 525 | 525 | $profile = "superadmin"; |
| 526 | - } else { |
|
| 526 | + }else { |
|
| 527 | 527 | $profile = "admin"; |
| 528 | 528 | } |
| 529 | 529 | if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) { |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | protected function getClassToCall($action) |
| 576 | 576 | { |
| 577 | 577 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 578 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
| 578 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
| 579 | 579 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
| 580 | 580 | return $class; |
| 581 | 581 | } |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | $expr = preg_quote($expr, '/'); |
| 595 | 595 | $expr = str_replace('###', '(.*)', $expr); |
| 596 | 596 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 597 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 597 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 598 | 598 | return $matched; |
| 599 | 599 | } |
| 600 | 600 | |
@@ -631,9 +631,9 @@ discard block |
||
| 631 | 631 | if (count($parameters) > 0) foreach ($parameters as $param) { |
| 632 | 632 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 633 | 633 | $params[$param->getName()] = $param->getDefaultValue(); |
| 634 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 634 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 635 | 635 | } |
| 636 | - } else $default = $regex; |
|
| 636 | + }else $default = $regex; |
|
| 637 | 637 | |
| 638 | 638 | return array($regex, $default, $params); |
| 639 | 639 | } |
@@ -689,16 +689,16 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 691 | 691 | { |
| 692 | - Logger::log('Executing route ' . $route); |
|
| 692 | + Logger::log('Executing route '.$route); |
|
| 693 | 693 | $this->session->setSessionKey("__CACHE__", $action); |
| 694 | 694 | $cache = Cache::needCache(); |
| 695 | 695 | $execute = TRUE; |
| 696 | 696 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
| 697 | 697 | $cacheDataName = $this->cache->getRequestCacheHash(); |
| 698 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () { |
|
| 698 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() { |
|
| 699 | 699 | }); |
| 700 | 700 | if (NULL !== $cachedData) { |
| 701 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () { |
|
| 701 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() { |
|
| 702 | 702 | }, Cache::JSON); |
| 703 | 703 | Template::getInstance()->renderCache($cachedData, $headers); |
| 704 | 704 | $execute = FALSE; |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | $translations = array(); |
| 748 | 748 | if (file_exists($absoluteTranslationFileName)) { |
| 749 | 749 | include($absoluteTranslationFileName); |
| 750 | - } else { |
|
| 750 | + }else { |
|
| 751 | 751 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 752 | 752 | } |
| 753 | 753 | |
@@ -286,8 +286,10 @@ discard block |
||
| 286 | 286 | $_route = explode("/", $url['path']); |
| 287 | 287 | $_pattern = explode("/", $pattern); |
| 288 | 288 | $get = array(); |
| 289 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
| 289 | + if (!empty($_pattern)) { |
|
| 290 | + foreach ($_pattern as $index => $component) { |
|
| 290 | 291 | $_get = array(); |
| 292 | + } |
|
| 291 | 293 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
| 292 | 294 | if (!empty($_get[1]) && isset($_route[$index])) { |
| 293 | 295 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -502,8 +504,10 @@ discard block |
||
| 502 | 504 | throw new RouterException(_("No existe la ruta especificada")); |
| 503 | 505 | } |
| 504 | 506 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
| 505 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
| 507 | + if (!empty($params)) { |
|
| 508 | + foreach ($params as $key => $value) { |
|
| 506 | 509 | $url = str_replace("{" . $key . "}", $value, $url); |
| 510 | + } |
|
| 507 | 511 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
| 508 | 512 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
| 509 | 513 | } |
@@ -628,12 +632,16 @@ discard block |
||
| 628 | 632 | $default = ''; |
| 629 | 633 | $params = array(); |
| 630 | 634 | $parameters = $method->getParameters(); |
| 631 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
| 635 | + if (count($parameters) > 0) { |
|
| 636 | + foreach ($parameters as $param) { |
|
| 632 | 637 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 633 | 638 | $params[$param->getName()] = $param->getDefaultValue(); |
| 639 | + } |
|
| 634 | 640 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
| 635 | 641 | } |
| 636 | - } else $default = $regex; |
|
| 642 | + } else { |
|
| 643 | + $default = $regex; |
|
| 644 | + } |
|
| 637 | 645 | |
| 638 | 646 | return array($regex, $default, $params); |
| 639 | 647 | } |
@@ -415,7 +415,7 @@ |
||
| 415 | 415 | * @param array $parts |
| 416 | 416 | * @param int $partLength |
| 417 | 417 | * |
| 418 | - * @return array |
|
| 418 | + * @return string[] |
|
| 419 | 419 | */ |
| 420 | 420 | private static function extractTsAndMod(array &$parts, $partLength) |
| 421 | 421 | { |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | public static function save($user) |
| 106 | 106 | { |
| 107 | 107 | $admins = array(); |
| 108 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 109 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
| 108 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 109 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
| 110 | 110 | } |
| 111 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 111 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 112 | 112 | $admins[$user['username']]['profile'] = $user['profile']; |
| 113 | 113 | |
| 114 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
| 114 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | public function getAdmins() |
| 146 | 146 | { |
| 147 | 147 | $admins = array(); |
| 148 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 149 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
| 148 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 149 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $admins; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | Logger::log('Checking admin session'); |
| 167 | 167 | if (!$this->authorized) { |
| 168 | 168 | $request = Request::getInstance(); |
| 169 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 169 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 170 | 170 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
| 171 | 171 | return Router::getInstance()->getAdmin()->adminers(); |
| 172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | if (!empty($user) && !empty($admins[$user])) { |
| 181 | 181 | $auth = $admins[$user]['hash']; |
| 182 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
| 182 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
| 183 | 183 | $this->admin = array( |
| 184 | 184 | 'alias' => $user, |
| 185 | 185 | 'profile' => $admins[$user]['profile'], |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | $axis = 0; |
| 399 | 399 | $parts = array(); |
| 400 | 400 | try { |
| 401 | - $partLength = floor(strlen($token) / 10); |
|
| 402 | - for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { |
|
| 401 | + $partLength = floor(strlen($token)/10); |
|
| 402 | + for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { |
|
| 403 | 403 | $parts[] = substr($token, $axis, $partLength); |
| 404 | 404 | $axis += $partLength; |
| 405 | 405 | } |
| 406 | - } catch (\Exception $e) { |
|
| 406 | + }catch (\Exception $e) { |
|
| 407 | 407 | $partLength = 0; |
| 408 | 408 | } |
| 409 | 409 | |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | $decoded = NULL; |
| 444 | 444 | list($partLength, $parts) = self::extractTokenParts($token); |
| 445 | 445 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength); |
| 446 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
| 446 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
| 447 | 447 | if (time() - (integer)$ts < 300 && $hashMod === $mod) { |
| 448 | 448 | $decoded = implode('', $parts); |
| 449 | 449 | } |
@@ -460,16 +460,16 @@ discard block |
||
| 460 | 460 | public static function generateToken($secret, $module = 'PSFS') |
| 461 | 461 | { |
| 462 | 462 | $ts = time(); |
| 463 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
| 463 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
| 464 | 464 | $hash = hash('sha256', $secret); |
| 465 | - $insert = floor(strlen($hash) / strlen($ts)); |
|
| 465 | + $insert = floor(strlen($hash)/strlen($ts)); |
|
| 466 | 466 | $j = 0; |
| 467 | 467 | $token = ''; |
| 468 | 468 | for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { |
| 469 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2); |
|
| 469 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2); |
|
| 470 | 470 | $j += $insert; |
| 471 | 471 | } |
| 472 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts))); |
|
| 472 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts))); |
|
| 473 | 473 | return $token; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -125,8 +125,8 @@ |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * @param $header |
|
| 129 | - * @param null $content |
|
| 128 | + * @param string $header |
|
| 129 | + * @param string $content |
|
| 130 | 130 | * |
| 131 | 131 | * @return $this |
| 132 | 132 | */ |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | $this->url = NULL; |
| 178 | 178 | $this->params = array(); |
| 179 | 179 | $this->headers = array(); |
| 180 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
| 180 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function __construct() |
| 21 | 21 | { |
| 22 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
| 22 | + Logger::log(get_class($this).' constructor invoked'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | $calledClass = get_called_class(); |
| 107 | 107 | try { |
| 108 | 108 | $instance = $this->constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
| 109 | - $setter = "set" . ucfirst($variable); |
|
| 109 | + $setter = "set".ucfirst($variable); |
|
| 110 | 110 | if (method_exists($calledClass, $setter)) { |
| 111 | 111 | $this->$setter($instance); |
| 112 | - } else { |
|
| 112 | + }else { |
|
| 113 | 113 | $this->$variable = $instance; |
| 114 | 114 | } |
| 115 | - } catch (\Exception $e) { |
|
| 116 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
| 115 | + }catch (\Exception $e) { |
|
| 116 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
| 117 | 117 | } |
| 118 | 118 | return $this; |
| 119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | public function init() |
| 125 | 125 | { |
| 126 | 126 | if (!$this->isLoaded()) { |
| 127 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json"; |
|
| 127 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json"; |
|
| 128 | 128 | /** @var \PSFS\base\Cache $cacheService */ |
| 129 | 129 | $cacheService = Cache::getInstance(); |
| 130 | 130 | /** @var \PSFS\base\config\Config $configService */ |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | $this->load($property, true, $class); |
| 140 | 140 | } |
| 141 | 141 | $this->setLoaded(); |
| 142 | - } else { |
|
| 143 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
| 142 | + }else { |
|
| 143 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | if (null === $class) { |
| 156 | 156 | $class = get_class($this); |
| 157 | 157 | } |
| 158 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
| 158 | + Logger::log('Extracting annotations properties from class '.$class); |
|
| 159 | 159 | $selfReflector = new \ReflectionClass($class); |
| 160 | 160 | if (false !== $selfReflector->getParentClass()) { |
| 161 | 161 | $properties = $this->getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
| 198 | 198 | { |
| 199 | - Logger::log('Create inyectable instance for ' . $classNameSpace . ' into ' . get_class($this)); |
|
| 199 | + Logger::log('Create inyectable instance for '.$classNameSpace.' into '.get_class($this)); |
|
| 200 | 200 | $reflector = new \ReflectionClass($calledClass); |
| 201 | 201 | $property = $reflector->getProperty($variable); |
| 202 | 202 | $varInstanceType = (null === $classNameSpace) ? $this->extractVarType($property->getDocComment()) : $classNameSpace; |
| 203 | 203 | if (true === $singleton && method_exists($varInstanceType, "getInstance")) { |
| 204 | 204 | $instance = $varInstanceType::getInstance(); |
| 205 | - } else { |
|
| 205 | + }else { |
|
| 206 | 206 | $instance = new $varInstanceType(); |
| 207 | 207 | } |
| 208 | 208 | return $instance; |
@@ -135,9 +135,11 @@ |
||
| 135 | 135 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON); |
| 136 | 136 | } |
| 137 | 137 | /** @var \ReflectionProperty $property */ |
| 138 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
| 138 | + if (!empty($properties) && is_array($properties)) { |
|
| 139 | + foreach ($properties as $property => $class) { |
|
| 139 | 140 | $this->load($property, true, $class); |
| 140 | 141 | } |
| 142 | + } |
|
| 141 | 143 | $this->setLoaded(); |
| 142 | 144 | } else { |
| 143 | 145 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function init() |
| 48 | 48 | { |
| 49 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json")) { |
|
| 49 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json")) { |
|
| 50 | 50 | $this->loadConfigData(); |
| 51 | 51 | } |
| 52 | 52 | return $this; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getTemplatePath() |
| 118 | 118 | { |
| 119 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
| 119 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
| 120 | 120 | return realpath($path); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | $final_data = self::saveExtraParams($data); |
| 164 | 164 | $saved = false; |
| 165 | 165 | try { |
| 166 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", $final_data, Cache::JSON, true); |
|
| 166 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", $final_data, Cache::JSON, true); |
|
| 167 | 167 | Config::getInstance()->loadConfigData(); |
| 168 | 168 | $saved = true; |
| 169 | - } catch (ConfigException $e) { |
|
| 169 | + }catch (ConfigException $e) { |
|
| 170 | 170 | Logger::log($e->getMessage(), LOG_ERR); |
| 171 | 171 | } |
| 172 | 172 | return $saved; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function getPropelParams() |
| 200 | 200 | { |
| 201 | - return Cache::getInstance()->getDataFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'properties.json', Cache::JSON, true); |
|
| 201 | + return Cache::getInstance()->getDataFromFile(__DIR__.DIRECTORY_SEPARATOR.'properties.json', Cache::JSON, true); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | try { |
| 212 | 212 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
| 213 | - throw new \Exception(_('Can\'t create directory ') . $dir); |
|
| 213 | + throw new \Exception(_('Can\'t create directory ').$dir); |
|
| 214 | 214 | } |
| 215 | - } catch (\Exception $e) { |
|
| 215 | + }catch (\Exception $e) { |
|
| 216 | 216 | Logger::log($e->getMessage(), LOG_WARNING); |
| 217 | 217 | if (!file_exists(dirname($dir))) { |
| 218 | - throw new ConfigException($e->getMessage() . $dir); |
|
| 218 | + throw new ConfigException($e->getMessage().$dir); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | $rootDirs = array("css", "js", "media", "font"); |
| 229 | 229 | foreach ($rootDirs as $dir) { |
| 230 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
| 230 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
| 231 | 231 | try { |
| 232 | - @shell_exec("rm -rf " . WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
| 233 | - } catch (\Exception $e) { |
|
| 232 | + @shell_exec("rm -rf ".WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
| 233 | + }catch (\Exception $e) { |
|
| 234 | 234 | Logger::log($e->getMessage()); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function loadConfigData() |
| 244 | 244 | { |
| 245 | - $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", Cache::JSON, TRUE) ?: array(); |
|
| 245 | + $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", Cache::JSON, TRUE) ?: array(); |
|
| 246 | 246 | $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | if (!defined("LOG_DIR")) { |
| 16 | - Config::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 17 | - define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 16 | + Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 17 | + define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $config = Config::getInstance(); |
| 44 | 44 | $args = func_get_args(); |
| 45 | 45 | list($logger, $debug, $path) = $this->setup($config, $args); |
| 46 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+"); |
|
| 46 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+"); |
|
| 47 | 47 | $this->addPushLogger($logger, $debug, $config); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | private function createLoggerPath(Config $config) |
| 186 | 186 | { |
| 187 | 187 | $logger = $this->setLoggerName($config); |
| 188 | - $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
| 188 | + $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
| 189 | 189 | Config::createDir($path); |
| 190 | 190 | |
| 191 | 191 | return $path; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $this->setStatusHeader(); |
| 133 | 133 | $this->setAuthHeaders(); |
| 134 | 134 | $this->setCookieHeaders($cookies); |
| 135 | - header('Content-type: ' . $contentType); |
|
| 135 | + header('Content-type: '.$contentType); |
|
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
@@ -148,14 +148,14 @@ 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 | $cache = Cache::needCache(); |
| 154 | 154 | if (false !== $cache && $this->status_code === 200 && $this->debug === false) { |
| 155 | 155 | Logger::log('Saving output response into cache'); |
| 156 | 156 | $cacheName = $this->cache->getRequestCacheHash(); |
| 157 | - $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName, $output); |
|
| 158 | - $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName . ".headers", headers_list(), Cache::JSON); |
|
| 157 | + $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName, $output); |
|
| 158 | + $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName.".headers", headers_list(), Cache::JSON); |
|
| 159 | 159 | } |
| 160 | 160 | echo $output; |
| 161 | 161 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | Logger::log('Close template render'); |
| 174 | 174 | $this->security->setSessionKey("lastRequest", array( |
| 175 | - "url" => Request::getInstance()->getRootUrl() . Request::requestUri(), |
|
| 175 | + "url" => Request::getInstance()->getRootUrl().Request::requestUri(), |
|
| 176 | 176 | "ts" => microtime(true), |
| 177 | 177 | )); |
| 178 | 178 | $this->security->updateSession(); |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | $dump = ''; |
| 225 | 225 | try { |
| 226 | 226 | $dump = $this->tpl->render($tpl, $vars); |
| 227 | - } catch (\Exception $e) { |
|
| 228 | - echo $e->getMessage() . "<pre>" . $e->getTraceAsString() . "</pre>"; |
|
| 227 | + }catch (\Exception $e) { |
|
| 228 | + echo $e->getMessage()."<pre>".$e->getTraceAsString()."</pre>"; |
|
| 229 | 229 | } |
| 230 | 230 | return $dump; |
| 231 | 231 | } |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | public function regenerateTemplates() |
| 339 | 339 | { |
| 340 | 340 | $this->generateTemplatesCache(); |
| 341 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true); |
|
| 341 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true); |
|
| 342 | 342 | $translations = []; |
| 343 | 343 | if (is_array($domains)) { |
| 344 | 344 | $translations = $this->parsePathTranslations($domains); |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | // force compilation |
| 361 | 361 | if ($file->isFile()) { |
| 362 | 362 | try { |
| 363 | - $this->tpl->loadTemplate(str_replace($tplDir . '/', '', $file)); |
|
| 364 | - } catch (\Exception $e) { |
|
| 363 | + $this->tpl->loadTemplate(str_replace($tplDir.'/', '', $file)); |
|
| 364 | + }catch (\Exception $e) { |
|
| 365 | 365 | Logger::log($e->getMessage(), LOG_ERR); |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | unset($_SERVER["PHP_AUTH_USER"]); |
| 432 | 432 | unset($_SERVER["PHP_AUTH_PW"]); |
| 433 | 433 | header_remove("Authorization"); |
| 434 | - } else { |
|
| 434 | + }else { |
|
| 435 | 435 | header('Authorization:'); |
| 436 | 436 | } |
| 437 | 437 | } |
@@ -458,9 +458,9 @@ discard block |
||
| 458 | 458 | Logger::log('Adding debug headers to render response'); |
| 459 | 459 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
| 460 | 460 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 461 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
| 462 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
| 463 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
| 461 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
| 462 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
| 463 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | return $vars; |
@@ -21,11 +21,11 @@ |
||
| 21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
| 22 | 22 | |
| 23 | 23 | // filepath |
| 24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
| 24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
| 25 | 25 | if (!file_exists($abs_path)) { |
| 26 | - pre('→ ' . $class); |
|
| 27 | - pre('→ ' . $path); |
|
| 28 | - pre('→ ' . $abs_path); |
|
| 26 | + pre('→ '.$class); |
|
| 27 | + pre('→ '.$path); |
|
| 28 | + pre('→ '.$abs_path); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // require the file |
@@ -4,16 +4,16 @@ |
||
| 4 | 4 | |
| 5 | 5 | if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
| 6 | 6 | if (preg_match('/vendor/', SOURCE_DIR)) { |
| 7 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
| 8 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
| 9 | -} else { |
|
| 10 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
| 11 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
| 7 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
| 8 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
| 9 | +}else { |
|
| 10 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
| 11 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
| 12 | 12 | } |
| 13 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 14 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 15 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 16 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 13 | +if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 14 | +if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
| 15 | +if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
| 16 | +if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
| 17 | 17 | |
| 18 | 18 | //Cargamos en memoria la función de desarrollo PRE |
| 19 | 19 | if (!function_exists('pre')) { |
@@ -1,19 +1,39 @@ |
||
| 1 | 1 | <?php |
| 2 | -if (defined('PSFS_BOOTSTRAP_LOADED')) return; |
|
| 2 | +if (defined('PSFS_BOOTSTRAP_LOADED')) { |
|
| 3 | + return; |
|
| 4 | +} |
|
| 3 | 5 | use Symfony\Component\Finder\Finder; |
| 4 | 6 | |
| 5 | -if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
|
| 7 | +if (!defined('SOURCE_DIR')) { |
|
| 8 | + define('SOURCE_DIR', __DIR__); |
|
| 9 | +} |
|
| 6 | 10 | if (preg_match('/vendor/', SOURCE_DIR)) { |
| 7 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
| 8 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
| 9 | -} else { |
|
| 10 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
| 11 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
| 12 | -} |
|
| 13 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 14 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 15 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 16 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 11 | + if (!defined('BASE_DIR')) { |
|
| 12 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
| 13 | + } |
|
| 14 | + if (!defined('CORE_DIR')) { |
|
| 15 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
| 16 | + } |
|
| 17 | + } else { |
|
| 18 | + if (!defined('BASE_DIR')) { |
|
| 19 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
| 20 | + } |
|
| 21 | + if (!defined('CORE_DIR')) { |
|
| 22 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | +if (!defined('LOG_DIR')) { |
|
| 26 | + define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 27 | +} |
|
| 28 | +if (!defined('CACHE_DIR')) { |
|
| 29 | + define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 30 | +} |
|
| 31 | +if (!defined('CONFIG_DIR')) { |
|
| 32 | + define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 33 | +} |
|
| 34 | +if (!defined('WEB_DIR')) { |
|
| 35 | + define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 36 | +} |
|
| 17 | 37 | |
| 18 | 38 | //Cargamos en memoria la función de desarrollo PRE |
| 19 | 39 | if (!function_exists('pre')) { |