commit changes

This commit is contained in:
2026-03-03 02:29:04 +01:00
parent e61f9fb889
commit c982cf1b51
7 changed files with 13 additions and 33 deletions

View File

@@ -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');

View File

@@ -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'));

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();
} }

View File

@@ -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,