1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Copyright (C) 2008-2011 FluxBB |
---|
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 | */ |
---|
8 | |
---|
9 | // Tell header.php to use the admin template |
---|
10 | define('PUN_ADMIN_CONSOLE', 1); |
---|
11 | |
---|
12 | define('PUN_ROOT', dirname(__FILE__).'/'); |
---|
13 | require PUN_ROOT.'include/common.php'; |
---|
14 | require PUN_ROOT.'include/common_admin.php'; |
---|
15 | |
---|
16 | |
---|
17 | if (!$pun_user['is_admmod']) |
---|
18 | message($lang_common['No permission']); |
---|
19 | |
---|
20 | // Load the admin_users.php language file |
---|
21 | require PUN_ROOT.'lang/'.$admin_language.'/admin_users.php'; |
---|
22 | |
---|
23 | // Show IP statistics for a certain user ID |
---|
24 | if (isset($_GET['ip_stats'])) |
---|
25 | { |
---|
26 | $ip_stats = intval($_GET['ip_stats']); |
---|
27 | if ($ip_stats < 1) |
---|
28 | message($lang_common['Bad request']); |
---|
29 | |
---|
30 | // Fetch ip count |
---|
31 | $result = $db->query('SELECT poster_ip, MAX(posted) AS last_used FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
32 | $num_ips = $db->num_rows($result); |
---|
33 | |
---|
34 | // Determine the ip offset (based on $_GET['p']) |
---|
35 | $num_pages = ceil($num_ips / 50); |
---|
36 | |
---|
37 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
---|
38 | $start_from = 50 * ($p - 1); |
---|
39 | |
---|
40 | // Generate paging links |
---|
41 | $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?ip_stats='.$ip_stats ); |
---|
42 | |
---|
43 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']); |
---|
44 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
45 | require PUN_ROOT.'header.php'; |
---|
46 | |
---|
47 | ?> |
---|
48 | <div class="linkst"> |
---|
49 | <div class="inbox crumbsplus"> |
---|
50 | <ul class="crumbs"> |
---|
51 | <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
---|
52 | <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
53 | <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
---|
54 | </ul> |
---|
55 | <div class="pagepost"> |
---|
56 | <p class="pagelink"><?php echo $paging_links ?></p> |
---|
57 | </div> |
---|
58 | <div class="clearer"></div> |
---|
59 | </div> |
---|
60 | </div> |
---|
61 | |
---|
62 | <div id="users1" class="blocktable"> |
---|
63 | <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2> |
---|
64 | <div class="box"> |
---|
65 | <div class="inbox"> |
---|
66 | <table cellspacing="0"> |
---|
67 | <thead> |
---|
68 | <tr> |
---|
69 | <th class="tcl" scope="col"><?php echo $lang_admin_users['Results IP address head'] ?></th> |
---|
70 | <th class="tc2" scope="col"><?php echo $lang_admin_users['Results last used head'] ?></th> |
---|
71 | <th class="tc3" scope="col"><?php echo $lang_admin_users['Results times found head'] ?></th> |
---|
72 | <th class="tcr" scope="col"><?php echo $lang_admin_users['Results action head'] ?></th> |
---|
73 | </tr> |
---|
74 | </thead> |
---|
75 | <tbody> |
---|
76 | <?php |
---|
77 | |
---|
78 | $result = $db->query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC LIMIT '.$start_from.', 50') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
79 | if ($db->num_rows($result)) |
---|
80 | { |
---|
81 | while ($cur_ip = $db->fetch_assoc($result)) |
---|
82 | { |
---|
83 | |
---|
84 | ?> |
---|
85 | <tr> |
---|
86 | <td class="tcl"><a href="moderate.php?get_host=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $cur_ip['poster_ip'] ?></a></td> |
---|
87 | <td class="tc2"><?php echo format_time($cur_ip['last_used']) ?></td> |
---|
88 | <td class="tc3"><?php echo $cur_ip['used_times'] ?></td> |
---|
89 | <td class="tcr"><a href="admin_users.php?show_users=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $lang_admin_users['Results find more link'] ?></a></td> |
---|
90 | </tr> |
---|
91 | <?php |
---|
92 | |
---|
93 | } |
---|
94 | } |
---|
95 | else |
---|
96 | echo "\t\t\t\t".'<tr><td class="tcl" colspan="4">'.$lang_admin_users['Results no posts found'].'</td></tr>'."\n"; |
---|
97 | |
---|
98 | ?> |
---|
99 | </tbody> |
---|
100 | </table> |
---|
101 | </div> |
---|
102 | </div> |
---|
103 | </div> |
---|
104 | |
---|
105 | <div class="linksb"> |
---|
106 | <div class="inbox crumbsplus"> |
---|
107 | <div class="pagepost"> |
---|
108 | <p class="pagelink"><?php echo $paging_links ?></p> |
---|
109 | </div> |
---|
110 | <ul class="crumbs"> |
---|
111 | <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
---|
112 | <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
113 | <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
---|
114 | </ul> |
---|
115 | <div class="clearer"></div> |
---|
116 | </div> |
---|
117 | </div> |
---|
118 | <?php |
---|
119 | |
---|
120 | require PUN_ROOT.'footer.php'; |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | if (isset($_GET['show_users'])) |
---|
125 | { |
---|
126 | $ip = trim($_GET['show_users']); |
---|
127 | |
---|
128 | if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $ip) && !@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}:))$%', $ip)) |
---|
129 | message($lang_admin_users['Bad IP message']); |
---|
130 | |
---|
131 | // Fetch user count |
---|
132 | $result = $db->query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\'') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
133 | $num_users = $db->num_rows($result); |
---|
134 | |
---|
135 | // Determine the user offset (based on $_GET['p']) |
---|
136 | $num_pages = ceil($num_users / 50); |
---|
137 | |
---|
138 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
---|
139 | $start_from = 50 * ($p - 1); |
---|
140 | |
---|
141 | // Generate paging links |
---|
142 | $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?show_users='.$ip); |
---|
143 | |
---|
144 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']); |
---|
145 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
146 | require PUN_ROOT.'header.php'; |
---|
147 | |
---|
148 | ?> |
---|
149 | <div class="linkst"> |
---|
150 | <div class="inbox crumbsplus"> |
---|
151 | <ul class="crumbs"> |
---|
152 | <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
---|
153 | <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
154 | <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
---|
155 | </ul> |
---|
156 | <div class="pagepost"> |
---|
157 | <p class="pagelink"><?php echo $paging_links ?></p> |
---|
158 | </div> |
---|
159 | <div class="clearer"></div> |
---|
160 | </div> |
---|
161 | </div> |
---|
162 | |
---|
163 | <div id="users2" class="blocktable"> |
---|
164 | <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2> |
---|
165 | <div class="box"> |
---|
166 | <div class="inbox"> |
---|
167 | <table cellspacing="0"> |
---|
168 | <thead> |
---|
169 | <tr> |
---|
170 | <th class="tcl" scope="col"><?php echo $lang_admin_users['Results username head'] ?></th> |
---|
171 | <th class="tc2" scope="col"><?php echo $lang_admin_users['Results e-mail head'] ?></th> |
---|
172 | <th class="tc3" scope="col"><?php echo $lang_admin_users['Results title head'] ?></th> |
---|
173 | <th class="tc4" scope="col"><?php echo $lang_admin_users['Results posts head'] ?></th> |
---|
174 | <th class="tc5" scope="col"><?php echo $lang_admin_users['Results admin note head'] ?></th> |
---|
175 | <th class="tcr" scope="col"><?php echo $lang_admin_users['Results actions head'] ?></th> |
---|
176 | </tr> |
---|
177 | </thead> |
---|
178 | <tbody> |
---|
179 | <?php |
---|
180 | |
---|
181 | $result = $db->query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\' ORDER BY poster DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
182 | $num_posts = $db->num_rows($result); |
---|
183 | |
---|
184 | if ($num_posts) |
---|
185 | { |
---|
186 | // Loop through users and print out some info |
---|
187 | for ($i = 0; $i < $num_posts; ++$i) |
---|
188 | { |
---|
189 | list($poster_id, $poster) = $db->fetch_row($result); |
---|
190 | |
---|
191 | $result2 = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
---|
192 | |
---|
193 | if (($user_data = $db->fetch_assoc($result2))) |
---|
194 | { |
---|
195 | $user_title = get_title($user_data); |
---|
196 | |
---|
197 | $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> | <a href="search.php?action=show_user_posts&user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>'; |
---|
198 | |
---|
199 | ?> |
---|
200 | <tr> |
---|
201 | <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td> |
---|
202 | <td class="tc2"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></td> |
---|
203 | <td class="tc3"><?php echo $user_title ?></td> |
---|
204 | <td class="tc4"><?php echo forum_number_format($user_data['num_posts']) ?></td> |
---|
205 | <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : ' ' ?></td> |
---|
206 | <td class="tcr"><?php echo $actions ?></td> |
---|
207 | </tr> |
---|
208 | <?php |
---|
209 | |
---|
210 | } |
---|
211 | else |
---|
212 | { |
---|
213 | |
---|
214 | ?> |
---|
215 | <tr> |
---|
216 | <td class="tcl"><?php echo pun_htmlspecialchars($poster) ?></td> |
---|
217 | <td class="tc2"> </td> |
---|
218 | <td class="tc3"><?php echo $lang_admin_users['Results guest'] ?></td> |
---|
219 | <td class="tc4"> </td> |
---|
220 | <td class="tc5"> </td> |
---|
221 | <td class="tcr"> </td> |
---|
222 | </tr> |
---|
223 | <?php |
---|
224 | |
---|
225 | } |
---|
226 | } |
---|
227 | } |
---|
228 | else |
---|
229 | echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">'.$lang_admin_users['Results no IP found'].'</td></tr>'."\n"; |
---|
230 | |
---|
231 | ?> |
---|
232 | </tbody> |
---|
233 | </table> |
---|
234 | </div> |
---|
235 | </div> |
---|
236 | </div> |
---|
237 | |
---|
238 | <div class="linksb"> |
---|
239 | <div class="inbox crumbsplus"> |
---|
240 | <div class="pagepost"> |
---|
241 | <p class="pagelink"><?php echo $paging_links ?></p> |
---|
242 | </div> |
---|
243 | <ul class="crumbs"> |
---|
244 | <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
---|
245 | <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
246 | <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
---|
247 | </ul> |
---|
248 | <div class="clearer"></div> |
---|
249 | </div> |
---|
250 | </div> |
---|
251 | <?php |
---|
252 | require PUN_ROOT.'footer.php'; |
---|
253 | } |
---|
254 | |
---|
255 | |
---|
256 | // Move multiple users to other user groups |
---|
257 | else if (isset($_POST['move_users']) || isset($_POST['move_users_comply'])) |
---|
258 | { |
---|
259 | if ($pun_user['g_id'] > PUN_ADMIN) |
---|
260 | message($lang_common['No permission']); |
---|
261 | |
---|
262 | confirm_referrer('admin_users.php'); |
---|
263 | |
---|
264 | if (isset($_POST['users'])) |
---|
265 | { |
---|
266 | $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']); |
---|
267 | $user_ids = array_map('intval', $user_ids); |
---|
268 | |
---|
269 | // Delete invalid IDs |
---|
270 | $user_ids = array_diff($user_ids, array(0, 1)); |
---|
271 | } |
---|
272 | else |
---|
273 | $user_ids = array(); |
---|
274 | |
---|
275 | if (empty($user_ids)) |
---|
276 | message($lang_admin_users['No users selected']); |
---|
277 | |
---|
278 | // Are we trying to batch move any admins? |
---|
279 | $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
---|
280 | if ($db->result($result) > 0) |
---|
281 | message($lang_admin_users['No move admins message']); |
---|
282 | |
---|
283 | // Fetch all user groups |
---|
284 | $all_groups = array(); |
---|
285 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id NOT IN ('.PUN_GUEST.','.PUN_ADMIN.') ORDER BY g_title ASC') or error('Unable to fetch groups', __FILE__, __LINE__, $db->error()); |
---|
286 | while ($row = $db->fetch_row($result)) |
---|
287 | $all_groups[$row[0]] = $row[1]; |
---|
288 | |
---|
289 | if (isset($_POST['move_users_comply'])) |
---|
290 | { |
---|
291 | $new_group = isset($_POST['new_group']) && isset($all_groups[$_POST['new_group']]) ? $_POST['new_group'] : message($lang_admin_users['Invalid group message']); |
---|
292 | |
---|
293 | // Is the new group a moderator group? |
---|
294 | $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$new_group) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
---|
295 | $new_group_mod = $db->result($result); |
---|
296 | |
---|
297 | // Fetch user groups |
---|
298 | $user_groups = array(); |
---|
299 | $result = $db->query('SELECT id, group_id FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error()); |
---|
300 | while ($cur_user = $db->fetch_assoc($result)) |
---|
301 | { |
---|
302 | if (!isset($user_groups[$cur_user['group_id']])) |
---|
303 | $user_groups[$cur_user['group_id']] = array(); |
---|
304 | |
---|
305 | $user_groups[$cur_user['group_id']][] = $cur_user['id']; |
---|
306 | } |
---|
307 | |
---|
308 | // Are any users moderators? |
---|
309 | $group_ids = array_keys($user_groups); |
---|
310 | $result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error()); |
---|
311 | while ($cur_group = $db->fetch_assoc($result)) |
---|
312 | { |
---|
313 | if ($cur_group['g_moderator'] == '0') |
---|
314 | unset($user_groups[$cur_group['g_id']]); |
---|
315 | } |
---|
316 | |
---|
317 | if (!empty($user_groups) && $new_group != PUN_ADMIN && $new_group_mod != '1') |
---|
318 | { |
---|
319 | // Fetch forum list and clean up their moderator list |
---|
320 | $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); |
---|
321 | while ($cur_forum = $db->fetch_assoc($result)) |
---|
322 | { |
---|
323 | $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); |
---|
324 | |
---|
325 | foreach ($user_groups as $group_users) |
---|
326 | $cur_moderators = array_diff($cur_moderators, $group_users); |
---|
327 | |
---|
328 | $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; |
---|
329 | $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | // Change user group |
---|
334 | $db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group.' WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to change user group', __FILE__, __LINE__, $db->error()); |
---|
335 | |
---|
336 | redirect('admin_users.php', $lang_admin_users['Users move redirect']); |
---|
337 | } |
---|
338 | |
---|
339 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Move users']); |
---|
340 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
341 | require PUN_ROOT.'header.php'; |
---|
342 | |
---|
343 | generate_admin_menu('users'); |
---|
344 | |
---|
345 | ?> |
---|
346 | <div class="blockform"> |
---|
347 | <h2><span><?php echo $lang_admin_users['Move users'] ?></span></h2> |
---|
348 | <div class="box"> |
---|
349 | <form name="confirm_move_users" method="post" action="admin_users.php"> |
---|
350 | <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" /> |
---|
351 | <div class="inform"> |
---|
352 | <fieldset> |
---|
353 | <legend><?php echo $lang_admin_users['Move users subhead'] ?></legend> |
---|
354 | <div class="infldset"> |
---|
355 | <table class="aligntop" cellspacing="0"> |
---|
356 | <tr> |
---|
357 | <th scope="row"><?php echo $lang_admin_users['New group label'] ?></th> |
---|
358 | <td> |
---|
359 | <select name="new_group" tabindex="1"> |
---|
360 | <?php foreach ($all_groups as $gid => $group) : ?> <option value="<?php echo $gid ?>"><?php echo pun_htmlspecialchars($group) ?></option> |
---|
361 | <?php endforeach; ?> |
---|
362 | </select> |
---|
363 | <span><?php echo $lang_admin_users['New group help'] ?></span> |
---|
364 | </td> |
---|
365 | </tr> |
---|
366 | </table> |
---|
367 | </div> |
---|
368 | </fieldset> |
---|
369 | </div> |
---|
370 | <p class="submitend"><input type="submit" name="move_users_comply" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="2" /></p> |
---|
371 | </form> |
---|
372 | </div> |
---|
373 | </div> |
---|
374 | <div class="clearer"></div> |
---|
375 | </div> |
---|
376 | <?php |
---|
377 | |
---|
378 | require PUN_ROOT.'footer.php'; |
---|
379 | } |
---|
380 | |
---|
381 | |
---|
382 | // Delete multiple users |
---|
383 | else if (isset($_POST['delete_users']) || isset($_POST['delete_users_comply'])) |
---|
384 | { |
---|
385 | if ($pun_user['g_id'] > PUN_ADMIN) |
---|
386 | message($lang_common['No permission']); |
---|
387 | |
---|
388 | confirm_referrer('admin_users.php'); |
---|
389 | |
---|
390 | if (isset($_POST['users'])) |
---|
391 | { |
---|
392 | $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']); |
---|
393 | $user_ids = array_map('intval', $user_ids); |
---|
394 | |
---|
395 | // Delete invalid IDs |
---|
396 | $user_ids = array_diff($user_ids, array(0, 1)); |
---|
397 | } |
---|
398 | else |
---|
399 | $user_ids = array(); |
---|
400 | |
---|
401 | if (empty($user_ids)) |
---|
402 | message($lang_admin_users['No users selected']); |
---|
403 | |
---|
404 | // Are we trying to delete any admins? |
---|
405 | $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
---|
406 | if ($db->result($result) > 0) |
---|
407 | message($lang_admin_users['No delete admins message']); |
---|
408 | |
---|
409 | if (isset($_POST['delete_users_comply'])) |
---|
410 | { |
---|
411 | // Fetch user groups |
---|
412 | $user_groups = array(); |
---|
413 | $result = $db->query('SELECT id, group_id FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error()); |
---|
414 | while ($cur_user = $db->fetch_assoc($result)) |
---|
415 | { |
---|
416 | if (!isset($user_groups[$cur_user['group_id']])) |
---|
417 | $user_groups[$cur_user['group_id']] = array(); |
---|
418 | |
---|
419 | $user_groups[$cur_user['group_id']][] = $cur_user['id']; |
---|
420 | } |
---|
421 | |
---|
422 | // Are any users moderators? |
---|
423 | $group_ids = array_keys($user_groups); |
---|
424 | $result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error()); |
---|
425 | while ($cur_group = $db->fetch_assoc($result)) |
---|
426 | { |
---|
427 | if ($cur_group['g_moderator'] == '0') |
---|
428 | unset($user_groups[$cur_group['g_id']]); |
---|
429 | } |
---|
430 | |
---|
431 | // Fetch forum list and clean up their moderator list |
---|
432 | $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); |
---|
433 | while ($cur_forum = $db->fetch_assoc($result)) |
---|
434 | { |
---|
435 | $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); |
---|
436 | |
---|
437 | foreach ($user_groups as $group_users) |
---|
438 | $cur_moderators = array_diff($cur_moderators, $group_users); |
---|
439 | |
---|
440 | $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; |
---|
441 | $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
---|
442 | } |
---|
443 | |
---|
444 | // Delete any subscriptions |
---|
445 | $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to delete topic subscriptions', __FILE__, __LINE__, $db->error()); |
---|
446 | $db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to delete forum subscriptions', __FILE__, __LINE__, $db->error()); |
---|
447 | |
---|
448 | // Remove them from the online list (if they happen to be logged in) |
---|
449 | $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id IN ('.implode(',', $user_ids).')') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); |
---|
450 | |
---|
451 | // Should we delete all posts made by these users? |
---|
452 | if (isset($_POST['delete_posts'])) |
---|
453 | { |
---|
454 | require PUN_ROOT.'include/search_idx.php'; |
---|
455 | @set_time_limit(0); |
---|
456 | |
---|
457 | // Find all posts made by this user |
---|
458 | $result = $db->query('SELECT p.id, p.topic_id, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE p.poster_id IN ('.implode(',', $user_ids).')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); |
---|
459 | if ($db->num_rows($result)) |
---|
460 | { |
---|
461 | while ($cur_post = $db->fetch_assoc($result)) |
---|
462 | { |
---|
463 | // Determine whether this post is the "topic post" or not |
---|
464 | $result2 = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['topic_id'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
465 | |
---|
466 | if ($db->result($result2) == $cur_post['id']) |
---|
467 | delete_topic($cur_post['topic_id']); |
---|
468 | else |
---|
469 | delete_post($cur_post['id'], $cur_post['topic_id']); |
---|
470 | |
---|
471 | update_forum($cur_post['forum_id']); |
---|
472 | } |
---|
473 | } |
---|
474 | } |
---|
475 | else |
---|
476 | // Set all their posts to guest |
---|
477 | $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id IN ('.implode(',', $user_ids).')') or error('Unable to update posts', __FILE__, __LINE__, $db->error()); |
---|
478 | |
---|
479 | // Delete the users |
---|
480 | $db->query('DELETE FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to delete users', __FILE__, __LINE__, $db->error()); |
---|
481 | |
---|
482 | // Delete user avatars |
---|
483 | foreach ($user_ids as $user_id) |
---|
484 | delete_avatar($user_id); |
---|
485 | |
---|
486 | // Regenerate the users info cache |
---|
487 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
488 | require PUN_ROOT.'include/cache.php'; |
---|
489 | |
---|
490 | generate_users_info_cache(); |
---|
491 | |
---|
492 | redirect('admin_users.php', $lang_admin_users['Users delete redirect']); |
---|
493 | } |
---|
494 | |
---|
495 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Delete users']); |
---|
496 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
497 | require PUN_ROOT.'header.php'; |
---|
498 | |
---|
499 | generate_admin_menu('users'); |
---|
500 | |
---|
501 | ?> |
---|
502 | <div class="blockform"> |
---|
503 | <h2><span><?php echo $lang_admin_users['Delete users'] ?></span></h2> |
---|
504 | <div class="box"> |
---|
505 | <form name="confirm_del_users" method="post" action="admin_users.php"> |
---|
506 | <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" /> |
---|
507 | <div class="inform"> |
---|
508 | <fieldset> |
---|
509 | <legend><?php echo $lang_admin_users['Confirm delete legend'] ?></legend> |
---|
510 | <div class="infldset"> |
---|
511 | <p><?php echo $lang_admin_users['Confirm delete info'] ?></p> |
---|
512 | <div class="rbox"> |
---|
513 | <label><input type="checkbox" name="delete_posts" value="1" checked="checked" /><?php echo $lang_admin_users['Delete posts'] ?><br /></label> |
---|
514 | </div> |
---|
515 | <p class="warntext"><strong><?php echo $lang_admin_users['Delete warning'] ?></strong></p> |
---|
516 | </div> |
---|
517 | </fieldset> |
---|
518 | </div> |
---|
519 | <p class="buttons"><input type="submit" name="delete_users_comply" value="<?php echo $lang_admin_users['Delete'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
---|
520 | </form> |
---|
521 | </div> |
---|
522 | </div> |
---|
523 | <div class="clearer"></div> |
---|
524 | </div> |
---|
525 | <?php |
---|
526 | |
---|
527 | require PUN_ROOT.'footer.php'; |
---|
528 | } |
---|
529 | |
---|
530 | |
---|
531 | // Ban multiple users |
---|
532 | else if (isset($_POST['ban_users']) || isset($_POST['ban_users_comply'])) |
---|
533 | { |
---|
534 | if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_ban_users'] == '0')) |
---|
535 | message($lang_common['No permission']); |
---|
536 | |
---|
537 | confirm_referrer('admin_users.php'); |
---|
538 | |
---|
539 | if (isset($_POST['users'])) |
---|
540 | { |
---|
541 | $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']); |
---|
542 | $user_ids = array_map('intval', $user_ids); |
---|
543 | |
---|
544 | // Delete invalid IDs |
---|
545 | $user_ids = array_diff($user_ids, array(0, 1)); |
---|
546 | } |
---|
547 | else |
---|
548 | $user_ids = array(); |
---|
549 | |
---|
550 | if (empty($user_ids)) |
---|
551 | message($lang_admin_users['No users selected']); |
---|
552 | |
---|
553 | // Are we trying to ban any admins? |
---|
554 | $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
---|
555 | if ($db->result($result) > 0) |
---|
556 | message($lang_admin_users['No ban admins message']); |
---|
557 | |
---|
558 | // Also, we cannot ban moderators |
---|
559 | $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id WHERE g.g_moderator=1 AND u.id IN ('.implode(',', $user_ids).')') or error('Unable to fetch moderator group info', __FILE__, __LINE__, $db->error()); |
---|
560 | if ($db->result($result) > 0) |
---|
561 | message($lang_admin_users['No ban mods message']); |
---|
562 | |
---|
563 | if (isset($_POST['ban_users_comply'])) |
---|
564 | { |
---|
565 | $ban_message = pun_trim($_POST['ban_message']); |
---|
566 | $ban_expire = pun_trim($_POST['ban_expire']); |
---|
567 | $ban_the_ip = isset($_POST['ban_the_ip']) ? intval($_POST['ban_the_ip']) : 0; |
---|
568 | |
---|
569 | if ($ban_expire != '' && $ban_expire != 'Never') |
---|
570 | { |
---|
571 | $ban_expire = strtotime($ban_expire.' GMT'); |
---|
572 | |
---|
573 | if ($ban_expire == -1 || !$ban_expire) |
---|
574 | message($lang_admin_users['Invalid date message'].' '.$lang_admin_users['Invalid date reasons']); |
---|
575 | |
---|
576 | $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
---|
577 | $ban_expire -= $diff; |
---|
578 | |
---|
579 | if ($ban_expire <= time()) |
---|
580 | message($lang_admin_users['Invalid date message'].' '.$lang_admin_users['Invalid date reasons']); |
---|
581 | } |
---|
582 | else |
---|
583 | $ban_expire = 'NULL'; |
---|
584 | |
---|
585 | $ban_message = ($ban_message != '') ? '\''.$db->escape($ban_message).'\'' : 'NULL'; |
---|
586 | |
---|
587 | // Fetch user information |
---|
588 | $user_info = array(); |
---|
589 | $result = $db->query('SELECT id, username, email, registration_ip FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
---|
590 | while ($cur_user = $db->fetch_assoc($result)) |
---|
591 | $user_info[$cur_user['id']] = array('username' => $cur_user['username'], 'email' => $cur_user['email'], 'ip' => $cur_user['registration_ip']); |
---|
592 | |
---|
593 | // Overwrite the registration IP with one from the last post (if it exists) |
---|
594 | if ($ban_the_ip != 0) |
---|
595 | { |
---|
596 | $result = $db->query('SELECT p.poster_id, p.poster_ip FROM '.$db->prefix.'posts AS p INNER JOIN (SELECT MAX(id) AS id FROM '.$db->prefix.'posts WHERE poster_id IN ('.implode(',', $user_ids).') GROUP BY poster_id) AS i ON p.id=i.id') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
597 | while ($cur_address = $db->fetch_assoc($result)) |
---|
598 | $user_info[$cur_address['poster_id']]['ip'] = $cur_address['poster_ip']; |
---|
599 | } |
---|
600 | |
---|
601 | // And insert the bans! |
---|
602 | foreach ($user_ids as $user_id) |
---|
603 | { |
---|
604 | $ban_username = '\''.$db->escape($user_info[$user_id]['username']).'\''; |
---|
605 | $ban_email = '\''.$db->escape($user_info[$user_id]['email']).'\''; |
---|
606 | $ban_ip = ($ban_the_ip != 0) ? '\''.$db->escape($user_info[$user_id]['ip']).'\'' : 'NULL'; |
---|
607 | |
---|
608 | $db->query('INSERT INTO '.$db->prefix.'bans (username, ip, email, message, expire, ban_creator) VALUES('.$ban_username.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.', '.$pun_user['id'].')') or error('Unable to add ban', __FILE__, __LINE__, $db->error()); |
---|
609 | } |
---|
610 | |
---|
611 | // Regenerate the bans cache |
---|
612 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
613 | require PUN_ROOT.'include/cache.php'; |
---|
614 | |
---|
615 | generate_bans_cache(); |
---|
616 | |
---|
617 | redirect('admin_users.php', $lang_admin_users['Users banned redirect']); |
---|
618 | } |
---|
619 | |
---|
620 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']); |
---|
621 | $focus_element = array('bans2', 'ban_message'); |
---|
622 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
623 | require PUN_ROOT.'header.php'; |
---|
624 | |
---|
625 | generate_admin_menu('users'); |
---|
626 | |
---|
627 | ?> |
---|
628 | <div class="blockform"> |
---|
629 | <h2><span><?php echo $lang_admin_users['Ban users'] ?></span></h2> |
---|
630 | <div class="box"> |
---|
631 | <form id="bans2" name="confirm_ban_users" method="post" action="admin_users.php"> |
---|
632 | <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" /> |
---|
633 | <div class="inform"> |
---|
634 | <fieldset> |
---|
635 | <legend><?php echo $lang_admin_users['Message expiry subhead'] ?></legend> |
---|
636 | <div class="infldset"> |
---|
637 | <table class="aligntop" cellspacing="0"> |
---|
638 | <tr> |
---|
639 | <th scope="row"><?php echo $lang_admin_users['Ban message label'] ?></th> |
---|
640 | <td> |
---|
641 | <input type="text" name="ban_message" size="50" maxlength="255" tabindex="1" /> |
---|
642 | <span><?php echo $lang_admin_users['Ban message help'] ?></span> |
---|
643 | </td> |
---|
644 | </tr> |
---|
645 | <tr> |
---|
646 | <th scope="row"><?php echo $lang_admin_users['Expire date label'] ?></th> |
---|
647 | <td> |
---|
648 | <input type="text" name="ban_expire" size="17" maxlength="10" tabindex="2" /> |
---|
649 | <span><?php echo $lang_admin_users['Expire date help'] ?></span> |
---|
650 | </td> |
---|
651 | </tr> |
---|
652 | <tr> |
---|
653 | <th scope="row"><?php echo $lang_admin_users['Ban IP label'] ?></th> |
---|
654 | <td> |
---|
655 | <input type="radio" name="ban_the_ip" tabindex="3" value="1" checked="checked" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="ban_the_ip" tabindex="4" value="0" checked="checked" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
---|
656 | <span><?php echo $lang_admin_users['Ban IP help'] ?></span> |
---|
657 | </td> |
---|
658 | </tr> |
---|
659 | </table> |
---|
660 | </div> |
---|
661 | </fieldset> |
---|
662 | </div> |
---|
663 | <p class="submitend"><input type="submit" name="ban_users_comply" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="3" /></p> |
---|
664 | </form> |
---|
665 | </div> |
---|
666 | </div> |
---|
667 | <div class="clearer"></div> |
---|
668 | </div> |
---|
669 | <?php |
---|
670 | |
---|
671 | require PUN_ROOT.'footer.php'; |
---|
672 | } |
---|
673 | |
---|
674 | |
---|
675 | else if (isset($_GET['find_user'])) |
---|
676 | { |
---|
677 | $form = isset($_GET['form']) ? $_GET['form'] : array(); |
---|
678 | |
---|
679 | // trim() all elements in $form |
---|
680 | $form = array_map('pun_trim', $form); |
---|
681 | $conditions = $query_str = array(); |
---|
682 | |
---|
683 | $posts_greater = isset($_GET['posts_greater']) ? trim($_GET['posts_greater']) : ''; |
---|
684 | $posts_less = isset($_GET['posts_less']) ? trim($_GET['posts_less']) : ''; |
---|
685 | $last_post_after = isset($_GET['last_post_after']) ? trim($_GET['last_post_after']) : ''; |
---|
686 | $last_post_before = isset($_GET['last_post_before']) ? trim($_GET['last_post_before']) : ''; |
---|
687 | $last_visit_after = isset($_GET['last_visit_after']) ? trim($_GET['last_visit_after']) : ''; |
---|
688 | $last_visit_before = isset($_GET['last_visit_before']) ? trim($_GET['last_visit_before']) : ''; |
---|
689 | $registered_after = isset($_GET['registered_after']) ? trim($_GET['registered_after']) : ''; |
---|
690 | $registered_before = isset($_GET['registered_before']) ? trim($_GET['registered_before']) : ''; |
---|
691 | $order_by = isset($_GET['order_by']) && in_array($_GET['order_by'], array('username', 'email', 'num_posts', 'last_post', 'last_visit', 'registered')) ? $_GET['order_by'] : 'username'; |
---|
692 | $direction = isset($_GET['direction']) && $_GET['direction'] == 'DESC' ? 'DESC' : 'ASC'; |
---|
693 | $user_group = isset($_GET['user_group']) ? intval($_GET['user_group']) : -1; |
---|
694 | |
---|
695 | $query_str[] = 'order_by='.$order_by; |
---|
696 | $query_str[] = 'direction='.$direction; |
---|
697 | $query_str[] = 'user_group='.$user_group; |
---|
698 | |
---|
699 | if (preg_match('%[^0-9]%', $posts_greater.$posts_less)) |
---|
700 | message($lang_admin_users['Non numeric message']); |
---|
701 | |
---|
702 | // Try to convert date/time to timestamps |
---|
703 | if ($last_post_after != '') |
---|
704 | { |
---|
705 | $query_str[] = 'last_post_after='.$last_post_after; |
---|
706 | |
---|
707 | $last_post_after = strtotime($last_post_after); |
---|
708 | if ($last_post_after === false || $last_post_after == -1) |
---|
709 | message($lang_admin_users['Invalid date time message']); |
---|
710 | |
---|
711 | $conditions[] = 'u.last_post>'.$last_post_after; |
---|
712 | } |
---|
713 | if ($last_post_before != '') |
---|
714 | { |
---|
715 | $query_str[] = 'last_post_before='.$last_post_before; |
---|
716 | |
---|
717 | $last_post_before = strtotime($last_post_before); |
---|
718 | if ($last_post_before === false || $last_post_before == -1) |
---|
719 | message($lang_admin_users['Invalid date time message']); |
---|
720 | |
---|
721 | $conditions[] = 'u.last_post<'.$last_post_before; |
---|
722 | } |
---|
723 | if ($last_visit_after != '') |
---|
724 | { |
---|
725 | $query_str[] = 'last_visit_after='.$last_visit_after; |
---|
726 | |
---|
727 | $last_visit_after = strtotime($last_visit_after); |
---|
728 | if ($last_visit_after === false || $last_visit_after == -1) |
---|
729 | message($lang_admin_users['Invalid date time message']); |
---|
730 | |
---|
731 | $conditions[] = 'u.last_visit>'.$last_visit_after; |
---|
732 | } |
---|
733 | if ($last_visit_before != '') |
---|
734 | { |
---|
735 | $query_str[] = 'last_visit_before='.$last_visit_before; |
---|
736 | |
---|
737 | $last_visit_before = strtotime($last_visit_before); |
---|
738 | if ($last_visit_before === false || $last_visit_before == -1) |
---|
739 | message($lang_admin_users['Invalid date time message']); |
---|
740 | |
---|
741 | $conditions[] = 'u.last_visit<'.$last_visit_before; |
---|
742 | } |
---|
743 | if ($registered_after != '') |
---|
744 | { |
---|
745 | $query_str[] = 'registered_after='.$registered_after; |
---|
746 | |
---|
747 | $registered_after = strtotime($registered_after); |
---|
748 | if ($registered_after === false || $registered_after == -1) |
---|
749 | message($lang_admin_users['Invalid date time message']); |
---|
750 | |
---|
751 | $conditions[] = 'u.registered>'.$registered_after; |
---|
752 | } |
---|
753 | if ($registered_before != '') |
---|
754 | { |
---|
755 | $query_str[] = 'registered_before='.$registered_before; |
---|
756 | |
---|
757 | $registered_before = strtotime($registered_before); |
---|
758 | if ($registered_before === false || $registered_before == -1) |
---|
759 | message($lang_admin_users['Invalid date time message']); |
---|
760 | |
---|
761 | $conditions[] = 'u.registered<'.$registered_before; |
---|
762 | } |
---|
763 | |
---|
764 | $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
---|
765 | foreach ($form as $key => $input) |
---|
766 | { |
---|
767 | if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) |
---|
768 | { |
---|
769 | $conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; |
---|
770 | $query_str[] = 'form%5B'.$key.'%5D='.urlencode($input); |
---|
771 | } |
---|
772 | } |
---|
773 | |
---|
774 | if ($posts_greater != '') |
---|
775 | { |
---|
776 | $query_str[] = 'posts_greater='.$posts_greater; |
---|
777 | $conditions[] = 'u.num_posts>'.$posts_greater; |
---|
778 | } |
---|
779 | if ($posts_less != '') |
---|
780 | { |
---|
781 | $query_str[] = 'posts_less='.$posts_less; |
---|
782 | $conditions[] = 'u.num_posts<'.$posts_less; |
---|
783 | } |
---|
784 | |
---|
785 | if ($user_group > -1) |
---|
786 | $conditions[] = 'u.group_id='.$user_group; |
---|
787 | |
---|
788 | // Fetch user count |
---|
789 | $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
---|
790 | $num_users = $db->result($result); |
---|
791 | |
---|
792 | // Determine the user offset (based on $_GET['p']) |
---|
793 | $num_pages = ceil($num_users / 50); |
---|
794 | |
---|
795 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
---|
796 | $start_from = 50 * ($p - 1); |
---|
797 | |
---|
798 | // Generate paging links |
---|
799 | $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?find_user=&'.implode('&', $query_str)); |
---|
800 | |
---|
801 | // Some helper variables for permissions |
---|
802 | $can_delete = $can_move = $pun_user['g_id'] == PUN_ADMIN; |
---|
803 | $can_ban = $pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && $pun_user['g_mod_ban_users'] == '1'); |
---|
804 | $can_action = ($can_delete || $can_ban || $can_move) && $num_users > 0; |
---|
805 | |
---|
806 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']); |
---|
807 | $page_head = array('js' => '<script type="text/javascript" src="common.js"></script>'); |
---|
808 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
809 | require PUN_ROOT.'header.php'; |
---|
810 | |
---|
811 | ?> |
---|
812 | <div class="linkst"> |
---|
813 | <div class="inbox crumbsplus"> |
---|
814 | <ul class="crumbs"> |
---|
815 | <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
---|
816 | <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
817 | <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
---|
818 | </ul> |
---|
819 | <div class="pagepost"> |
---|
820 | <p class="pagelink"><?php echo $paging_links ?></p> |
---|
821 | </div> |
---|
822 | <div class="clearer"></div> |
---|
823 | </div> |
---|
824 | </div> |
---|
825 | |
---|
826 | |
---|
827 | <form id="search-users-form" action="admin_users.php" method="post"> |
---|
828 | <div id="users2" class="blocktable"> |
---|
829 | <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2> |
---|
830 | <div class="box"> |
---|
831 | <div class="inbox"> |
---|
832 | <table cellspacing="0"> |
---|
833 | <thead> |
---|
834 | <tr> |
---|
835 | <th class="tcl" scope="col"><?php echo $lang_admin_users['Results username head'] ?></th> |
---|
836 | <th class="tc2" scope="col"><?php echo $lang_admin_users['Results e-mail head'] ?></th> |
---|
837 | <th class="tc3" scope="col"><?php echo $lang_admin_users['Results title head'] ?></th> |
---|
838 | <th class="tc4" scope="col"><?php echo $lang_admin_users['Results posts head'] ?></th> |
---|
839 | <th class="tc5" scope="col"><?php echo $lang_admin_users['Results admin note head'] ?></th> |
---|
840 | <th class="tcr" scope="col"><?php echo $lang_admin_users['Results actions head'] ?></th> |
---|
841 | <?php if ($can_action): ?> <th class="tcmod" scope="col"><?php echo $lang_admin_users['Select'] ?></th> |
---|
842 | <?php endif; ?> |
---|
843 | </tr> |
---|
844 | </thead> |
---|
845 | <tbody> |
---|
846 | <?php |
---|
847 | |
---|
848 | $result = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '').' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction).' LIMIT '.$start_from.', 50') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
---|
849 | if ($db->num_rows($result)) |
---|
850 | { |
---|
851 | while ($user_data = $db->fetch_assoc($result)) |
---|
852 | { |
---|
853 | $user_title = get_title($user_data); |
---|
854 | |
---|
855 | // This script is a special case in that we want to display "Not verified" for non-verified users |
---|
856 | if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned']) |
---|
857 | $user_title = '<span class="warntext">'.$lang_admin_users['Not verified'].'</span>'; |
---|
858 | |
---|
859 | $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> | <a href="search.php?action=show_user_posts&user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>'; |
---|
860 | |
---|
861 | ?> |
---|
862 | <tr> |
---|
863 | <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td> |
---|
864 | <td class="tc2"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></td> |
---|
865 | <td class="tc3"><?php echo $user_title ?></td> |
---|
866 | <td class="tc4"><?php echo forum_number_format($user_data['num_posts']) ?></td> |
---|
867 | <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : ' ' ?></td> |
---|
868 | <td class="tcr"><?php echo $actions ?></td> |
---|
869 | <?php if ($can_action): ?> <td class="tcmod"><input type="checkbox" name="users[<?php echo $user_data['id'] ?>]" value="1" /></td> |
---|
870 | <?php endif; ?> |
---|
871 | </tr> |
---|
872 | <?php |
---|
873 | |
---|
874 | } |
---|
875 | } |
---|
876 | else |
---|
877 | echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">'.$lang_admin_users['No match'].'</td></tr>'."\n"; |
---|
878 | |
---|
879 | ?> |
---|
880 | </tbody> |
---|
881 | </table> |
---|
882 | </div> |
---|
883 | </div> |
---|
884 | </div> |
---|
885 | |
---|
886 | <div class="linksb"> |
---|
887 | <div class="inbox crumbsplus"> |
---|
888 | <div class="pagepost"> |
---|
889 | <p class="pagelink"><?php echo $paging_links ?></p> |
---|
890 | <?php if ($can_action): ?> <p class="conr modbuttons"><a href="#" onclick="return select_checkboxes('search-users-form', this, '<?php echo $lang_admin_users['Unselect all'] ?>')"><?php echo $lang_admin_users['Select all'] ?></a> <?php if ($can_ban) : ?><input type="submit" name="ban_users" value="<?php echo $lang_admin_users['Ban'] ?>" /><?php endif; if ($can_delete) : ?><input type="submit" name="delete_users" value="<?php echo $lang_admin_users['Delete'] ?>" /><?php endif; if ($can_move) : ?><input type="submit" name="move_users" value="<?php echo $lang_admin_users['Change group'] ?>" /><?php endif; ?></p> |
---|
891 | <?php endif; ?> |
---|
892 | </div> |
---|
893 | <ul class="crumbs"> |
---|
894 | <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
---|
895 | <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
896 | <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
---|
897 | </ul> |
---|
898 | <div class="clearer"></div> |
---|
899 | </div> |
---|
900 | </div> |
---|
901 | </form> |
---|
902 | <?php |
---|
903 | |
---|
904 | require PUN_ROOT.'footer.php'; |
---|
905 | } |
---|
906 | |
---|
907 | |
---|
908 | else |
---|
909 | { |
---|
910 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users']); |
---|
911 | $focus_element = array('find_user', 'form[username]'); |
---|
912 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
913 | require PUN_ROOT.'header.php'; |
---|
914 | |
---|
915 | generate_admin_menu('users'); |
---|
916 | |
---|
917 | ?> |
---|
918 | <div class="blockform"> |
---|
919 | <h2><span><?php echo $lang_admin_users['User search head'] ?></span></h2> |
---|
920 | <div class="box"> |
---|
921 | <form id="find_user" method="get" action="admin_users.php"> |
---|
922 | <p class="submittop"><input type="submit" name="find_user" value="<?php echo $lang_admin_users['Submit search'] ?>" tabindex="1" /></p> |
---|
923 | <div class="inform"> |
---|
924 | <fieldset> |
---|
925 | <legend><?php echo $lang_admin_users['User search subhead'] ?></legend> |
---|
926 | <div class="infldset"> |
---|
927 | <p><?php echo $lang_admin_users['User search info'] ?></p> |
---|
928 | <table class="aligntop" cellspacing="0"> |
---|
929 | <tr> |
---|
930 | <th scope="row"><?php echo $lang_admin_users['Username label'] ?></th> |
---|
931 | <td><input type="text" name="form[username]" size="25" maxlength="25" tabindex="2" /></td> |
---|
932 | </tr> |
---|
933 | <tr> |
---|
934 | <th scope="row"><?php echo $lang_admin_users['E-mail address label'] ?></th> |
---|
935 | <td><input type="text" name="form[email]" size="30" maxlength="80" tabindex="3" /></td> |
---|
936 | </tr> |
---|
937 | <tr> |
---|
938 | <th scope="row"><?php echo $lang_admin_users['Title label'] ?></th> |
---|
939 | <td><input type="text" name="form[title]" size="30" maxlength="50" tabindex="4" /></td> |
---|
940 | </tr> |
---|
941 | <tr> |
---|
942 | <th scope="row"><?php echo $lang_admin_users['Real name label'] ?></th> |
---|
943 | <td><input type="text" name="form[realname]" size="30" maxlength="40" tabindex="5" /></td> |
---|
944 | </tr> |
---|
945 | <tr> |
---|
946 | <th scope="row"><?php echo $lang_admin_users['Website label'] ?></th> |
---|
947 | <td><input type="text" name="form[url]" size="35" maxlength="100" tabindex="6" /></td> |
---|
948 | </tr> |
---|
949 | <tr> |
---|
950 | <th scope="row"><?php echo $lang_admin_users['Jabber label'] ?></th> |
---|
951 | <td><input type="text" name="form[jabber]" size="30" maxlength="75" tabindex="7" /></td> |
---|
952 | </tr> |
---|
953 | <tr> |
---|
954 | <th scope="row"><?php echo $lang_admin_users['ICQ label'] ?></th> |
---|
955 | <td><input type="text" name="form[icq]" size="12" maxlength="12" tabindex="8" /></td> |
---|
956 | </tr> |
---|
957 | <tr> |
---|
958 | <th scope="row"><?php echo $lang_admin_users['MSN label'] ?></th> |
---|
959 | <td><input type="text" name="form[msn]" size="30" maxlength="50" tabindex="9" /></td> |
---|
960 | </tr> |
---|
961 | <tr> |
---|
962 | <th scope="row"><?php echo $lang_admin_users['AOL label'] ?></th> |
---|
963 | <td><input type="text" name="form[aim]" size="20" maxlength="20" tabindex="10" /></td> |
---|
964 | </tr> |
---|
965 | <tr> |
---|
966 | <th scope="row"><?php echo $lang_admin_users['Yahoo label'] ?></th> |
---|
967 | <td><input type="text" name="form[yahoo]" size="20" maxlength="20" tabindex="11" /></td> |
---|
968 | </tr> |
---|
969 | <tr> |
---|
970 | <th scope="row"><?php echo $lang_admin_users['Location label'] ?></th> |
---|
971 | <td><input type="text" name="form[location]" size="30" maxlength="30" tabindex="12" /></td> |
---|
972 | </tr> |
---|
973 | <tr> |
---|
974 | <th scope="row"><?php echo $lang_admin_users['Signature label'] ?></th> |
---|
975 | <td><input type="text" name="form[signature]" size="35" maxlength="512" tabindex="13" /></td> |
---|
976 | </tr> |
---|
977 | <tr> |
---|
978 | <th scope="row"><?php echo $lang_admin_users['Admin note label'] ?></th> |
---|
979 | <td><input type="text" name="form[admin_note]" size="30" maxlength="30" tabindex="14" /></td> |
---|
980 | </tr> |
---|
981 | <tr> |
---|
982 | <th scope="row"><?php echo $lang_admin_users['Posts more than label'] ?></th> |
---|
983 | <td><input type="text" name="posts_greater" size="5" maxlength="8" tabindex="15" /></td> |
---|
984 | </tr> |
---|
985 | <tr> |
---|
986 | <th scope="row"><?php echo $lang_admin_users['Posts less than label'] ?></th> |
---|
987 | <td><input type="text" name="posts_less" size="5" maxlength="8" tabindex="16" /></td> |
---|
988 | </tr> |
---|
989 | <tr> |
---|
990 | <th scope="row"><?php echo $lang_admin_users['Last post after label'] ?></th> |
---|
991 | <td><input type="text" name="last_post_after" size="24" maxlength="19" tabindex="17" /> |
---|
992 | <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
---|
993 | </tr> |
---|
994 | <tr> |
---|
995 | <th scope="row"><?php echo $lang_admin_users['Last post before label'] ?></th> |
---|
996 | <td><input type="text" name="last_post_before" size="24" maxlength="19" tabindex="18" /> |
---|
997 | <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
---|
998 | </tr> |
---|
999 | <tr> |
---|
1000 | <th scope="row"><?php echo $lang_admin_users['Last visit after label'] ?></th> |
---|
1001 | <td><input type="text" name="last_visit_after" size="24" maxlength="19" tabindex="17" /> |
---|
1002 | <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
---|
1003 | </tr> |
---|
1004 | <tr> |
---|
1005 | <th scope="row"><?php echo $lang_admin_users['Last visit before label'] ?></th> |
---|
1006 | <td><input type="text" name="last_visit_before" size="24" maxlength="19" tabindex="18" /> |
---|
1007 | <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
---|
1008 | </tr> |
---|
1009 | <tr> |
---|
1010 | <th scope="row"><?php echo $lang_admin_users['Registered after label'] ?></th> |
---|
1011 | <td><input type="text" name="registered_after" size="24" maxlength="19" tabindex="19" /> |
---|
1012 | <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
---|
1013 | </tr> |
---|
1014 | <tr> |
---|
1015 | <th scope="row"><?php echo $lang_admin_users['Registered before label'] ?></th> |
---|
1016 | <td><input type="text" name="registered_before" size="24" maxlength="19" tabindex="20" /> |
---|
1017 | <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
---|
1018 | </tr> |
---|
1019 | <tr> |
---|
1020 | <th scope="row"><?php echo $lang_admin_users['Order by label'] ?></th> |
---|
1021 | <td> |
---|
1022 | <select name="order_by" tabindex="21"> |
---|
1023 | <option value="username" selected="selected"><?php echo $lang_admin_users['Order by username'] ?></option> |
---|
1024 | <option value="email"><?php echo $lang_admin_users['Order by e-mail'] ?></option> |
---|
1025 | <option value="num_posts"><?php echo $lang_admin_users['Order by posts'] ?></option> |
---|
1026 | <option value="last_post"><?php echo $lang_admin_users['Order by last post'] ?></option> |
---|
1027 | <option value="last_visit"><?php echo $lang_admin_users['Order by last visit'] ?></option> |
---|
1028 | <option value="registered"><?php echo $lang_admin_users['Order by registered'] ?></option> |
---|
1029 | </select>   <select name="direction" tabindex="22"> |
---|
1030 | <option value="ASC" selected="selected"><?php echo $lang_admin_users['Ascending'] ?></option> |
---|
1031 | <option value="DESC"><?php echo $lang_admin_users['Descending'] ?></option> |
---|
1032 | </select> |
---|
1033 | </td> |
---|
1034 | </tr> |
---|
1035 | <tr> |
---|
1036 | <th scope="row"><?php echo $lang_admin_users['User group label'] ?></th> |
---|
1037 | <td> |
---|
1038 | <select name="user_group" tabindex="23"> |
---|
1039 | <option value="-1" selected="selected"><?php echo $lang_admin_users['All groups'] ?></option> |
---|
1040 | <option value="0"><?php echo $lang_admin_users['Unverified users'] ?></option> |
---|
1041 | <?php |
---|
1042 | |
---|
1043 | $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
---|
1044 | |
---|
1045 | while ($cur_group = $db->fetch_assoc($result)) |
---|
1046 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
---|
1047 | |
---|
1048 | ?> |
---|
1049 | </select> |
---|
1050 | </td> |
---|
1051 | </tr> |
---|
1052 | </table> |
---|
1053 | </div> |
---|
1054 | </fieldset> |
---|
1055 | </div> |
---|
1056 | <p class="submitend"><input type="submit" name="find_user" value="<?php echo $lang_admin_users['Submit search'] ?>" tabindex="25" /></p> |
---|
1057 | </form> |
---|
1058 | </div> |
---|
1059 | |
---|
1060 | <h2 class="block2"><span><?php echo $lang_admin_users['IP search head'] ?></span></h2> |
---|
1061 | <div class="box"> |
---|
1062 | <form method="get" action="admin_users.php"> |
---|
1063 | <div class="inform"> |
---|
1064 | <fieldset> |
---|
1065 | <legend><?php echo $lang_admin_users['IP search subhead'] ?></legend> |
---|
1066 | <div class="infldset"> |
---|
1067 | <table class="aligntop" cellspacing="0"> |
---|
1068 | <tr> |
---|
1069 | <th scope="row"><?php echo $lang_admin_users['IP address label'] ?><div><input type="submit" value="<?php echo $lang_admin_users['Find IP address'] ?>" tabindex="26" /></div></th> |
---|
1070 | <td><input type="text" name="show_users" size="18" maxlength="15" tabindex="24" /> |
---|
1071 | <span><?php echo $lang_admin_users['IP address help'] ?></span></td> |
---|
1072 | </tr> |
---|
1073 | </table> |
---|
1074 | </div> |
---|
1075 | </fieldset> |
---|
1076 | </div> |
---|
1077 | </form> |
---|
1078 | </div> |
---|
1079 | </div> |
---|
1080 | <div class="clearer"></div> |
---|
1081 | </div> |
---|
1082 | <?php |
---|
1083 | |
---|
1084 | require PUN_ROOT.'footer.php'; |
---|
1085 | } |
---|