50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
header("Access-Control-Allow-Origin: *");
|
||
|
|
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||
|
|
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-API-KEY");
|
||
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
||
|
|
|
||
|
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||
|
|
http_response_code(200);
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
header('Content-Type: application/json');
|
||
|
|
|
||
|
|
// TODO: Implementasi logic events di sini
|
||
|
|
// Validasi Authorization token
|
||
|
|
/*
|
||
|
|
$headers = getallheaders();
|
||
|
|
if (!isset($headers['Authorization'])) {
|
||
|
|
http_response_code(401);
|
||
|
|
echo json_encode(['error' => 'unauthorized']);
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Validasi X-API-KEY
|
||
|
|
if (!isset($_SERVER['HTTP_X_API_KEY']) || $_SERVER['HTTP_X_API_KEY'] !== 'RETRIBUSI-DASHBOARD-KEY') {
|
||
|
|
http_response_code(401);
|
||
|
|
echo json_encode(['error' => 'unauthorized']);
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Validasi role admin
|
||
|
|
// ... kode validasi role admin ...
|
||
|
|
|
||
|
|
// Logic events
|
||
|
|
$date = $_GET['date'] ?? null;
|
||
|
|
$location_code = $_GET['location_code'] ?? null;
|
||
|
|
$gate_code = $_GET['gate_code'] ?? null;
|
||
|
|
$category = $_GET['category'] ?? null;
|
||
|
|
$page = intval($_GET['page'] ?? 1);
|
||
|
|
$limit = intval($_GET['limit'] ?? 20);
|
||
|
|
|
||
|
|
// ... kode events yang sudah ada ...
|
||
|
|
|
||
|
|
echo json_encode([
|
||
|
|
'events' => [],
|
||
|
|
'total_pages' => 1,
|
||
|
|
'current_page' => $page
|
||
|
|
]);
|
||
|
|
*/
|