-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
admin_gallery.php
146 lines (136 loc) · 4.31 KB
/
admin_gallery.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
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
protect_page();
admin_only($user_data);
// start
// Delete
if (isset($_POST['delete'])) {
$data = explode(":", $_POST['delete']);
echo 'Image '. $data[0] .' deleted.';
updateImage($data[0], 3);
}
// Remove
if (isset($_POST['remove'])) {
$data = explode(":", $_POST['remove']);
$did = (int)$data[0];
echo 'Image '. $did .' removed.';
$delhash = $_POST['delhash'];
$imgurClientID = $config['gallery']['Client ID'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.imgur.com/3/image/{$delhash}");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Client-ID {$imgurClientID}"
));
$response = json_decode(curl_exec($ch));
mysql_delete("DELETE FROM `znote_images` WHERE `id`='$did' LIMIT 1;");
}
// Accept
if (isset($_POST['accept'])) {
$data = explode(":", $_POST['accept']);
echo 'Image '. $data[0] .' accepted and is now public.';
updateImage($data[0], 2);
}
// Wether we accept or delete, re-create the cache
if (isset($_POST['accept']) || isset($_POST['delete'])) {
$cache = new Cache('engine/cache/gallery');
$images = fetchImages(2);
if ($images != false) {
$data = array();
foreach ($images as $image) {
$row['title'] = $image['title'];
$row['desc'] = $image['desc'];
$row['date'] = $image['date'];
$row['image'] = $image['image'];
$data[] = $row;
}
} else $data = "";
$cache->setContent($data);
$cache->save();
}
?><h1>Images in need of moderation:</h1><?php
$images = fetchImages(1);
if ($images != false) {
foreach($images as $image) {
?>
<table>
<tr class="yellow">
<td><h2><?php echo $image['title']; ?><form action="" method="post"><input type="submit" name="accept" value="<?php echo $image['id']; ?>:Accept Image"/></form><form action="" method="post"><input type="submit" name="delete" value="<?php echo $image['id']; ?>:Delete Image"/></form></h2></td>
</tr>
<tr>
<td>
<a href="<?php echo $image['image']; ?>"><img src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>" style="max-width: 100%;"/></a>
</td>
</tr>
<tr>
<td>
<?php
$descr = str_replace("\\r", "", $image['desc']);
$descr = str_replace("\\n", "<br />", $descr);
?>
<p><?php echo $descr; ?></p>
</td>
</tr>
</table>
<?php }
} else echo '<h2>All good, no new images to moderate.</h2>';
?><h1>Public Images:</h1><?php
$images = fetchImages(2);
if ($images != false) {
foreach($images as $image) {
?>
<table>
<tr class="yellow">
<td><h2><?php echo $image['title']; ?><form action="" method="post"><input type="submit" name="delete" value="<?php echo $image['id']; ?>:Delete Image"/></form></h2></td>
</tr>
<tr>
<td>
<a href="<?php echo $image['image']; ?>"><img src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>" style="max-width: 100%;"/></a>
</td>
</tr>
<tr>
<td>
<?php
$descr = str_replace("\\r", "", $image['desc']);
$descr = str_replace("\\n", "<br />", $descr);
?>
<p><?php echo $descr; ?></p>
</td>
</tr>
</table>
<?php }
} else echo '<h2>There are currently no public images.</h2>';
?><h1>Deleted Images:</h1><?php
$images = fetchImages(3);
if ($images != false) {
foreach($images as $image) {
?>
<table>
<tr class="yellow">
<td><h2><?php echo $image['title']; ?><form action="" method="post">
<input type="submit" name="accept" value="<?php echo $image['id']; ?>:Recover Image"/>
<input type="hidden" name="delhash" value="<?php echo $image['delhash']; ?>">
<input type="submit" name="remove" value="<?php echo $image['id']; ?>:Remove Image"/>
</form></h2></td>
</tr>
<tr>
<td>
<a href="<?php echo $image['image']; ?>"><img src="<?php echo $image['image']; ?>" alt="<?php echo $image['title']; ?>" style="max-width: 100%;"/></a>
</td>
</tr>
<tr>
<td>
<?php
$descr = str_replace("\\r", "", $image['desc']);
$descr = str_replace("\\n", "<br />", $descr);
?>
<p><?php echo $descr; ?></p>
</td>
</tr>
</table>
<?php }
} else echo '<h2>There are currently no deleted images.</h2>';
// end
include 'layout/overall/footer.php'; ?>