From 2b1f7e3a383060c559779dafec66315e2d470386 Mon Sep 17 00:00:00 2001 From: luptmoor Date: Tue, 21 Apr 2026 13:49:10 +0200 Subject: [PATCH 1/4] SSL mode changed to disable --- public/api/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/api/init.php b/public/api/init.php index 1519732..37f2952 100644 --- a/public/api/init.php +++ b/public/api/init.php @@ -33,7 +33,7 @@ try { PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false ]; - $dsn = "pgsql:host=$host;dbname=$db;port=$port"; + $dsn = "pgsql:host=$host;dbname=$db;port=$port;sslmode=disable"; $pdo = new PDO($dsn, $user, $pass, $opt); -- 2.49.1 From c52dbf618eb45fb5be0b86c23bf18776bd29575c Mon Sep 17 00:00:00 2001 From: luptmoor Date: Thu, 23 Apr 2026 09:28:35 +0200 Subject: [PATCH 2/4] added comments for slug as env var --- public/admin.php | 2 +- public/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/admin.php b/public/admin.php index 697c4ed..9d137ec 100644 --- a/public/admin.php +++ b/public/admin.php @@ -43,7 +43,7 @@ if ($page === 'logout') { // ----------------------------------------------------------------- $pdo = get_db(); $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug"); -$stmt->execute([':slug' => 'lohne']); +$stmt->execute([':slug' => 'lohne']); # TODO: add slug as env var $municipality = $stmt->fetch(); // Shows Login Page if not authenticated diff --git a/public/index.php b/public/index.php index b3b189e..4c2e12e 100644 --- a/public/index.php +++ b/public/index.php @@ -14,7 +14,7 @@ require_once __DIR__ . '/api/db.php'; // ----------------------------------------------------------------- $pdo = get_db(); $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug"); -$stmt->execute([':slug' => 'lohne']); +$stmt->execute([':slug' => 'lohne']); # TODO: add slug as env var $municipality = $stmt->fetch(); if (!$municipality) { -- 2.49.1 From 0b02b435ef41692bb48ae5ea8bc86fb5ac1317ec Mon Sep 17 00:00:00 2001 From: luptmoor Date: Thu, 23 Apr 2026 10:01:18 +0200 Subject: [PATCH 3/4] added municipality slug as env var --- .env.example | 7 +++++-- public/admin.php | 13 ++++++++++++- public/index.php | 13 ++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 6daedb4..755543a 100644 --- a/.env.example +++ b/.env.example @@ -3,5 +3,8 @@ POSTGRES_HOSTNAME=postgres_host POSTGRES_PORT=postgres_port POSTGRES_DB=postgres_database POSTGRES_USER=postgres_user -POSTGRES_PASSWORD= -ADMIN_PASSWORD= \ No newline at end of file +POSTGRES_PASSWORD=xxxx + +ADMIN_PASSWORD=xxxxx + +MUNICIPALITY_SLUG=lohne \ No newline at end of file diff --git a/public/admin.php b/public/admin.php index 9d137ec..f0ca626 100644 --- a/public/admin.php +++ b/public/admin.php @@ -11,6 +11,17 @@ // - Analytics Tab // ===================================================================== +// Reads Environment Configfile +$envFile = __DIR__ . '/../../.env'; +if (file_exists($envFile)) { + $lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + if (strpos(trim($line), '#') === 0) continue; + list($key, $value) = array_map('trim', explode('=', $line, 2)); + putenv("$key=$value"); + } +} + require_once __DIR__ . '/api/db.php'; require_once __DIR__ . '/api/auth.php'; @@ -43,7 +54,7 @@ if ($page === 'logout') { // ----------------------------------------------------------------- $pdo = get_db(); $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug"); -$stmt->execute([':slug' => 'lohne']); # TODO: add slug as env var +$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); # TODO: test slug as env var $municipality = $stmt->fetch(); // Shows Login Page if not authenticated diff --git a/public/index.php b/public/index.php index 4c2e12e..b151586 100644 --- a/public/index.php +++ b/public/index.php @@ -5,6 +5,17 @@ // Renders Leaflet Map Interface including Leaflet Plugins // ===================================================================== +// Reads Environment Configfile +$envFile = __DIR__ . '/../../.env'; +if (file_exists($envFile)) { + $lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + if (strpos(trim($line), '#') === 0) continue; + list($key, $value) = array_map('trim', explode('=', $line, 2)); + putenv("$key=$value"); + } +} + require_once __DIR__ . '/api/db.php'; // ----------------------------------------------------------------- @@ -14,7 +25,7 @@ require_once __DIR__ . '/api/db.php'; // ----------------------------------------------------------------- $pdo = get_db(); $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug"); -$stmt->execute([':slug' => 'lohne']); # TODO: add slug as env var +$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); # TODO: test slug as env var $municipality = $stmt->fetch(); if (!$municipality) { -- 2.49.1 From 025cd975f0fa03b10730eae7b510541ed8c826e6 Mon Sep 17 00:00:00 2001 From: luptmoor Date: Thu, 23 Apr 2026 10:10:53 +0200 Subject: [PATCH 4/4] removed TODOs after successful test --- public/admin.php | 2 +- public/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/admin.php b/public/admin.php index f0ca626..144d407 100644 --- a/public/admin.php +++ b/public/admin.php @@ -54,7 +54,7 @@ if ($page === 'logout') { // ----------------------------------------------------------------- $pdo = get_db(); $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug"); -$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); # TODO: test slug as env var +$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); $municipality = $stmt->fetch(); // Shows Login Page if not authenticated diff --git a/public/index.php b/public/index.php index b151586..7423017 100644 --- a/public/index.php +++ b/public/index.php @@ -25,7 +25,7 @@ require_once __DIR__ . '/api/db.php'; // ----------------------------------------------------------------- $pdo = get_db(); $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug"); -$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); # TODO: test slug as env var +$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]); $municipality = $stmt->fetch(); if (!$municipality) { -- 2.49.1