0"))[0]; $totalTransactions = mysqli_fetch_row(mysqli_query($con, "SELECT COUNT(*) FROM transactions"))[0]; $dailyVolume = mysqli_fetch_row(mysqli_query($con, "SELECT SUM(amount) FROM transactions WHERE time > (UNIX_TIMESTAMP() - 86400)"))[0] ?? 0; $avgBalance = $totalUsers > 0 ? $totalMoney / $totalUsers : 0; return [ 'total_money' => $totalMoney, 'total_users' => $totalUsers, 'total_transactions' => $totalTransactions, 'daily_volume' => $dailyVolume, 'avg_balance' => $avgBalance ]; } function getTopUsers($con, $type = 'balance', $limit = 10) { if ($type == 'balance') { $sql = "SELECT b.*, ua.FirstName, ua.LastName FROM balances b LEFT JOIN UserAccounts ua ON b.PrincipalID = ua.PrincipalID ORDER BY b.balance DESC LIMIT " . intval($limit); } elseif ($type == 'transactions') { $sql = "SELECT COUNT(*) as transaction_count, t.fromID as PrincipalID, ua.FirstName, ua.LastName FROM transactions t LEFT JOIN UserAccounts ua ON t.fromID = ua.PrincipalID WHERE t.time > (UNIX_TIMESTAMP() - (30*86400)) GROUP BY t.fromID ORDER BY transaction_count DESC LIMIT " . intval($limit); } return mysqli_query($con, $sql); } function getTransactionTypes($con, $userId = null, $days = 30) { $sql = "SELECT type, COUNT(*) as count, SUM(amount) as total_amount FROM transactions WHERE time > (UNIX_TIMESTAMP() - (" . intval($days) . "*86400))"; if ($userId) { $sql .= " AND (fromID = '" . mysqli_real_escape_string($con, $userId) . "' OR toID = '" . mysqli_real_escape_string($con, $userId) . "')"; } $sql .= " GROUP BY type ORDER BY total_amount DESC"; return mysqli_query($con, $sql); } function getRecentTransactions($con, $limit = 20) { $sql = "SELECT t.*, ua_from.FirstName as FromFirstName, ua_from.LastName as FromLastName, ua_to.FirstName as ToFirstName, ua_to.LastName as ToLastName FROM transactions t LEFT JOIN UserAccounts ua_from ON t.fromID = ua_from.PrincipalID LEFT JOIN UserAccounts ua_to ON t.toID = ua_to.PrincipalID ORDER BY t.time DESC LIMIT " . intval($limit); return mysqli_query($con, $sql); } // Parameter verarbeiten $action = isset($_GET['action']) ? $_GET['action'] : 'dashboard'; $userId = isset($_GET['user']) ? $_GET['user'] : ''; $period = isset($_GET['period']) ? $_GET['period'] : '30'; // Dummy-Benutzer-ID für Demo (normalerweise aus Session) $currentUserId = '00000000-0000-0000-0000-000000000001'; // Beispiel-User-ID ?>
Aktueller Kontostand
Ausgaben (30 Tage)
Einnahmen (30 Tage)
| Datum | Von/An | Betrag | Typ | Beschreibung |
|---|---|---|---|---|
| → ← | L$ |
Übersicht über die Grid-Wirtschaft
Geld im Umlauf
Aktive Konten
Gesamt Transaktionen
24h Volumen
| Transaktionstyp | Anzahl (30 Tage) | Volumen (30 Tage) | Durchschnitt |
|---|---|---|---|
| L$ | L$ |
Von:
An: