From 99d43b4ccf85851b2b94123c9119e3e12a202567 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sun, 10 May 2026 01:11:44 +0300 Subject: [PATCH] add new featurs like realtime 2026-5-10-11 --- functions.php | 2 +- ride/kazan/update.php | 6 +++--- test_audit.php | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 test_audit.php diff --git a/functions.php b/functions.php index 350ae3b..7ea50f1 100755 --- a/functions.php +++ b/functions.php @@ -479,6 +479,6 @@ function logAudit($con, $adminId, $action, $tableName = null, $recordId = null, return true; } catch (Exception $e) { error_log("Audit Log Error: " . $e->getMessage()); - return false; + return $e->getMessage(); } } diff --git a/ride/kazan/update.php b/ride/kazan/update.php index bb31470..eb9f5c8 100644 --- a/ride/kazan/update.php +++ b/ride/kazan/update.php @@ -31,12 +31,12 @@ $stmt = $con->prepare($sql); $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) { - jsonSuccess(null, "Kazan data updated successfully"); + jsonSuccess(null, "Kazan data updated successfully. Audit: " . ($auditResult === true ? 'OK' : $auditResult)); } else { // 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)); } ?> \ No newline at end of file diff --git a/test_audit.php b/test_audit.php new file mode 100644 index 0000000..aff2743 --- /dev/null +++ b/test_audit.php @@ -0,0 +1,33 @@ +فحص نظام السجلات (Audit Log Test)"; + +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 "

✅ نجاح: تم إضافة سجل اختباري بنجاح إلى قاعدة البيانات.

"; + } else { + echo "

⚠️ فشل الإضافة ولكن لم يظهر خطأ!

"; + } +} catch (Exception $e) { + echo "

❌ خطأ في قاعدة البيانات: " . $e->getMessage() . "

"; +} +?>