Skip to content
Newer
Older
100644 1343 lines (1022 sloc) 48.6 KB
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1 <?php
2
e5f7b2a @reines Updating copyright notices in all files
reines authored Feb 20, 2010
3 /**
8637b8a @reines Updating the copyright notices to 2011.
reines authored Jan 22, 2011
4 * Copyright (C) 2008-2011 FluxBB
e5f7b2a @reines Updating copyright notices in all files
reines authored Feb 20, 2010
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
8
f5ee836 @reines Changing PUN_ROOT to use absolute paths, this solves some issues with…
reines authored Dec 7, 2010
9 define('PUN_ROOT', dirname(__FILE__).'/');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
10 require PUN_ROOT.'include/common.php';
11
12
13 // This particular function doesn't require forum-based moderator access. It can be used
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
14 // by all moderators and admins
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
15 if (isset($_GET['get_host']))
16 {
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
17 if (!$pun_user['is_admmod'])
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
18 message($lang_common['No permission']);
19
20 // Is get_host an IP address or a post ID?
b1deb69 @reines Updating all the regular expressions to use % as a delimiter. Before …
reines authored Jun 5, 2011
21 if (@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $_GET['get_host']) || @preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $_GET['get_host']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
22 $ip = $_GET['get_host'];
23 else
24 {
25 $get_host = intval($_GET['get_host']);
26 if ($get_host < 1)
27 message($lang_common['Bad request']);
28
0cfb58d @reines Updating some more queries
reines authored Mar 27, 2011
29 $query = new SelectQuery(array('poster_ip' => 'p.poster_ip'), 'posts AS p');
30 $query->where = 'id = :pid';
31
32 $params = array(':pid' => $get_host);
33
34 $result = $db->query($query, $params);
35 if (empty($result))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
36 message($lang_common['Bad request']);
37
0cfb58d @reines Updating some more queries
reines authored Mar 27, 2011
38 $ip = $result[0]['poster_ip'];
39 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
40 }
ccf65ea @ridgerunner Cleaned all lines having trailing whitespace
ridgerunner authored Mar 12, 2010
41
4564b65 @Quy Localized string.
Quy authored Mar 8, 2010
42 // Load the misc.php language file
43 require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
44
20326bf @reines Tidying up the misc language entry related to fetching a users IP.
reines authored Mar 8, 2010
45 message(sprintf($lang_misc['Host info 1'], $ip).'<br />'.sprintf($lang_misc['Host info 2'], @gethostbyaddr($ip)).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">'.$lang_misc['Show more users'].'</a>');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
46 }
47
48
49 // All other functions require moderator/admin access
50 $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
51 if ($fid < 1)
52 message($lang_common['Bad request']);
53
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
54 $query = new SelectQuery(array('moderators' => 'f.moderators'), 'forums AS f');
55 $query->where = 'f.id = :forum_id';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
56
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
57 $params = array(':forum_id' => $fid);
58
59 $result = $db->query($query, $params);
60 $mods_array = empty($result[0]['moderators']) ? array() : unserialize($result[0]['moderators']);
61 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
62
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
63 if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] == '0' || !array_key_exists($pun_user['username'], $mods_array)))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
64 message($lang_common['No permission']);
65
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
66 // Get topic/forum tracking data
67 if (!$pun_user['is_guest'])
68 $tracked_topics = get_tracked_topics();
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
69
70 // Load the misc.php language file
71 require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
72
73
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
74 // All other topic moderation features require a topic ID in GET
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
75 if (isset($_GET['tid']))
76 {
77 $tid = intval($_GET['tid']);
78 if ($tid < 1)
79 message($lang_common['Bad request']);
80
81 // Fetch some info about the topic
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
82 $query = new SelectQuery(array('subject' => 't.subject', 'num_replies' => 't.num_replies', 'first_post_id' => 't.first_post_id', 'forum_id' => 'f.id AS forum_id', 'forum_name' => 'forum_name'), 'topics AS t');
83
84 $query->joins['f'] = new InnerJoin('forums AS f');
85 $query->joins['f']->on = 'f.id = t.forum_id';
86
87 $query->joins['fp'] = new LeftJoin('forum_perms AS fp');
88 $query->joins['fp']->on = 'fp.forum_id = f.id AND fp.group_id = :group_id';
89
90 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND f.id = :forum_id AND t.id = :topic_id AND t.moved_to IS NULL';
91
92 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $fid, ':topic_id' => $tid);
93
94 $result = $db->query($query, $params);
95 if (empty($result))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
96 message($lang_common['Bad request']);
97
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
98 $cur_topic = $result[0];
99 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
100
101 // Delete one or more posts
102 if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply']))
103 {
104 if (isset($_POST['delete_posts_comply']))
105 {
106 confirm_referrer('moderate.php');
107
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
108 if (@preg_match('%[^0-9,]%', $_POST['posts']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
109 message($lang_common['Bad request']);
110
89d59dc @reines Converting some more queries
reines authored Apr 8, 2011
111 $posts = explode(',', $_POST['posts']);
112 if (empty($posts))
113 message($lang_misc['No posts selected']);
114
115 // How many posts did we just delete?
116 $num_posts_deleted = count($posts);
117
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
118 // Verify that the post IDs are valid
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
119 $query = new SelectQuery(array('num_posts' => 'COUNT(p.id) AS num_posts'), 'posts AS p');
120 $query->where = 'p.id IN :pids AND p.topic_id = :topic_id';
121
122 $params = array(':pids' => $posts, ':topic_id' => $tid);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
123
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
124 $result = $db->query($query, $params);
125 if ($result[0]['num_posts'] != $num_posts_deleted)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
126 message($lang_common['Bad request']);
127
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
128 unset ($result, $query, $params);
129
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
130 // Delete the posts
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
131 $query = new DeleteQuery('posts');
132 $query->where = 'id IN :pids';
133
134 $params = array(':pids' => $posts);
135
136 $db->query($query, $params);
137 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
138
139 require PUN_ROOT.'include/search_idx.php';
140 strip_search_index($posts);
141
142 // Get last_post, last_post_id, and last_poster for the topic after deletion
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
143 $query = new SelectQuery(array('id' => 'p.id', 'poster' => 'p.poster', 'posted' => 'p.posted'), 'posts AS p');
144 $query->where = 'p.topic_id = :topic_id';
145 $query->order = array('id' => 'p.id DESC');
146 $query->limit = 1;
147
148 $params = array(':topic_id' => $tid);
149
150 $result = $db->query($query, $params);
151 $last_post = $result[0];
152 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
153
154 // Update the topic
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
155 $query = new UpdateQuery(array('last_post' => ':last_post', 'last_post_id' => ':last_post_id', 'last_poster' => ':last_poster', 'num_replies' => 'num_replies - :num_deleted'), 'topics');
156 $query->where = 'id = :topic_id';
157
158 $params = array(':last_post' => $last_post['posted'], ':last_post_id' => $last_post['id'], ':last_poster' => $last_post['poster'], ':num_deleted' => $num_posts_deleted, ':topic_id' => $tid);
159
160 $db->query($query, $params);
161 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
162
163 update_forum($fid);
164
165 redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']);
166 }
167
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
168 $posts = isset($_POST['posts']) ? $_POST['posts'] : array();
169 if (empty($posts))
170 message($lang_misc['No posts selected']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
171
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
172 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
173 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
174 require PUN_ROOT.'header.php';
175
176 ?>
177 <div class="blockform">
178 <h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2>
179 <div class="box">
180 <form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
181 <div class="inform">
182 <fieldset>
183 <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
184 <div class="infldset">
191d485 Fixed several potential XSS vectors in moderate.php.
Neal Poole authored Jul 10, 2008
185 <input type="hidden" name="posts" value="<?php echo implode(',', array_map('intval', array_keys($posts))) ?>" />
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
186 <p><?php echo $lang_misc['Delete posts comply'] ?></p>
187 </div>
188 </fieldset>
189 </div>
60136cd Making sure post markup is consistent to ease styling.
Paul Sullivan authored Jan 3, 2010
190 <p class="buttons"><input type="submit" name="delete_posts_comply" value="<?php echo $lang_misc['Delete'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
191 </form>
192 </div>
193 </div>
194 <?php
195
196 require PUN_ROOT.'footer.php';
197 }
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
198 else if (isset($_POST['split_posts']) || isset($_POST['split_posts_comply']))
199 {
200 if (isset($_POST['split_posts_comply']))
201 {
202 confirm_referrer('moderate.php');
203
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
204 if (@preg_match('%[^0-9,]%', $_POST['posts']))
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
205 message($lang_common['Bad request']);
206
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
207 $posts = explode(',', $_POST['posts']);
208 if (empty($posts))
209 message($lang_misc['No posts selected']);
210
b49a66a @Quy Allow forum selection to move split posts.
Quy authored Feb 6, 2011
211 $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0;
212 if ($move_to_forum < 1)
213 message($lang_common['Bad request']);
214
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
215 // How many posts did we just split off?
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
216 $num_posts_splitted = count($posts);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
217
218 // Verify that the post IDs are valid
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
219 $query = new SelectQuery(array('num_posts' => 'COUNT(p.id) AS num_posts'), 'posts AS p');
220 $query->where = 'p.id IN :pids AND p.topic_id = :topic_id';
221
222 $params = array(':pids' => $posts, ':topic_id' => $tid);
223
224 $result = $db->query($query, $params);
225 if ($result[0]['num_posts'] != $num_posts_splitted)
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
226 message($lang_common['Bad request']);
227
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
228 unset ($result, $query, $params);
229
8754b22 @reines Only allow moderators to move topics to boards they can post in, inst…
reines authored Feb 7, 2011
230 // Verify that the move to forum ID is valid
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
231 $query = new SelectQuery(array('one' => '1'), 'forums AS f');
232
233 $query->joins['fp'] = new LeftJoin('forum_perms AS fp');
234 $query->joins['fp']->on = 'fp.group_id = :group_id AND fp.forum_id = :forum_id';
235
236 $query->where = 'f.redirect_url IS NULL AND (fp.post_topics IS NULL OR fp.post_topics = 1)';
237
238 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $move_to_forum);
239
240 $result = $db->query($query, $params);
241 if (empty($result))
8754b22 @reines Only allow moderators to move topics to boards they can post in, inst…
reines authored Feb 7, 2011
242 message($lang_common['Bad request']);
243
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
244 unset ($result, $query, $params);
245
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
246 // Load the post.php language file
247 require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';
248
249 // Check subject
250 $new_subject = isset($_POST['new_subject']) ? pun_trim($_POST['new_subject']) : '';
251
252 if ($new_subject == '')
253 message($lang_post['No subject']);
254 else if (pun_strlen($new_subject) > 70)
255 message($lang_post['Too long subject']);
256
257 // Get data from the new first post
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
258 $query = new SelectQuery(array('id' => 'p.id', 'poster' => 'p.poster', 'posted' => 'p.posted'), 'posts AS p');
259 $query->where = 'p.id IN :pids';
260 $query->order = array('id' => 'o.id ASC');
261 $query->limit = 1;
262
263 $params = array(':pids' => $posts);
264
265 $result = $db->query($query, $params);
266 $first_post = $result[0];
267 unset ($result, $query, $params);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
268
269 // Create the new topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
270 $query = new InsertQuery(array('poster' => ':poster', 'subject' => ':subject', 'posted' => ':posted', 'first_post_id' => ':first_post_id', 'forum_id' => ':forum_id'), 'topics');
271 $params = array(':poster' => $first_post['poster'], ':subject' => $new_subject, ':posted' => $first_post['posted'], ':first_post_id' => $first_post['id'], ':forum_id' => $move_to_forum);
272
273 $db->query($query, $params);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
274 $new_tid = $db->insert_id();
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
275 unset ($query, $params);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
276
277 // Move the posts to the new topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
278 $query = new UpdateQuery(array('topic_id' => ':topic_id'), 'posts');
279 $query->where = 'id IN :pids';
280
281 $params = array(':topic_id' => $new_tid, ':pids' => $posts);
282
283 $db->query($query, $params);
284 unset ($query, $params);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
285
286 // Get last_post, last_post_id, and last_poster from the topic and update it
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
287 $query = new SelectQuery(array('id' => 'p.id', 'poster' => 'p.poster', 'posted' => 'p.posted'), 'posts AS p');
288 $query->where = 'p.topic_id = :topic_id';
289 $query->order = array('id' => 'p.id DESC');
290 $query->limit = 1;
291
292 $params = array(':topic_id' => $tid);
293 $result = $db->query($query, $params);
294 $last_post = $result[0];
295 unset ($result, $query, $params);
296
297 $query = new UpdateQuery(array('last_post' => ':last_post', 'last_post_id' => ':last_post_id', 'last_poster' => ':last_poster', 'num_replies' => 'num_replies - :num_splitted'), 'topics');
298 $query->where = 'id = :topic_id';
299
300 $params = array(':last_post' => $last_post['posted'], ':last_post_id' => $last_post['id'], ':last_poster' => $last_post['poster'], ':num_splitted' => $num_posts_splitted, ':topic_id' => $tid);
301
302 $db->query($query, $params);
303 unset ($query, $params);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
304
305 // Get last_post, last_post_id, and last_poster from the new topic and update it
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
306 $query = new SelectQuery(array('id' => 'p.id', 'poster' => 'p.poster', 'posted' => 'p.posted'), 'posts AS p');
307 $query->where = 'p.topic_id = :topic_id';
308 $query->order = array('id' => 'p.id DESC');
309 $query->limit = 1;
310
311 $params = array(':topic_id' => $new_tid);
312 $result = $db->query($query, $params);
313 $last_post = $result[0];
314 unset ($result, $query, $params);
315
316 $query = new UpdateQuery(array('last_post' => ':last_post', 'last_post_id' => ':last_post_id', 'last_poster' => ':last_poster', 'num_replies' => ':num_replies'), 'topics');
317 $query->where = 'id = :topic_id';
318
319 $params = array(':last_post' => $last_post['posted'], ':last_post_id' => $last_post['id'], ':last_poster' => $last_post['poster'], ':num_replies' => $num_posts_splitted - 1, ':topic_id' => $new_tid);
320
321 $db->query($query, $params);
322 unset ($query, $params);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
323
324 update_forum($fid);
b49a66a @Quy Allow forum selection to move split posts.
Quy authored Feb 6, 2011
325 update_forum($move_to_forum);
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
326
327 redirect('viewtopic.php?id='.$new_tid, $lang_misc['Split posts redirect']);
328 }
329
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
330 $query = new SelectQuery(array('cid' => 'c.id AS cid', 'cat_name' => 'c.cat_name', 'fid' => 'f.id AS fid', 'forum_name' => 'f.forum_name'), 'categories AS c');
331
332 $query->joins['f'] = new InnerJoin('forums AS f');
333 $query->joins['f']->on = 'c.id = f.cat_id';
334
335 $query->joins['fp'] = new LeftJoin('forum_perms AS fp');
336 $query->joins['fp']->on = 'fp.forum_id = f.id AND fp.group_id = :group_id';
337
338 $query->where = '(fp.post_topics IS NULL OR fp.post_topics = 1) AND f.redirect_url IS NULL';
339 $query->order = array('cposition' => 'c.disp_position ASC', 'cid' => 'c.id ASC', 'fposition' => 'f.disp_position ASC');
340
341 $params = array(':group_id' => $pun_user['g_id']);
342
343 $result = $db->query($query, $params);
b49a66a @Quy Allow forum selection to move split posts.
Quy authored Feb 6, 2011
344
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
345 $posts = isset($_POST['posts']) ? $_POST['posts'] : array();
346 if (empty($posts))
347 message($lang_misc['No posts selected']);
348
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
349 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
350 $focus_element = array('subject','new_subject');
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
351 define('PUN_ACTIVE_PAGE', 'index');
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
352 require PUN_ROOT.'header.php';
353
354 ?>
355 <div class="blockform">
356 <h2><span><?php echo $lang_misc['Split posts'] ?></span></h2>
357 <div class="box">
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
358 <form id="subject" method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
359 <div class="inform">
360 <fieldset>
361 <legend><?php echo $lang_misc['Confirm split legend'] ?></legend>
362 <div class="infldset">
363 <input type="hidden" name="posts" value="<?php echo implode(',', array_map('intval', array_keys($posts))) ?>" />
ef91b66 Adding hidden required text to required fields with minimum alteratio…
Paul Sullivan authored Feb 17, 2010
364 <label class="required"><strong><?php echo $lang_misc['New subject'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br /><input type="text" name="new_subject" size="80" maxlength="70" /><br /></label>
b49a66a @Quy Allow forum selection to move split posts.
Quy authored Feb 6, 2011
365 <label><?php echo $lang_misc['Move to'] ?>
366 <br /><select name="move_to_forum">
367 <?php
368
369 $cur_category = 0;
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
370 foreach ($result as $cur_forum)
b49a66a @Quy Allow forum selection to move split posts.
Quy authored Feb 6, 2011
371 {
372 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
373 {
374 if ($cur_category)
375 echo "\t\t\t\t\t\t\t".'</optgroup>'."\n";
376
377 echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
378 $cur_category = $cur_forum['cid'];
379 }
380
381 echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"'.($fid == $cur_forum['fid'] ? ' selected="selected"' : '').'>'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
382 }
383
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
384 unset ($result, $query, $params);
385
b49a66a @Quy Allow forum selection to move split posts.
Quy authored Feb 6, 2011
386 ?>
387 </optgroup>
388 </select>
389 <br /></label>
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
390 <p><?php echo $lang_misc['Split posts comply'] ?></p>
391 </div>
392 </fieldset>
393 </div>
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored Jan 1, 2010
394 <p class="buttons"><input type="submit" name="split_posts_comply" value="<?php echo $lang_misc['Split'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
395 </form>
396 </div>
397 </div>
398 <?php
399
400 require PUN_ROOT.'footer.php';
401 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
402
403
0069a88 "Split posts" function is ready (for testing).
Frank Smit authored May 12, 2009
404 // Show the moderate posts view
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
405
406 // Load the viewtopic.php language file
407 require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
408
409 // Used to disable the Move and Delete buttons if there are no replies to this topic
02f9a93 Fixed markup error. Reported by kierownik.
Frank Smit authored Jun 29, 2009
410 $button_status = ($cur_topic['num_replies'] == 0) ? ' disabled="disabled"' : '';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
411
412
413 // Determine the post offset (based on $_GET['p'])
414 $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
415
1226d2d @Quy Fixed $_GET['p'] parameter (page number).
Quy authored Jun 8, 2009
416 $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
417 $start_from = $pun_user['disp_posts'] * ($p - 1);
418
419 // Generate paging links
421c354 Moving hard coded colon to language file. Putting span around pages l…
Paul Sullivan authored Mar 28, 2010
420 $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&amp;tid='.$tid);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
421
422
423 if ($pun_config['o_censoring'] == '1')
424 $cur_topic['subject'] = censor_words($cur_topic['subject']);
425
426
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
427 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_topic['forum_name']), pun_htmlspecialchars($cur_topic['subject']));
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
428 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
429 require PUN_ROOT.'header.php';
430
431 ?>
432 <div class="linkst">
bbf4d49 Added extra class to top and bottom links that have breadcrumbs plus …
Paul Sullivan authored Jan 27, 2010
433 <div class="inbox crumbsplus">
a66809c Added class .crumbs to the breadcrumbs lists to avoid having to style…
Paul Sullivan authored Dec 19, 2009
434 <ul class="crumbs">
a607380 The bits I missed with the previous commit.
Paul Sullivan authored Dec 4, 2009
435 <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
8d5b6c0 @reines Replacing some entities with their UTF-8 character equivalent.
reines authored May 15, 2010
436 <li><span&#160;</span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li>
437 <li><span&#160;</span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></a></li>
438 <li><span&#160;</span><strong><?php echo $lang_misc['Moderate'] ?></strong></li>
a607380 The bits I missed with the previous commit.
Paul Sullivan authored Dec 4, 2009
439 </ul>
bdd1406 Fixing and improving display of breadcrumbs.
Paul authored May 25, 2010
440 <div class="pagepost">
441 <p class="pagelink conl"><?php echo $paging_links ?></p>
442 </div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
443 <div class="clearer"></div>
444 </div>
445 </div>
446
447 <form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
448 <?php
449
450 require PUN_ROOT.'include/parser.php';
451
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
452 $post_count = 0; // Keep track of post numbers
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
453
cf806e8 @reines Splitting the query to select posts within a topic into 2 parts. The …
reines authored May 27, 2010
454 // Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
455 $query = new SelectQuery(array('id' => 'p.id'), 'posts AS p');
456 $query->where = 'p.topic_id = :topic_id';
457 $query->order = array('id' => 'p.id ASC');
458 $query->offset = $start_from;
459 $query->limit = $pun_user['disp_posts'];
460
461 $params = array(':topic_id' => $tid);
462
463 $post_ids = $db->query($query, $params);
464 unset ($query, $params);
cf806e8 @reines Splitting the query to select posts within a topic into 2 parts. The …
reines authored May 27, 2010
465
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
466 // If there are posts in this topic
467 if (empty($post_ids))
468 error('The post table and topic table seem to be out of sync!', __FILE__, __LINE__);
469
470 // Translate from a 3d array into 2d array: $post_ids[0]['id'] -> $post_ids[0]
471 foreach ($post_ids as $key => $value)
472 $post_ids[$key] = $value['id'];
cf806e8 @reines Splitting the query to select posts within a topic into 2 parts. The …
reines authored May 27, 2010
473
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
474 // Retrieve the posts (and their respective poster)
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
475 $query = new SelectQuery(array('title' => 'u.title', 'num_posts' => 'u.num_posts', 'g_id' => 'g.g_id', 'g_user_title' => 'g.g_user_title', 'id' => 'p.id', 'poster' => 'p.poster', 'poster_id' => 'p.poster_id', 'message' => 'p.message', 'hide_smilies' => 'p.hide_smilies', 'posted' => 'p.posted', 'edited' => 'p.edited', 'edited_by' => 'p.edited_by'), 'posts AS p');
476
477 $query->joins['u'] = new InnerJoin('users AS u');
478 $query->joins['u']->on = 'u.id = p.poster_id';
479
480 $query->joins['g'] = new Innerjoin('groups AS g');
481 $query->joins['g']->on = 'g.g_id = u.group_id';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
482
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
483 $query->where = 'p.id IN :pids';
484 $query->order = array('id' => 'p.id ASC');
485
486 $params = array(':pids' => $post_ids);
487
488 $result = $db->query($query, $params);
489 foreach ($result as $cur_post)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
490 {
491 $post_count++;
492
ccb8295 @franzliedke Fixed a whole bunch of mainly comment typos, reported by Darren.
franzliedke authored Oct 14, 2009
493 // If the poster is a registered user
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
494 if ($cur_post['poster_id'] > 1)
495 {
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
496 if ($pun_user['g_view_users'] == '1')
497 $poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>';
498 else
499 $poster = pun_htmlspecialchars($cur_post['poster']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
500
501 // get_title() requires that an element 'username' be present in the array
502 $cur_post['username'] = $cur_post['poster'];
503 $user_title = get_title($cur_post);
504
505 if ($pun_config['o_censoring'] == '1')
506 $user_title = censor_words($user_title);
507 }
508 // If the poster is a guest (or a user that has been deleted)
509 else
510 {
511 $poster = pun_htmlspecialchars($cur_post['poster']);
512 $user_title = $lang_topic['Guest'];
513 }
514
515 // Perform the main parsing of the message (BBCode, smilies, censor words etc)
516 $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
517
518 ?>
519
5a5d7f1 The field first_post_id had been added to the topics table but wasn't…
Paul Sullivan authored Feb 11, 2010
520 <div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php if($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost' ?><?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($post_count == 1) echo ' blockpost1' ?>">
3f30344 Removed code that provides alternating row styles for posts which pre…
Paul Sullivan authored Dec 31, 2009
521 <h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?></span> <a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
522 <div class="box">
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored Jan 1, 2010
523 <div class="inbox">
524 <div class="postbody">
d2df1c5 Added an extra div to posts. This will make it easier to style posts …
Paul Sullivan authored Dec 4, 2009
525 <div class="postleft">
526 <dl>
527 <dt><strong><?php echo $poster ?></strong></dt>
5933214 Added usertitle class to moderate posts to make it consistent with vi…
Paul Sullivan authored Jan 25, 2010
528 <dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
d2df1c5 Added an extra div to posts. This will make it easier to style posts …
Paul Sullivan authored Dec 4, 2009
529 </dl>
530 </div>
531 <div class="postright">
532 <h3 class="nosize"><?php echo $lang_common['Message'] ?></h3>
533 <div class="postmsg">
534 <?php echo $cur_post['message']."\n" ?>
535 <?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?>
536 </div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
537 </div>
538 </div>
60136cd Making sure post markup is consistent to ease styling.
Paul Sullivan authored Jan 3, 2010
539 </div>
540 <div class="inbox">
541 <div class="postfoot clearb">
5a5d7f1 The field first_post_id had been added to the topics table but wasn't…
Paul Sullivan authored Feb 11, 2010
542 <div class="postfootright"><?php echo ($cur_post['id'] != $cur_topic['first_post_id']) ? '<p class="multidelete"><label><strong>'.$lang_misc['Select'].'</strong>&#160;<input type="checkbox" name="posts['.$cur_post['id'].']" value="1" /></label></p>' : '<p>'.$lang_misc['Cannot select first'].'</p>' ?></div>
60136cd Making sure post markup is consistent to ease styling.
Paul Sullivan authored Jan 3, 2010
543 </div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
544 </div>
545 </div>
546 </div>
547
548 <?php
549
550 }
551
362f584 @reines Converting some queries in moderate.php (still lots left!)
reines authored Apr 7, 2011
552 unset ($result, $query, $params);
553
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
554 ?>
555 <div class="postlinksb">
be38cd6 @reines Adding breadcrumbs to the bottom of moderate page to be consistent wi…
reines authored Feb 12, 2011
556 <div class="inbox crumbsplus">
bdd1406 Fixing and improving display of breadcrumbs.
Paul authored May 25, 2010
557 <div class="pagepost">
558 <p class="pagelink conl"><?php echo $paging_links ?></p>
559 <p class="conr modbuttons"><input type="submit" name="split_posts" value="<?php echo $lang_misc['Split'] ?>"<?php echo $button_status ?> /> <input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /></p>
c44b271 @FSX Fixed display issues with the Oxygen style. Actually all styles were …
FSX authored Aug 11, 2010
560 <div class="clearer"></div>
bdd1406 Fixing and improving display of breadcrumbs.
Paul authored May 25, 2010
561 </div>
be38cd6 @reines Adding breadcrumbs to the bottom of moderate page to be consistent wi…
reines authored Feb 12, 2011
562 <ul class="crumbs">
563 <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
564 <li><span&#160;</span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li>
565 <li><span&#160;</span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></a></li>
566 <li><span&#160;</span><strong><?php echo $lang_misc['Moderate'] ?></strong></li>
567 </ul>
568 <div class="clearer"></div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
569 </div>
570 </div>
571 </form>
572 <?php
573
574 require PUN_ROOT.'footer.php';
575 }
576
577
578 // Move one or more topics
49d6e8b @Quy Reverted some changes in [1013]. Reported by trichome.
Quy authored Jun 7, 2009
579 if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
580 {
581 if (isset($_POST['move_topics_to']))
582 {
583 confirm_referrer('moderate.php');
584
b1deb69 @reines Updating all the regular expressions to use % as a delimiter. Before …
reines authored Jun 5, 2011
585 if (@preg_match('%[^0-9,]%', $_POST['topics']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
586 message($lang_common['Bad request']);
587
588 $topics = explode(',', $_POST['topics']);
589 $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0;
590 if (empty($topics) || $move_to_forum < 1)
591 message($lang_common['Bad request']);
592
593 // Verify that the topic IDs are valid
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
594 $query = new SelectQuery(array('num_topics' => 'COUNT(t.id) AS num_topics'), 'topics AS t');
595 $query->where = 't.id IN :tids AND t.forum_id = :forum_id';
596
597 $params = array(':tids' => $topics, ':forum_id' => $fid);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
598
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
599 $result = $db->query($query, $params);
600 if ($result[0]['num_topics'] != count($topics))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
601 message($lang_common['Bad request']);
602
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
603 unset ($result, $query, $params);
604
8754b22 @reines Only allow moderators to move topics to boards they can post in, inst…
reines authored Feb 7, 2011
605 // Verify that the move to forum ID is valid
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
606 $query = new SelectQuery(array('one' => '1'), 'forums AS f');
607
608 $query->joins['fp'] = new LeftJoin('forum_perms AS fp');
609 $query->joins['fp']->on = 'fp.group_id = :group_id AND fp.forum_id = :forum_id';
610
611 $query->where = 'f.redirect_url IS NULL AND (fp.post_topics IS NULL OR fp.post_topics = 1)';
612
613 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $move_to_forum);
614
615 if (empty($result))
8754b22 @reines Only allow moderators to move topics to boards they can post in, inst…
reines authored Feb 7, 2011
616 message($lang_common['Bad request']);
617
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
618 unset ($result, $query, $params);
619
ccb8295 @franzliedke Fixed a whole bunch of mainly comment typos, reported by Darren.
franzliedke authored Oct 14, 2009
620 // Delete any redirect topics if there are any (only if we moved/copied the topic back to where it was once moved from)
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
621 $query = new DeleteQuery('topics');
622 $query->where = 'forum_id = :forum_id AND moved_to IN :tids';
623
624 $params = array(':forum_id' => $move_to_forum, ':tids' => $topics);
625
626 $db->query($query, $params);
627 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
628
629 // Move the topic(s)
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
630 $query = new UpdateQuery(array('forum_id' => ':forum_id'), 'topics');
631 $query->where = 'id IN :tids';
632
633 $params = array(':forum_id' => $move_to_forum, ':tids' => $topics);
634
635 $db->query($query, $params);
636 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
637
638 // Should we create redirect topics?
639 if (isset($_POST['with_redirect']))
640 {
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
641 $query = new SelectQuery(array('poster' => 't.poster', 'subject' => 't.subject', 'posted' => 't.posted', 'last_post' => 't.last_post'), 'topics AS t');
642 $query->where = 't.id IN :tids';
643
644 $params = array(':tids' => $topics);
645
646 $result = $db->query($query, $params);
647 unset ($query, $params);
648
649 $insert_query = new InsertQuery(array('poster' => ':poster', 'subject' => ':subject', 'posted' => ':posted', 'last_post' => ':last_post', 'moved_to' => ':moved_to', 'forum_id' => ':forum_id'), 'topics');
650
651 foreach ($result as $cur_topic)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
652 {
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
653 $params = array(':poster' => $cur_topic['poster'], ':subject' => $cur_topic['subject'], ':posted' => $cur_topic['posted'], ':last_post' => $cur_topic['last_post'], ':moved_to' => $cur_topic,':forum_id' => $fid);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
654
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
655 $db->query($insert_query, $params);
656 unset ($params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
657 }
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
658
659 unset ($result, $insert_query);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
660 }
661
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
662 update_forum($fid); // Update the forum FROM which the topic was moved
663 update_forum($move_to_forum); // Update the forum TO which the topic was moved
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
664
665 $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect'];
666 redirect('viewforum.php?id='.$move_to_forum, $redirect_msg);
667 }
668
669 if (isset($_POST['move_topics']))
670 {
671 $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
672 if (empty($topics))
673 message($lang_misc['No topics selected']);
674
191d485 Fixed several potential XSS vectors in moderate.php.
Neal Poole authored Jul 10, 2008
675 $topics = implode(',', array_map('intval', array_keys($topics)));
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
676 $action = 'multi';
677 }
678 else
679 {
680 $topics = intval($_GET['move_topics']);
681 if ($topics < 1)
682 message($lang_common['Bad request']);
683
684 $action = 'single';
685 }
686
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
687 $query = new SelectQuery(array('cid' => 'c.id AS cid', 'cat_name' => 'c.cat_name', 'fid' => 'f.id AS fid', 'forum_name' => 'f.forum_name'), 'categories AS c');
688
689 $query->joins['f'] = new InnerJoin('forums AS f');
690 $query->joins['f']->on = 'c.id = f.cat_id';
691
692 $query->joins['fp'] = new LeftJoin('forum_perms AS fp');
693 $query->joins['fp']->on = 'fp.forum_id = f.id AND fp.group_id = :group_id';
694
695 $query->where = '(fp.post_topics IS NULL OR fp.post_topics = 1) AND f.redirect_url IS NULL';
696 $query->order = array('cposition' => 'c.disp_position ASC', 'cid' => 'c.id ASC', 'fposition' => 'f.disp_position ASC');
697
698 $params = array(':group_id' => $pun_user['g_id']);
699
700 $result = $db->query($query, $params);
701 unset ($query, $params);
702
703 if (count($result) < 2)
3584549 @Quy Fixed #89.
Quy authored Aug 29, 2009
704 message($lang_misc['Nowhere to move']);
705
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
706 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
707 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
708 require PUN_ROOT.'header.php';
709
710 ?>
711 <div class="blockform">
712 <h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2>
713 <div class="box">
714 <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
715 <div class="inform">
716 <input type="hidden" name="topics" value="<?php echo $topics ?>" />
717 <fieldset>
718 <legend><?php echo $lang_misc['Move legend'] ?></legend>
719 <div class="infldset">
720 <label><?php echo $lang_misc['Move to'] ?>
721 <br /><select name="move_to_forum">
722 <?php
723
724 $cur_category = 0;
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
725 foreach ($result as $cur_forum)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
726 {
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
727 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
728 {
729 if ($cur_category)
730 echo "\t\t\t\t\t\t\t".'</optgroup>'."\n";
731
732 echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
733 $cur_category = $cur_forum['cid'];
734 }
735
736 if ($cur_forum['fid'] != $fid)
737 echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
738 }
739
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
740 unset ($result);
741
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
742 ?>
743 </optgroup>
744 </select>
745 <br /></label>
746 <div class="rbox">
747 <label><input type="checkbox" name="with_redirect" value="1"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
748 </div>
749 </div>
750 </fieldset>
751 </div>
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored Jan 1, 2010
752 <p class="buttons"><input type="submit" name="move_topics_to" value="<?php echo $lang_misc['Move'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
753 </form>
754 </div>
755 </div>
756 <?php
757
758 require PUN_ROOT.'footer.php';
759 }
760
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
761 // Merge two or more topics
9a41d76 Replaced $_REQUEST's with $_POST's.
Frank Smit authored May 26, 2009
762 else if (isset($_POST['merge_topics']) || isset($_POST['merge_topics_comply']))
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
763 {
764 if (isset($_POST['merge_topics_comply']))
02f9a93 Fixed markup error. Reported by kierownik.
Frank Smit authored Jun 29, 2009
765 {
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
766 confirm_referrer('moderate.php');
767
b1deb69 @reines Updating all the regular expressions to use % as a delimiter. Before …
reines authored Jun 5, 2011
768 if (@preg_match('%[^0-9,]%', $_POST['topics']))
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
769 message($lang_common['Bad request']);
770
771 $topics = explode(',', $_POST['topics']);
772 if (count($topics) < 2)
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
773 message($lang_misc['Not enough topics selected']);
774
30e712f @franzliedke Clean up comments in moderate.php. Suggested by Koos in #474.
franzliedke authored Aug 12, 2011
775 // Verify that the topic IDs are valid (redirect links will point to the merged topic after the merge)
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
776 $query = new SelectQuery(array('id' => 't.id'), 'topics AS t');
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
777 $query->where = 't.id IN :tids AND t.forum_id = :forum_id';
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
778 $query->order = array('id' => 't.id ASC');
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
779
780 $params = array(':tids' => $topics, ':forum_id' => $fid);
781
782 $result = $db->query($query, $params);
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
783 if (count($result[0]) != count($topics))
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
784 message($lang_common['Bad request']);
785
14f523e @franzliedke #480: Combine two queries in moderate.php.
franzliedke authored Aug 12, 2011
786 // The topic that we are merging into is the one with the smallest ID
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
787 $merge_to_tid = $result[0]['id'];
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
788 unset ($result, $query, $params);
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
789
790 // Make any redirect topics point to our new, merged topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
791 $query = new UpdateQuery(array('moved_to' => ':merge_id'), 'topics');
792 $query->where = 'moved_to IN :tids';
793
794 $params = array(':merge_id' => $merge_to_tid, ':tids' => $topics);
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
795
796 // Should we create redirect topics?
797 if (isset($_POST['with_redirect']))
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
798 $query->where .= ' OR (id IN :tids AND id != :merge_id)';
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
799
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
800 $db->query($query, $params);
801 unset ($query, $params);
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
802
803 // Merge the posts into the topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
804 $query = new UpdateQuery(array('topic_id' => ':merge_id'), 'posts');
805 $query->where = 'topic_id IN :tids';
806
807 $params = array(':merge_id' => $merge_to_tid, ':tids' => $topics);
808
809 $db->query($query, $params);
810 unset ($query, $params);
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
811
812 // Delete any subscriptions
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
813 $query = new DeleteQuery('topic_subscriptions');
814 $query->where = 'topic_id IN :tids AND topic_id != :merge_id';
815
816 $params = array(':merge_id' => $merge_to_tid, ':tids' => $topics);
817
818 $db->query($query, $params);
819 unset ($query, $params);
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
820
821 // Without redirection the old topics are removed
822 if (!isset($_POST['with_redirect']))
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
823 {
824 $query = new DeleteQuery('topics');
825 $query->where = 'id IN :tids AND id != :merge_id';
826
827 $params = array(':merge_id' => $merge_to_tid, ':tids' => $topics);
828
829 $db->query($query, $params);
830 unset ($query, $params);
831 }
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
832
19c4c59 Merge topic: topic reply count now updated too.
Frank Smit authored Mar 28, 2009
833 // Count number of replies in the topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
834 $query = new SelectQuery(array('num_replies' => '(COUNT(p.id) - 1) AS num_replies'), 'posts AS p');
835 $query->where = 'p.topic_id = :merge_to';
836
837 $params = array(':merge_to' => $merge_to_tid);
838
839 $result = $db->query($query, $params);
840 $num_replies = $result[0]['num_replies'];
841 unset ($result, $query, $params);
19c4c59 Merge topic: topic reply count now updated too.
Frank Smit authored Mar 28, 2009
842
843 // Get last_post, last_post_id and last_poster
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
844 $query = new SelectQuery(array('posted' => 'p.posted', 'id' => 'p.id', 'poster' => 'p.poster'), 'posts AS p');
845 $query->where = 'p.topic_id = :merge_to';
846 $query->order = array('id' => 'p.id DESC');
847 $query->limit = 1;
848
849 $result = $db->query($query, $params);
850 $last_post = $result[0];
851 unset ($result, $query, $params);
19c4c59 Merge topic: topic reply count now updated too.
Frank Smit authored Mar 28, 2009
852
853 // Update topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
854 $query = new UpdateQuery(array('num_replies' => ':num_replies', 'last_post' => ':last_post', 'last_post_id' => ':last_post_id', 'last_poster' => ':last_poster'), 'topics');
855 $query->where = 'id = :merge_to';
856
857 $params = array(':num_replies' => $num_replies, ':last_post' => $last_post['posted'], ':last_post_id' => $last_post['id'], ':last_poster' => $last_post['poster'], ':merge_to' => $merge_to_tid);
858
859 $db->query($query, $params);
860 unset ($query, $params);
19c4c59 Merge topic: topic reply count now updated too.
Frank Smit authored Mar 28, 2009
861
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
862 // Update the forum FROM which the topic was moved and redirect
863 update_forum($fid);
864 redirect('viewforum.php?id='.$fid, $lang_misc['Merge topics redirect']);
865 }
02f9a93 Fixed markup error. Reported by kierownik.
Frank Smit authored Jun 29, 2009
866
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
867 $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
868 if (count($topics) < 2)
869 message($lang_misc['Not enough topics selected']);
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
870
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
871 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
872 define('PUN_ACTIVE_PAGE', 'index');
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
873 require PUN_ROOT.'header.php';
874
875 ?>
876 <div class="blockform">
5cb6812 @Quy Added missing spans.
Quy authored Jan 17, 2010
877 <h2><span><?php echo $lang_misc['Merge topics'] ?></span></h2>
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
878 <div class="box">
879 <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
880 <input type="hidden" name="topics" value="<?php echo implode(',', array_map('intval', array_keys($topics))) ?>" />
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
881 <div class="inform">
882 <fieldset>
883 <legend><?php echo $lang_misc['Confirm merge legend'] ?></legend>
884 <div class="infldset">
885 <div class="rbox">
04490a6 @Quy Improved code in moderate.php.
Quy authored Jun 7, 2009
886 <label><input type="checkbox" name="with_redirect" value="1" /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
887 </div>
888 </div>
889 </fieldset>
890 </div>
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored Jan 1, 2010
891 <p class="buttons"><input type="submit" name="merge_topics_comply" value="<?php echo $lang_misc['Merge'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
9224568 Added "Merge topics" functionality. Should be tested.
Frank Smit authored Mar 24, 2009
892 </form>
893 </div>
894 </div>
895 <?php
896
897 require PUN_ROOT.'footer.php';
898 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
899
900 // Delete one or more topics
9a41d76 Replaced $_REQUEST's with $_POST's.
Frank Smit authored May 26, 2009
901 else if (isset($_POST['delete_topics']) || isset($_POST['delete_topics_comply']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
902 {
903 if (isset($_POST['delete_topics_comply']))
904 {
905 confirm_referrer('moderate.php');
906
731999f @franzliedke Merge commit 'bf7116c9aa232c42dc38457906d6060e126a74fc' into fluxbb-2…
franzliedke authored Aug 27, 2011
907 if (@preg_match('%[^0-9,]%', $_POST['topics']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
908 message($lang_common['Bad request']);
909
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
910 $topics = explode(',', $_POST['topics']);
911 if (empty($topics))
912 message($lang_misc['No topics selected']);
913
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
914 require PUN_ROOT.'include/search_idx.php';
915
916 // Verify that the topic IDs are valid
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
917 $query = new SelectQuery(array('num_topics' => 'COUNT(t.id) AS num_topics'), 'topics AS t');
918 $query->where = 'id IN :tids AND forum_id = :forum_id';
919
920 $params = array(':tids' => $topics, ':forum_id' => $fid);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
921
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
922 $result = $db->query($query, $params);
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
923 if ($result[0]['num_topics'] != count($topics))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
924 message($lang_common['Bad request']);
925
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
926 unset ($result, $query, $params);
927
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
928 // Delete the topics and any redirect topics
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
929 $query = new DeleteQuery('topics');
930 $query->where = 'id IN :tids OR moved_to IN :tids';
931
932 $params = array(':tids' => $topics);
933
934 $db->query($query, $params);
935 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
936
937 // Delete any subscriptions
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
938 $query = new DeleteQuery('topic_subscriptions');
939 $query->where = 'topic_id IN :tids';
940
941 $params = array(':tids' => $topics);
942
943 $db->query($query, $params);
944 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
945
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
946 // Create a list of the post IDs in this topic and then strip the search index
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
947 $query = new SelectQuery(array('id' => 'p.id'), 'posts AS p');
948 $query->where = 'p.topic_id IN :tids';
949
950 $params = array(':tids' => $topics);
951
952 $result = $db->query($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
953
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
954 $post_ids = array();
955 foreach ($result as $cur_post)
956 $post_ids[] = $cur_post['id'];
957
958 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
959
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
960 // We have to check that we actually have a list of post IDs since we could be deleting just a redirect topic
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
961 if (!empty($post_ids))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
962 strip_search_index($post_ids);
963
964 // Delete posts
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
965 $query = new DeleteQuery('posts');
966 $query->where = 'topic_id IN :tids';
967
968 $params = array(':tids' => $topics);
969
970 $db->query($query, $params);
971 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
972
973 update_forum($fid);
974
975 redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']);
976 }
977
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
978 $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
979 if (empty($topics))
980 message($lang_misc['No topics selected']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
981
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
982 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
983 define('PUN_ACTIVE_PAGE', 'index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
984 require PUN_ROOT.'header.php';
985
986 ?>
987 <div class="blockform">
5cb6812 @Quy Added missing spans.
Quy authored Jan 17, 2010
988 <h2><span><?php echo $lang_misc['Delete topics'] ?></span></h2>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
989 <div class="box">
990 <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
191d485 Fixed several potential XSS vectors in moderate.php.
Neal Poole authored Jul 10, 2008
991 <input type="hidden" name="topics" value="<?php echo implode(',', array_map('intval', array_keys($topics))) ?>" />
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
992 <div class="inform">
993 <fieldset>
994 <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
995 <div class="infldset">
996 <p><?php echo $lang_misc['Delete topics comply'] ?></p>
997 </div>
998 </fieldset>
999 </div>
57eb86e Correcting an assortment of issues and inconsistencies discovered whi…
Paul Sullivan authored Jan 1, 2010
1000 <p class="buttons"><input type="submit" name="delete_topics_comply" value="<?php echo $lang_misc['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1001 </form>
1002 </div>
1003 </div>
1004 <?php
1005
1006 require PUN_ROOT.'footer.php';
1007 }
1008
1009
1010 // Open or close one or more topics
49d6e8b @Quy Reverted some changes in [1013]. Reported by trichome.
Quy authored Jun 7, 2009
1011 else if (isset($_REQUEST['open']) || isset($_REQUEST['close']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1012 {
49d6e8b @Quy Reverted some changes in [1013]. Reported by trichome.
Quy authored Jun 7, 2009
1013 $action = (isset($_REQUEST['open'])) ? 0 : 1;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1014
49d6e8b @Quy Reverted some changes in [1013]. Reported by trichome.
Quy authored Jun 7, 2009
1015 // There could be an array of topic IDs in $_POST
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1016 if (isset($_POST['open']) || isset($_POST['close']))
1017 {
1018 confirm_referrer('moderate.php');
1019
1020 $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array();
1021 if (empty($topics))
1022 message($lang_misc['No topics selected']);
1023
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1024 $query = new UpdateQuery(array('closed' => ':closed'), 'topics');
1025 $query->where = 'id IN :tids AND forum_id = :forum_id';
1026
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1027 $params = array(':closed' => $action, ':tids' => $topics, ':forum_id' => $fid);
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1028
1029 $db->query($query, $params);
1030 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1031
1032 $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect'];
1033 redirect('moderate.php?fid='.$fid, $redirect_msg);
1034 }
1035 // Or just one in $_GET
1036 else
1037 {
1038 confirm_referrer('viewtopic.php');
1039
1040 $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']);
1041 if ($topic_id < 1)
1042 message($lang_common['Bad request']);
1043
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1044 $query = new UpdateQuery(array('closed' => ':closed'), 'topics');
1045 $query->where = 'id = :topic_id AND forum_id = :forum_id';
1046
1047 $params = array(':closed' => $action, ':topic_id' => $topic_id, ':forum_id' => $fid);
1048
1049 $db->query($query, $params);
1050 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1051
1052 $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect'];
1053 redirect('viewtopic.php?id='.$topic_id, $redirect_msg);
1054 }
1055 }
1056
1057
1058 // Stick a topic
1059 else if (isset($_GET['stick']))
1060 {
1061 confirm_referrer('viewtopic.php');
1062
1063 $stick = intval($_GET['stick']);
1064 if ($stick < 1)
1065 message($lang_common['Bad request']);
1066
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1067 $query = new UpdateQuery(array('sticky' => '1'), 'topics');
1068 $query->where = 'id = :topic_id AND forum_id = :forum_id';
1069
1070 $params = array(':topic_id' => $stick, ':forum_id' => $fid);
1071
1072 $db->query($query, $params);
1073 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1074
1075 redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']);
1076 }
1077
1078
1079 // Unstick a topic
1080 else if (isset($_GET['unstick']))
1081 {
1082 confirm_referrer('viewtopic.php');
1083
1084 $unstick = intval($_GET['unstick']);
1085 if ($unstick < 1)
1086 message($lang_common['Bad request']);
1087
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1088 $query = new UpdateQuery(array('sticky' => '0'), 'topics');
1089 $query->where = 'id = :topic_id AND forum_id = :forum_id';
1090
1091 $params = array(':topic_id' => $unstick, ':forum_id' => $fid);
1092
1093 $db->query($query, $params);
1094 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1095
1096 redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']);
1097 }
1098
1099
1100 // No specific forum moderation action was specified in the query string, so we'll display the moderator forum
1101
1102 // Load the viewforum.php language file
1103 require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
1104
1105 // Fetch some info about the forum
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1106 $query = new SelectQuery(array('forum_name' => 'f.forum_name', 'redirect_url' => 'f.redirect_url', 'num_topics' => 'f.num_topics', 'sort_by' => 'f.sort_by'), 'forums AS f');
1107
1108 $query->joins['fp'] = new LeftJoin('forum_perms AS fp');
1109 $query->joins['fp']->on = 'fp.forum_id = f.id AND fp.group_id = :group_id';
1110
1111 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND f.id = :forum_id';
1112
1113 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $fid);
1114
1115 $result = $db->query($query, $params);
1116 if (empty($result))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1117 message($lang_common['Bad request']);
1118
89d59dc @reines Converting some more queries
reines authored Apr 7, 2011
1119 $cur_forum = $result[0];
1120 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1121
1122 // Is this a redirect forum? In that case, abort!
1123 if ($cur_forum['redirect_url'] != '')
1124 message($lang_common['Bad request']);
1125
fbd37d2 @reines Add the option to sort forums alphabetically.
reines authored Jan 23, 2011
1126 switch ($cur_forum['sort_by'])
1127 {
1128 case 0:
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1129 $sort_by = 't.last_post DESC';
fbd37d2 @reines Add the option to sort forums alphabetically.
reines authored Jan 23, 2011
1130 break;
1131 case 1:
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1132 $sort_by = 't.posted DESC';
fbd37d2 @reines Add the option to sort forums alphabetically.
reines authored Jan 23, 2011
1133 break;
1134 case 2:
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1135 $sort_by = 't.subject ASC';
fbd37d2 @reines Add the option to sort forums alphabetically.
reines authored Jan 23, 2011
1136 break;
1137 default:
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1138 $sort_by = 't.last_post DESC';
fbd37d2 @reines Add the option to sort forums alphabetically.
reines authored Jan 23, 2011
1139 break;
1140 }
1141
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1142 // Determine the topic offset (based on $_GET['p'])
1143 $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);
1144
1226d2d @Quy Fixed $_GET['p'] parameter (page number).
Quy authored Jun 8, 2009
1145 $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1146 $start_from = $pun_user['disp_topics'] * ($p - 1);
1147
1148 // Generate paging links
421c354 Moving hard coded colon to language file. Putting span around pages l…
Paul Sullivan authored Mar 28, 2010
1149 $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'moderate.php?fid='.$fid);
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
1150
1151 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_forum['forum_name']));
a43f248 @Quy Changed prefix to PUN for consistency.
Quy authored Feb 7, 2010
1152 define('PUN_ACTIVE_PAGE', 'index');
8b59f34 @Quy Removed pun_htmlspecialchars from the generate_page_title function.
Quy authored Jan 30, 2010
1153 require PUN_ROOT.'header.php';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1154
1155 ?>
1156 <div class="linkst">
bbf4d49 Added extra class to top and bottom links that have breadcrumbs plus …
Paul Sullivan authored Jan 27, 2010
1157 <div class="inbox crumbsplus">
a66809c Added class .crumbs to the breadcrumbs lists to avoid having to style…
Paul Sullivan authored Dec 19, 2009
1158 <ul class="crumbs">
bde6dd7 Fixing rendering of crumbs, pagelinks, postlink.
Paul Sullivan authored Dec 4, 2009
1159 <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
8d5b6c0 @reines Replacing some entities with their UTF-8 character equivalent.
reines authored May 15, 2010
1160 <li><span&#160;</span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></a></li>
1161 <li><span&#160;</span><strong><?php echo $lang_misc['Moderate'] ?></strong></li>
bde6dd7 Fixing rendering of crumbs, pagelinks, postlink.
Paul Sullivan authored Dec 4, 2009
1162 </ul>
bdd1406 Fixing and improving display of breadcrumbs.
Paul authored May 25, 2010
1163 <div class="pagepost">
1164 <p class="pagelink conl"><?php echo $paging_links ?></p>
1165 </div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1166 <div class="clearer"></div>
1167 </div>
1168 </div>
1169
1170 <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
1171 <div id="vf" class="blocktable">
1172 <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2>
1173 <div class="box">
1174 <div class="inbox">
1175 <table cellspacing="0">
1176 <thead>
1177 <tr>
1178 <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th>
1179 <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th>
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
1180 <?php if ($pun_config['o_topic_views'] == '1'): ?> <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th>
1181 <?php endif; ?> <th class="tcr"><?php echo $lang_common['Last post'] ?></th>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1182 <th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th>
1183 </tr>
1184 </thead>
1185 <tbody>
1186 <?php
1187
5d5ab3a @reines Applying the changes from viewforum.php to moderate.php too
reines authored Jul 24, 2010
1188
1189 // Retrieve a list of topic IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1190 $query = new SelectQuery(array('id' => 't.id'), 'topics AS t');
1191 $query->where = 't.forum_id = :forum_id';
1192 $query->order = array('sticky' => 't.sticky DESC', 'sort' => $sort_by, 'id' => 't.id DESC');
1193 $query->limit = $pun_user['disp_topics'];
1194 $query->offset = $start_from;
1195
1196 $params = array(':forum_id' => $fid);
1197
1198 $topic_ids = $db->query($query, $params);
1199 unset ($query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1200
ccb8295 @franzliedke Fixed a whole bunch of mainly comment typos, reported by Darren.
franzliedke authored Oct 14, 2009
1201 // If there are topics in this forum
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1202 if (!empty($topic_ids))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1203 {
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1204 // Translate from a 3d array into 2d array: $topics_ids[0]['id'] -> $topics_ids[0]
1205 foreach ($topic_ids as $key => $value)
1206 $topic_ids[$key] = $value['id'];
5d5ab3a @reines Applying the changes from viewforum.php to moderate.php too
reines authored Jul 24, 2010
1207
1208 // Select topics
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1209 $query = new SelectQuery(array('id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to'), 'topics AS t');
1210 $query->where = 't.id IN :tids';
1211 $query->order = array('sticky' => 't.sticky DESC', 'sort' => $sort_by, 'id' => 't.id DESC');
1212
1213 $params = array(':tids' => $topic_ids);
5d5ab3a @reines Applying the changes from viewforum.php to moderate.php too
reines authored Jul 24, 2010
1214
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1215 $button_status = '';
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1216 $topic_count = 0;
24eab3d @reines Converting the remaining queries in moderate.php
reines authored Apr 8, 2011
1217
1218 $result = $db->query($query, $params);
1219 foreach ($result as $cur_topic)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1220 {
1221
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1222 ++$topic_count;
1223 $status_text = array();
1224 $item_status = ($topic_count % 2 == 0) ? 'roweven' : 'rowodd';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1225 $icon_type = 'icon';
1226
1227 if ($cur_topic['moved_to'] == null)
1228 {
985148b Tidying up some inconsistencies in table markup spotted by quy.
Paul Sullivan authored Jan 25, 2010
1229 $last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1230 $ghost_topic = false;
1231 }
1232 else
1233 {
f4f58f7 Generally tidying up. Eliminating some inconsistencies. Eliminating t…
Paul Sullivan authored Jan 28, 2010
1234 $last_post = '- - -';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1235 $ghost_topic = true;
1236 }
1237
1238 if ($pun_config['o_censoring'] == '1')
1239 $cur_topic['subject'] = censor_words($cur_topic['subject']);
1240
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1241 if ($cur_topic['sticky'] == '1')
1242 {
1243 $item_status .= ' isticky';
1244 $status_text[] = '<span class="stickytext">'.$lang_forum['Sticky'].'</span>';
1245 }
1246
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1247 if ($cur_topic['moved_to'] != 0)
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1248 {
1249 $subject = '<a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
1250 $status_text[] = '<span class="movedtext">'.$lang_forum['Moved'].'</span>';
1251 $item_status .= ' imoved';
1252 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1253 else if ($cur_topic['closed'] == '0')
f4f58f7 Generally tidying up. Eliminating some inconsistencies. Eliminating t…
Paul Sullivan authored Jan 28, 2010
1254 $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1255 else
1256 {
1257 $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1258 $status_text[] = '<span class="closedtext">'.$lang_forum['Closed'].'</span>';
1259 $item_status .= ' iclosed';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1260 }
1261
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
1262 if (!$ghost_topic && $cur_topic['last_post'] > $pun_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']) && (!isset($tracked_topics['forums'][$fid]) || $tracked_topics['forums'][$fid] < $cur_topic['last_post']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1263 {
1264 $item_status .= ' inew';
0f5b8bc 1. Tweaking the css of status icons making it more obvious.
Paul Sullivan authored Jan 24, 2010
1265 $icon_type = 'icon icon-new';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1266 $subject = '<strong>'.$subject.'</strong>';
e05f264 Discovered and corrected a few whitespace errors and some oddly incon…
Paul Sullivan authored Dec 24, 2009
1267 $subject_new_posts = '<span class="newtext">[ <a href="viewtopic.php?id='.$cur_topic['id'].'&amp;action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a> ]</span>';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1268 }
1269 else
1270 $subject_new_posts = null;
1271
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1272 // Insert the status text before the subject
1273 $subject = implode(' ', $status_text).' '.$subject;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1274
1275 $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
1276
1277 if ($num_pages_topic > 1)
e05f264 Discovered and corrected a few whitespace errors and some oddly incon…
Paul Sullivan authored Dec 24, 2009
1278 $subject_multipage = '<span class="pagestext">[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]</span>';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1279 else
1280 $subject_multipage = null;
1281
1282 // Should we show the "New posts" and/or the multipage links?
1283 if (!empty($subject_new_posts) || !empty($subject_multipage))
1284 {
e05f264 Discovered and corrected a few whitespace errors and some oddly incon…
Paul Sullivan authored Dec 24, 2009
1285 $subject .= !empty($subject_new_posts) ? ' '.$subject_new_posts : '';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1286 $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
1287 }
1288
1289 ?>
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1290 <tr class="<?php echo $item_status ?>">
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1291 <td class="tcl">
ba4df65 1. Removed hidden text from status icons and from language files.
Paul Sullivan authored Jan 21, 2010
1292 <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo forum_number_format($topic_count + $start_from) ?></div></div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1293 <div class="tclcon">
e05f264 Discovered and corrected a few whitespace errors and some oddly incon…
Paul Sullivan authored Dec 24, 2009
1294 <div>
1295 <?php echo $subject."\n" ?>
1296 </div>
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1297