Update Project 3 files
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* get_laporan_user.php — Ambil semua laporan (untuk history masyarakat)
|
||||
* Masyarakat bisa melihat semua laporan tapi read-only
|
||||
*/
|
||||
session_start();
|
||||
require_once 'koneksi.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Belum login']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = ['success' => true, 'reports' => []];
|
||||
|
||||
$result = $conn->query("SELECT * FROM laporan ORDER BY created_at DESC LIMIT 100");
|
||||
if ($result) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$response['reports'][] = [
|
||||
'id' => (int)$row['id'],
|
||||
'name' => $row['pelapor'] ?? 'Anonim',
|
||||
'text' => $row['deskripsi'],
|
||||
'imgBase64'=> $row['foto_base64'] ?? null,
|
||||
'time' => date('d/m/Y H:i', strtotime($row['created_at']))
|
||||
];
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
$conn->close();
|
||||
Reference in New Issue
Block a user