forked from MightyGorgon/icy_phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.php
146 lines (122 loc) · 4.25 KB
/
bin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*
* @Extra credits for this file
* Kooky ([email protected])
*
*/
define('ROBOTS_NOINDEX', true);
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
include_once(IP_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT);
if (empty($class_mcp)) $class_mcp = new class_mcp();
@include_once(IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
$class_topics = new class_topics();
// Init common vars: forum_id, topic_id, post_id, etc.
$class_topics->var_init(true);
$confirm = true;
// Continue var definitions
$start = request_var('start', 0);
$start = ($start < 0) ? 0 : $start;
// session id check
$sid = request_var('sid', '');
// Obtain relevant data
if (!empty($topic_id))
{
$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.topic_id = " . $topic_id . "
AND f.forum_id = t.forum_id";
$db->sql_return_on_error(true);
$result = $db->sql_query($sql);
$db->sql_return_on_error(false);
if (!$result)
{
if (!defined('STATUS_404')) define('STATUS_404', true);
message_die(GENERAL_MESSAGE, 'NO_TOPIC');
}
$topic_row = $db->sql_fetchrow($result);
$forum_topics = ($topic_row['forum_topics'] == 0) ? 1 : $topic_row['forum_topics'];
$forum_id = $topic_row['forum_id'];
$forum_name = $topic_row['forum_name'];
}
elseif (!empty($forum_id))
{
$sql = "SELECT forum_name, forum_topics
FROM " . FORUMS_TABLE . "
WHERE forum_id = " . $forum_id;
$db->sql_return_on_error(true);
$result = $db->sql_query($sql);
$db->sql_return_on_error(false);
if (!$result)
{
if (!defined('STATUS_404')) define('STATUS_404', true);
message_die(GENERAL_MESSAGE, 'NO_FORUM');
}
$topic_row = $db->sql_fetchrow($result);
$forum_topics = ($topic_row['forum_topics'] == 0) ? 1 : $topic_row['forum_topics'];
$forum_name = $topic_row['forum_name'];
}
else
{
if (!defined('STATUS_404')) define('STATUS_404', true);
message_die(GENERAL_MESSAGE, 'NO_FORUM');
}
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
// session id check
if ($sid == '' || ($sid != $user->data['session_id']))
{
message_die(GENERAL_ERROR, 'INVALID_SESSION');
}
// Start auth check
$is_auth = auth(AUTH_ALL, $forum_id, $user->data);
if (!$is_auth['auth_mod'])
{
message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorized']);
}
// End Auth Check
if ($confirm)
{
if (($config['bin_forum'] == 0) || (empty($_POST['topic_id_list']) && empty($topic_id)))
{
$redirect_url = CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id . '&sid=' . $user->data['session_id'];
$message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
$message = $message . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id . '&sid=' . $user->data['session_id'] . '">', '</a>');
meta_refresh(3, $redirect_url);
message_die(GENERAL_MESSAGE, $lang['Bin_disabled'] . '<br /><br />' . $message);
}
else
{
$topics = (isset($_POST['topic_id_list'])) ? $_POST['topic_id_list'] : array($topic_id);
if($class_mcp->topic_recycle($topics, $forum_id))
{
$message = $lang['Topics_Moved_bin'];
}
else
{
$message = $lang['No_Topics_Moved'];
}
$redirect_url = CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $forum_id . '&' . POST_TOPIC_URL . '=' . $topic_id . '&sid=' . $user->data['session_id'];
$message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . $redirect_url . '">', '</a>');
$message = $message . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id . '&sid=' . $user->data['session_id'] . '">', '</a>');
meta_refresh(3, $redirect_url);
message_die(GENERAL_MESSAGE, $message);
}
}
?>