prepare("SELECT * FROM admin_users WHERE username = :username LIMIT 1"); $stmt->execute([':username' => $username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { $_SESSION['admin_logged_in'] = true; $_SESSION['admin_username'] = $username; header('Location: index.php'); exit; } else { $loginError = 'Invalid username or password'; } } // ─── Logout Handler ─── if (isset($_GET['action']) && $_GET['action'] === 'logout') { session_destroy(); header('Location: index.php'); exit; } // ─── Toggle Device Active Status ─── if (isset($_GET['action']) && $_GET['action'] === 'toggle' && isset($_GET['id']) && !empty($_SESSION['admin_logged_in'])) { $db = getDB(); $stmt = $db->prepare("UPDATE devices SET is_active = NOT is_active WHERE id = :id"); $stmt->execute([':id' => (int)$_GET['id']]); header('Location: index.php'); exit; } // ─── Delete Device ─── if (isset($_GET['action']) && $_GET['action'] === 'delete' && isset($_GET['id']) && !empty($_SESSION['admin_logged_in'])) { $db = getDB(); $stmt = $db->prepare("DELETE FROM devices WHERE id = :id"); $stmt->execute([':id' => (int)$_GET['id']]); header('Location: index.php'); exit; } // ─── Check Auth ─── $isLoggedIn = !empty($_SESSION['admin_logged_in']); // ─── Fetch Stats (if logged in) ─── $stats = []; $devices = []; $search = trim($_GET['search'] ?? ''); if ($isLoggedIn) { $db = getDB(); // Total devices $stats['total'] = $db->query("SELECT COUNT(*) FROM devices")->fetchColumn(); // Active devices (seen in last 10 minutes) $stats['online'] = $db->query("SELECT COUNT(*) FROM devices WHERE last_seen >= DATE_SUB(NOW(), INTERVAL 10 MINUTE) AND is_active = 1")->fetchColumn(); // Active today $stats['today'] = $db->query("SELECT COUNT(*) FROM devices WHERE DATE(last_seen) = CURDATE()")->fetchColumn(); // Disabled devices $stats['disabled'] = $db->query("SELECT COUNT(*) FROM devices WHERE is_active = 0")->fetchColumn(); // Unique versions $versionRows = $db->query("SELECT app_version, COUNT(*) as cnt FROM devices GROUP BY app_version ORDER BY cnt DESC")->fetchAll(); // OS breakdown $osRows = $db->query("SELECT os_name, COUNT(*) as cnt FROM devices GROUP BY os_name ORDER BY cnt DESC")->fetchAll(); // Device list $query = "SELECT * FROM devices"; $params = []; if ($search) { $query .= " WHERE device_id LIKE :search OR device_name LIKE :search2 OR ip_address LIKE :search3"; $params = [':search' => "%$search%", ':search2' => "%$search%", ':search3' => "%$search%"]; } $query .= " ORDER BY last_seen DESC LIMIT 200"; $stmt = $db->prepare($query); $stmt->execute($params); $devices = $stmt->fetchAll(); } ?> RajbariIT Player — Admin

🎬 RajbariIT Player

Admin Dashboard

Total Installs
Online Now
Active Today
Disabled

📦 App Versions

v devices
No data yet

💻 Operating Systems

devices
No data yet

📋 All Devices

= strtotime('-10 minutes'); $isDisabled = !$d['is_active']; ?>
# App ID Device Name OS Version IP First Seen Last Seen Status Actions
v Disabled Online Offline Delete
No devices registered yet