This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdash.php
357 lines (282 loc) · 11.9 KB
/
dash.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<!-- index.php -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<?php
$random_id = uniqid();
session_start();
session_name("rms_session");
require 'db_connection.php';
if (!isset($_SESSION['user_id'])) {
header("Location: " . ($phpenable === 'true' ? $login_url . '.php' : $login_url));
exit;
}
$sql = "SELECT * FROM benutzer WHERE id = " . $_SESSION['user_id'];
$result = $conn->query($sql);
$user = $result->fetch_assoc();
// Überprüfen, ob der Benutzeraccount gesperrt ist
$userId = $_SESSION['user_id'];
$sql = "SELECT gesperrt, name FROM benutzer WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $userId);
$stmt->execute();
$stmt->bind_result($isLocked, $userName);
$stmt->fetch();
$stmt->close();
if ($isLocked) {
session_destroy();
header("Location: " . ($phpenable === 'true' ? $login_url . '.php' : $login_url));
exit;
}
if (empty($userName)) {
session_destroy();
header("Location: " . ($phpenable === 'true' ? $login_url . '.php' : $login_url));
exit;
}
?>
<?php
include 'settings/config.php';
include 'settings/head.php';
include 'settings/header.php';
?>
<title>
<?= str_replace('{websiteName}', $name, $translations['dash_page']['title']) ?>
</title>
<section class="pt-5 bg-section-secondary">
<div class=container>
<div class="row justify-content-center">
<div class=col-lg-9>
<?php if (isset($_SESSION['success_message'])) { ?>
<div class="alert alert-success" role="alert">
<div class="alert-group-prepend">
<span class="alert-group-icon text-">
<i class="fa-solid fa-circle-check"></i>
</span>
<?php echo $_SESSION['success_message']; ?>
</div>
</div>
<?php unset($_SESSION['success_message']); // Lösche die Session-Variablen nach der Anzeige ?>
<?php } ?>
<?php if (isset($_SESSION['error_message'])) { ?>
<div class="alert alert-danger" role="alert">
<div class="alert-group-prepend">
<span class="alert-group-icon text-">
<i class="fa-solid fa-circle-exclamation"></i>
</span>
<?php echo $_SESSION['error_message']; ?>
</div>
</div>
<?php unset($_SESSION['error_message']); // Lösche die Session-Variablen nach der Anzeige ?>
<?php } ?>
<script>
setTimeout(function () {
var errorMessage = document.getElementById('error-message');
if (errorMessage) {
errorMessage.style.display = 'none';
window.location.href = '?';
}
}, 5000);
</script>
<?php
if ($user['email'] === NULL) {
// Zeige eine Fehlermeldung direkt auf der Seite an
echo '<div class="alert alert-group alert-danger alert-icon" role="alert">
<div class="alert-group-prepend">
<span class="alert-group-icon text-">
<i class="fa-regular fa-circle-exclamation"></i>
</span>
</div>
<div class="alert-content">
Du hast keine E-Mail hinzugefügt. Bitte füge eine E-Mail hinzu.
</div>
<div class="alert-action">
<a href="' . ($phpenable === 'true' ? $settings_url . '.php' : $settings_url) . '" class="btn btn-neutral" aria-label="Hinzufügen">E-Mail hinzufügen</a>
</div>
</div>';
}
echo '<div class="alert alert-group alert-danger alert-icon" role="alert">
<div class="alert-group-prepend">
<span class="alert-group-icon text-">
<i class="fa-regular fa-circle-exclamation"></i>
</span>
</div>
<div class="alert-content">
McSlot Schließt am 10.05.2024
</div>
<div class="alert-action">
<a href="closed" class="btn btn-neutral" aria-label="Hinzufügen">Weitere Informationen</a>
</div>
</div>';
?>
<div class="card mb-n7 position-relative zindex-100">
<?php
date_default_timezone_set('Europe/Berlin');
$stunde = date("H");
if ($stunde >= 6 && $stunde < 12) {
$begruessung = str_replace('{username}', $userName, $translations['dash_page']['welcome_text_morning']);
} elseif ($stunde >= 12 && $stunde < 18) {
$begruessung = str_replace('{username}', $userName, $translations['dash_page']['welcome_text_afternoon']);
} elseif ($stunde >= 18 && $stunde < 24) {
$begruessung = str_replace('{username}', $userName, $translations['dash_page']['welcome_text_evening']);
} else {
$begruessung = str_replace('{username}', $userName, $translations['dash_page']['welcome_text_night']);
}
$productCount = $result->num_rows;
echo '<h1 class="text-center mt-5">' . $begruessung . '</h1>';
?>
<div class="card-body px-5">
<h5 class="text pt-4">
<?= str_replace('{websiteName}', '<strong>' . $name . '</strong>', $translations['dash_page']['welcome_text']) ?>
</h5>
<p class="text opacity-8">
<?= str_replace('{websiteName}', $name, $translations['dash_page']['text_info']) ?>
</p>
<p class="text opacity-8">
<?= str_replace('{here}', '<a href="changelogs/">' . $translations['dash_page']['changelogs_here'] . '</a>', $translations['dash_page']['text_changelogs']) ?>
</p>
</div>
<center>
<?php
// Zeitzone setzen
date_default_timezone_set('Europe/Berlin');
$today = date('m-d');
$sql = "SELECT name FROM holydays WHERE DATE_FORMAT(date_from, '%m-%d') <= '$today' AND DATE_FORMAT(date_to, '%m-%d') >= '$today'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$holiday_name = $row["name"];
switch($holiday_name) {
case "christmas":
echo '<p class="text-success opacity-8">Frohe Weihnachten! 🎅</p>';
break;
case "easter":
echo '<p class="text-info opacity-8">Frohe Ostern! 🐰</p>';
break;
default:
echo '<p class="text-info opacity-8">Heute ist ein Feiertag: ' . $holiday_name . '</p>';
}
}
} else {
}
$conn->close();
?>
</center>
</div>
</div>
</div>
</div><br>
</section>
<?php
require 'db_connection.php';
echo '<div class="slice slice-sm bg-section-secondary">';
echo ' <div class="container">';
echo ' <div class="row justify-content-center">';
echo ' <div class="col-lg-9">';
echo ' <div class="row">';
echo ' <div class="col-lg-12">';
echo ' <h5>' . ($translations['dash_page']['table']['title']) . '</h5>';
echo ' <div class="table-responsive">';
echo ' <table class="table table-cards align-items-center" id="files-table">';
echo ' <thead>';
// Im <thead>-Bereich immer "Kategorie", "Dateiname", "Dateigröße" und "Hochgeladen" anzeigen
if (!isset($_GET['cat'])) {
// In der Kategorieliste nur "Kategorie" im <thead>-Bereich anzeigen
echo ' <tr>';
echo ' <th scope="col">' . ($translations['dash_page']['table']['category']['text_1']) . '</th>';
echo ' <th scope="col">' . ($translations['dash_page']['table']['category']['text_2']) . '</th>';
echo ' </tr>';
} else {
// In der Dateiliste "Dateiname", "Dateigröße" und "Hochgeladen" im <thead>-Bereich anzeigen
echo ' <tr>';
echo ' <th scope="col">' . ( $translations['dash_page']['table']['files']['text_1']) . '</th>';
echo ' <th scope="col">' . ($translations['dash_page']['table']['files']['text_2']) . '</th>';
echo ' <th scope="col">' . ($translations['dash_page']['table']['files']['text_3']) . '</th>';
echo ' </tr>';
}
echo ' </thead>';
echo ' <tbody class="list">';
echo ' <tr id="loading-row"><td colspan="3"><div class="text-center"><div class="spinner-border" role="status"></div>';
echo ' </tbody>';
echo ' </table>';
echo ' </div>';
echo ' </div>';
echo ' </div>';
echo ' </div>';
echo ' </div>';
echo ' </div>';
echo '</div>';
$conn->close();
?>
<script>
$(document).ready(function() {
function generateBadge(released) {
if (released === 'Yes') {
return '<span class="badge badge-success badge-pill"><i class="fa-solid fa-check"></i> ' + '<?php echo $translations['dash_page']['table']['files']['released_yes']; ?>' + '</span>';
} else if (released === 'No') {
return '<span class="badge badge-secondary badge-pill"><i class="fa-solid fa-xmark"></i> ' + '<?php echo $translations['dash_page']['table']['files']['released_no']; ?>' + '</span>';
} else if (released === 'disabled') {
return '<span class="badge badge-warning badge-pill"><i class="fa-solid fa-ban"></i> ' + '<?php echo $translations['dash_page']['table']['files']['released_disabled']; ?>' + '</span>';
} else {
return '<span class="badge badge-primary badge-pill"><i class="fa-solid fa-certificate"></i> ' + '<?php echo $translations['dash_page']['table']['files']['released_only_verfied']; ?>' + '</span>';
}
}
function loadCategories() {
$.ajax({
url: 'actions/ajax_get_category.php',
type: 'GET',
dataType: 'json',
success: function(response) {
$('.list').empty();
$.each(response, function(index, categoryInfo) {
var link = '<a href="?cat=' + encodeURIComponent(categoryInfo.category) + '">' + categoryInfo.category + '</a>';
var fileCount = '<span class="file-count">' + categoryInfo.file_count + ' Dateien</span>';
var row = '<tr><th>' + link + '</th><td>' + fileCount + '</td></tr>';
$('.list').append(row);
});
},
error: function(xhr, status, error) {
console.error("AJAX Error:", status, error);
setTimeout(loadCategories, 5000);
}
});
}
function loadFiles(category) {
$.ajax({
url: 'actions/ajax_get_files.php',
type: 'GET',
data: { cat: category },
dataType: 'json',
beforeSend: function() {
$('#loading-row td').html('<div class="text-center"><div class="spinner-border" role="status"></div>');
},
success: function(response) {
$('.list').empty();
if (Array.isArray(response)) {
$.each(response, function(index, file) {
var row = '<tr>' +
'<th><a href="download?file=' + file.name + '">' + file.name + '</a></th>' +
'<td>' + file.size + '</td>' +
'<td>' + file.date + '</td>' +
'<td>' + generateBadge(file.released) + '</td>' +
'</tr>';
$('.list').append(row);
});
} else {
loadCategories();
}
},
error: function(xhr, status, error) {
console.error("AJAX Error:", status, error);
setTimeout(function() { loadFiles(category); }, 5000);
}
});
}
var categoryParam = '<?php echo isset($_GET['cat']) ? $_GET['cat'] : ''; ?>';
if (categoryParam !== '') {
loadFiles(categoryParam);
} else {
loadCategories();
}
});
</script>
<?php
include 'settings/footer.php';
?>