Files
UAS_WEBGIS_AlifaAisyahRahma…/Web GIS Layer/config.php
T
2026-06-10 16:47:45 +07:00

47 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// ============================================================
// Konfigurasi Koneksi Database
// WebGIS Manajemen Data Jalan & Parsil Tanah
// ============================================================
define('DB_HOST', 'vg4so4ccs0444o4cgkssgos8');
define('DB_PORT', 3306);
define('DB_USER', 'mysql');
define('DB_PASS', 'tg9lvPlr4hgUhgtT7aPq9XelkCEvvMGtsoV8eB4dD5FAkz891PwkJT340xmaEWxL');
define('DB_NAME', 'default');
define('DB_CHARSET', 'utf8mb4');
// ── Buat koneksi ─────────────────────────────────────────────
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT);
if ($conn->connect_error) {
http_response_code(500);
die(json_encode([
'status' => 'error',
'message' => 'Koneksi database gagal: ' . $conn->connect_error
]));
}
$conn->set_charset(DB_CHARSET);
// ── Fungsi utilitas ──────────────────────────────────────────
/**
* Kembalikan response JSON dan hentikan eksekusi.
*/
function jsonResponse(array $data, int $httpCode = 200): void
{
http_response_code($httpCode);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
}
/**
* Sanitasi input string.
*/
function clean(string $value): string
{
return htmlspecialchars(strip_tags(trim($value)));
}