@@ -26,11 +26,29 @@ function toCommunityID($id) {
26
26
$ whereClause = '' ;
27
27
$ params = [];
28
28
29
+ $ serverIds = [];
30
+ try {
31
+ $ serverIds = $ pdo ->query ("SELECT DISTINCT server_id FROM chat_logs " )->fetchAll (PDO ::FETCH_COLUMN );
32
+ } catch (PDOException $ e ) {
33
+ error_log ("Error fetching server IDs: " . $ e ->getMessage ());
34
+ }
35
+
36
+ $ selectedServerId = isset ($ _GET ['server_id ' ]) ? $ _GET ['server_id ' ] : null ;
37
+
29
38
if ($ search !== '' ) {
30
39
$ whereClause = "WHERE CONCAT(date, steam_id, player_name, message) LIKE :search " ;
31
40
$ params [':search ' ] = "% $ search% " ;
32
41
}
33
42
43
+ if ($ selectedServerId ) {
44
+ if ($ whereClause ) {
45
+ $ whereClause .= " AND server_id = :server_id " ;
46
+ } else {
47
+ $ whereClause = "WHERE server_id = :server_id " ;
48
+ }
49
+ $ params [':server_id ' ] = $ selectedServerId ;
50
+ }
51
+
34
52
$ query = "SELECT SQL_CALC_FOUND_ROWS * FROM chat_logs $ whereClause ORDER BY id DESC LIMIT :limit OFFSET :offset " ;
35
53
$ stmt = $ pdo ->prepare ($ query );
36
54
@@ -73,15 +91,14 @@ function getTeamPrefix(int $where): string {
73
91
}
74
92
?>
75
93
76
-
77
94
<!DOCTYPE html>
78
95
<html lang="en">
79
96
<head>
80
97
<meta charset="UTF-8">
81
98
<meta name="viewport" content="width=device-width, initial-scale=1.0">
82
99
<title>[CS2] Chat Logger</title>
83
100
<link rel="stylesheet" href="style.css">
84
- <link rel="icon" href="icon_small.png" type="image/png">
101
+ <link rel="icon" href="icon_small.png" type="image/png">
85
102
</head>
86
103
<body class="<?= $ isDarkMode ? 'dark ' : 'light ' ?> ">
87
104
<header class="header-container">
@@ -91,57 +108,88 @@ function getTeamPrefix(int $where): string {
91
108
Chat Logger
92
109
</h1>
93
110
<div class="theme-toggle">
94
- <label class="switch">
95
- <input type="checkbox" id="themeCheckbox" onchange="toggleTheme()" <?= $ isDarkMode ? 'checked ' : '' ?> >
96
- <span class="slider-container">
97
- <!-- Visible track background -->
98
- <span class="slider-track-bg"></span>
99
-
100
- <!-- Animated path -->
101
- <span class="slider-path"></span>
102
-
103
- <!-- Slider ball with icons -->
104
- <span class="slider-ball">
105
- <span class="sun">
106
- <svg viewBox="0 0 24 24">
107
- <circle cx="12" cy="12" r="5" fill="#FFD700"/>
108
- <path d="M12 5v2M12 17v2M5 12h2M17 12h2" stroke="#FFD700" stroke-width="2" stroke-linecap="round"/>
109
- <path d="M7.05 7.05l1.41 1.41M15.54 15.54l1.41 1.41" stroke="#FFD700" stroke-width="2"/>
110
- <path d="M7.05 16.95l1.41-1.41M15.54 8.46l1.41-1.41" stroke="#FFD700" stroke-width="2"/>
111
- </svg>
112
- </span>
113
- <span class="moon">
114
- <svg viewBox="0 0 24 24">
115
- <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" fill="#000000"/>
116
- </svg>
117
- </span>
118
- </span>
119
- </span>
120
- </label>
121
- </div>
111
+ <label class="switch">
112
+ <input type="checkbox" id="themeCheckbox" onchange="toggleTheme()" <?= $ isDarkMode ? 'checked ' : '' ?> >
113
+ <span class="slider-container">
114
+ <!-- Visible track background -->
115
+ <span class="slider-track-bg"></span>
116
+
117
+ <!-- Animated path -->
118
+ <span class="slider-path"></span>
119
+
120
+ <!-- Slider ball with icons -->
121
+ <span class="slider-ball">
122
+ <span class="sun">
123
+ <svg viewBox="0 0 24 24">
124
+ <circle cx="12" cy="12" r="5" fill="#FFD700"/>
125
+ <path d="M12 5v2M12 17v2M5 12h2M17 12h2" stroke="#FFD700" stroke-width="2" stroke-linecap="round"/>
126
+ <path d="M7.05 7.05l1.41 1.41M15.54 15.54l1.41 1.41" stroke="#FFD700" stroke-width="2"/>
127
+ <path d="M7.05 16.95l1.41-1.41M15.54 8.46l1.41-1.41" stroke="#FFD700" stroke-width="2"/>
128
+ </svg>
129
+ </span>
130
+ <span class="moon">
131
+ <svg viewBox="0 0 24 24">
132
+ <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" fill="#000000"/>
133
+ </svg>
134
+ </span>
135
+ </span>
136
+ </span>
137
+ </label>
138
+ </div>
122
139
</header>
123
140
124
141
<main>
125
- <form method="get" class="searchBox">
126
- <input class="searchInput" name="search" type="text"
127
- placeholder="Search... Time/SteamID/Name/Message" value="<?= htmlspecialchars ($ search ) ?> ">
128
- <button class="searchButton" type="submit">
129
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">
130
- <path d="M23.809 21.646l-6.205-6.205c1.167-1.605 1.857-3.579 1.857-5.711 0-5.365-4.365-9.73-9.731-9.73-5.365 0-9.73 4.365-9.73 9.73 0 5.366 4.365 9.73 9.73 9.73 2.034 0 3.923-.627 5.487-1.698l6.238 6.238 2.354-2.354zm-20.955-11.916c0-3.792 3.085-6.877 6.877-6.877s6.877 3.085 6.877 6.877-3.085 6.877-6.877 6.877c-3.793 0-6.877-3.085-6.877-6.877z"/>
131
- </svg>
132
- </button>
133
- </form>
134
-
135
- <div class="page-controls">
136
- <form method="get" class="per-page-form">
137
- <input type="hidden" name="search" value="<?= htmlspecialchars ($ search ) ?> ">
138
- <select name="perPage" onchange="this.form.submit()" class="per-page-select">
139
- <option value="10" <?= $ perPage === 10 ? 'selected ' : '' ?> >10 per page</option>
140
- <option value="25" <?= $ perPage === 25 ? 'selected ' : '' ?> >25 per page</option>
141
- <option value="50" <?= $ perPage === 50 ? 'selected ' : '' ?> >50 per page</option>
142
- </select>
143
- </form>
144
- </div>
142
+ <div class="filters-container">
143
+ <form method="get" class="searchBox">
144
+ <input class="searchInput" name="search" type="text"
145
+ placeholder="Search... Time/SteamID/Name/Message" value="<?= htmlspecialchars ($ search ) ?> ">
146
+ <button class="searchButton" type="submit">
147
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">
148
+ <path d="M23.809 21.646l-6.205-6.205c1.167-1.605 1.857-3.579 1.857-5.711 0-5.365-4.365-9.73-9.731-9.73-5.365 0-9.73 4.365-9.73 9.73 0 5.366 4.365 9.73 9.73 9.73 2.034 0 3.923-.627 5.487-1.698l6.238 6.238 2.354-2.354zm-20.955-11.916c0-3.792 3.085-6.877 6.877-6.877s6.877 3.085 6.877 6.877-3.085 6.877-6.877 6.877c-3.793 0-6.877-3.085-6.877-6.877z"/>
149
+ </svg>
150
+ </button>
151
+ <?php if ($ selectedServerId ): ?>
152
+ <input type="hidden" name="server_id" value="<?= htmlspecialchars ($ selectedServerId ) ?> ">
153
+ <?php endif ; ?>
154
+ <?php if ($ perPage != 10 ): ?>
155
+ <input type="hidden" name="perPage" value="<?= $ perPage ?> ">
156
+ <?php endif ; ?>
157
+ </form>
158
+
159
+ <form method="get" class="server-filter-form">
160
+ <select name="server_id" onchange="this.form.submit()" class="custom-select server-select">
161
+ <option value="">All Servers</option>
162
+ <?php foreach ($ serverIds as $ serverId ): ?>
163
+ <option value="<?= htmlspecialchars ($ serverId ) ?> "
164
+ <?= $ selectedServerId == $ serverId ? 'selected ' : '' ?> >
165
+ <?= htmlspecialchars ($ serverId ) ?>
166
+ </option>
167
+ <?php endforeach ; ?>
168
+ </select>
169
+ <?php if ($ search !== '' ): ?>
170
+ <input type="hidden" name="search" value="<?= htmlspecialchars ($ search ) ?> ">
171
+ <?php endif ; ?>
172
+ <?php if ($ perPage != 10 ): ?>
173
+ <input type="hidden" name="perPage" value="<?= $ perPage ?> ">
174
+ <?php endif ; ?>
175
+ </form>
176
+ </div>
177
+
178
+ <div class="page-controls">
179
+ <form method="get" class="per-page-form">
180
+ <?php if ($ search !== '' ): ?>
181
+ <input type="hidden" name="search" value="<?= htmlspecialchars ($ search ) ?> ">
182
+ <?php endif ; ?>
183
+ <?php if ($ selectedServerId ): ?>
184
+ <input type="hidden" name="server_id" value="<?= htmlspecialchars ($ selectedServerId ) ?> ">
185
+ <?php endif ; ?>
186
+ <select name="perPage" onchange="this.form.submit()" class="per-page-select">
187
+ <option value="10" <?= $ perPage === 10 ? 'selected ' : '' ?> >10 per page</option>
188
+ <option value="25" <?= $ perPage === 25 ? 'selected ' : '' ?> >25 per page</option>
189
+ <option value="50" <?= $ perPage === 50 ? 'selected ' : '' ?> >50 per page</option>
190
+ </select>
191
+ </form>
192
+ </div>
145
193
146
194
<table class="chat-table">
147
195
<thead>
@@ -169,82 +217,87 @@ class="steamid" target="_blank">
169
217
</td>
170
218
</tr>
171
219
<?php endforeach ; ?>
172
- <?php if (!empty ($ noResultsMessage )): ?>
173
- <tr class="no-messages">
174
- <td colspan="4"><?= $ noResultsMessage ?> </td>
175
- </tr>
176
- <?php endif ; ?>
220
+ <?php if (!empty ($ noResultsMessage )): ?>
221
+ <tr class="no-messages">
222
+ <td colspan="4"><?= $ noResultsMessage ?> </td>
223
+ </tr>
224
+ <?php endif ; ?>
177
225
</tbody>
178
226
</table>
179
227
180
228
<?php if ($ totalPages > 1 ): ?>
181
229
<div class="pagination">
182
230
<div class="page-info">Page <?= $ page ?> of <?= $ totalPages ?> </div>
183
231
<div class="page-numbers">
232
+ <?php
233
+ $ serverParam = $ selectedServerId ? "&server_id= " . urlencode ($ selectedServerId ) : '' ;
234
+ $ searchParam = $ search ? "&search= " . urlencode ($ search ) : '' ;
235
+ ?>
236
+
184
237
<?php if ($ page > 1 ): ?>
185
- <a class="letter" href="?page=<?= $ page -1 ?> &search =<?= urlencode ( $ search ) ?> &perPage= <?= $ perPage ?> ">Previous</a>
186
- <?php endif ; ?>
238
+ <a class="letter" href="?page=<?= $ page -1 ?> &perPage =<?= $ perPage ?> <?= $ searchParam ?> <?= $ serverParam ?> ">Previous</a>
239
+ <?php endif ; ?>
187
240
188
241
<?php
189
242
$ startPage = max (1 , $ page - 2 );
190
243
$ endPage = min ($ totalPages , $ page + 2 );
191
244
192
245
if ($ startPage > 1 ): ?>
193
- <a class="letter" href="?page=1&search =<?= urlencode ( $ search ) ?> ">1</a>
246
+ <a class="letter" href="?page=1&perPage =<?= $ perPage ?> <?= $ searchParam ?> <?= $ serverParam ?> ">1</a>
194
247
<?php if ($ startPage > 2 ): ?>
195
248
<span class="letter">...</span>
196
249
<?php endif ; ?>
197
250
<?php endif ; ?>
198
251
199
252
<?php for ($ i = $ startPage ; $ i <= $ endPage ; $ i ++): ?>
200
253
<a class="letter <?= $ i === $ page ? 'active ' : '' ?> "
201
- href="?page=<?= $ i ?> &search =<?= urlencode ( $ search ) ?> &perPage= <?= $ perPage ?> "><?= $ i ?> </a>
254
+ href="?page=<?= $ i ?> &perPage =<?= $ perPage ?> <?= $ searchParam ?> <?= $ serverParam ?> "><?= $ i ?> </a>
202
255
<?php endfor ; ?>
203
256
204
257
<?php if ($ endPage < $ totalPages ): ?>
205
258
<?php if ($ endPage < $ totalPages - 1 ): ?>
206
259
<span class="letter">...</span>
207
260
<?php endif ; ?>
208
- <a class="letter" href="?page=<?= $ totalPages ?> &search =<?= urlencode ( $ search ) ?> "><?= $ totalPages ?> </a>
261
+ <a class="letter" href="?page=<?= $ totalPages ?> &perPage =<?= $ perPage ?> <?= $ searchParam ?> <?= $ serverParam ?> "><?= $ totalPages ?> </a>
209
262
<?php endif ; ?>
210
263
211
264
<?php if ($ page < $ totalPages ): ?>
212
- <a class="letter" href="?page=<?= $ page +1 ?> &search =<?= urlencode ( $ search ) ?> &perPage= <?= $ perPage ?> ">Next</a>
265
+ <a class="letter" href="?page=<?= $ page +1 ?> &perPage =<?= $ perPage ?> <?= $ searchParam ?> <?= $ serverParam ?> ">Next</a>
213
266
<?php endif ; ?>
214
267
</div>
215
268
</div>
216
269
<?php endif ; ?>
217
270
</main>
218
271
219
- <footer class="footer">
220
- <div>Created by <a class="venus" href="https://github.com/oqyh/">Gold KingZ</a></div>
221
- <a href="https://github.com/oqyh/cs2-Chat-Logger-GoldKingZ" class="version" target="_blank" rel="noopener noreferrer">1.0.0 </a>
222
- </footer>
272
+ <footer class="footer">
273
+ <div>Created by <a class="venus" href="https://github.com/oqyh/">Gold KingZ</a></div>
274
+ <a href="https://github.com/oqyh/cs2-Chat-Logger-GoldKingZ" class="version" target="_blank" rel="noopener noreferrer">1.0.1 </a>
275
+ </footer>
223
276
224
277
<script>
225
- if (document.cookie.indexOf('darkMode=') === -1) {
226
- document.cookie = 'darkMode=true; path=/; max-age=31536000; SameSite=Lax';
227
- }
228
-
229
- function toggleTheme() {
230
- const isDark = !document.body.classList.contains('dark');
231
- document.cookie = `darkMode=${isDark}; path=/; max-age=31536000; SameSite=Lax`;
232
- document.body.classList.toggle('dark', isDark);
233
-
234
- const ball = document.querySelector('.slider-ball');
235
- ball.style.boxShadow = `0 0 15px ${isDark ? 'rgba(224,224,224,0.7)' : 'rgba(253,184,19,0.7)'},
236
- inset 0 -2px 5px rgba(0,0,0,0.1)`;
237
-
238
- setTimeout(() => {
239
- ball.style.boxShadow = '';
240
- }, 500);
241
- }
242
-
243
- document.addEventListener('DOMContentLoaded', function() {
244
- if (document.cookie.indexOf('darkMode=true') !== -1) {
245
- document.body.classList.add('dark');
246
- }
247
- });
248
- </script>
278
+ if (document.cookie.indexOf('darkMode=') === -1) {
279
+ document.cookie = 'darkMode=true; path=/; max-age=31536000; SameSite=Lax';
280
+ }
281
+
282
+ function toggleTheme() {
283
+ const isDark = !document.body.classList.contains('dark');
284
+ document.cookie = `darkMode=${isDark}; path=/; max-age=31536000; SameSite=Lax`;
285
+ document.body.classList.toggle('dark', isDark);
286
+
287
+ const ball = document.querySelector('.slider-ball');
288
+ ball.style.boxShadow = `0 0 15px ${isDark ? 'rgba(224,224,224,0.7)' : 'rgba(253,184,19,0.7)'},
289
+ inset 0 -2px 5px rgba(0,0,0,0.1)`;
290
+
291
+ setTimeout(() => {
292
+ ball.style.boxShadow = '';
293
+ }, 500);
294
+ }
295
+
296
+ document.addEventListener('DOMContentLoaded', function() {
297
+ if (document.cookie.indexOf('darkMode=true') !== -1) {
298
+ document.body.classList.add('dark');
299
+ }
300
+ });
301
+ </script>
249
302
</body>
250
303
</html>
0 commit comments