@@ -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')) { |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function setAdminHeaders() |
| 33 | 33 | { |
| 34 | - if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup"); |
|
| 34 | + if("login" === $this->config->get("admin_login")) { |
|
| 35 | + return Admin::getInstance()->adminLogin("admin-setup"); |
|
| 36 | + } |
|
| 35 | 37 | $platform = trim(Config::getInstance()->get("platform_name")); |
| 36 | 38 | header('HTTP/1.1 401 Unauthorized'); |
| 37 | 39 | header('WWW-Authenticate: Basic Realm="' . $platform. '"'); |
@@ -63,17 +65,20 @@ discard block |
||
| 63 | 65 | */ |
| 64 | 66 | private function parseAdmins(&$admins) |
| 65 | 67 | { |
| 66 | - if(!empty($admins)) foreach($admins as &$admin) |
|
| 68 | + if(!empty($admins)) { |
|
| 69 | + foreach($admins as &$admin) |
|
| 67 | 70 | { |
| 68 | 71 | if(isset($admin["profile"])) |
| 69 | 72 | { |
| 70 | 73 | switch($admin["profile"]) { |
| 71 | - case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning'; break; |
|
| 74 | + case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning'; |
|
| 75 | + } |
|
| 76 | + break; |
|
| 72 | 77 | case Security::ADMIN_ID_TOKEN: $admin['class'] = 'info'; break; |
| 73 | 78 | default: |
| 74 | 79 | case Security::USER_ID_TOKEN: $admin['class'] = 'primary'; break; |
| 75 | 80 | } |
| 76 | - }else{ |
|
| 81 | + } else{ |
|
| 77 | 82 | $admin["class"] = "primary"; |
| 78 | 83 | } |
| 79 | 84 | } |
@@ -94,7 +99,9 @@ discard block |
||
| 94 | 99 | $size = $file->getSize() / 8 / 1024; |
| 95 | 100 | $time = date("c", $file->getMTime()); |
| 96 | 101 | $dateTime = new \DateTime($time); |
| 97 | - if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
| 102 | + if(!isset($logs[$dateTime->format("Y")])) { |
|
| 103 | + $logs[$dateTime->format("Y")] = array(); |
|
| 104 | + } |
|
| 98 | 105 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
| 99 | 106 | "filename" => $file->getFilename(), |
| 100 | 107 | "size" => round($size, 3) |
@@ -138,7 +145,9 @@ discard block |
||
| 138 | 145 | $detailLog[] = array_merge(array( |
| 139 | 146 | "log" => $line, |
| 140 | 147 | ), $detail); |
| 141 | - if(count($detailLog) >= 1000) break; |
|
| 148 | + if(count($detailLog) >= 1000) { |
|
| 149 | + break; |
|
| 150 | + } |
|
| 142 | 151 | } |
| 143 | 152 | $log = $detailLog; |
| 144 | 153 | } |
@@ -162,7 +171,9 @@ discard block |
||
| 162 | 171 | |
| 163 | 172 | $detail = json_decode($match[0][0], TRUE); |
| 164 | 173 | } |
| 165 | - if (empty($detail)) $detail = array(); |
|
| 174 | + if (empty($detail)) { |
|
| 175 | + $detail = array(); |
|
| 176 | + } |
|
| 166 | 177 | preg_match_all('/\>\ (.*):/i', $line, $match); |
| 167 | 178 | |
| 168 | 179 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use PSFS\base\Logger; |
| 14 | 14 | use PSFS\base\Singleton; |
| 15 | 15 | |
| 16 | -require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php"; |
|
| 16 | +require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php"; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Class Dispatcher |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | private function setLocale() |
| 75 | 75 | { |
| 76 | 76 | $this->locale = $this->config->get("default_language"); |
| 77 | - Logger::log('Set locale to project [' . $this->locale . ']'); |
|
| 77 | + Logger::log('Set locale to project ['.$this->locale.']'); |
|
| 78 | 78 | // Load translations |
| 79 | - putenv("LC_ALL=" . $this->locale); |
|
| 79 | + putenv("LC_ALL=".$this->locale); |
|
| 80 | 80 | setlocale(LC_ALL, $this->locale); |
| 81 | 81 | // Load the locale path |
| 82 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 83 | - Logger::log('Set locale dir ' . $locale_path); |
|
| 82 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 83 | + Logger::log('Set locale dir '.$locale_path); |
|
| 84 | 84 | Config::createDir($locale_path); |
| 85 | 85 | bindtextdomain('translations', $locale_path); |
| 86 | 86 | textdomain('translations'); |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | if (!$this->parser->isFile()) { |
| 101 | 101 | return $this->router->execute($this->actualUri); |
| 102 | 102 | } |
| 103 | - } else { |
|
| 103 | + }else { |
|
| 104 | 104 | return $this->router->getAdmin()->config(); |
| 105 | 105 | } |
| 106 | - } catch (ConfigException $c) { |
|
| 106 | + }catch (ConfigException $c) { |
|
| 107 | 107 | return $this->dumpException($c); |
| 108 | - } catch (SecurityException $s) { |
|
| 108 | + }catch (SecurityException $s) { |
|
| 109 | 109 | return $this->security->notAuthorized($this->actualUri); |
| 110 | - } catch (RouterException $r) { |
|
| 110 | + }catch (RouterException $r) { |
|
| 111 | 111 | return $this->router->httpNotFound($r); |
| 112 | - } catch (\Exception $e) { |
|
| 112 | + }catch (\Exception $e) { |
|
| 113 | 113 | return $this->dumpException($e); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $use /= 1024; |
| 152 | 152 | break; |
| 153 | 153 | case "MBytes": |
| 154 | - $use /= (1024 * 1024); |
|
| 154 | + $use /= (1024*1024); |
|
| 155 | 155 | break; |
| 156 | 156 | case "Bytes": |
| 157 | 157 | default: |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | if ($this->config->getDebugMode()) { |
| 178 | 178 | Logger::log('Added handlers for errors'); |
| 179 | 179 | //Warning & Notice handler |
| 180 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
| 180 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
| 181 | 181 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]); |
| 182 | 182 | throw new \Exception($errstr, 500); |
| 183 | 183 | }); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | Logger::log('Initialicing stats (mem + ts)'); |
| 193 | 193 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
| 194 | 194 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
| 195 | - } else { |
|
| 195 | + }else { |
|
| 196 | 196 | $this->ts = $this->parser->getTs(); |
| 197 | 197 | } |
| 198 | 198 | $this->mem = memory_get_usage(); |