From c1a97a368fd42d8295ebfc9c10064ac8c29463ef Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sun, 10 May 2026 02:07:14 +0300 Subject: [PATCH] add new featurs like realtime 2026-5-10-18 --- Admin/v2/security/audit_logs.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Admin/v2/security/audit_logs.php b/Admin/v2/security/audit_logs.php index 4bb9c89..8cb4b25 100644 --- a/Admin/v2/security/audit_logs.php +++ b/Admin/v2/security/audit_logs.php @@ -1,26 +1,31 @@ getMessage() . "\n", FILE_APPEND); + http_response_code(500); + echo json_encode(['status' => 'failure', 'message' => 'connect failed: ' . $e->getMessage()]); + exit; +} // ── فحص الصلاحيات ──────────────────────────────────────── if ($role !== 'super_admin' && $role !== 'admin') { - $msg = "Unauthorized. role=$role, user_id=$user_id"; - file_put_contents($debugFile, " → BLOCKED: $msg\n", FILE_APPEND); - jsonError($msg, 403); + file_put_contents($debugFile, " → BLOCKED: role=$role\n", FILE_APPEND); + jsonError("Unauthorized. role=$role", 403); } try { - // فحص وجود الجدول $tableExists = $con->query("SHOW TABLES LIKE 'admin_audit_log'")->rowCount() > 0; if (!$tableExists) { - file_put_contents($debugFile, " → Table admin_audit_log NOT FOUND\n", FILE_APPEND); + file_put_contents($debugFile, " → Table NOT FOUND\n", FILE_APPEND); jsonSuccess([], 'Audit log table not found'); } @@ -41,7 +46,7 @@ try { jsonSuccess($logs); } catch (Exception $e) { - file_put_contents($debugFile, " → ERROR: " . $e->getMessage() . "\n", FILE_APPEND); - jsonError('Audit log query failed: ' . $e->getMessage(), 500); + file_put_contents($debugFile, " → QUERY ERROR: " . $e->getMessage() . "\n", FILE_APPEND); + jsonError('Query failed: ' . $e->getMessage(), 500); } ?>