forked from XoopsModules25x/newbb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoderate.php
260 lines (248 loc) · 12.6 KB
/
moderate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
/**
* NewBB 4.3x, the forum module for XOOPS project
*
* @copyright XOOPS Project (http://xoops.org)
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.) <[email protected]>
* @since 4.00
* @package module::newbb
*/
include_once __DIR__ . '/header.php';
$topic_id = XoopsRequest::getInt('topic_id', XoopsRequest::getInt('topic_id', 0, 'POST'), 'GET');
$forum_userid = XoopsRequest::getInt('fuid', 0, 'GET');
$isadmin = newbb_isAdmin($forum_id);
if (!$isadmin) {
redirect_header(XOOPS_URL . '/index.php', 2, _MD_NORIGHTTOACCESS);
}
$is_administrator = $GLOBALS['xoopsUserIsAdmin'];
$moderateHandler = xoops_getModuleHandler('moderate', 'newbb');
if (XoopsRequest::getString('submit', '', 'POST') && XoopsRequest::getInt('expire', 0, 'POST')) {
if (XoopsRequest::getString('ip', '', 'POST')
&& !preg_match("/^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$/", XoopsRequest::getString('ip', '', 'POST'))
) {
$_POST['ip'] = '';
}
if ((XoopsRequest::getInt('uid', 0, 'POST')
&& $moderateHandler->getLatest(XoopsRequest::getInt('uid', 0, 'POST')) > (time() + XoopsRequest::getInt('expire', 0, 'POST') * 3600 * 24))
|| (XoopsRequest::getString('ip', '', 'POST')
&& $moderateHandler->getLatest(XoopsRequest::getString('ip', '', 'POST'), false) > (time() + XoopsRequest::getInt('expire', 0, 'POST') * 3600 * 24))
|| (!XoopsRequest::getInt('uid', 0, 'POST') && !XoopsRequest::getString('ip', '', 'POST'))
) {
} else {
$moderate_obj = $moderateHandler->create();
$moderate_obj->setVar('uid', XoopsRequest::getInt('uid', 0, 'POST'));
$moderate_obj->setVar('ip', XoopsRequest::getString('ip', '', 'POST'));
$moderate_obj->setVar('forum_id', $forum_id);
$moderate_obj->setVar('mod_start', time());
$moderate_obj->setVar('mod_end', time() + XoopsRequest::getInt('expire', 0, 'POST') * 3600 * 24);
$moderate_obj->setVar('mod_desc', XoopsRequest::getString('desc', '', 'POST'));
$res = $moderateHandler->insert($moderate_obj);
if (XoopsRequest::getInt('uid', 0, 'POST') > 0) {
$onlineHandler = xoops_getHandler('online');
$onlines =& $onlineHandler->getAll(new Criteria('online_uid', XoopsRequest::getInt('uid', 0, 'POST')));
if (false !== $onlines) {
$online_ip = $onlines[0]['online_ip'];
$sql = sprintf('DELETE FROM %s WHERE sess_ip = %s', $GLOBALS['xoopsDB']->prefix('session'), $GLOBALS['xoopsDB']->quoteString($online_ip));
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
}
}
}
if (XoopsRequest::getString('ip', '', 'POST')) {
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('session') . ' WHERE sess_ip LIKE ' . $GLOBALS['xoopsDB']->quoteString('%' . XoopsRequest::getString('ip', '', 'POST'));
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
}
}
redirect_header('moderate.php?forum=$forum_id', 2, _MD_DBUPDATED);
}
} elseif (XoopsRequest::getString('del', '', 'GET')) {
$moderate_obj = $moderateHandler->get(XoopsRequest::getString('del', '', 'GET'));
if ($is_administrator || $moderate_obj->getVar('forum_id') == $forum_id) {
$moderateHandler->delete($moderate_obj, true);
redirect_header('moderate.php?forum=$forum_id', 2, _MD_DBUPDATED);
}
}
$start = XoopsRequest::getInt('start', 0, 'GET');
$sortname = XoopsRequest::getString('sort', '', 'GET');
switch ($sortname) {
case 'uid':
$sort = 'uid ASC, ip';
$order = 'ASC';
break;
case 'start':
$sort = 'mod_start';
$order = 'ASC';
break;
case 'expire':
$sort = 'mod_end';
$order = 'DESC';
break;
default:
$sort = 'forum_id ASC, uid ASC, ip';
$order = 'ASC';
break;
}
// START - irmtfan - only show all bans for module admin - for moderator just show its forum_id bans
$criteria = new CriteriaCompo();
if (!$is_administrator) {
$criteria->add(new Criteria('forum_id', $forum_id, '='));
}
// END - irmtfan - only show all bans for module admin - for moderator just show its forum_id bans
$criteria->setLimit($GLOBALS['xoopsModuleConfig']['topics_per_page']);
$criteria->setStart($start);
$criteria->setSort($sort);
$criteria->setOrder($order);
$moderate_objs = $moderateHandler->getObjects($criteria);
$moderate_count = $moderateHandler->getCount($criteria);
include $GLOBALS['xoops']->path('header.php');
$url = 'index.php';
if ($forum_id) {
$url = 'viewforum.php?forum=' . $forum_id;
}
echo '<div class="forum_intro odd">
<div class="forum_title">
<a href="index.php">' . sprintf(_MD_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)) . '</a>
<span class="delimiter">»</span>
' . _MD_SUSPEND_MANAGEMENT . '
<br><br>
</div>
<div style="clear:both;"></div>
</div>
<br>';
echo '<div style="padding: 10px; margin-left:auto; margin-right:auto; text-align:center;"><a href="' . $url . '"><h2>' . _MD_SUSPEND_MANAGEMENT . '</h2></a></div>';
if (!empty($moderate_count)) {
$_users = array();
foreach (array_keys($moderate_objs) as $id) {
$_users[$moderate_objs[$id]->getVar('uid')] = 1;
}
$users =& newbb_getUnameFromIds(array_keys($_users), $GLOBALS['xoopsModuleConfig']['show_realname'], true);
echo '
<table class="outer" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<tr class="head" align="left">
<td width="5%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=uid" title="Sort by uid">' . _MD_SUSPEND_UID . '</a></strong>
</td>
<td width="10%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=start" title="Sort by start">' . _MD_SUSPEND_START . '</a></strong>
</td>
<td width="10%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=expire" title="Sort by expire">' . _MD_SUSPEND_EXPIRE . '</a></strong>
</td>
<td width="10%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=forum" title="Sort by expire">' . _MD_SUSPEND_SCOPE . '</a></strong>
</td>
<td align="left">
<strong>' . _MD_SUSPEND_DESC . '</strong>
</td>
<td width="5%" align="center" nowrap="nowrap">
<strong>' . _DELETE . '</strong>
</td>
</tr>
';
// START irmtfan add forum name in moderate.php
$forumHandler = xoops_getModuleHandler('forum', 'newbb');
$forum_list = $forumHandler->getAll(null, array('forum_name'), false);
// END irmtfan add forum name in moderate.php
foreach (array_keys($moderate_objs) as $id) {
echo '
<tr>
<td width="5%" align="center" nowrap="nowrap">
'
. ($moderate_objs[$id]->getVar('uid') ? (isset($users[$moderate_objs[$id]->getVar('uid')]) ? $users[$moderate_objs[$id]->getVar('uid')] : $moderate_objs[$id]->getVar('uid')) : $moderate_objs[$id]->getVar('ip'))
. '
</td>
<td width="10%" align="center">
'
. formatTimestamp($moderate_objs[$id]->getVar('mod_start'))
. '
</td>
<td width="10%" align="center">
'
. formatTimestamp($moderate_objs[$id]->getVar('mod_end'))
. '
</td>
<td width="10%" align="center">
'
. ($moderate_objs[$id]->getVar('forum_id') ? $forum_list[$moderate_objs[$id]->getVar('forum_id')]['forum_name'] /*irmtfan add forum name in moderate.php*/ : _ALL)
. '
</td>
<td align="left">
'
. ($moderate_objs[$id]->getVar('mod_desc') ?: _NONE)
. '
</td>
<td width="5%" align="center" nowrap="nowrap">
'
. (($is_administrator
|| $moderate_objs[$id]->getVar('forum_id') == $forum_id) ? '<a href="moderate.php?forum='
. $forum_id
. '&del='
. $moderate_objs[$id]->getVar('mod_id')
. '">'
. _DELETE
. '</a>' : ' ')
. '
</td>
</tr>
';
}
echo '
<tr class="head" align="left">
<td width="5%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=uid" title="Sort by uid">' . _MD_SUSPEND_UID . '</a></strong>
</td>
<td width="10%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=start" title="Sort by start">' . _MD_SUSPEND_START . '</a></strong>
</td>
<td width="10%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=expire" title="Sort by expire">' . _MD_SUSPEND_EXPIRE . '</a></strong>
</td>
<td width="10%" align="center" nowrap="nowrap">
<strong><a href="moderate.php?forum=' . $forum_id . '&start=' . $start . '&sort=forum" title="Sort by expire">' . _MD_SUSPEND_SCOPE . '</a></strong>
</td>
<td align="left">
<strong>' . _MD_SUSPEND_DESC . '</strong>
</td>
<td width="5%" align="center" nowrap="nowrap">
<strong>' . _DELETE . '</strong>
</td>
</tr>
';
if ($moderate_count > $GLOBALS['xoopsModuleConfig']['topics_per_page']) {
include $GLOBALS['xoops']->path('class/pagenav.php');
$nav = new XoopsPageNav($all_topics, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start, 'start', 'forum=' . $forum_id . '&sort=' . $sortname);
if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
$nav->url = formatURL($_SERVER['SERVER_NAME']) . ' /' . $nav->url;
}
echo '<tr><td colspan="6">' . $nav->renderNav(4) . '</td></tr>';
}
echo '</table><br><br>';
}
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
$forum_form = new XoopsThemeForm(_ADD, 'suspend', 'moderate.php', 'post');
//$forum_form->addElement(new XoopsFormText(_MD_SUSPEND_UID, 'uid', 20, 25 , $forum_userid));
$forum_form->addElement(new XoopsFormSelectUser(_MD_SUSPEND_UID, 'uid', true, $forum_userid, 1, false));
$forum_form->addElement(new XoopsFormText(_MD_SUSPEND_IP, 'ip', 20, 25));
$forum_form->addElement(new XoopsFormText(_MD_SUSPEND_DURATION, 'expire', 20, 25, '5'), true);
$forum_form->addElement(new XoopsFormText(_MD_SUSPEND_DESC, 'desc', 50, 255));
// START irmtfan add forum select box for admins
mod_loadFunctions('forum', 'newbb');
if (newbb_isAdmin()) {
$forumSel = '<select name=\'forum\'>';// if user dont select any it select "0"
$forumSel .= '<option value=\'0\' ';
if ($forum_id == 0) {
$forumSel .= ' selected';
}
$forumSel .= '>' . _ALL . '</option>';
$forumSel .= newbb_forumSelectBox($forum_id, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = true
$forumSel .= '</select>';
$forumEle = new XoopsFormLabel(_MD_SELFORUM, $forumSel);
$forumEle->customValidationCode[] = 'if (document.suspend.forum.value < 0) {return false;} ';
$forum_form->addElement($forumEle);
} else {
$forum_form->addElement(new XoopsFormHidden('forum', $forum_id));
}
// END irmtfan add forum select box for admins
$forum_form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$forum_form->display();
include $GLOBALS['xoops']->path('footer.php');