Persiapan hosting: config DB, perbaikan role, fix redirect

This commit is contained in:
Athallah Ghathfan Aqila
2026-06-13 13:56:43 +07:00
parent e3d7750f11
commit 46e999a9d0
9 changed files with 255 additions and 26 deletions
+9 -5
View File
@@ -1,9 +1,13 @@
<?php
$host = getenv('DB_HOST') ?: '127.0.0.1';
$user = getenv('DB_USER') ?: 'root';
$pass = getenv('DB_PASS') ?: '';
$name = getenv('DB_NAME') ?: 'db_webgis';
$port = (int)(getenv('DB_PORT') ?: 3306);
if (!defined('DB_HOST')) {
$cfg = __DIR__ . '/config.php';
if (file_exists($cfg)) require_once $cfg;
}
$host = defined('DB_HOST') ? DB_HOST : (getenv('DB_HOST') ?: '127.0.0.1');
$user = defined('DB_USER') ? DB_USER : (getenv('DB_USER') ?: 'root');
$pass = defined('DB_PASS') ? DB_PASS : (getenv('DB_PASS') ?: '');
$name = defined('DB_NAME') ? DB_NAME : (getenv('DB_NAME') ?: 'db_webgis');
$port = defined('DB_PORT') ? (int)DB_PORT : (int)(getenv('DB_PORT') ?: 3306);
$conn = mysqli_connect($host, $user, $pass, $name, $port);
if (!$conn) {
die(json_encode(['status' => 'error', 'message' => 'Koneksi database gagal: ' . mysqli_connect_error()]));