commit changes
This commit is contained in:
@@ -3,28 +3,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base database for Nexus core (users, settings, modules).
|
* Base database for Nexus core (users, settings, modules).
|
||||||
* This uses the environment-specific config in /config/{env}/db_settings_basic.php.
|
* Sync copies the correct file into /config.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$env = getenv('APP_ENV');
|
$path = __DIR__ . '/db_settings_basic.php';
|
||||||
if (!$env && defined('APP_ENV')) {
|
if (!file_exists($path)) {
|
||||||
$env = APP_ENV;
|
throw new RuntimeException('Missing base DB config: expected config/db_settings_basic.php');
|
||||||
}
|
|
||||||
if (!$env) {
|
|
||||||
$env = 'prod';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$env = strtolower((string)$env);
|
|
||||||
$candidates = [
|
|
||||||
__DIR__ . '/' . $env . '/db_settings_basic.php',
|
|
||||||
__DIR__ . '/staging/db_settings_basic.php',
|
|
||||||
__DIR__ . '/prod/db_settings_basic.php',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($candidates as $path) {
|
|
||||||
if (file_exists($path)) {
|
|
||||||
return require $path;
|
return require $path;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException('Missing base DB config: expected config/{env}/db_settings_basic.php');
|
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ foreach (['domaindata.php', 'settings.php'] as $cfgFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Environment: staging|prod|local (example)
|
|
||||||
if (!defined('APP_ENV')) {
|
|
||||||
define('APP_ENV', 'local');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Asset versioning
|
// Asset versioning
|
||||||
if (!defined('ASSET_VERSION')) {
|
if (!defined('ASSET_VERSION')) {
|
||||||
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
define('APP_ENV', 'local');
|
|
||||||
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
||||||
define('APP_DOMAIN_PRIMARY', APP_DOMAIN_NAME);
|
define('APP_DOMAIN_PRIMARY', APP_DOMAIN_NAME);
|
||||||
define('APP_URL_PRIMARY', 'https://' . APP_DOMAIN_PRIMARY);
|
define('APP_URL_PRIMARY', 'https://' . APP_DOMAIN_PRIMARY);
|
||||||
@@ -9,3 +8,5 @@
|
|||||||
define('APP_DB_AUTO_INIT', true);
|
define('APP_DB_AUTO_INIT', true);
|
||||||
define('APP_KEA_DB_VERSION', '2.6.3');
|
define('APP_KEA_DB_VERSION', '2.6.3');
|
||||||
define('APP_BASE_DB_ENABLED', true);
|
define('APP_BASE_DB_ENABLED', true);
|
||||||
|
define('APP_BASIC_AUTH', false);
|
||||||
|
define('APP_SEARCH_DEBUG', false);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
define('APP_ENV', 'local');
|
|
||||||
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
define('ASSET_VERSION', 'dev-' . date('Ymd-His'));
|
||||||
define('APP_DOMAIN_PRIMARY', APP_DOMAIN_NAME);
|
define('APP_DOMAIN_PRIMARY', APP_DOMAIN_NAME);
|
||||||
define('APP_URL_PRIMARY', 'https://' . APP_DOMAIN_PRIMARY);
|
define('APP_URL_PRIMARY', 'https://' . APP_DOMAIN_PRIMARY);
|
||||||
@@ -9,3 +8,5 @@
|
|||||||
define('APP_DB_AUTO_INIT', true);
|
define('APP_DB_AUTO_INIT', true);
|
||||||
define('APP_KEA_DB_VERSION', '2.6.3');
|
define('APP_KEA_DB_VERSION', '2.6.3');
|
||||||
define('APP_BASE_DB_ENABLED', true);
|
define('APP_BASE_DB_ENABLED', true);
|
||||||
|
define('APP_BASIC_AUTH', true);
|
||||||
|
define('APP_SEARCH_DEBUG', true);
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||||||
// boot application (config, autoload, services)
|
// boot application (config, autoload, services)
|
||||||
require_once __DIR__ . '/../config/fileload.php';
|
require_once __DIR__ . '/../config/fileload.php';
|
||||||
|
|
||||||
// Staging-Access-Protection (Basic Auth)
|
// Access-Protection (Basic Auth)
|
||||||
$uriPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
|
$uriPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
|
||||||
$uriPath = preg_replace('~/{2,}~', '/', $uriPath);
|
$uriPath = preg_replace('~/{2,}~', '/', $uriPath);
|
||||||
$uriPath = trim($uriPath, '/');
|
$uriPath = trim($uriPath, '/');
|
||||||
$isRetoolPath = ($uriPath === 'retool' || str_starts_with($uriPath, 'retool/'));
|
$isRetoolPath = ($uriPath === 'retool' || str_starts_with($uriPath, 'retool/'));
|
||||||
if (defined('APP_ENV') && APP_ENV === 'staging' && !$isRetoolPath) {
|
if (defined('APP_BASIC_AUTH') && APP_BASIC_AUTH && !$isRetoolPath) {
|
||||||
$authUser = getenv('STAGING_AUTH_USER') ?: 'staging';
|
$authUser = getenv('STAGING_AUTH_USER') ?: 'staging';
|
||||||
$authPass = getenv('STAGING_AUTH_PASS') ?: 'staging123';
|
$authPass = getenv('STAGING_AUTH_PASS') ?: 'staging123';
|
||||||
$user = $_SERVER['PHP_AUTH_USER'] ?? null;
|
$user = $_SERVER['PHP_AUTH_USER'] ?? null;
|
||||||
|
|||||||
@@ -24,11 +24,10 @@ final class Database
|
|||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
|
|
||||||
$env = defined('APP_ENV') ? APP_ENV : 'prod';
|
|
||||||
$dbDebug = defined('APP_DB_DEBUG') && APP_DB_DEBUG;
|
$dbDebug = defined('APP_DB_DEBUG') && APP_DB_DEBUG;
|
||||||
$details = 'Database connection error.';
|
$details = 'Database connection error.';
|
||||||
|
|
||||||
if ($env !== 'prod' || $dbDebug) {
|
if ($dbDebug) {
|
||||||
$details .= ' ' . $e->getMessage();
|
$details .= ' ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ final class Search
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (defined('APP_ENV') && APP_ENV === 'staging') {
|
if (defined('APP_SEARCH_DEBUG') && APP_SEARCH_DEBUG) {
|
||||||
$logOk = [
|
$logOk = [
|
||||||
'status' => 'ok',
|
'status' => 'ok',
|
||||||
'sql' => $sql,
|
'sql' => $sql,
|
||||||
|
|||||||
Reference in New Issue
Block a user