/** * Get relative path * @description full relative path * @param integer $index * @return string */ public static function index($index = -1) { $r = Tools::chef(self::all(), $index, null); return $r['path']; }
/** * Initialize registry, core values, readonly system variables * @param void * @return void */ private static function release($config = []) { // Read only $config = !is_array($config) ? [] : $config; $valid = ['db', 'mail', 'store', 'system']; foreach ($valid as $v) { if (!Tools::chef(self::$config, $v)) { $config[$v] = []; } } // Server override $__SERVER_NAME = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : PHP_SAPI; $__REQUEST_URI = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; // INIT defaults // Server root directory $config['system']['root'] = __LETHE_ROOT__; // Protocol $config['system']['protocol'] = Tools::ssl() === true ? 'https://' : 'http://'; // Port umber $config['system']['port'] = isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != '443' ? (int) $_SERVER["SERVER_PORT"] : 80; // Port used in URLs $config['system']['portPath'] = isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != '443' ? ':' . $_SERVER["SERVER_PORT"] : null; // Full site, domain and REQUEST_URI (only dirname) $config['system']['site'] = (string) ($config['system']['protocol'] . $__SERVER_NAME . $config['system']['portPath'] . $__REQUEST_URI); $config['system']['site'] = mb_substr((string) $config['system']['site'], -1, 1, 'UTF-8') === '/' ? mb_substr((string) $config['system']['site'], 0, -1, 'UTF-8') : $config['system']['site']; // Full site, domain and REQUEST_URI (only dirname), // Mostly the same as site, but if you use some htaccess tricks: // EXAMPLE: // ReWriteCond %{REQUEST_URI} public-fake-dir // ReWriteRule ^public-fake-dir/(.*)$ real/server/directory/$1 [L,QSA] // siteOrigin will point to 'real/server/directory' $config['system']['siteOrigin'] = (string) ($config['system']['protocol'] . $__SERVER_NAME . $config['system']['portPath'] . dirname($_SERVER['SCRIPT_NAME'])); $config['system']['siteOrigin'] = mb_substr((string) $config['system']['siteOrigin'], -1, 1, 'UTF-8') === '/' ? mb_substr((string) $config['system']['siteOrigin'], 0, -1, 'UTF-8') : $config['system']['siteOrigin']; // Domain used in system $config['system']['domain'] = (string) ($config['system']['protocol'] . $__SERVER_NAME . $config['system']['portPath']); // Clear domain name without www or http... $config['system']['domainName'] = str_replace('www.', NULL, (string) $__SERVER_NAME); // Full address $config['system']['url'] = $config['system']['protocol'] . $__SERVER_NAME . $config['system']['portPath'] . $__REQUEST_URI; // Relative path $config['system']['rel'] = isset($_SERVER['REQUEST_URI']) ? $__REQUEST_URI : '/'; // Browser address parsed $config['system']['urlArray'] = parse_url($config['system']['url']); // Browser query string parsed $_queryArray = []; if (array_key_exists('query', $config['system']['urlArray'])) { parse_str($config['system']['urlArray']['query'], $_queryArray); } $config['system']['queryArray'] = $_queryArray; // Initial time $config['system']['start'] = microtime(true); // Initial max memory usage $config['system']['initMemTop'] = memory_get_usage(true); // Initial avg memory usage $config['system']['initMemPeakTop'] = memory_get_peak_usage(true); // Browser language $config['system']['lang'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en'; // Browser type $config['system']['userAgent'] = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : 'Unknown'; // OS type $config['system']['os'] = PHP_OS; // Server API type $config['system']['sapi'] = PHP_SAPI; // System identification $config['system']['productName'] = 'Lethe'; // System version $config['system']['version'] = '0.8.8'; // Code name $config['system']['productCodename'] = 'Rising Decay'; self::$config = $config; }