feat: complete WebGIS implementation with nominal bantuan and cache busting
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// ================================================================
|
||||
// API: Notify — Cek apakah ada data baru sejak timestamp tertentu
|
||||
// ================================================================
|
||||
require_once __DIR__ . '/../config/database.php';
|
||||
require_once __DIR__ . '/../includes/functions.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
$db = getDB();
|
||||
$since = $_GET['since'] ?? date('Y-m-d H:i:s', strtotime('-1 minute'));
|
||||
|
||||
// Sanitasi sederhana
|
||||
$since = preg_replace('/[^0-9\-: ]/', '', $since);
|
||||
|
||||
$newMiskin = (int)$db->prepare("SELECT COUNT(*) FROM penduduk_miskin WHERE created_at > ?")->execute([$since]) ? 0 : 0;
|
||||
$stmtM = $db->prepare("SELECT COUNT(*) FROM penduduk_miskin WHERE created_at > ?");
|
||||
$stmtM->execute([$since]);
|
||||
$newMiskin = (int)$stmtM->fetchColumn();
|
||||
|
||||
$stmtI = $db->prepare("SELECT COUNT(*) FROM rumah_ibadah WHERE created_at > ?");
|
||||
$stmtI->execute([$since]);
|
||||
$newIbadah = (int)$stmtI->fetchColumn();
|
||||
|
||||
$stmtTotal = $db->query("SELECT COUNT(*) FROM penduduk_miskin WHERE status_bantuan='belum'");
|
||||
$belumDibantu = (int)$stmtTotal->fetchColumn();
|
||||
|
||||
jsonResponse([
|
||||
'success' => true,
|
||||
'new_miskin' => $newMiskin,
|
||||
'new_ibadah' => $newIbadah,
|
||||
'belum_dibantu' => $belumDibantu,
|
||||
'has_new' => ($newMiskin + $newIbadah) > 0,
|
||||
'server_time' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
Reference in New Issue
Block a user