Update api.php

This commit is contained in:
2026-06-09 07:18:33 +00:00
parent 11706d80a8
commit be292d42c7
+8 -12
View File
@@ -1,25 +1,21 @@
<?php <?php
session_start(); session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
header("Content-Type: application/json"); header("Content-Type: application/json");
// ── KONFIGURASI DATABASE INTERNAL COOLIFY ───────────────────── // ── KONFIGURASI DATABASE ──────────────────────────────────────
$host = 'mysql-database-xwc8cwc88g4ksccsw0880848'; $host = getenv('DB_HOST') ?: $_ENV['DB_HOST'] ?: $_SERVER['DB_HOST'] ?: '127.0.0.1';
$port = '3306'; $db = getenv('DB_NAME') ?: $_ENV['DB_NAME'] ?: $_SERVER['DB_NAME'] ?: 'webgis_poverty';
$db = 'default'; $user = getenv('DB_USER') ?: $_ENV['DB_USER'] ?: $_SERVER['DB_USER'] ?: 'root';
$user = 'mysql'; $pass = getenv('DB_PASS') ?: $_ENV['DB_PASS'] ?: $_SERVER['DB_PASS'] ?: '';
$pass = 'hKZQ51CbVYQsSQL7j5799WtF0kgqTHg4hNRgKo6fq3WSQAHHDFBz3gtIPRAMfTcO';
try { try {
$pdo = new PDO("mysql:host=$host;port=$port;dbname=$db;charset=utf8mb4", $user, $pass, [ $pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
PDO::ATTR_TIMEOUT => 5
]); ]);
} catch (PDOException $e) { } catch (PDOException $e) {
http_response_code(500); http_response_code(500);
echo json_encode(['error' => 'Gagal Konek Internal: ' . $e->getMessage()]); echo json_encode(['error' => 'Koneksi DB Gagal: ' . $e->getMessage()]);
exit; exit;
} }