| 1 |
561 |
uid29890 |
<?php
|
| 2 |
877 |
thefinn |
/***************************************************************************
|
| 3 |
932 |
psotfx |
* modcp.php
|
| 4 |
877 |
thefinn |
* -------------------
|
| 5 |
572 |
thefinn |
* begin : July 4, 2001
|
| 6 |
877 |
thefinn |
* copyright : (C) 2001 The phpBB Group
|
| 7 |
877 |
thefinn |
* email : support@phpbb.com
|
| 8 |
877 |
thefinn |
*
|
| 9 |
877 |
thefinn |
* $Id$
|
| 10 |
877 |
thefinn |
*
|
| 11 |
877 |
thefinn |
***************************************************************************/
|
| 12 |
561 |
uid29890 |
|
| 13 |
976 |
thefinn |
/***************************************************************************
|
| 14 |
976 |
thefinn |
*
|
| 15 |
976 |
thefinn |
* This program is free software; you can redistribute it and/or modify
|
| 16 |
976 |
thefinn |
* it under the terms of the GNU General Public License as published by
|
| 17 |
976 |
thefinn |
* the Free Software Foundation; either version 2 of the License, or
|
| 18 |
976 |
thefinn |
* (at your option) any later version.
|
| 19 |
976 |
thefinn |
*
|
| 20 |
976 |
thefinn |
***************************************************************************/
|
| 21 |
976 |
thefinn |
|
| 22 |
561 |
uid29890 |
/**
|
| 23 |
561 |
uid29890 |
* Moderator Control Panel
|
| 24 |
561 |
uid29890 |
*
|
| 25 |
561 |
uid29890 |
* From this 'Control Panel' the moderator of a forum will be able to do
|
| 26 |
561 |
uid29890 |
* mass topic operations (locking/unlocking/moving/deleteing), and it will
|
| 27 |
877 |
thefinn |
* provide an interface to do quick locking/unlocking/moving/deleting of
|
| 28 |
561 |
uid29890 |
* topics via the moderator operations buttons on all of the viewtopic pages.
|
| 29 |
561 |
uid29890 |
*/
|
| 30 |
877 |
thefinn |
|
| 31 |
2305 |
psotfx |
define('IN_PHPBB', true);
|
| 32 |
2350 |
psotfx |
$phpbb_root_path = './';
|
| 33 |
646 |
psotfx |
include($phpbb_root_path . 'extension.inc');
|
| 34 |
646 |
psotfx |
include($phpbb_root_path . 'common.'.$phpEx);
|
| 35 |
646 |
psotfx |
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
|
| 36 |
2305 |
psotfx |
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
| 37 |
561 |
uid29890 |
|
| 38 |
1043 |
psotfx |
//
|
| 39 |
1043 |
psotfx |
// Obtain initial var settings
|
| 40 |
1043 |
psotfx |
//
|
| 41 |
2350 |
psotfx |
if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
|
| 42 |
1043 |
psotfx |
{
|
| 43 |
1307 |
psotfx |
$forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
|
| 44 |
1043 |
psotfx |
}
|
| 45 |
1043 |
psotfx |
else
|
| 46 |
1043 |
psotfx |
{
|
| 47 |
2350 |
psotfx |
$forum_id = '';
|
| 48 |
1043 |
psotfx |
}
|
| 49 |
561 |
uid29890 |
|
| 50 |
2350 |
psotfx |
if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
|
| 51 |
1043 |
psotfx |
{
|
| 52 |
1307 |
psotfx |
$post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
|
| 53 |
1043 |
psotfx |
}
|
| 54 |
1043 |
psotfx |
else
|
| 55 |
1043 |
psotfx |
{
|
| 56 |
2350 |
psotfx |
$post_id = '';
|
| 57 |
1043 |
psotfx |
}
|
| 58 |
561 |
uid29890 |
|
| 59 |
2350 |
psotfx |
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) )
|
| 60 |
561 |
uid29890 |
{
|
| 61 |
1307 |
psotfx |
$topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]);
|
| 62 |
1043 |
psotfx |
}
|
| 63 |
1043 |
psotfx |
else
|
| 64 |
1043 |
psotfx |
{
|
| 65 |
2350 |
psotfx |
$topic_id = '';
|
| 66 |
1043 |
psotfx |
}
|
| 67 |
1043 |
psotfx |
|
| 68 |
1307 |
psotfx |
$confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0;
|
| 69 |
1043 |
psotfx |
|
| 70 |
1043 |
psotfx |
//
|
| 71 |
1043 |
psotfx |
// Continue var definitions
|
| 72 |
1043 |
psotfx |
//
|
| 73 |
2599 |
psotfx |
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
|
| 74 |
6772 |
acydburn |
$start = ($start < 0) ? 0 : $start;
|
| 75 |
1043 |
psotfx |
|
| 76 |
2350 |
psotfx |
$delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE;
|
| 77 |
2350 |
psotfx |
$move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE;
|
| 78 |
2350 |
psotfx |
$lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE;
|
| 79 |
2350 |
psotfx |
$unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;
|
| 80 |
1043 |
psotfx |
|
| 81 |
2350 |
psotfx |
if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
|
| 82 |
1043 |
psotfx |
{
|
| 83 |
1043 |
psotfx |
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
|
| 84 |
4863 |
acydburn |
$mode = htmlspecialchars($mode);
|
| 85 |
1043 |
psotfx |
}
|
| 86 |
1043 |
psotfx |
else
|
| 87 |
1043 |
psotfx |
{
|
| 88 |
2350 |
psotfx |
if ( $delete )
|
| 89 |
1043 |
psotfx |
{
|
| 90 |
1043 |
psotfx |
$mode = 'delete';
|
| 91 |
1043 |
psotfx |
}
|
| 92 |
2350 |
psotfx |
else if ( $move )
|
| 93 |
1043 |
psotfx |
{
|
| 94 |
1043 |
psotfx |
$mode = 'move';
|
| 95 |
1043 |
psotfx |
}
|
| 96 |
2350 |
psotfx |
else if ( $lock )
|
| 97 |
1043 |
psotfx |
{
|
| 98 |
1043 |
psotfx |
$mode = 'lock';
|
| 99 |
1043 |
psotfx |
}
|
| 100 |
2350 |
psotfx |
else if ( $unlock )
|
| 101 |
1043 |
psotfx |
{
|
| 102 |
1043 |
psotfx |
$mode = 'unlock';
|
| 103 |
1043 |
psotfx |
}
|
| 104 |
1043 |
psotfx |
else
|
| 105 |
1043 |
psotfx |
{
|
| 106 |
2350 |
psotfx |
$mode = '';
|
| 107 |
1043 |
psotfx |
}
|
| 108 |
1043 |
psotfx |
}
|
| 109 |
1043 |
psotfx |
|
| 110 |
3167 |
psotfx |
// session id check
|
| 111 |
3167 |
psotfx |
if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
|
| 112 |
3167 |
psotfx |
{
|
| 113 |
3167 |
psotfx |
$sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
|
| 114 |
3167 |
psotfx |
}
|
| 115 |
3167 |
psotfx |
else
|
| 116 |
3167 |
psotfx |
{
|
| 117 |
3167 |
psotfx |
$sid = '';
|
| 118 |
3167 |
psotfx |
}
|
| 119 |
8457 |
Kellanved |
// privileged session id check
|
| 120 |
8457 |
Kellanved |
if (!empty($HTTP_POST_VARS['p_sid']) || !empty($HTTP_GET_VARS['p_sid']))
|
| 121 |
8457 |
Kellanved |
{
|
| 122 |
8457 |
Kellanved |
$p_sid = (!empty($HTTP_POST_VARS['p_sid'])) ? $HTTP_POST_VARS['p_sid'] : $HTTP_GET_VARS['p_sid'];
|
| 123 |
8457 |
Kellanved |
}
|
| 124 |
8457 |
Kellanved |
else
|
| 125 |
8457 |
Kellanved |
{
|
| 126 |
8457 |
Kellanved |
$p_sid = '';
|
| 127 |
8457 |
Kellanved |
}
|
| 128 |
3167 |
psotfx |
|
| 129 |
1043 |
psotfx |
//
|
| 130 |
1043 |
psotfx |
// Obtain relevant data
|
| 131 |
1043 |
psotfx |
//
|
| 132 |
2347 |
psotfx |
if ( !empty($topic_id) )
|
| 133 |
1043 |
psotfx |
{
|
| 134 |
877 |
thefinn |
$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
|
| 135 |
877 |
thefinn |
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
|
| 136 |
877 |
thefinn |
WHERE t.topic_id = " . $topic_id . "
|
| 137 |
686 |
psotfx |
AND f.forum_id = t.forum_id";
|
| 138 |
2347 |
psotfx |
if ( !($result = $db->sql_query($sql)) )
|
| 139 |
561 |
uid29890 |
{
|
| 140 |
2347 |
psotfx |
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
|
| 141 |
561 |
uid29890 |
}
|
| 142 |
1043 |
psotfx |
$topic_row = $db->sql_fetchrow($result);
|
| 143 |
686 |
psotfx |
|
| 144 |
5099 |
acydburn |
if (!$topic_row)
|
| 145 |
5099 |
acydburn |
{
|
| 146 |
5099 |
acydburn |
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
|
| 147 |
5099 |
acydburn |
}
|
| 148 |
5099 |
acydburn |
|
| 149 |
2476 |
psotfx |
$forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
|
| 150 |
1043 |
psotfx |
$forum_id = $topic_row['forum_id'];
|
| 151 |
1043 |
psotfx |
$forum_name = $topic_row['forum_name'];
|
| 152 |
561 |
uid29890 |
}
|
| 153 |
2347 |
psotfx |
else if ( !empty($forum_id) )
|
| 154 |
561 |
uid29890 |
{
|
| 155 |
877 |
thefinn |
$sql = "SELECT forum_name, forum_topics
|
| 156 |
877 |
thefinn |
FROM " . FORUMS_TABLE . "
|
| 157 |
686 |
psotfx |
WHERE forum_id = " . $forum_id;
|
| 158 |
2347 |
psotfx |
if ( !($result = $db->sql_query($sql)) )
|
| 159 |
561 |
uid29890 |
{
|
| 160 |
2347 |
psotfx |
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
|
| 161 |
561 |
uid29890 |
}
|
| 162 |
1043 |
psotfx |
$topic_row = $db->sql_fetchrow($result);
|
| 163 |
686 |
psotfx |
|
| 164 |
5099 |
acydburn |
if (!$topic_row)
|
| 165 |
5099 |
acydburn |
{
|
| 166 |
5099 |
acydburn |
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
|
| 167 |
5099 |
acydburn |
}
|
| 168 |
5099 |
acydburn |
|
| 169 |
2476 |
psotfx |
$forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
|
| 170 |
1043 |
psotfx |
$forum_name = $topic_row['forum_name'];
|
| 171 |
561 |
uid29890 |
}
|
| 172 |
2347 |
psotfx |
else
|
| 173 |
2347 |
psotfx |
{
|
| 174 |
2347 |
psotfx |
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
|
| 175 |
2347 |
psotfx |
}
|
| 176 |
561 |
uid29890 |
|
| 177 |
561 |
uid29890 |
//
|
| 178 |
561 |
uid29890 |
// Start session management
|
| 179 |
561 |
uid29890 |
//
|
| 180 |
2260 |
psotfx |
$userdata = session_pagestart($user_ip, $forum_id);
|
| 181 |
561 |
uid29890 |
init_userprefs($userdata);
|
| 182 |
561 |
uid29890 |
//
|
| 183 |
561 |
uid29890 |
// End session management
|
| 184 |
561 |
uid29890 |
//
|
| 185 |
561 |
uid29890 |
|
| 186 |
3167 |
psotfx |
// session id check
|
| 187 |
8457 |
Kellanved |
if ($p_sid === '' || $p_sid !== $userdata['priv_session_id'])
|
| 188 |
3167 |
psotfx |
{
|
| 189 |
3289 |
psotfx |
message_die(GENERAL_ERROR, 'Invalid_session');
|
| 190 |
3167 |
psotfx |
}
|
| 191 |
3167 |
psotfx |
|
| 192 |
561 |
uid29890 |
//
|
| 193 |
2570 |
psotfx |
// Check if user did or did not confirm
|
| 194 |
2570 |
psotfx |
// If they did not, forward them to the last page they were on
|
| 195 |
2570 |
psotfx |
//
|
| 196 |
2570 |
psotfx |
if ( isset($HTTP_POST_VARS['cancel']) )
|
| 197 |
2570 |
psotfx |
{
|
| 198 |
2570 |
psotfx |
if ( $topic_id )
|
| 199 |
2570 |
psotfx |
{
|
| 200 |
2570 |
psotfx |
$redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
|
| 201 |
2570 |
psotfx |
}
|
| 202 |
2570 |
psotfx |
else if ( $forum_id )
|
| 203 |
2570 |
psotfx |
{
|
| 204 |
2570 |
psotfx |
$redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
|
| 205 |
2570 |
psotfx |
}
|
| 206 |
2570 |
psotfx |
else
|
| 207 |
2570 |
psotfx |
{
|
| 208 |
2570 |
psotfx |
$redirect = "index.$phpEx";
|
| 209 |
2570 |
psotfx |
}
|
| 210 |
2570 |
psotfx |
|
| 211 |
3154 |
psotfx |
redirect(append_sid($redirect, true));
|
| 212 |
2570 |
psotfx |
}
|
| 213 |
2570 |
psotfx |
|
| 214 |
2570 |
psotfx |
//
|
| 215 |
561 |
uid29890 |
// Start auth check
|
| 216 |
561 |
uid29890 |
//
|
| 217 |
561 |
uid29890 |
$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
|
| 218 |
561 |
uid29890 |
|
| 219 |
2448 |
psotfx |
if ( !$is_auth['auth_mod'] )
|
| 220 |
561 |
uid29890 |
{
|
| 221 |
676 |
psotfx |
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
|
| 222 |
561 |
uid29890 |
}
|
| 223 |
1043 |
psotfx |
//
|
| 224 |
1043 |
psotfx |
// End Auth Check
|
| 225 |
1043 |
psotfx |
//
|
| 226 |
561 |
uid29890 |
|
| 227 |
619 |
thefinn |
//
|
| 228 |
1043 |
psotfx |
// Do major work ...
|
| 229 |
1043 |
psotfx |
//
|
| 230 |
2462 |
psotfx |
switch( $mode )
|
| 231 |
561 |
uid29890 |
{
|
| 232 |
561 |
uid29890 |
case 'delete':
|
| 233 |
3121 |
psotfx |
if (!$is_auth['auth_delete'])
|
| 234 |
3121 |
psotfx |
{
|
| 235 |
5204 |
acydburn |
message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
|
| 236 |
3121 |
psotfx |
}
|
| 237 |
3121 |
psotfx |
|
| 238 |
1440 |
psotfx |
$page_title = $lang['Mod_CP'];
|
| 239 |
1440 |
psotfx |
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
| 240 |
1440 |
psotfx |
|
| 241 |
2104 |
psotfx |
if ( $confirm )
|
| 242 |
572 |
thefinn |
{
|
| 243 |
5478 |
grahamje |
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
|
| 244 |
5478 |
grahamje |
{
|
| 245 |
5478 |
grahamje |
message_die(GENERAL_MESSAGE, $lang['None_selected']);
|
| 246 |
5478 |
grahamje |
}
|
| 247 |
5478 |
grahamje |
|
| 248 |
2347 |
psotfx |
include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
|
| 249 |
2347 |
psotfx |
|
| 250 |
4331 |
acydburn |
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
|
| 251 |
1043 |
psotfx |
|
| 252 |
2350 |
psotfx |
$topic_id_sql = '';
|
| 253 |
1043 |
psotfx |
for($i = 0; $i < count($topics); $i++)
|
| 254 |
619 |
thefinn |
{
|
| 255 |
4331 |
acydburn |
$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
|
| 256 |
619 |
thefinn |
}
|
| 257 |
1043 |
psotfx |
|
| 258 |
4331 |
acydburn |
$sql = "SELECT topic_id
|
| 259 |
4331 |
acydburn |
FROM " . TOPICS_TABLE . "
|
| 260 |
4331 |
acydburn |
WHERE topic_id IN ($topic_id_sql)
|
| 261 |
4331 |
acydburn |
AND forum_id = $forum_id";
|
| 262 |
4331 |
acydburn |
if ( !($result = $db->sql_query($sql)) )
|
| 263 |
4331 |
acydburn |
{
|
| 264 |
4331 |
acydburn |
message_die(GENERAL_ERROR, 'Could not get topic id information', '', __LINE__, __FILE__, $sql);
|
| 265 |
4331 |
acydburn |
}
|
| 266 |
4331 |
acydburn |
|
| 267 |
4331 |
acydburn |
$topic_id_sql = '';
|
| 268 |
4331 |
acydburn |
while ($row = $db->sql_fetchrow($result))
|
| 269 |
4331 |
acydburn |
{
|
| 270 |
4331 |
acydburn |
$topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);
|
| 271 |
4331 |
acydburn |
}
|
| 272 |
4331 |
acydburn |
$db->sql_freeresult($result);
|
| 273 |
4331 |
acydburn |
|
| 274 |
5478 |
grahamje |
if ( $topic_id_sql == '')
|
| 275 |
5478 |
grahamje |
{
|
| 276 |
5478 |
grahamje |
message_die(GENERAL_MESSAGE, $lang['None_selected']);
|
| 277 |
5478 |
grahamje |
}
|
| 278 |
5478 |
grahamje |
|
| 279 |
2729 |
psotfx |
$sql = "SELECT poster_id, COUNT(post_id) AS posts
|
| 280 |
2729 |
psotfx |
FROM " . POSTS_TABLE . "
|
| 281 |
2729 |
psotfx |
WHERE topic_id IN ($topic_id_sql)
|
| 282 |
2729 |
psotfx |
GROUP BY poster_id";
|
| 283 |
2729 |
psotfx |
if ( !($result = $db->sql_query($sql)) )
|
| 284 |
2729 |
psotfx |
{
|
| 285 |
2729 |
psotfx |
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
|
| 286 |
2729 |
psotfx |
}
|
| 287 |
2729 |
psotfx |
|
| 288 |
2729 |
psotfx |
$count_sql = array();
|
| 289 |
2729 |
psotfx |
while ( $row = $db->sql_fetchrow($result) )
|
| 290 |
2729 |
psotfx |
{
|
| 291 |
2729 |
psotfx |
$count_sql[] = "UPDATE " . USERS_TABLE . "
|
| 292 |
2729 |
psotfx |
SET user_posts = user_posts - " . $row['posts'] . "
|
| 293 |
2729 |
psotfx |
WHERE user_id = " . $row['poster_id'];
|
| 294 |
2729 |
psotfx |
}
|
| 295 |
2729 |
psotfx |
$db->sql_freeresult($result);
|
| 296 |
2729 |
psotfx |
|
| 297 |
2729 |
psotfx |
if ( sizeof($count_sql) )
|
| 298 |
2729 |
psotfx |
{
|
| 299 |
2729 |
psotfx |
for($i = 0; $i < sizeof($count_sql); $i++)
|
| 300 |
2729 |
psotfx |
{
|
| 301 |
2729 |
psotfx |
if ( !$db->sql_query($count_sql[$i]) )
|
| 302 |
2729 |
psotfx |
{
|
| 303 |
2729 |
psotfx |
message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
|
| 304 |
2729 |
psotfx |
}
|
| 305 |
2729 |
psotfx |
}
|
| 306 |
2729 |
psotfx |
}
|
| 307 |
2729 |
psotfx |
|
| 308 |
1043 |
psotfx |
$sql = "SELECT post_id
|
| 309 |
1043 |
psotfx |
FROM " . POSTS_TABLE . "
|
| 310 |
1043 |
psotfx |
WHERE topic_id IN ($topic_id_sql)";
|
| 311 |
2729 |
psotfx |
if ( !($result = $db->sql_query($sql)) )
|
| 312 |
619 |
thefinn |
{
|
| 313 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
|
| 314 |
619 |
thefinn |
}
|
| 315 |
877 |
thefinn |
|
| 316 |
2350 |
psotfx |
$post_id_sql = '';
|
| 317 |
2462 |
psotfx |
while ( $row = $db->sql_fetchrow($result) )
|
| 318 |
572 |
thefinn |
{
|
| 319 |
4331 |
acydburn |
$post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . intval($row['post_id']);
|
| 320 |
572 |
thefinn |
}
|
| 321 |
2462 |
psotfx |
$db->sql_freeresult($result);
|
| 322 |
877 |
thefinn |
|
| 323 |
1043 |
psotfx |
$sql = "SELECT vote_id
|
| 324 |
1043 |
psotfx |
FROM " . VOTE_DESC_TABLE . "
|
| 325 |
1043 |
psotfx |
WHERE topic_id IN ($topic_id_sql)";
|
| 326 |
2350 |
psotfx |
if ( !($result = $db->sql_query($sql)) )
|
| 327 |
572 |
thefinn |
{
|
| 328 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
|
| 329 |
572 |
thefinn |
}
|
| 330 |
1043 |
psotfx |
|
| 331 |
2350 |
psotfx |
$vote_id_sql = '';
|
| 332 |
2462 |
psotfx |
while ( $row = $db->sql_fetchrow($result) )
|
| 333 |
619 |
thefinn |
{
|
| 334 |
2462 |
psotfx |
$vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
|
| 335 |
619 |
thefinn |
}
|
| 336 |
2462 |
psotfx |
$db->sql_freeresult($result);
|
| 337 |
877 |
thefinn |
|
| 338 |
1043 |
psotfx |
//
|
| 339 |
1043 |
psotfx |
// Got all required info so go ahead and start deleting everything
|
| 340 |
1043 |
psotfx |
//
|
| 341 |
1043 |
psotfx |
$sql = "DELETE
|
| 342 |
1043 |
psotfx |
FROM " . TOPICS_TABLE . "
|
| 343 |
1071 |
psotfx |
WHERE topic_id IN ($topic_id_sql)
|
| 344 |
1071 |
psotfx |
OR topic_moved_id IN ($topic_id_sql)";
|
| 345 |
2462 |
psotfx |
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
|
| 346 |
877 |
thefinn |
{
|
| 347 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
|
| 348 |
619 |
thefinn |
}
|
| 349 |
877 |
thefinn |
|
| 350 |
2350 |
psotfx |
if ( $post_id_sql != '' )
|
| 351 |
619 |
thefinn |
{
|
| 352 |
1314 |
bartvb |
$sql = "DELETE
|
| 353 |
1314 |
bartvb |
FROM " . POSTS_TABLE . "
|
| 354 |
1314 |
bartvb |
WHERE post_id IN ($post_id_sql)";
|
| 355 |
2462 |
psotfx |
if ( !$db->sql_query($sql) )
|
| 356 |
1314 |
bartvb |
{
|
| 357 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
|
| 358 |
1314 |
bartvb |
}
|
| 359 |
877 |
thefinn |
|
| 360 |
1314 |
bartvb |
$sql = "DELETE
|
| 361 |
1314 |
bartvb |
FROM " . POSTS_TEXT_TABLE . "
|
| 362 |
1314 |
bartvb |
WHERE post_id IN ($post_id_sql)";
|
| 363 |
2462 |
psotfx |
if ( !$db->sql_query($sql) )
|
| 364 |
1314 |
bartvb |
{
|
| 365 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
|
| 366 |
1314 |
bartvb |
}
|
| 367 |
1439 |
psotfx |
|
| 368 |
2337 |
psotfx |
remove_search_post($post_id_sql);
|
| 369 |
619 |
thefinn |
}
|
| 370 |
877 |
thefinn |
|
| 371 |
2350 |
psotfx |
if ( $vote_id_sql != '' )
|
| 372 |
890 |
gpolins |
{
|
| 373 |
1071 |
psotfx |
$sql = "DELETE
|
| 374 |
1071 |
psotfx |
FROM " . VOTE_DESC_TABLE . "
|
| 375 |
1071 |
psotfx |
WHERE vote_id IN ($vote_id_sql)";
|
| 376 |
2462 |
psotfx |
if ( !$db->sql_query($sql) )
|
| 377 |
1071 |
psotfx |
{
|
| 378 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
|
| 379 |
1071 |
psotfx |
}
|
| 380 |
892 |
thefinn |
|
| 381 |
1071 |
psotfx |
$sql = "DELETE
|
| 382 |
1071 |
psotfx |
FROM " . VOTE_RESULTS_TABLE . "
|
| 383 |
1071 |
psotfx |
WHERE vote_id IN ($vote_id_sql)";
|
| 384 |
2462 |
psotfx |
if ( !$db->sql_query($sql) )
|
| 385 |
1071 |
psotfx |
{
|
| 386 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
|
| 387 |
1071 |
psotfx |
}
|
| 388 |
1043 |
psotfx |
|
| 389 |
1071 |
psotfx |
$sql = "DELETE
|
| 390 |
1071 |
psotfx |
FROM " . VOTE_USERS_TABLE . "
|
| 391 |
1071 |
psotfx |
WHERE vote_id IN ($vote_id_sql)";
|
| 392 |
2462 |
psotfx |
if ( !$db->sql_query($sql) )
|
| 393 |
1071 |
psotfx |
{
|
| 394 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
|
| 395 |
1071 |
psotfx |
}
|
| 396 |
1043 |
psotfx |
}
|
| 397 |
1043 |
psotfx |
|
| 398 |
1073 |
psotfx |
$sql = "DELETE
|
| 399 |
1073 |
psotfx |
FROM " . TOPICS_WATCH_TABLE . "
|
| 400 |
1073 |
psotfx |
WHERE topic_id IN ($topic_id_sql)";
|
| 401 |
2462 |
psotfx |
if ( !$db->sql_query($sql, END_TRANSACTION) )
|
| 402 |
1073 |
psotfx |
{
|
| 403 |
2350 |
psotfx |
message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
|
| 404 |
1073 |
psotfx |
}
|
| 405 |
1073 |
psotfx |
|
| 406 |
2350 |
psotfx |
sync('forum', $forum_id);
|
| 407 |
877 |
thefinn |
|
| 408 |
2350 |
psotfx |
if ( !empty($topic_id) )
|
| 409 |
625 |
thefinn |
{
|
| 410 |
8457 |
Kellanved |
$redirect_page = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
|
| 411 |
2104 |
psotfx |
$l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
|
| 412 |
625 |
thefinn |
}
|
| 413 |
625 |
thefinn |
else
|
| 414 |
625 |
thefinn |
{
|
| 415 |
8457 |
Kellanved |
$redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&p_sid=" . $userdata['priv_session_id']);
|
| 416 |
2104 |
psotfx |
$l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
|
| 417 |
625 |
thefinn |
}
|
| 418 |
877 |
thefinn |
|
| 419 |
1307 |
psotfx |
$template->assign_vars(array(
|
| 420 |
2350 |
psotfx |
'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
|
| 421 |
1307 |
psotfx |
);
|
| 422 |
1307 |
psotfx |
|
| 423 |
2350 |
psotfx |
message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
|
| 424 |
609 |
thefinn |
}
|
| 425 |
609 |
thefinn |
else
|
| 426 |
609 |
thefinn |
{
|
| 427 |
2104 |
psotfx |
// Not confirmed, show confirmation message
|
| 428 |
2350 |
psotfx |
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
|
| 429 |
976 |
thefinn |
{
|
| 430 |
2350 |
psotfx |
message_die(GENERAL_MESSAGE, $lang['None_selected']);
|
| 431 |
976 |
thefinn |
}
|
| 432 |
1043 |
psotfx |
|
| 433 |
8457 |
Kellanved |
$hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="p_sid" value="' . $userdata['priv_session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
|
| 434 |
1043 |
psotfx |
|
| 435 |
2350 |
psotfx |
if ( isset($HTTP_POST_VARS['topic_id_list']) )
|
| 436 |
572 |
thefinn |
{
|
| 437 |
1043 |
psotfx |
$topics = $HTTP_POST_VARS['topic_id_list'];
|
| 438 |
1043 |
psotfx |
for($i = 0; $i < count($topics); $i++)
|
| 439 |
619 |
thefinn |
{
|
| 440 |
2503 |
psotfx |
$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
|
| 441 |
619 |
thefinn |
}
|
| 442 |
572 |
thefinn |
}
|
|