dump
This commit is contained in:
@@ -3,9 +3,43 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
header('Content-Type: text/plain; charset=utf-8');
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
|
|
||||||
$conf = @include __DIR__ . '/../../inc/config.php';
|
function loadProjectConfig(): ?array
|
||||||
if (!is_array($conf) || empty($conf['projectdb']) || !is_array($conf['projectdb'])) {
|
{
|
||||||
|
$paths = [
|
||||||
|
dirname(__DIR__, 2) . '/inc/config.php',
|
||||||
|
dirname(__DIR__, 2) . '/config/emailtemplate.conf.php',
|
||||||
|
dirname(__DIR__) . '/inc/config.php',
|
||||||
|
];
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
if (!is_file($path)) continue;
|
||||||
|
try {
|
||||||
|
$cfg = include $path;
|
||||||
|
if (is_array($cfg) && isset($cfg['projectdb']) && is_array($cfg['projectdb'])) {
|
||||||
|
return $cfg;
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$env = [
|
||||||
|
'db_host' => getenv('DB_HOST') ?: getenv('DB_TPL_HOST'),
|
||||||
|
'db_name' => getenv('DB_NAME') ?: getenv('DB_TPL_NAME'),
|
||||||
|
'db_user' => getenv('DB_USER') ?: getenv('DB_TPL_USER'),
|
||||||
|
'db_pass' => getenv('DB_PASS') ?: getenv('DB_TPL_PASS'),
|
||||||
|
'db_charset' => getenv('DB_CHARSET') ?: 'utf8mb4',
|
||||||
|
'db_port' => (int)(getenv('DB_PORT') ?: 3306),
|
||||||
|
'db_socket' => getenv('DB_SOCKET') ?: null,
|
||||||
|
];
|
||||||
|
if (!empty($env['db_name']) && !empty($env['db_user'])) {
|
||||||
|
return ['projectdb' => $env];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conf = loadProjectConfig();
|
||||||
|
if (!$conf || !is_array($conf['projectdb'])) {
|
||||||
echo "-- Fehler: config.php konnte nicht geladen werden oder enthält keine projectdb-Einträge.\n";
|
echo "-- Fehler: config.php konnte nicht geladen werden oder enthält keine projectdb-Einträge.\n";
|
||||||
|
echo "-- Hinweis: Stelle sicher, dass inc/config.php oder config/emailtemplate.conf.php auf dem Server vorhanden und lesbar ist.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user