-
Notifications
You must be signed in to change notification settings - Fork 1
/
manageforum.php
345 lines (310 loc) · 11.6 KB
/
manageforum.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
<?php
/*
Viscacha - A bulletin board solution for easily managing your content
Copyright (C) 2004-2009 The Viscacha Project
Author: Matthias Mohr (et al.)
Publisher: The Viscacha Project, http://www.viscacha.org
Start Date: May 22, 2004
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
error_reporting(E_ALL);
define('SCRIPTNAME', 'manageforum');
define('VISCACHA_CORE', '1');
include ("data/config.inc.php");
include ("classes/function.viscacha_frontend.php");
$board = $gpc->get('id', int);
$catbid = $scache->load('cat_bid');
$fc = $catbid->get();
if (empty($board) || !isset($fc[$board]) || empty($_GET['action'])) {
error($lang->phrase('query_string_error'));
}
$info = $fc[$board];
if ($info['forumzahl'] < 1) {
$info['forumzahl'] = $config['forumzahl'];
}
$my->p = $slog->Permissions($info['id']);
$my->mp = $slog->ModPermissions($info['id']);
forum_opt($info);
$breadcrumb->Add($lang->phrase('teamcp'));
($code = $plugins->load('manageforum_start')) ? eval($code) : null;
if (!$my->vlogin || $my->mp[0] == 0) {
errorLogin($lang->phrase('not_allowed'));
}
if ($_GET['action'] == "index") {
if ($_GET['type'] == 'open') {
$marksql = ' AND status = "1" ';
}
elseif ($_GET['type'] == 'close') {
$marksql = ' AND status = "0" ';
}
else { // 'close' or 'move'
$marksql = '';
}
($code = $plugins->load('manageforum_filter_query')) ? eval($code) : null;
if (!empty($marksql)) {
$result = $db->query("SELECT COUNT(*) FROM {$db->pre}topics WHERE board = '$board' {$marksql}");
$vlasttopics = $db->fetch_num($result);
$info['topics'] = $vlasttopics[0];
}
$pages = pages($info['topics'], $info['forumzahl'], 'manageforum.php?action=index&id='.$board.'&type='.$_GET['type'].'&', $_GET['page']);
$inner['index_bit'] = '';
if ($info['topics'] > 0) {
$start = $_GET['page']*$info['forumzahl'];
$start = $start-$info['forumzahl'];
($code = $plugins->load('manageforum_query')) ? eval($code) : null;
$result = $db->query("
SELECT prefix, vquestion, posts, mark, id, board, topic, date, status, last, last_name, sticky, name
FROM {$db->pre}topics
WHERE board = '{$board}' {$marksql}
ORDER BY sticky DESC, last DESC LIMIT {$start}, {$info['forumzahl']}
");
$memberdata_obj = $scache->load('memberdata');
$memberdata = $memberdata_obj->get();
$prefix_obj = $scache->load('prefix');
$prefix_arr = $prefix_obj->get($board);
while ($row = $gpc->prepare($db->fetch_object($result))) {
$pref = '';
$showprefix = false;
if (isset($prefix_arr[$row->prefix]) && $row->prefix > 0) {
$prefix = $prefix_arr[$row->prefix]['value'];
$showprefix = true;
}
else {
$prefix = '';
}
if(is_id($row->name) && isset($memberdata[$row->name])) {
$row->mid = $row->name;
$row->name = $memberdata[$row->name];
}
else {
$row->mid = FALSE;
}
if (is_id($row->last_name) && isset($memberdata[$row->last_name])) {
$row->last_name = $memberdata[$row->last_name];
}
$rstart = str_date($lang->phrase('dformat1'),times($row->date));
$rlast = str_date($lang->phrase('dformat1'),times($row->last));
if ($row->status == '2') {
$pref .= $lang->phrase('forum_moved');
}
else {
if ($row->mark === null && !empty($info['auto_status'])) {
$row->mark = $info['auto_status'];
}
if ($row->mark == 'n') {
$pref .= $lang->phrase('forum_mark_n');
}
elseif ($row->mark == 'a') {
$pref .= $lang->phrase('forum_mark_a');
}
elseif ($row->mark == 'b') {
$pref .= $lang->phrase('forum_mark_b');
}
elseif ($row->mark == 'g') {
$pref .= $lang->phrase('forum_mark_g');
}
if ($row->sticky == '1') {
$pref .= $lang->phrase('forum_announcement');
}
}
($code = $plugins->load('manageforum_entry_prepared')) ? eval($code) : null;
$inner['index_bit'] .= $tpl->parse("admin/forum/index_bit");
}
}
else {
($code = $plugins->load('manageforum_empty')) ? eval($code) : null;
$inner['index_bit'] .= $tpl->parse("admin/forum/index_bit_empty");
}
echo $tpl->parse("header");
echo $tpl->parse("menu");
($code = $plugins->load('manageforum_index_prepared')) ? eval($code) : null;
echo $tpl->parse("admin/forum/index");
($code = $plugins->load('manageforum_index_end')) ? eval($code) : null;
}
elseif ($_GET['action'] == "close") {
if (count($_POST['delete']) == 0) {
$slog->updatelogged();
$db->close();
if (empty($_GET['action'])) {
$url = 'showforum.php?id='.$board.SID2URL_JS_x;
}
else {
$url = 'manageforum.php?action=index&id='.$board.'&type='.$_GET['action'].SID2URL_JS_x;
}
sendStatusCode(302, $config['furl'].'/'.$url);
exit;
}
$db->query("UPDATE {$db->pre}topics SET status = '1' WHERE board = '{$board}' AND id IN(".implode(',', $_POST['delete']).")");
if ($db->affected_rows() > 0) {
ok($lang->phrase('admin_topicstatus_changed'),'showforum.php?id='.$board.SID2URL_x);
}
else {
error($lang->phrase('admin_failed'),'showforum.php?id='.$board.SID2URL_x);
}
}
elseif ($_GET['action'] == "open") {
if (count($_POST['delete']) == 0) {
$slog->updatelogged();
$db->close();
if (empty($_GET['action'])) {
$url = 'showforum.php?id='.$board.SID2URL_JS_x;
}
else {
$url = 'manageforum.php?action=index&id='.$board.'&type='.$_GET['action'].SID2URL_JS_x;
}
sendStatusCode(302, $config['furl'].'/'.$url);
exit;
}
$db->query("UPDATE {$db->pre}topics SET status = '0' WHERE board = '{$board}' AND id IN(".implode(',', $_POST['delete']).")");
if ($db->affected_rows() > 0) {
ok($lang->phrase('admin_topicstatus_changed'),'showforum.php?id='.$board.SID2URL_x);
}
else {
error($lang->phrase('admin_failed'),'showforum.php?id='.$board.SID2URL_x);
}
}
elseif ($_GET['action'] == "move") {
if (count($_POST['delete']) == 0) {
if (empty($_GET['action'])) {
$url = 'showforum.php?id='.$board.SID2URL_JS_x;
}
else {
$url = 'manageforum.php?action=index&id='.$board.'&type='.$_GET['action'].SID2URL_JS_x;
}
sendStatusCode(302, $config['furl'].'/'.$url);
}
$my->pb = $slog->GlobalPermissions();
if ($my->mp[0] == 1 && $my->mp[5] == 0) {
errorLogin($lang->phrase('not_allowed'), 'showforum.php?id='.$board.SID2URL_x);
}
$forums = BoardSubs();
echo $tpl->parse("header");
echo $tpl->parse("menu");
echo $tpl->parse("admin/forum/move");
}
elseif ($_GET['action'] == "move2") {
if ($my->mp[0] == 1 && $my->mp[5] == 0) {
errorLogin($lang->phrase('not_allowed'), 'manageforum.php?action=index&id='.$board.'&type='.$_GET['action'].SID2URL_x);
}
$anz = 0;
foreach ($_POST['delete'] as $id) {
$result = $db->query("
SELECT r.date, r.topic, r.name, r.guest, r.email, u.name AS uname, u.mail AS uemail
FROM {$db->pre}replies AS r
LEFT JOIN {$db->pre}user AS u ON u.id = r.name AND r.guest = '0'
WHERE topic_id = '{$id}' AND tstart = '1'
");
$old = $db->fetch_assoc($result);
$db->query("UPDATE {$db->pre}topics SET board = '{$_POST['opt_0']}' WHERE id = '{$id}' LIMIT 1");
$anz += $db->affected_rows();
$db->query("UPDATE {$db->pre}replies SET board = '{$_POST['opt_0']}' WHERE topic_id = '{$id}'");
$anz += $db->affected_rows();
if ($_POST['temp'] == 1) {
// Prefix wird nicht übernommen!
$db->query("INSERT INTO {$db->pre}topics SET status = '2', topic = '".$gpc->save_str($old['topic'])."', board='{$board}', name = '".$gpc->save_str($old['name'])."', date = '{$old['date']}', last_name = '".$gpc->save_str($old['name'])."', last = '{$old['date']}', vquestion = ''");
$tid = $db->insert_id();
$db->query("INSERT INTO {$db->pre}replies SET tstart = '1', topic_id = '{$tid}', comment = '{$id}', topic = '".$gpc->save_str($old['topic'])."', board='{$board}', name = '".$gpc->save_str($old['name'])."', email = '{$old['email']}', date = '{$old['date']}', guest = '{$old['guest']}', edit = '', report = ''");
}
if ($_POST['temp2'] == 1) {
if ($old['guest'] == 0) {
$old['email'] = $old['uemail'];
$old['name'] = $old['uname'];
}
$data = $lang->get_mail('mass_topic_moved');
$to = array('0' => array('name' => $old['name'], 'mail' => $old['email']));
$from = array();
xmail($to, $from, $data['title'], $data['comment']);
}
}
if ($config['updateboardstats'] == 1) {
UpdateBoardStats($board);
UpdateBoardStats($_POST['opt_0']);
}
else {
UpdateBoardLastStats($board);
UpdateBoardLastStats($_POST['opt_0']);
}
ok($lang->phrase('x_entries_moved'),'showforum.php?id='.$board.SID2URL_x);
}
elseif ($_GET['action'] == "delete") {
if ($my->mp[0] == 1 && $my->mp[4] == 0) {
errorLogin($lang->phrase('not_allowed'),'manageforum.php?action=index&id='.$board.'&type='.$_GET['action'].SID2URL_x);
}
if (count($_POST['delete']) == 0) {
$slog->updatelogged();
$db->close();
if (empty($_GET['action'])) {
$url = 'showforum.php?id='.$board.SID2URL_JS_x;
}
else {
$url = 'manageforum.php?action=index&id='.$board.'&type='.$_GET['action'].SID2URL_JS_x;
}
sendStatusCode(302, $config['furl'].'/'.$url);
exit;
}
$ids = implode(',', $_POST['delete']);
if ($config['updatepostcounter'] == 1 && $info['count_posts'] == 1) {
$result = $db->query("SELECT COUNT(*) AS posts, name FROM {$db->pre}replies WHERE guest = '0' AND topic_id IN({$ids}) GROUP BY name");
while ($row = $db->fetch_assoc($result)) {
$db->query("UPDATE {$db->pre}user SET posts = posts-{$row['posts']} WHERE id = '{$row['name']}'");
}
}
$db->query ("DELETE FROM {$db->pre}replies WHERE topic_id IN({$ids})");
$anz = $db->affected_rows();
$uresult = $db->query ("SELECT id, source FROM {$db->pre}uploads WHERE topic_id IN({$ids})");
while ($urow = $db->fetch_assoc($uresult)) {
$filesystem->unlink('uploads/topics/'.$urow['source']);
$thumb = 'uploads/topics/thumbnails/'.$urow['id'].get_extension($urow['source'], true);
if (file_exists($thumb)) {
$filesystem->unlink($thumb);
}
}
$db->query ("DELETE FROM {$db->pre}uploads WHERE topic_id IN({$ids})");
$anz += $db->affected_rows();
$db->query ("DELETE FROM {$db->pre}postratings WHERE tid IN({$ids})");
$anz += $db->affected_rows();
$db->query ("DELETE FROM {$db->pre}abos WHERE tid IN({$ids})");
$anz += $db->affected_rows();
$db->query ("DELETE FROM {$db->pre}topics WHERE id IN({$ids})");
$anz += $db->affected_rows();
$votes = $db->query("SELECT id FROM {$db->pre}vote WHERE tid IN({$ids})");
$voteaids = array();
while ($row = $db->fetch_num($votes)) {
$voteaids[] = $row[0];
}
if (count($voteaids) > 0) {
$db->query ("DELETE FROM {$db->pre}votes WHERE id IN (".implode(',', $voteaids).")");
$anz += $db->affected_rows();
}
$db->query ("DELETE FROM {$db->pre}vote WHERE tid IN({$ids})");
$anz += $db->affected_rows();
($code = $plugins->load('manageforum_delete_end')) ? eval($code) : null;
if ($config['updateboardstats'] == 1) {
UpdateBoardStats($board);
}
else {
UpdateBoardLastStats($board);
}
ok($lang->phrase('x_entries_deleted'),"showforum.php?id=".$board.SID2URL_x);
}
elseif ($_GET['action'] == "stat") {
UpdateBoardStats($info['id']);
ok($lang->phrase('data_success'),'showforum.php?id='.$board.SID2URL_x);
}
($code = $plugins->load('manageforum_end')) ? eval($code) : null;
$slog->updatelogged();
$zeitmessung = t2();
echo $tpl->parse("footer");
$phpdoc->Out();
$db->close();
?>