add new featurs like realtime 2026-5-10-11

This commit is contained in:
Hamza-Ayed
2026-05-10 01:11:44 +03:00
parent 8d37725ffb
commit 99d43b4ccf
3 changed files with 37 additions and 4 deletions

View File

@@ -479,6 +479,6 @@ function logAudit($con, $adminId, $action, $tableName = null, $recordId = null,
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
error_log("Audit Log Error: " . $e->getMessage()); error_log("Audit Log Error: " . $e->getMessage());
return false; return $e->getMessage();
} }
} }

View File

@@ -31,12 +31,12 @@ $stmt = $con->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
// تسجيل العملية في السجل دائماً (حتى لو لم تتغير القيمة) لضمان الشفافية // تسجيل العملية في السجل دائماً (حتى لو لم تتغير القيمة) لضمان الشفافية
logAudit($con, $user_id, "تحديث عمولة/أسعار النظام (Kazan)", "kazan", $id, $params); $auditResult = logAudit($con, $user_id ?? 'unknown_admin', "تحديث عمولة/أسعار النظام (Kazan)", "kazan", $id, $params);
if ($stmt->rowCount() > 0) { if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Kazan data updated successfully"); jsonSuccess(null, "Kazan data updated successfully. Audit: " . ($auditResult === true ? 'OK' : $auditResult));
} else { } else {
// If no rows were changed but execute was successful, it might be because the data is the same // If no rows were changed but execute was successful, it might be because the data is the same
jsonSuccess(null, "Kazan data remains unchanged or updated"); jsonSuccess(null, "Kazan data remains unchanged or updated. Audit: " . ($auditResult === true ? 'OK' : $auditResult));
} }
?> ?>

33
test_audit.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
require_once __DIR__ . '/connect.php';
// لتعطيل الفحص الأمني مؤقتاً لأغراض الفحص من المتصفح
// لا تقم برفع هذا الملف إلى السيرفر الحي إلا للفحص ثم حذفه
ini_set('display_errors', 1);
error_reporting(E_ALL);
echo "<h3>فحص نظام السجلات (Audit Log Test)</h3>";
try {
$stmt = $con->prepare("
INSERT INTO `admin_audit_log` (`admin_id`, `action`, `table_name`, `record_id`, `details`)
VALUES (:admin_id, :action, :table_name, :record_id, :details)
");
$result = $stmt->execute([
':admin_id' => 'test_admin_01',
':action' => 'فحص النظام',
':table_name' => 'test_table',
':record_id' => '999',
':details' => json_encode(['status' => 'test'], JSON_UNESCAPED_UNICODE)
]);
if ($result) {
echo "<p style='color: green;'>✅ نجاح: تم إضافة سجل اختباري بنجاح إلى قاعدة البيانات.</p>";
} else {
echo "<p style='color: orange;'>⚠️ فشل الإضافة ولكن لم يظهر خطأ!</p>";
}
} catch (Exception $e) {
echo "<p style='color: red;'>❌ خطأ في قاعدة البيانات: " . $e->getMessage() . "</p>";
}
?>