From 9aa5517bf8efc79e991f15fd509faeeb940e8d7d Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 22 Feb 2026 06:05:40 +0000 Subject: [PATCH] Autosave: 20260222-060540 --- admin/index.php | 8 +- admin/layout.php | 44 ++++++++++- api/admin_notifications.php | 12 ++- db/config.php | 1 + includes/footer.php | 146 +++++++++--------------------------- includes/header.php | 12 +++ recharge.php | 71 +++++------------- withdraw.php | 8 +- 8 files changed, 131 insertions(+), 171 deletions(-) diff --git a/admin/index.php b/admin/index.php index 619bc4b..b1394d8 100644 --- a/admin/index.php +++ b/admin/index.php @@ -18,7 +18,7 @@ ob_start();
总用户数
-
+
@@ -29,7 +29,7 @@ ob_start();
总充值 (USDT)
-
+
@@ -40,7 +40,7 @@ ob_start();
总提现 (USDT)
-
+
@@ -51,7 +51,7 @@ ob_start();
待办事项
-
+
diff --git a/admin/layout.php b/admin/layout.php index 11a46cb..b079364 100644 --- a/admin/layout.php +++ b/admin/layout.php @@ -337,16 +337,37 @@ function renderAdminPage($content, $title = '后台管理') { utterance.lang = 'zh-CN'; window.speechSynthesis.speak(utterance); } + // Also try native notification + if (Notification.permission === "granted") { + new Notification("新消息提醒", { body: text, icon: '/assets/images/logo.png' }); + } + } + + // Request notification permission + if (Notification.permission !== "granted" && Notification.permission !== "denied") { + Notification.requestPermission(); } function checkNotifications() { const currentPage = window.location.pathname; - fetch('../api/admin_notifications.php') + const isDashboard = currentPage.includes('index.php') || currentPage.endsWith('/admin/'); + const url = isDashboard ? '../api/admin_notifications.php?stats=1' : '../api/admin_notifications.php'; + + fetch(url) .then(r => r.json()) .then(data => { if (data.success) { const counts = data.counts; + // Update dashboard stats if available + if (data.stats) { + const s = data.stats; + if (document.getElementById('stat-total-users')) document.getElementById('stat-total-users').innerText = parseInt(s.total_users).toLocaleString(); + if (document.getElementById('stat-total-recharge')) document.getElementById('stat-total-recharge').innerText = parseFloat(s.total_recharge).toLocaleString(undefined, {minimumFractionDigits: 2}); + if (document.getElementById('stat-total-withdrawal')) document.getElementById('stat-total-withdrawal').innerText = parseFloat(s.total_withdrawal).toLocaleString(undefined, {minimumFractionDigits: 2}); + if (document.getElementById('stat-pending-tasks')) document.getElementById('stat-pending-tasks').innerText = s.pending_tasks; + } + // Auto-clear current page types if (currentPage.includes('finance.php')) { fetch('../api/admin_notifications.php?action=clear&type=finance'); @@ -455,6 +476,27 @@ function renderAdminPage($content, $title = '后台管理') { if (lastSoundTotal !== -1 && soundTotal > lastSoundTotal) { speak("你有新的消息,请注意查收"); + // Show a Toast notification + if (window.Swal) { + Swal.fire({ + title: '新提醒', + text: '您有新的充提申请或客服消息', + icon: 'info', + toast: true, + position: 'top-end', + showConfirmButton: false, + timer: 5000, + timerProgressBar: true, + didOpen: (toast) => { + toast.addEventListener('mouseenter', Swal.stopTimer) + toast.addEventListener('mouseleave', Swal.resumeTimer) + toast.onclick = () => { + if (counts.recharge > 0 || counts.withdrawal > 0) location.href = 'finance.php'; + else if (counts.messages > 0) location.href = 'customer_service.php'; + }; + } + }); + } } lastTotal = total; lastSoundTotal = soundTotal; diff --git a/api/admin_notifications.php b/api/admin_notifications.php index cb380a9..1d3d675 100644 --- a/api/admin_notifications.php +++ b/api/admin_notifications.php @@ -66,6 +66,15 @@ if ($admin['is_agent']) { $total = $pending_recharge + $pending_withdrawal + $pending_kyc + $active_binary + $active_spot + $active_contract + $new_messages; $sound_trigger_count = $total; // Trigger sound for any pending action +// Add dashboard stats if requested +$stats = []; +if (isset($_GET['stats'])) { + $stats['total_users'] = getCount($db, "SELECT COUNT(*) FROM users", []); + $stats['total_recharge'] = (float)getCount($db, "SELECT SUM(amount) FROM finance_requests WHERE type='recharge' AND status='3'", []) ?: 0; + $stats['total_withdrawal'] = (float)getCount($db, "SELECT SUM(amount) FROM finance_requests WHERE type='withdrawal' AND status='3'", []) ?: 0; + $stats['pending_tasks'] = $pending_recharge + $pending_withdrawal + $pending_kyc; +} + echo json_encode([ 'success' => true, 'counts' => [ @@ -79,5 +88,6 @@ echo json_encode([ 'users' => $new_registrations, 'total' => $total, 'sound_total' => $sound_trigger_count - ] + ], + 'stats' => $stats ]); diff --git a/db/config.php b/db/config.php index b627add..399e44b 100644 --- a/db/config.php +++ b/db/config.php @@ -1,6 +1,7 @@ - diff --git a/includes/header.php b/includes/header.php index c59a7c1..99509c2 100644 --- a/includes/header.php +++ b/includes/header.php @@ -37,6 +37,18 @@ if (isset($_SESSION['user_id'])) { +