-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
151 lines (139 loc) · 6.42 KB
/
Copy pathadmin.php
File metadata and controls
151 lines (139 loc) · 6.42 KB
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
<?php
session_start();
require_once 'functions.php';
if (!isAdminLoggedIn()) {
header('Location: admin_login.php');
exit;
}
if (isset($_GET['logout'])) {
session_destroy();
header('Location: admin_login.php');
exit;
}
if (isset($_GET['approve']) && !empty($_GET['approve'])) {
$result = approveBanner($_GET['approve']);
$approveMessage = $result['message'];
}
if (isset($_GET['delete']) && !empty($_GET['delete'])) {
$result = deleteBanner($_GET['delete'], null, true);
$deleteMessage = $result['message'];
}
$banners = getAllBanners(true);
$pendingBanners = [];
$approvedBanners = [];
foreach ($banners as $banner) {
if ($banner['approved']) {
$approvedBanners[] = $banner;
} else {
$pendingBanners[] = $banner;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MODS = GODS</title>
<link rel="stylesheet" href="/public/css/global.css">
</head>
<body>
<div class="container">
<div>
<h3>Banner Moderation</h3>
<div>
<a href="admin.php?logout=1">Logout</a>
</div>
</div>
<?php if (isset($approveMessage)): ?>
<div class="success"><?php echo htmlspecialchars($approveMessage); ?></div>
<?php endif; ?>
<?php if (isset($deleteMessage)): ?>
<div class="success"><?php echo htmlspecialchars($deleteMessage); ?></div>
<?php endif; ?>
<div>
<h3>Pending Banners (<?php echo count($pendingBanners); ?>)</h3>
<?php if (empty($pendingBanners)): ?>
<p>No pending banners.</p>
<?php else: ?>
<table style="width: 100%;">
<thead>
<tr>
<th width="10%">Actions</th>
<th width="15%">Title</th>
<th width="40%">Banner</th>
<th width="15%">Link</th>
<th width="10%">Size</th>
<th width="10%">Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($pendingBanners as $banner): ?>
<tr class="banner-row">
<td>
<a href="admin.php?approve=<?php echo $banner['_id']; ?>" class="action-button approve-button">Approve</a>
<a href="admin.php?delete=<?php echo $banner['_id']; ?>" class="action-button delete-button" onclick="return confirm('Are you sure you want to delete this banner?');">Delete</a>
</td>
<td><?php echo !empty($banner['title']) ? htmlspecialchars($banner['title']) : '<em>No title</em>'; ?></td>
<td>
<a href="<?php echo htmlspecialchars($banner['link']); ?>" target="_blank">
<img src="/.banners/<?php echo htmlspecialchars($banner['filename']); ?>" style="max-width: 100%; height: auto;">
</a>
</td>
<td>
<a href="<?php echo htmlspecialchars($banner['link']); ?>" target="_blank">
<?php echo htmlspecialchars(substr($banner['link'], 0, 30)) . (strlen($banner['link']) > 30 ? '...' : ''); ?>
</a>
</td>
<td><?php echo isset($banner['fileSize']) ? number_format($banner['fileSize'] / (1024 * 1024), 2) . ' MB' : '0.00 MB'; ?></td>
<td><?php echo date('Y-m-d', $banner['uploadDate']->toDateTime()->getTimestamp()); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<div>
<h3>Approved Banners (<?php echo count($approvedBanners); ?>)</h3>
<?php if (empty($approvedBanners)): ?>
<p>No approved banners.</p>
<?php else: ?>
<table style="width: 100%;">
<thead>
<tr>
<th width="10%">Actions</th>
<th width="15%">Title</th>
<th width="40%">Banner</th>
<th width="15%">Link</th>
<th width="10%">Size</th>
<th width="10%">Date</th>
</tr>
</thead>
<tbody>
<?php foreach ($approvedBanners as $banner): ?>
<tr class="banner-row">
<td >
<a href="admin.php?delete=<?php echo $banner['_id']; ?>" onclick="return confirm('Are you sure you want to delete this banner?');">Delete</a>
</td>
<td><?php echo !empty($banner['title']) ? htmlspecialchars($banner['title']) : '<em>No title</em>'; ?></td>
<td>
<a href="<?php echo htmlspecialchars($banner['link']); ?>" target="_blank">
<img src="/.banners/<?php echo htmlspecialchars($banner['filename']); ?>" style="max-width: 100%; height: auto;">
</a>
</td>
<td>
<a href="<?php echo htmlspecialchars($banner['link']); ?>" target="_blank">
<?php echo htmlspecialchars(substr($banner['link'], 0, 30)) . (strlen($banner['link']) > 30 ? '...' : ''); ?>
</a>
</td>
<td><?php echo isset($banner['fileSize']) ? number_format($banner['fileSize'] / (1024 * 1024), 2) . ' MB' : '0.00 MB'; ?></td>
<td><?php echo date('Y-m-d', $banner['uploadDate']->toDateTime()->getTimestamp()); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
</div>
</body>
</html>