root/ip/trunk/bin.php

119157
22
include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
22
include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
23
include_once(IP_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
23
include_once(IP_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
24
24
25
include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
26
$mcp_topic = new class_mcp_topic();
27
25
@include_once(IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
28
@include_once(IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
26
$class_topics = new class_topics();
29
$class_topics = new class_topics();
27
30
...
...
110
{
113
{
111
	if (($config['bin_forum'] == 0) || (empty($_POST['topic_id_list']) && empty($topic_id)))
114
	if (($config['bin_forum'] == 0) || (empty($_POST['topic_id_list']) && empty($topic_id)))
112
	{
115
	{
113
		$redirect_url = CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $forum_id . '&' . POST_TOPIC_URL . '=' . $topic_id . '&sid=' . $userdata['session_id'];
116
		$redirect_url = CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id . '&sid=' . $userdata['session_id'];
114
		$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
117
		$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
115
		$message = $message . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '='
. $forum_id . '&amp;sid=' . $userdata['session_id'] . '">', '</a>');
118
		$message = $message . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '='
. $forum_id . '&amp;sid=' . $userdata['session_id'] . '">', '</a>');
116
119
...
...
120
	}
123
	}
121
	else
124
	else
122
	{
125
	{
123
		// Define bin forum
126
		$topics = (isset($_POST['topic_id_list'])) ? $_POST['topic_id_list'] : array($topic_id);
124
		$new_forum_id = intval($config['bin_forum']);
125
		$old_forum_id = $forum_id;
126
127
127
		if ($new_forum_id != $old_forum_id)
128
		if($mcp_topic->topic_recycle($topics, $forum_id))
128
		{
129
		{
129
			$topics = (isset($_POST['topic_id_list'])) ?  $_POST['topic_id_list'] : array($topic_id);
130
131
			$topic_list = '';
132
			for($i = 0; $i < sizeof($topics); $i++)
133
			{
134
				$topic_list .= (($topic_list != '') ? ', ' : '') . intval($topics[$i]);
135
			}
136
137
			$sql = "SELECT *
138
				FROM " . TOPICS_TABLE . "
139
				WHERE topic_id IN ($topic_list)
140
					AND forum_id = $old_forum_id
141
					AND topic_status <> " . TOPIC_MOVED;
142
			$result = $db->sql_query($sql);
143
			$row = $db->sql_fetchrowset($result);
144
			$db->sql_freeresult($result);
145
146
			$db->sql_transaction('begin');
147
148
			for($i = 0; $i < sizeof($row); $i++)
149
			{
150
				$topic_id = $row[$i]['topic_id'];
151
152
				if (isset($_POST['move_leave_shadow']))
153
				{
154
					// Insert topic in the old forum that indicates that the forum has moved.
155
					$sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id)
156
						VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)";
157
					$result = $db->sql_query($sql);
158
				}
159
160
				$sql = "UPDATE " . TOPICS_TABLE . "
161
					SET forum_id = " . $new_forum_id . "
162
					WHERE topic_id = " . $topic_id;
163
				$result = $db->sql_query($sql);
164
165
				$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = " . $topic_id;
166
				$result = $db->sql_query($sql);
167
168
//<!-- BEGIN Unread Post Information to Database Mod -->
169
				$sql = "UPDATE " . UPI2DB_LAST_POSTS_TABLE . "
170
					SET forum_id = " . $new_forum_id . "
171
					WHERE topic_id = " . $topic_id;
172
				$result = $db->sql_query($sql);
173
174
				$sql = "UPDATE " . UPI2DB_UNREAD_POSTS_TABLE . "
175
					SET forum_id = " . $new_forum_id . "
176
					WHERE topic_id = " . $topic_id;
177
				$result = $db->sql_query($sql);
178
//<!-- BEGIN Unread Post Information to Database Mod -->
179
180
				$sql = "UPDATE " . POSTS_TABLE . "
181
					SET forum_id = " . $new_forum_id . "
182
					WHERE topic_id = " . $topic_id;
183
				$result = $db->sql_query($sql);
184
			}
185
186
			$db->sql_transaction('commit');
187
188
			// Sync the forum indexes
189
			empty_cache_folders(POSTS_CACHE_FOLDER);
190
			empty_cache_folders(FORUMS_CACHE_FOLDER);
191
			sync('forum', $new_forum_id);
192
			sync('forum', $old_forum_id);
193
194
			$message = $lang['Topics_Moved_bin'];
130
			$message = $lang['Topics_Moved_bin'];
195
		}
131
		}
196
		else
132
		else
...
...
201
		$redirect_url = CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $forum_id . '&amp;' . POST_TOPIC_URL . '=' . $topic_id . '&amp;sid=' .
$userdata['session_id'];
137
		$redirect_url = CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $forum_id . '&amp;' . POST_TOPIC_URL . '=' . $topic_id . '&amp;sid=' .
$userdata['session_id'];
202
		$message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
138
		$message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
203
139
204
		$message = $message . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $old_forum_id . '&amp;sid=' . $userdata['session_id'] . '">', '</a>');
140
		$message = $message . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '='
. $forum_id . '&amp;sid=' . $userdata['session_id'] . '">', '</a>');
205
141
206
		meta_refresh(3, $redirect_url);
142
		meta_refresh(3, $redirect_url);
207
143