-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage_statistics.php
150 lines (138 loc) · 4.12 KB
/
usage_statistics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
session_start();
require_once 'functions.php';
// Admin-Login prüfen
if (!isset($_SESSION['admin_logged_in'])) {
header("Location: login.php");
exit;
}
// Nutzungsliste abrufen
function getUsageLogs() {
$pdo = getDatabaseConnection();
$stmt = $pdo->query("SELECT * FROM usage_logs ORDER BY timestamp DESC");
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Mods-Statistik abrufen
function getModStatistics() {
$pdo = getDatabaseConnection();
$stmt = $pdo->query(
"SELECT mod_name, COUNT(*) AS usage_count
FROM usage_logs
GROUP BY mod_name
ORDER BY usage_count DESC"
);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Maps-Statistik abrufen
function getMapStatistics() {
$pdo = getDatabaseConnection();
$stmt = $pdo->query(
"SELECT map_name, COUNT(*) AS usage_count
FROM usage_logs
GROUP BY map_name
ORDER BY usage_count DESC"
);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// Server-Statistik abrufen
function getServerStatistics() {
$pdo = getDatabaseConnection();
$stmt = $pdo->query(
"SELECT server_id, COUNT(*) AS usage_count
FROM usage_logs
GROUP BY server_id
ORDER BY usage_count DESC"
);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
$usage_logs = getUsageLogs();
$mod_statistics = getModStatistics();
$map_statistics = getMapStatistics();
$server_statistics = getServerStatistics();
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nutzungsstatistiken</title>
</head>
<body>
<h1>Nutzungsstatistiken</h1>
<h2>Letzte Nutzungen</h2>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Server ID</th>
<th>Map</th>
<th>Mod</th>
<th>Timestamp</th>
</tr>
</thead>
<tbody>
<?php foreach ($usage_logs as $log): ?>
<tr>
<td><?php echo htmlspecialchars($log['id']); ?></td>
<td><?php echo htmlspecialchars($log['server_id']); ?></td>
<td><?php echo htmlspecialchars($log['map_name']); ?></td>
<td><?php echo htmlspecialchars($log['mod_name']); ?></td>
<td><?php echo htmlspecialchars($log['timestamp']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2>Mod-Statistiken</h2>
<table border="1">
<thead>
<tr>
<th>Mod</th>
<th>Anzahl</th>
</tr>
</thead>
<tbody>
<?php foreach ($mod_statistics as $mod): ?>
<tr>
<td><?php echo htmlspecialchars($mod['mod_name']); ?></td>
<td><?php echo htmlspecialchars($mod['usage_count']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2>Map-Statistiken</h2>
<table border="1">
<thead>
<tr>
<th>Map</th>
<th>Anzahl</th>
</tr>
</thead>
<tbody>
<?php foreach ($map_statistics as $map): ?>
<tr>
<td><?php echo htmlspecialchars($map['map_name']); ?></td>
<td><?php echo htmlspecialchars($map['usage_count']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2>Server-Statistiken</h2>
<table border="1">
<thead>
<tr>
<th>Server ID</th>
<th>Anzahl</th>
</tr>
</thead>
<tbody>
<?php foreach ($server_statistics as $server): ?>
<tr>
<td><?php echo htmlspecialchars($server['server_id']); ?></td>
<td><?php echo htmlspecialchars($server['usage_count']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<a href="admin.php">Zurück zum Admin-Dashboard</a>
</body>
</html>