Use native __DIR__ for BB_PATH (#702)

This commit is contained in:
Roman Kelesidis 2023-05-21 23:13:28 +07:00 committed by GitHub
commit f7d9a1c53d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions

View file

@ -13,6 +13,7 @@ if (isset($_REQUEST['GLOBALS'])) {
define('TIMESTART', utime()); define('TIMESTART', utime());
define('TIMENOW', time()); define('TIMENOW', time());
define('BB_PATH', __DIR__);
if (empty($_SERVER['REMOTE_ADDR'])) { if (empty($_SERVER['REMOTE_ADDR'])) {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
@ -42,13 +43,13 @@ if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
} }
// Get all constants // Get all constants
require_once __DIR__ . '/library/defines.php'; require_once BB_PATH . '/library/defines.php';
// Composer // Composer
if (!file_exists(__DIR__ . '/vendor/autoload.php')) { if (!file_exists(BB_PATH . '/vendor/autoload.php')) {
die('Please <a href="https://getcomposer.org/download/" target="_blank" rel="noreferrer" style="color:#0a25bb;">install composer</a> and run <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">composer install</code>'); die('Please <a href="https://getcomposer.org/download/" target="_blank" rel="noreferrer" style="color:#0a25bb;">install composer</a> and run <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">composer install</code>');
} }
require_once __DIR__ . '/vendor/autoload.php'; require_once BB_PATH . '/vendor/autoload.php';
/** /**
* Gets the value of an environment variable. * Gets the value of an environment variable.
@ -63,13 +64,13 @@ function env(string $key, $default = null)
} }
// Get initial config // Get initial config
$dotenv = Dotenv\Dotenv::createMutable(__DIR__); $dotenv = Dotenv\Dotenv::createMutable(BB_PATH);
$dotenv->safeLoad(); $dotenv->safeLoad();
require_once __DIR__ . '/library/config.php'; require_once BB_PATH . '/library/config.php';
// Local config // Local config
if (file_exists(__DIR__ . '/library/config.local.php')) { if (file_exists(BB_PATH . '/library/config.local.php')) {
require_once __DIR__ . '/library/config.local.php'; require_once BB_PATH . '/library/config.local.php';
} }
/** /**

View file

@ -11,11 +11,6 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__)); die(basename(__FILE__));
} }
// Root path
$rootPath = __DIR__;
if (DIRECTORY_SEPARATOR != '/') $rootPath = str_replace(DIRECTORY_SEPARATOR, '/', $rootPath);
define('BB_PATH', dirname($rootPath));
// System // System
define('CHECK_REQIREMENTS', [ define('CHECK_REQIREMENTS', [
'status' => true, 'status' => true,