70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php /*error_reporting(E_ALL)*/;
|
|
|
|
$develop = getenv('DEVELOP');
|
|
|
|
// Funktion, um .env-Datei zu laden
|
|
if (!function_exists('loadEnv')) {
|
|
function loadEnv($path)
|
|
{
|
|
if (!file_exists($path)) {
|
|
throw new Exception(".env file not found at: $path");
|
|
}
|
|
|
|
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
foreach ($lines as $line) {
|
|
// Kommentare überspringen
|
|
if (strpos(trim($line), '#') === 0) continue;
|
|
|
|
// Schlüssel/Wert trennen
|
|
if (strpos($line, '=') !== false) {
|
|
list($name, $value) = explode('=', $line, 2);
|
|
$name = trim($name);
|
|
$value = trim($value);
|
|
|
|
// Entferne Anführungszeichen, falls vorhanden
|
|
$value = trim($value, "\"'");
|
|
|
|
// In Umgebungsvariablen schreiben
|
|
putenv("$name=$value");
|
|
$_ENV[$name] = $value;
|
|
$_SERVER[$name] = $value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// .env laden
|
|
try {
|
|
loadEnv(__DIR__ . '/../.env');
|
|
} catch (Exception $e) {
|
|
die("Fehler beim Laden der .env: " . $e->getMessage());
|
|
}
|
|
|
|
|
|
if ($develop == 'true') {
|
|
$host = getenv('DB_HOST') ?: 'gitea-db';
|
|
$user = getenv('DB_USER') ?: 'sternwarte';
|
|
$pass = getenv('DB_PASSWORD') ?: getenv('MYSQL_PASSWD');
|
|
$dbase = getenv('DB_NAME') ?: 'sternwarte';
|
|
} else {
|
|
$host = 'localhost';
|
|
$user = 'db310927';
|
|
$pass = 'vetivene-albarco-earner';
|
|
$dbase = 'db310927';
|
|
}
|
|
|
|
$db = mysqli_connect($host, $user, $pass, $dbase) or die("Couldn't connect to the database_server $host - Develop = $develop");
|
|
mysqli_select_db($db,$dbase) or die("Couldn't select the database");
|
|
|
|
mysqli_query($db,"SET NAMES 'utf8'");
|
|
mysqli_query($db,"SET CHARACTER SET 'utf8'");
|
|
|
|
date_default_timezone_set('Europe/Berlin');
|
|
|
|
// Weitere Konstanten:
|
|
$maxBesucher = 25;
|
|
$defaultabsender = 'anmeldung@sternwarte-welzheim.de';
|
|
$maxProPerson = 10;
|
|
|
|
?>
|