<?php
require_once 'db_pdo.php';
require_once 'auth.php';
require_admin_login(true);
header('Content-Type: application/json');

try {
    $stmt = $pdo->query("SELECT * FROM rumah_ibadah ORDER BY nama ASC");
    $data = $stmt->fetchAll();

    echo json_encode([
        'success' => true,
        'data' => $data
    ]);
} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => $e->getMessage()]);
}
