Initial commit

This commit is contained in:
Porawit Dongwang
2026-09-16 23:20:08 +07:00
commit 0041668dbb
32577 changed files with 3687927 additions and 0 deletions
@@ -0,0 +1,37 @@
<?php
require_once '../includes/auth.php';
require_once '../includes/db.php';
require_once '../includes/api_helper.php';
// Check if user is admin
if (!isAdmin()) {
sendJson(403, ['error' => 'Permission denied. Admins only.']);
}
$method = $_SERVER['REQUEST_METHOD'];
function sendJson($statusCode, $data) {
http_response_code($statusCode);
header('Content-Type: application/json');
echo json_encode($data);
exit();
}
if ($method === 'GET') {
try {
$stmt = $pdo->query("
SELECT al.id, al.user_id, al.action, al.table_name, al.record_id, al.ip_address, al.created_at, u.full_name as user_name
FROM activity_logs al
LEFT JOIN users u ON al.user_id = u.id
ORDER BY al.created_at DESC
LIMIT 1000
");
$logs = $stmt->fetchAll(PDO::FETCH_ASSOC);
sendJson(200, ['logs' => $logs]);
} catch (PDOException $e) {
sendJson(500, ['error' => 'Database error: ' . $e->getMessage()]);
}
} else {
sendJson(405, ['error' => 'Method Not Allowed']);
}
?>