64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
use Dotenv\Dotenv;
|
|
|
|
require __DIR__ . '/../../composer/vendor/autoload.php';
|
|
|
|
$envFile = realpath(__DIR__ . '/../../config/.env.db-tables');
|
|
|
|
if ($envFile === false) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'success' => false,
|
|
'message' => "Environment file not found"
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$envDir = dirname($envFile);
|
|
|
|
$dotenv = Dotenv::createImmutable($envDir, '.env.db-tables');
|
|
|
|
$dotenv->load();
|
|
} catch (Throwable $e) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'success' => false,
|
|
'message' => "Dotenv error"
|
|
]);
|
|
}
|
|
|
|
|
|
$prefix = $_ENV['DB_PREFIX'] ?? '';
|
|
|
|
|
|
$tableDefinitions = [
|
|
'Turnerinnen' => 'DB_TABLE_TURNERINNEN',
|
|
'Orders' => 'DB_TABLE_ORDERS',
|
|
'BasketItems' => 'DB_TABLE_BASKET_ITEMS',
|
|
'Var' => 'DB_TABLE_VARIABLES',
|
|
'OTL' => 'DB_TABLE_OTL',
|
|
'KrProtokoll' => 'DB_TABLE_KR_PROTOKOLL',
|
|
'Programme' => 'DB_TABLE_PROGRAMME',
|
|
'InternUsers' => 'DB_TABLE_INTERN_USERS',
|
|
'Vereine' => 'DB_TABLE_VEREINE',
|
|
'Abt' => 'DB_TABLE_ABTEILUNGEN',
|
|
'TurnerinnenAbt' => 'DB_TABLE_TURNERINNEN_ABTEILUNGEN',
|
|
'Geraete' => 'DB_TABLE_GERAETE',
|
|
'Audiofiles' => 'DB_TABLE_AUDIOFILES',
|
|
'Noten' => 'DB_TABLE_NOTEN',
|
|
'NotenBezeichnungen' => 'DB_TABLE_NOTEN_BEZEICHNUNGEN'
|
|
];
|
|
|
|
|
|
foreach ($tableDefinitions as $baseName => $envVarKey) {
|
|
|
|
$rawTableName = $_ENV[$envVarKey] ?? '';
|
|
|
|
$fullTableName = $prefix . $rawTableName;
|
|
|
|
$variableName = 'table' . ucfirst($baseName);
|
|
|
|
$$variableName = $fullTableName;
|
|
} |