Files
pontianak-poverty-webgis/config.php
T

24 lines
682 B
PHP

<?php
function loadEnv($path) {
if (!file_exists($path)) return;
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) continue;
$parts = explode('=', $line, 2);
if (count($parts) === 2) {
$_ENV[trim($parts[0])] = trim($parts[1]);
}
}
}
loadEnv(__DIR__ . '/.env');
$host = $_ENV['DB_HOST'] ?? 'localhost';
$user = $_ENV['DB_USER'] ?? 'root';
$pass = $_ENV['DB_PASS'] ?? '';
$db = $_ENV['DB_NAME'] ?? 'webgis_pontianak';
$conn = mysqli_connect($host, $user, $pass, $db);
if (!$conn) {
die('Koneksi gagal: ' . mysqli_connect_error());
}