PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/admin/users.php

https://bitbucket.org/gencer/punbb
PHP | 1464 lines | 1126 code | 270 blank | 68 comment | 175 complexity | c2e881659402e8cb7982fce87d0a6aea MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * User search page.
  4. *
  5. * Allows administrators or moderators to search the existing users based on various criteria.
  6. *
  7. * @copyright (C) 2008-2012 PunBB, partially based on code (C) 2008-2009 FluxBB.org
  8. * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  9. * @package PunBB
  10. */
  11. if (!defined('FORUM_ROOT'))
  12. define('FORUM_ROOT', '../');
  13. require FORUM_ROOT.'include/common.php';
  14. require FORUM_ROOT.'include/common_admin.php';
  15. ($hook = get_hook('aus_start')) ? eval($hook) : null;
  16. if (!$forum_user['is_admmod'])
  17. message($lang_common['No permission']);
  18. // Load the admin.php language file
  19. require FORUM_ROOT.'lang/'.$forum_user['language'].'/admin_common.php';
  20. require FORUM_ROOT.'lang/'.$forum_user['language'].'/admin_users.php';
  21. require FORUM_ROOT.'lang/'.$forum_user['language'].'/admin_bans.php';
  22. // Show IP statistics for a certain user ID
  23. if (isset($_GET['ip_stats']))
  24. {
  25. $ip_stats = intval($_GET['ip_stats']);
  26. if ($ip_stats < 1)
  27. message($lang_common['Bad request']);
  28. ($hook = get_hook('aus_ip_stats_selected')) ? eval($hook) : null;
  29. $query = array(
  30. 'SELECT' => 'p.poster_ip, MAX(p.posted) AS last_used, COUNT(p.id) AS used_times',
  31. 'FROM' => 'posts AS p',
  32. 'WHERE' => 'p.poster_id='.$ip_stats,
  33. 'GROUP BY' => 'p.poster_ip',
  34. 'ORDER BY' => 'last_used DESC'
  35. );
  36. ($hook = get_hook('aus_ip_stats_qr_get_user_ips')) ? eval($hook) : null;
  37. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  38. $founded_ips = array();
  39. while ($cur_ip = $forum_db->fetch_assoc($result))
  40. {
  41. $founded_ips[] = $cur_ip;
  42. }
  43. $forum_page['num_users'] = count($founded_ips);
  44. // Setup breadcrumbs
  45. $forum_page['crumbs'] = array(
  46. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  47. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index']))
  48. );
  49. if ($forum_user['g_id'] == FORUM_ADMIN)
  50. $forum_page['crumbs'][] = array($lang_admin_common['Users'], forum_link($forum_url['admin_users']));
  51. $forum_page['crumbs'][] = array($lang_admin_common['Searches'], forum_link($forum_url['admin_users']));
  52. $forum_page['crumbs'][] = $lang_admin_users['User search results'];
  53. ($hook = get_hook('aus_ip_stats_pre_header_load')) ? eval($hook) : null;
  54. define('FORUM_PAGE_SECTION', 'users');
  55. define('FORUM_PAGE', 'admin-iresults');
  56. require FORUM_ROOT.'header.php';
  57. // START SUBST - <!-- forum_main -->
  58. ob_start();
  59. // Set up table headers
  60. $forum_page['table_header'] = array();
  61. $forum_page['table_header']['ip'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['IP address'].'</th>';
  62. $forum_page['table_header']['lastused'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Last used'].'</th>';
  63. $forum_page['table_header']['timesfound'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Times found'].'</th>';
  64. $forum_page['table_header']['actions'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Actions'].'</th>';
  65. ($hook = get_hook('aus_ip_stats_output_start')) ? eval($hook) : null;
  66. ?>
  67. <div class="main-head">
  68. <?php
  69. if (!empty($forum_page['main_head_options']))
  70. echo "\n\t\t".'<p class="options">'.implode(' ', $forum_page['main_head_options']).'</p>';
  71. ?>
  72. <h2 class="hn"><span><?php printf($lang_admin_users['IP addresses found'], $forum_page['num_users']) ?></span></h2>
  73. </div>
  74. <div class="main-content main-forum">
  75. <table>
  76. <thead>
  77. <tr>
  78. <?php echo implode("\n\t\t\t\t", $forum_page['table_header'])."\n" ?>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. <?php
  83. if ($forum_page['num_users'])
  84. {
  85. $forum_page['item_count'] = 0;
  86. foreach ($founded_ips as $cur_ip)
  87. {
  88. ++$forum_page['item_count'];
  89. $forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even');
  90. if ($forum_page['item_count'] == 1)
  91. $forum_page['item_style'] .= ' row1';
  92. ($hook = get_hook('aus_ip_stats_pre_row_generation')) ? eval($hook) : null;
  93. $forum_page['table_row'] = array();
  94. $forum_page['table_row']['ip'] = '<td class="tc'.count($forum_page['table_row']).'"><a href="'.forum_link($forum_url['get_host'], $cur_ip['poster_ip']).'">'.$cur_ip['poster_ip'].'</a></td>';
  95. $forum_page['table_row']['lastused'] = '<td class="tc'.count($forum_page['table_row']).'">'.format_time($cur_ip['last_used']).'</td>';
  96. $forum_page['table_row']['timesfound'] = '<td class="tc'.count($forum_page['table_row']).'">'.$cur_ip['used_times'].'</td>';
  97. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"><a href="'.forum_link($forum_url['admin_users']).'?show_users='.$cur_ip['poster_ip'].'">'.$lang_admin_users['Find more users'].'</a></td>';
  98. ($hook = get_hook('aus_ip_stats_pre_row_output')) ? eval($hook) : null;
  99. ?>
  100. <tr class="<?php echo $forum_page['item_style'] ?>">
  101. <?php echo implode("\n\t\t\t\t", $forum_page['table_row'])."\n" ?>
  102. </tr>
  103. <?php
  104. }
  105. }
  106. else
  107. {
  108. ($hook = get_hook('aus_ip_stats_pre_no_results_row_generation')) ? eval($hook) : null;
  109. $forum_page['table_row'] = array();
  110. $forum_page['table_row']['ip'] = '<td class="tc'.count($forum_page['table_row']).'">'.$lang_admin_users['No posts by user'].'</td>';
  111. $forum_page['table_row']['lastused'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  112. $forum_page['table_row']['timesfound'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  113. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  114. ($hook = get_hook('aus_ip_stats_pre_no_results_row_output')) ? eval($hook) : null;
  115. ?>
  116. <tr class="odd row1">
  117. <?php echo implode("\n\t\t\t\t", $forum_page['table_row'])."\n" ?>
  118. </tr>
  119. <?php
  120. }
  121. ?>
  122. </tbody>
  123. </table>
  124. </div>
  125. <div class="main-foot">
  126. <?php
  127. if (!empty($forum_page['main_foot_options']))
  128. echo "\n\t\t".'<p class="options">'.implode(' ', $forum_page['main_foot_options']).'</p>';
  129. ?>
  130. <h2 class="hn"><span><?php printf($lang_admin_users['IP addresses found'], $forum_page['num_users']) ?></span></h2>
  131. </div>
  132. <?php
  133. ($hook = get_hook('aus_ip_stats_end')) ? eval($hook) : null;
  134. $tpl_temp = forum_trim(ob_get_contents());
  135. $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
  136. ob_end_clean();
  137. // END SUBST - <!-- forum_main -->
  138. require FORUM_ROOT.'footer.php';
  139. }
  140. // Show users that have at one time posted with the specified IP address
  141. else if (isset($_GET['show_users']))
  142. {
  143. $ip = $_GET['show_users'];
  144. if (empty($ip) || (!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)))
  145. message($lang_admin_users['Invalid IP address']);
  146. ($hook = get_hook('aus_show_users_selected')) ? eval($hook) : null;
  147. // Load the misc.php language file
  148. require FORUM_ROOT.'lang/'.$forum_user['language'].'/misc.php';
  149. $query = array(
  150. 'SELECT' => 'DISTINCT p.poster_id, p.poster',
  151. 'FROM' => 'posts AS p',
  152. 'WHERE' => 'p.poster_ip=\''.$forum_db->escape($ip).'\'',
  153. 'ORDER BY' => 'p.poster DESC'
  154. );
  155. ($hook = get_hook('aus_show_users_qr_get_users_matching_ip')) ? eval($hook) : null;
  156. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  157. $users = array();
  158. while ($cur_user = $forum_db->fetch_assoc($result))
  159. {
  160. $users[] = $cur_user;
  161. }
  162. $forum_page['num_users'] = count($users);
  163. // Setup breadcrumbs
  164. $forum_page['crumbs'] = array(
  165. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  166. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index']))
  167. );
  168. if ($forum_user['g_id'] == FORUM_ADMIN)
  169. $forum_page['crumbs'][] = array($lang_admin_common['Users'], forum_link($forum_url['admin_users']));
  170. $forum_page['crumbs'][] = array($lang_admin_common['Searches'], forum_link($forum_url['admin_users']));
  171. $forum_page['crumbs'][] = $lang_admin_users['User search results'];
  172. ($hook = get_hook('aus_show_users_pre_header_load')) ? eval($hook) : null;
  173. define('FORUM_PAGE_SECTION', 'users');
  174. define('FORUM_PAGE', 'admin-uresults');
  175. require FORUM_ROOT.'header.php';
  176. // START SUBST - <!-- forum_main -->
  177. ob_start();
  178. // Set up table headers
  179. $forum_page['table_header'] = array();
  180. $forum_page['table_header']['username'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['User information'].'</th>';
  181. $forum_page['table_header']['title'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Title column'].'</th>';
  182. $forum_page['table_header']['posts'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Posts'].'</th>';
  183. $forum_page['table_header']['actions'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Actions'].'</th>';
  184. $forum_page['table_header']['select'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_misc['Select'] .'</th>';
  185. if ($forum_page['num_users'] > 0)
  186. $forum_page['main_head_options']['select'] = $forum_page['main_foot_options']['select'] = '<span class="select-all js_link" data-check-form="aus-show-users-results-form">'.$lang_admin_common['Select all'].'</span>';
  187. ($hook = get_hook('aus_show_users_output_start')) ? eval($hook) : null;
  188. ?>
  189. <div class="main-head">
  190. <?php
  191. if (!empty($forum_page['main_head_options']))
  192. echo "\n\t\t".'<p class="options">'.implode(' ', $forum_page['main_head_options']).'</p>';
  193. ?>
  194. <h2 class="hn"><span><?php printf($lang_admin_users['Users found'], $forum_page['num_users']) ?></span></h2>
  195. </div>
  196. <form id="aus-show-users-results-form" class="frm-form" method="post" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_users']) ?>?action=modify_users">
  197. <div class="main-content main-frm">
  198. <div class="hidden">
  199. <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_users']).'?action=modify_users') ?>" />
  200. </div>
  201. <table>
  202. <thead>
  203. <tr>
  204. <?php echo implode("\n\t\t\t\t", $forum_page['table_header'])."\n" ?>
  205. </tr>
  206. </thead>
  207. <tbody>
  208. <?php
  209. if ($forum_page['num_users'] > 0)
  210. {
  211. $forum_page['item_count'] = 0;
  212. // Loop through users and print out some info
  213. foreach ($users as $user)
  214. {
  215. $query = array(
  216. 'SELECT' => 'u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title',
  217. 'FROM' => 'users AS u',
  218. 'JOINS' => array(
  219. array(
  220. 'INNER JOIN' => 'groups AS g',
  221. 'ON' => 'g.g_id=u.group_id'
  222. )
  223. ),
  224. 'WHERE' => 'u.id>1 AND u.id='.$user['poster_id']
  225. );
  226. ($hook = get_hook('aus_show_users_qr_get_user_details')) ? eval($hook) : null;
  227. $result2 = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  228. ++$forum_page['item_count'];
  229. $forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even');
  230. if ($forum_page['item_count'] == 1)
  231. $forum_page['item_style'] .= ' row1';
  232. ($hook = get_hook('aus_show_users_pre_row_generation')) ? eval($hook) : null;
  233. if ($user_data = $forum_db->fetch_assoc($result2))
  234. {
  235. $forum_page['table_row'] = array();
  236. $forum_page['table_row']['username'] = '<td class="tc'.count($forum_page['table_row']).'"><span><a href="'.forum_link($forum_url['user'], $user_data['id']).'">'.forum_htmlencode($user_data['username']).'</a></span><span class="usermail"><a href="mailto:'.forum_htmlencode($user_data['email']).'">'.forum_htmlencode($user_data['email']).'</a></span>'.(($user_data['admin_note'] != '') ? '<span class="usernote">'.$lang_admin_users['Admin note'].' '.forum_htmlencode($user_data['admin_note']).'</span>' : '').'</td>';
  237. $forum_page['table_row']['title'] = '<td class="tc'.count($forum_page['table_row']).'">'.get_title($user_data).'</td>';
  238. $forum_page['table_row']['posts'] = '<td class="tc'.count($forum_page['table_row']).'">'.forum_number_format($user_data['num_posts']).'</td>';
  239. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"><span><a href="'.forum_link($forum_url['admin_users']).'?ip_stats='.$user_data['id'].'">'.$lang_admin_users['View IP stats'].'</a></span> <span><a href="'.forum_link($forum_url['search_user_posts'], $user_data['id']).'">'.$lang_admin_users['Show posts'].'</a></span></td>';
  240. $forum_page['table_row']['select'] = '<td class="tc'.count($forum_page['table_row']).'"><input type="checkbox" name="users['.$user_data['id'].']" value="1" /></td>';
  241. }
  242. else
  243. {
  244. $forum_page['table_row'] = array();
  245. $forum_page['table_row']['username'] = '<td class="tc'.count($forum_page['table_row']).'">'.forum_htmlencode($user['poster']).'</td>';
  246. $forum_page['table_row']['title'] = '<td class="tc'.count($forum_page['table_row']).'">'.$lang_admin_users['Guest'].'</td>';
  247. $forum_page['table_row']['posts'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  248. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  249. $forum_page['table_row']['select'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  250. }
  251. ($hook = get_hook('aus_show_users_pre_row_output')) ? eval($hook) : null;
  252. ?>
  253. <tr class="<?php echo $forum_page['item_style'] ?>">
  254. <?php echo implode("\n\t\t\t\t", $forum_page['table_row'])."\n" ?>
  255. </tr>
  256. <?php
  257. }
  258. }
  259. else
  260. {
  261. ($hook = get_hook('aus_show_users_pre_no_results_row_generation')) ? eval($hook) : null;
  262. $forum_page['table_row'] = array();
  263. $forum_page['table_row']['username'] = '<td class="tc'.count($forum_page['table_row']).'">'.$lang_admin_users['Cannot find IP'].'</td>';
  264. $forum_page['table_row']['title'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  265. $forum_page['table_row']['posts'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  266. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  267. $forum_page['table_row']['select'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  268. ($hook = get_hook('aus_show_users_pre_no_results_row_output')) ? eval($hook) : null;
  269. ?>
  270. <tr class="odd row1">
  271. <?php echo implode("\n\t\t\t\t", $forum_page['table_row'])."\n" ?>
  272. </tr>
  273. <?php
  274. }
  275. ?>
  276. </tbody>
  277. </table>
  278. </div>
  279. <?php
  280. // Setup control buttons
  281. $forum_page['mod_options'] = array();
  282. if ($forum_page['num_users'] > 0)
  283. {
  284. if ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && $forum_user['g_mod_ban_users'] == '1'))
  285. $forum_page['mod_options']['ban'] = '<span class="submit'.((empty($forum_page['mod_options'])) ? ' first-item' : '').'"><input type="submit" name="ban_users" value="'.$lang_admin_users['Ban'].'" /></span>';
  286. if ($forum_user['g_id'] == FORUM_ADMIN)
  287. {
  288. $forum_page['mod_options']['delete'] = '<span class="submit'.((empty($forum_page['mod_options'])) ? ' first-item' : '').'"><input type="submit" name="delete_users" value="'.$lang_admin_common['Delete'].'" /></span>';
  289. $forum_page['mod_options']['change_group'] = '<span class="submit'.((empty($forum_page['mod_options'])) ? ' first-item' : '').'"><input type="submit" name="change_group" value="'.$lang_admin_users['Change group'].'" /></span>';
  290. }
  291. }
  292. ($hook = get_hook('aus_show_users_pre_moderation_buttons')) ? eval($hook) : null;
  293. if (!empty($forum_page['mod_options']))
  294. {
  295. ?>
  296. <div class="main-options gen-content">
  297. <p class="options"><?php echo implode(' ', $forum_page['mod_options']) ?></p>
  298. </div>
  299. <?php
  300. }
  301. ?>
  302. </form>
  303. <div class="main-foot">
  304. <?php
  305. if (!empty($forum_page['main_foot_options']))
  306. echo "\n\t\t".'<p class="options">'.implode(' ', $forum_page['main_foot_options']).'</p>';
  307. ?>
  308. <h2 class="hn"><span><?php printf($lang_admin_users['Users found'], $forum_page['num_users']) ?></span></h2>
  309. </div>
  310. <?php
  311. // Init JS helper for select-all
  312. $forum_loader->add_js('PUNBB.common.addDOMReadyEvent(PUNBB.common.initToggleCheckboxes);', array('type' => 'inline'));
  313. ($hook = get_hook('aus_show_users_end')) ? eval($hook) : null;
  314. $tpl_temp = forum_trim(ob_get_contents());
  315. $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
  316. ob_end_clean();
  317. // END SUBST - <!-- forum_main -->
  318. require FORUM_ROOT.'footer.php';
  319. }
  320. else if (isset($_POST['delete_users']) || isset($_POST['delete_users_comply']) || isset($_POST['delete_users_cancel']))
  321. {
  322. // User pressed the cancel button
  323. if (isset($_POST['delete_users_cancel']))
  324. redirect(forum_link($forum_url['admin_users']), $lang_admin_common['Cancel redirect']);
  325. if ($forum_user['g_id'] != FORUM_ADMIN)
  326. message($lang_common['No permission']);
  327. if (empty($_POST['users']))
  328. message($lang_admin_users['No users selected']);
  329. ($hook = get_hook('aus_delete_users_selected')) ? eval($hook) : null;
  330. if (!is_array($_POST['users']))
  331. $users = explode(',', $_POST['users']);
  332. else
  333. $users = array_keys($_POST['users']);
  334. $users = array_map('intval', $users);
  335. // We check to make sure there are no administrators in this list
  336. $query = array(
  337. 'SELECT' => 'COUNT(u.id)',
  338. 'FROM' => 'users AS u',
  339. 'WHERE' => 'u.id IN ('.implode(',', $users).') AND u.group_id='.FORUM_ADMIN
  340. );
  341. ($hook = get_hook('aus_delete_users_qr_check_for_admins')) ? eval($hook) : null;
  342. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  343. if ($forum_db->result($result) > 0)
  344. message($lang_admin_users['Delete admin message']);
  345. if (isset($_POST['delete_users_comply']))
  346. {
  347. ($hook = get_hook('aus_delete_users_form_submitted')) ? eval($hook) : null;
  348. foreach ($users as $id)
  349. {
  350. // We don't want to delete the Guest user
  351. if ($id > 1)
  352. delete_user($id, isset($_POST['delete_posts']));
  353. }
  354. // Remove cache file with forum stats
  355. if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
  356. {
  357. require FORUM_ROOT.'include/cache.php';
  358. }
  359. clean_stats_cache();
  360. ($hook = get_hook('aus_delete_users_pre_redirect')) ? eval($hook) : null;
  361. redirect(forum_link($forum_url['admin_users']), $lang_admin_users['Users deleted']);
  362. }
  363. // Setup form
  364. $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
  365. // Setup breadcrumbs
  366. $forum_page['crumbs'] = array(
  367. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  368. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index'])),
  369. array($lang_admin_common['Users'], forum_link($forum_url['admin_users'])),
  370. array($lang_admin_common['Searches'], forum_link($forum_url['admin_users'])),
  371. $lang_admin_users['Delete users']
  372. );
  373. ($hook = get_hook('aus_delete_users_pre_header_load')) ? eval($hook) : null;
  374. define('FORUM_PAGE_SECTION', 'users');
  375. define('FORUM_PAGE', 'admin-users');
  376. require FORUM_ROOT.'header.php';
  377. // START SUBST - <!-- forum_main -->
  378. ob_start();
  379. ($hook = get_hook('aus_delete_users_output_start')) ? eval($hook) : null;
  380. ?>
  381. <div class="main-subhead">
  382. <h2 class="hn"><span><?php echo $lang_admin_users['Confirm delete'] ?></span></h2>
  383. </div>
  384. <div class="main-content main-frm">
  385. <div class="ct-box warn-box">
  386. <p class="warn"><?php echo $lang_admin_users['Delete warning'] ?></p>
  387. </div>
  388. <form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_users']) ?>?action=modify_users">
  389. <div class="hidden">
  390. <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_users']).'?action=modify_users') ?>" />
  391. <input type="hidden" name="users" value="<?php echo implode(',', $users) ?>" />
  392. </div>
  393. <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
  394. <legend class="group-legend"><span><?php echo $lang_admin_users['Delete posts legend'] ?></span></legend>
  395. <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  396. <div class="sf-box checkbox">
  397. <span class="fld-input"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="delete_posts" value="1" checked="checked" /></span>
  398. <label for="fld<?php echo $forum_page['fld_count'] ?>"><span><?php echo $lang_admin_users['Delete posts'] ?></span> <?php echo $lang_admin_users['Delete posts label'] ?></label>
  399. </div>
  400. </div>
  401. </fieldset>
  402. <div class="frm-buttons">
  403. <span class="submit primary caution"><input type="submit" name="delete_users_comply" value="<?php echo $lang_admin_users['Delete users'] ?>" /></span>
  404. <span class="cancel"><input type="submit" name="delete_users_cancel" value="<?php echo $lang_admin_common['Cancel'] ?>" /></span>
  405. </div>
  406. </form>
  407. </div>
  408. <?php
  409. ($hook = get_hook('aus_delete_users_end')) ? eval($hook) : null;
  410. $tpl_temp = forum_trim(ob_get_contents());
  411. $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
  412. ob_end_clean();
  413. // END SUBST - <!-- forum_main -->
  414. require FORUM_ROOT.'footer.php';
  415. }
  416. else if (isset($_POST['ban_users']) || isset($_POST['ban_users_comply']))
  417. {
  418. if ($forum_user['g_id'] != FORUM_ADMIN && ($forum_user['g_moderator'] != '1' || $forum_user['g_mod_ban_users'] == '0'))
  419. message($lang_common['No permission']);
  420. if (empty($_POST['users']))
  421. message($lang_admin_users['No users selected']);
  422. ($hook = get_hook('aus_ban_users_selected')) ? eval($hook) : null;
  423. if (!is_array($_POST['users']))
  424. $users = explode(',', $_POST['users']);
  425. else
  426. $users = array_keys($_POST['users']);
  427. $users = array_map('intval', $users);
  428. // We check to make sure there are no administrators in this list
  429. $query = array(
  430. 'SELECT' => 'COUNT(u.id)',
  431. 'FROM' => 'users AS u',
  432. 'WHERE' => 'u.id IN ('.implode(',', $users).') AND u.group_id='.FORUM_ADMIN
  433. );
  434. ($hook = get_hook('aus_ban_users_qr_check_for_admins')) ? eval($hook) : null;
  435. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  436. if ($forum_db->result($result) > 0)
  437. message($lang_admin_users['Ban admin message']);
  438. if (isset($_POST['ban_users_comply']))
  439. {
  440. $ban_message = forum_trim($_POST['ban_message']);
  441. $ban_expire = forum_trim($_POST['ban_expire']);
  442. ($hook = get_hook('aus_ban_users_form_submitted')) ? eval($hook) : null;
  443. if ($ban_expire != '' && $ban_expire != 'Never')
  444. {
  445. $ban_expire = strtotime($ban_expire);
  446. if ($ban_expire == -1 || $ban_expire <= time())
  447. message($lang_admin_bans['Invalid expire message']);
  448. }
  449. else
  450. $ban_expire = 'NULL';
  451. $ban_message = ($ban_message != '') ? '\''.$forum_db->escape($ban_message).'\'' : 'NULL';
  452. // Get the latest IPs for the posters and store them for a little later
  453. $query = array(
  454. 'SELECT' => 'p.poster_id, p.poster_ip',
  455. 'FROM' => 'posts AS p',
  456. 'WHERE' => 'p.poster_id IN ('.implode(',', $users).') AND p.poster_id>1',
  457. 'ORDER BY' => 'p.posted ASC'
  458. );
  459. ($hook = get_hook('aus_ban_users_qr_get_latest_user_ips')) ? eval($hook) : null;
  460. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  461. $ips = array();
  462. while ($cur_post = $forum_db->fetch_assoc($result))
  463. $ips[$cur_post['poster_id']] = $cur_post['poster_ip'];
  464. // Get the rest of the data for the posters, merge in the IP information, create a ban
  465. $query = array(
  466. 'SELECT' => 'u.id, u.username, u.email, u.registration_ip',
  467. 'FROM' => 'users AS u',
  468. 'WHERE' => 'id IN ('.implode(',', $users).') AND id>1'
  469. );
  470. ($hook = get_hook('aus_ban_users_qr_get_users')) ? eval($hook) : null;
  471. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  472. while ($cur_user = $forum_db->fetch_assoc($result))
  473. {
  474. $ban_ip = isset($ips[$cur_user['id']]) ? $ips[$cur_user['id']] : $cur_user['registration_ip'];
  475. $query = array(
  476. 'INSERT' => 'username, ip, email, message, expire, ban_creator',
  477. 'INTO' => 'bans',
  478. 'VALUES' => '\''.$forum_db->escape($cur_user['username']).'\', \''.$ban_ip.'\', \''.$forum_db->escape($cur_user['email']).'\', '.$ban_message.', '.$ban_expire.', '.$forum_user['id']
  479. );
  480. ($hook = get_hook('aus_ban_users_qr_add_ban')) ? eval($hook) : null;
  481. $forum_db->query_build($query) or error(__FILE__, __LINE__);
  482. }
  483. // Regenerate the bans cache
  484. if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
  485. require FORUM_ROOT.'include/cache.php';
  486. generate_bans_cache();
  487. // Add flash message
  488. $forum_flash->add_info($lang_admin_users['Users banned']);
  489. ($hook = get_hook('aus_ban_users_pre_redirect')) ? eval($hook) : null;
  490. redirect(forum_link($forum_url['admin_users']), $lang_admin_users['Users banned']);
  491. }
  492. // Setup form
  493. $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
  494. // Setup breadcrumbs
  495. $forum_page['crumbs'] = array(
  496. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  497. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index']))
  498. );
  499. if ($forum_user['g_id'] == FORUM_ADMIN)
  500. $forum_page['crumbs'][] = array($lang_admin_common['Users'], forum_link($forum_url['admin_users']));
  501. $forum_page['crumbs'][] = array($lang_admin_common['Searches'], forum_link($forum_url['admin_users']));
  502. $forum_page['crumbs'][] = $lang_admin_users['Ban users'];
  503. ($hook = get_hook('aus_ban_users_pre_header_load')) ? eval($hook) : null;
  504. define('FORUM_PAGE_SECTION', 'users');
  505. define('FORUM_PAGE', 'admin-users');
  506. require FORUM_ROOT.'header.php';
  507. // START SUBST - <!-- forum_main -->
  508. ob_start();
  509. ($hook = get_hook('aus_ban_users_output_start')) ? eval($hook) : null;
  510. ?>
  511. <div class="main-subhead">
  512. <h2 class="hn"><span><?php echo $lang_admin_users['Ban users'] ?></span></h2>
  513. </div>
  514. <div class="main-content main-frm">
  515. <div class="ct-box">
  516. <p><?php echo $lang_admin_users['Mass ban info'] ?></p>
  517. </div>
  518. <form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_users']) ?>?action=modify_users">
  519. <div class="hidden">
  520. <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_users']).'?action=modify_users') ?>" />
  521. <input type="hidden" name="users" value="<?php echo implode(',', $users) ?>" />
  522. </div>
  523. <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
  524. <legend class="group-legend"><span><?php echo $lang_admin_users['Ban settings legend'] ?></span></legend>
  525. <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  526. <div class="sf-box text">
  527. <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_bans['Ban message label'] ?></span> <small><?php echo $lang_admin_bans['Ban message help'] ?></small></label><br />
  528. <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="ban_message" size="50" maxlength="255" /></span>
  529. </div>
  530. </div>
  531. <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  532. <div class="sf-box text">
  533. <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_bans['Expire date label'] ?></span> <small><?php echo $lang_admin_bans['Expire date help'] ?></small></label><br />
  534. <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="ban_expire" size="17" maxlength="10" /></span>
  535. </div>
  536. </div>
  537. </fieldset>
  538. <div class="frm-buttons">
  539. <span class="submit primary"><input type="submit" name="ban_users_comply" value="<?php echo $lang_admin_users['Ban'] ?>" /></span>
  540. </div>
  541. </form>
  542. </div>
  543. <?php
  544. ($hook = get_hook('aus_ban_users_end')) ? eval($hook) : null;
  545. $tpl_temp = forum_trim(ob_get_contents());
  546. $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
  547. ob_end_clean();
  548. // END SUBST - <!-- forum_main -->
  549. require FORUM_ROOT.'footer.php';
  550. }
  551. else if (isset($_POST['change_group']) || isset($_POST['change_group_comply']) || isset($_POST['change_group_cancel']))
  552. {
  553. if ($forum_user['g_id'] != FORUM_ADMIN)
  554. message($lang_common['No permission']);
  555. // User pressed the cancel button
  556. if (isset($_POST['change_group_cancel']))
  557. redirect(forum_link($forum_url['admin_users']), $lang_admin_common['Cancel redirect']);
  558. if (empty($_POST['users']))
  559. message($lang_admin_users['No users selected']);
  560. ($hook = get_hook('aus_change_group_selected')) ? eval($hook) : null;
  561. if (!is_array($_POST['users']))
  562. $users = explode(',', $_POST['users']);
  563. else
  564. $users = array_keys($_POST['users']);
  565. $users = array_map('intval', $users);
  566. if (isset($_POST['change_group_comply']))
  567. {
  568. $move_to_group = intval($_POST['move_to_group']);
  569. ($hook = get_hook('aus_change_group_form_submitted')) ? eval($hook) : null;
  570. // We need some information on the group
  571. $query = array(
  572. 'SELECT' => 'g.g_moderator',
  573. 'FROM' => 'groups AS g',
  574. 'WHERE' => 'g.g_id='.$move_to_group
  575. );
  576. ($hook = get_hook('aus_change_group_qr_get_group_moderator_status')) ? eval($hook) : null;
  577. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  578. $group_is_mod = $forum_db->result($result);
  579. if ($move_to_group == FORUM_GUEST || (is_null($group_is_mod) || $group_is_mod === false))
  580. message($lang_common['Bad request']);
  581. // Move users
  582. $query = array(
  583. 'UPDATE' => 'users',
  584. 'SET' => 'group_id='.$move_to_group,
  585. 'WHERE' => 'id IN ('.implode(',', $users).') AND id>1'
  586. );
  587. ($hook = get_hook('aus_change_group_qr_change_user_group')) ? eval($hook) : null;
  588. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  589. if ($move_to_group != FORUM_ADMIN && ($group_is_mod !== false && $group_is_mod == '0'))
  590. clean_forum_moderators();
  591. ($hook = get_hook('aus_change_group_pre_redirect')) ? eval($hook) : null;
  592. redirect(forum_link($forum_url['admin_users']), $lang_admin_users['User groups updated']);
  593. }
  594. // Setup form
  595. $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
  596. // Setup breadcrumbs
  597. $forum_page['crumbs'] = array(
  598. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  599. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index'])),
  600. array($lang_admin_common['Users'], forum_link($forum_url['admin_users'])),
  601. array($lang_admin_common['Searches'], forum_link($forum_url['admin_users'])),
  602. $lang_admin_users['Change group']
  603. );
  604. ($hook = get_hook('aus_change_group_pre_header_load')) ? eval($hook) : null;
  605. define('FORUM_PAGE_SECTION', 'users');
  606. define('FORUM_PAGE', 'admin-users');
  607. require FORUM_ROOT.'header.php';
  608. // START SUBST - <!-- forum_main -->
  609. ob_start();
  610. ($hook = get_hook('aus_change_group_output_start')) ? eval($hook) : null;
  611. ?>
  612. <div class="main-subhead">
  613. <h2 class="hn"><span><?php echo $lang_admin_users['Change group head'] ?></span></h2>
  614. </div>
  615. <div class="main-content main-frm">
  616. <form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_users']) ?>?action=modify_users">
  617. <div class="hidden">
  618. <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_users']).'?action=modify_users') ?>" />
  619. <input type="hidden" name="users" value="<?php echo implode(',', $users) ?>" />
  620. </div>
  621. <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
  622. <legend class="group-legend"><span><?php echo $lang_admin_users['Move users legend'] ?></span></legend>
  623. <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  624. <div class="sf-box select">
  625. <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_users['Move users to label'] ?></span></label><br />
  626. <span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="move_to_group">
  627. <?php
  628. $query = array(
  629. 'SELECT' => 'g.g_id, g.g_title',
  630. 'FROM' => 'groups AS g',
  631. 'WHERE' => 'g.g_id!='.FORUM_GUEST,
  632. 'ORDER BY' => 'g.g_title'
  633. );
  634. ($hook = get_hook('aus_change_group_qr_get_groups')) ? eval($hook) : null;
  635. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  636. while ($cur_group = $forum_db->fetch_assoc($result))
  637. {
  638. if ($cur_group['g_id'] == $forum_config['o_default_user_group']) // Pre-select the default Members group
  639. echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.forum_htmlencode($cur_group['g_title']).'</option>'."\n";
  640. else
  641. echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.forum_htmlencode($cur_group['g_title']).'</option>'."\n";
  642. }
  643. ?>
  644. </select></span>
  645. </div>
  646. </div>
  647. </fieldset>
  648. <div class="frm-buttons">
  649. <span class="submit primary"><input type="submit" name="change_group_comply" value="<?php echo $lang_admin_users['Change group'] ?>" /></span>
  650. <span class="cancel"><input type="submit" name="change_group_cancel" value="<?php echo $lang_admin_common['Cancel'] ?>" /></span>
  651. </div>
  652. </form>
  653. </div>
  654. <?php
  655. ($hook = get_hook('aus_change_group_end')) ? eval($hook) : null;
  656. $tpl_temp = forum_trim(ob_get_contents());
  657. $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
  658. ob_end_clean();
  659. // END SUBST - <!-- forum_main -->
  660. require FORUM_ROOT.'footer.php';
  661. }
  662. else if (isset($_GET['find_user']))
  663. {
  664. $form = isset($_GET['form']) ? $_GET['form'] : array();
  665. // trim() all elements in $form
  666. $form = array_map('forum_trim', $form);
  667. $conditions = $query_str = array();
  668. //Check up for order_by and direction values
  669. $order_by = isset($_GET['order_by']) ? forum_trim($_GET['order_by']) : null;
  670. $direction = isset($_GET['direction']) ? forum_trim($_GET['direction']) : null;
  671. if ($order_by == null || $direction == null)
  672. message($lang_common['Bad request']);
  673. if (!in_array($order_by, array('username', 'email', 'num_posts', 'num_posts', 'registered')) || !in_array($direction, array('ASC', 'DESC')))
  674. message($lang_common['Bad request']);
  675. ($hook = get_hook('aus_find_user_selected')) ? eval($hook) : null;
  676. $query_str[] = 'order_by='.$order_by;
  677. $query_str[] = 'direction='.$direction;
  678. $posts_greater = isset($_GET['posts_greater']) ? forum_trim($_GET['posts_greater']) : '';
  679. $posts_less = isset($_GET['posts_less']) ? forum_trim($_GET['posts_less']) : '';
  680. $last_post_after = isset($_GET['last_post_after']) ? forum_trim($_GET['last_post_after']) : '';
  681. $last_post_before = isset($_GET['last_post_before']) ? forum_trim($_GET['last_post_before']) : '';
  682. $registered_after = isset($_GET['registered_after']) ? forum_trim($_GET['registered_after']) : '';
  683. $registered_before = isset($_GET['registered_before']) ? forum_trim($_GET['registered_before']) : '';
  684. $user_group = isset($_GET['user_group']) ? intval($_GET['user_group']) : -1;
  685. $query_str[] = 'user_group='.$user_group;
  686. if ((!empty($posts_greater) || !empty($posts_less)) && !ctype_digit($posts_greater.$posts_less))
  687. message($lang_admin_users['Non numeric value message']);
  688. // Try to convert date/time to timestamps
  689. if ($last_post_after != '')
  690. {
  691. $query_str[] = 'last_post_after='.$last_post_after;
  692. $last_post_after = strtotime($last_post_after);
  693. if ($last_post_after === false || $last_post_after == -1)
  694. message($lang_admin_users['Invalid date/time message']);
  695. $conditions[] = 'u.last_post>'.$last_post_after;
  696. }
  697. if ($last_post_before != '')
  698. {
  699. $query_str[] = 'last_post_before='.$last_post_before;
  700. $last_post_before = strtotime($last_post_before);
  701. if ($last_post_before === false || $last_post_before == -1)
  702. message($lang_admin_users['Invalid date/time message']);
  703. $conditions[] = 'u.last_post<'.$last_post_before;
  704. }
  705. if ($registered_after != '')
  706. {
  707. $query_str[] = 'registered_after='.$registered_after;
  708. $registered_after = strtotime($registered_after);
  709. if ($registered_after === false || $registered_after == -1)
  710. message($lang_admin_users['Invalid date/time message']);
  711. $conditions[] = 'u.registered>'.$registered_after;
  712. }
  713. if ($registered_before != '')
  714. {
  715. $query_str[] = 'registered_before='.$registered_before;
  716. $registered_before = strtotime($registered_before);
  717. if ($registered_before === false || $registered_before == -1)
  718. message($lang_admin_users['Invalid date/time message']);
  719. $conditions[] = 'u.registered<'.$registered_before;
  720. }
  721. $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
  722. foreach ($form as $key => $input)
  723. {
  724. if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note')))
  725. {
  726. $conditions[] = 'u.'.$forum_db->escape($key).' '.$like_command.' \''.$forum_db->escape(str_replace('*', '%', $input)).'\'';
  727. $query_str[] = 'form%5B'.$key.'%5D='.urlencode($input);
  728. }
  729. }
  730. if ($posts_greater != '')
  731. {
  732. $query_str[] = 'posts_greater='.$posts_greater;
  733. $conditions[] = 'u.num_posts>'.$posts_greater;
  734. }
  735. if ($posts_less != '')
  736. {
  737. $query_str[] = 'posts_less='.$posts_less;
  738. $conditions[] = 'u.num_posts<'.$posts_less;
  739. }
  740. if ($user_group > -1)
  741. $conditions[] = 'u.group_id='.intval($user_group);
  742. if (empty($conditions))
  743. message($lang_admin_users['No search terms message']);
  744. // Load the misc.php language file
  745. require FORUM_ROOT.'lang/'.$forum_user['language'].'/misc.php';
  746. // Fetch user count
  747. $query = array(
  748. 'SELECT' => 'COUNT(id)',
  749. 'FROM' => 'users AS u',
  750. 'JOINS' => array(
  751. array(
  752. 'LEFT JOIN' => 'groups AS g',
  753. 'ON' => 'g.g_id=u.group_id'
  754. )
  755. ),
  756. 'WHERE' => 'u.id>1 AND '.implode(' AND ', $conditions)
  757. );
  758. ($hook = get_hook('aus_find_user_qr_count_find_users')) ? eval($hook) : null;
  759. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  760. $forum_page['num_users'] = $forum_db->result($result);
  761. $forum_page['num_pages'] = ceil($forum_page['num_users'] / $forum_user['disp_topics']);
  762. $forum_page['page'] = (!isset($_GET['p']) || !is_numeric($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $forum_page['num_pages']) ? 1 : $_GET['p'];
  763. $forum_page['start_from'] = $forum_user['disp_topics'] * ($forum_page['page'] - 1);
  764. $forum_page['finish_at'] = min(($forum_page['start_from'] + $forum_user['disp_topics']), ($forum_page['num_users']));
  765. // Setup breadcrumbs
  766. $forum_page['crumbs'] = array(
  767. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  768. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index']))
  769. );
  770. if ($forum_user['g_id'] == FORUM_ADMIN)
  771. $forum_page['crumbs'][] = array($lang_admin_common['Users'], forum_link($forum_url['admin_users']));
  772. $forum_page['crumbs'][] = array($lang_admin_common['Searches'], forum_link($forum_url['admin_users']));
  773. $forum_page['crumbs'][] = $lang_admin_users['User search results'];
  774. // Generate paging
  775. $forum_page['page_post']['paging'] = '<p class="paging"><span class="pages">'.$lang_common['Pages'].'</span> '.paginate($forum_page['num_pages'], $forum_page['page'], $forum_url['admin_users'].'?find_user=&amp;'.implode('&amp;', $query_str), $lang_common['Paging separator'], null, true).'</p>';
  776. ($hook = get_hook('aus_find_user_pre_header_load')) ? eval($hook) : null;
  777. define('FORUM_PAGE_SECTION', 'users');
  778. define('FORUM_PAGE', 'admin-uresults');
  779. require FORUM_ROOT.'header.php';
  780. // START SUBST - <!-- forum_main -->
  781. ob_start();
  782. // Set up table headers
  783. $forum_page['table_header'] = array();
  784. $forum_page['table_header']['username'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['User information'].'</th>';
  785. $forum_page['table_header']['title'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Title column'].'</th>';
  786. $forum_page['table_header']['posts'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Posts'].'</th>';
  787. $forum_page['table_header']['actions'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_admin_users['Actions'].'</th>';
  788. $forum_page['table_header']['select'] = '<th class="tc'.count($forum_page['table_header']).'" scope="col">'.$lang_misc['Select'] .'</th>';
  789. if ($forum_page['num_users'] > 0)
  790. $forum_page['main_head_options']['select'] = $forum_page['main_foot_options']['select'] = '<span class="select-all js_link" data-check-form="aus-find-user-results-form">'.$lang_admin_common['Select all'].'</span>';
  791. ($hook = get_hook('aus_find_user_output_start')) ? eval($hook) : null;
  792. ?>
  793. <div class="main-head">
  794. <?php
  795. if (!empty($forum_page['main_head_options']))
  796. echo "\n\t\t".'<p class="options">'.implode(' ', $forum_page['main_head_options']).'</p>';
  797. ?>
  798. <h2 class="hn"><span><?php printf($lang_admin_users['Users found'], $forum_page['num_users']) ?></span></h2>
  799. </div>
  800. <form id="aus-find-user-results-form" class="frm-form" method="post" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_users']) ?>?action=modify_users">
  801. <div class="main-content main-forum">
  802. <div class="hidden">
  803. <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_users']).'?action=modify_users') ?>" />
  804. </div>
  805. <table>
  806. <thead>
  807. <tr>
  808. <?php echo implode("\n\t\t\t\t", $forum_page['table_header'])."\n" ?>
  809. </tr>
  810. </thead>
  811. <tbody>
  812. <?php
  813. // Find any users matching the conditions
  814. $query = array(
  815. 'SELECT' => 'u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title',
  816. 'FROM' => 'users AS u',
  817. 'JOINS' => array(
  818. array(
  819. 'LEFT JOIN' => 'groups AS g',
  820. 'ON' => 'g.g_id=u.group_id'
  821. )
  822. ),
  823. 'WHERE' => 'u.id>1 AND '.implode(' AND ', $conditions),
  824. 'ORDER BY' => $order_by.' '.$direction,
  825. 'LIMIT' => $forum_page['start_from'].', '.$forum_page['finish_at']
  826. );
  827. ($hook = get_hook('aus_find_user_qr_find_users')) ? eval($hook) : null;
  828. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  829. if ($forum_page['num_users'] > 0)
  830. {
  831. $forum_page['item_count'] = 0;
  832. while ($user_data = $forum_db->fetch_assoc($result))
  833. {
  834. ++$forum_page['item_count'];
  835. // This script is a special case in that we want to display "Not verified" for non-verified users
  836. if (($user_data['g_id'] == '' || $user_data['g_id'] == FORUM_UNVERIFIED) && $user_data['title'] != $lang_common['Banned'])
  837. $user_title = '<strong>'.$lang_admin_users['Not verified'].'</strong>';
  838. else
  839. $user_title = get_title($user_data);
  840. $forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even');
  841. if ($forum_page['item_count'] == 1)
  842. $forum_page['item_style'] .= ' row1';
  843. ($hook = get_hook('aus_find_user_pre_row_generation')) ? eval($hook) : null;
  844. $forum_page['table_row'] = array();
  845. $forum_page['table_row']['username'] = '<td class="tc'.count($forum_page['table_row']).'"><span><a href="'.forum_link($forum_url['user'], $user_data['id']).'">'.forum_htmlencode($user_data['username']).'</a></span><span class="usermail"><a href="mailto:'.forum_htmlencode($user_data['email']).'">'.forum_htmlencode($user_data['email']).'</a></span>'.(($user_data['admin_note'] != '') ? '<span class="usernote">'.$lang_admin_users['Admin note'].' '.forum_htmlencode($user_data['admin_note']).'</span>' : '').'</td>';
  846. $forum_page['table_row']['title'] = '<td class="tc'.count($forum_page['table_row']).'">'.$user_title.'</td>';
  847. $forum_page['table_row']['posts'] = '<td class="tc'.count($forum_page['table_row']).'">'.forum_number_format($user_data['num_posts']).'</td>';
  848. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"><span><a href="'.forum_link($forum_url['admin_users']).'?ip_stats='.$user_data['id'].'">'.$lang_admin_users['View IP stats'].'</a></span> <span><a href="'.forum_link($forum_url['search_user_posts'], $user_data['id']).'">'.$lang_admin_users['Show posts'].'</a></span></td>';
  849. $forum_page['table_row']['select'] = '<td class="tc'.count($forum_page['table_row']).'"><input type="checkbox" name="users['.$user_data['id'].']" value="1" /></td>';
  850. ($hook = get_hook('aus_find_user_pre_row_output')) ? eval($hook) : null;
  851. ?>
  852. <tr class="<?php echo $forum_page['item_style'] ?>">
  853. <?php echo implode("\n\t\t\t\t", $forum_page['table_row'])."\n" ?>
  854. </tr>
  855. <?php
  856. }
  857. }
  858. else
  859. {
  860. ($hook = get_hook('aus_find_user_pre_no_results_row_generation')) ? eval($hook) : null;
  861. $forum_page['table_row'] = array();
  862. $forum_page['table_row']['username'] = '<td class="tc'.count($forum_page['table_row']).'">'.$lang_admin_users['No match'].'</td>';
  863. $forum_page['table_row']['title'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  864. $forum_page['table_row']['posts'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  865. $forum_page['table_row']['actions'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  866. $forum_page['table_row']['select'] = '<td class="tc'.count($forum_page['table_row']).'"> - </td>';
  867. ($hook = get_hook('aus_find_user_pre_no_results_row_output')) ? eval($hook) : null;
  868. ?>
  869. <tr class="odd row1">
  870. <?php echo implode("\n\t\t\t\t", $forum_page['table_row'])."\n" ?>
  871. </tr>
  872. <?php
  873. }
  874. ?>
  875. </tbody>
  876. </table>
  877. </div>
  878. <?php
  879. // Setup control buttons
  880. $forum_page['mod_options'] = array();
  881. if ($forum_page['num_users'] > 0)
  882. {
  883. if ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && $forum_user['g_mod_ban_users'] == '1'))
  884. $forum_page['mod_options']['ban'] = '<span class="submit'.((empty($forum_page['mod_options'])) ? ' first-item' : '').'"><input type="submit" name="ban_users" value="'.$lang_admin_users['Ban'].'" /></span>';
  885. if ($forum_user['g_id'] == FORUM_ADMIN)
  886. {
  887. $forum_page['mod_options']['delete'] = '<span class="submit'.((empty($forum_page['mod_options'])) ? ' first-item' : '').'"><input type="submit" name="delete_users" value="'.$lang_admin_common['Delete'].'" /></span>';
  888. $forum_page['mod_options']['change_group'] = '<span class="submit'.((empty($forum_page['mod_options'])) ? ' first-item' : '').'"><input type="submit" name="change_group" value="'.$lang_admin_users['Change group'].'" /></span>';
  889. }
  890. }
  891. ($hook = get_hook('aus_find_user_pre_moderation_buttons')) ? eval($hook) : null;
  892. if (!empty($forum_page['mod_options']))
  893. {
  894. ?>
  895. <div class="main-options gen-content">
  896. <p class="options"><?php echo implode(' ', $forum_page['mod_options']) ?></p>
  897. </div>
  898. <?php
  899. }
  900. ?>
  901. </form>
  902. <div class="main-foot">
  903. <?php
  904. if (!empty($forum_page['main_foot_options']))
  905. echo "\n\t\t".'<p class="options">'.implode(' ', $forum_page['main_foot_options']).'</p>';
  906. ?>
  907. <h2 class="hn"><span><?php printf($lang_admin_users['Users found'], $forum_page['num_users']) ?></span></h2>
  908. </div>
  909. <?php
  910. // Init JS helper for select-all
  911. $forum_loader->add_js('PUNBB.common.addDOMReadyEvent(PUNBB.common.initToggleCheckboxes);', array('type' => 'inline'));
  912. ($hook = get_hook('aus_find_user_end')) ? eval($hook) : null;
  913. $tpl_temp = forum_trim(ob_get_contents());
  914. $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
  915. ob_end_clean();
  916. // END SUBST - <!-- forum_main -->
  917. require FORUM_ROOT.'footer.php';
  918. }
  919. ($hook = get_hook('aus_new_action')) ? eval($hook) : null;
  920. // Setup form
  921. $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
  922. // Setup breadcrumbs
  923. $forum_page['crumbs'] = array(
  924. array($forum_config['o_board_title'], forum_link($forum_url['index'])),
  925. array($lang_admin_common['Forum administration'], forum_link($forum_url['admin_index']))
  926. );
  927. if ($forum_user['g_id'] == FORUM_ADMIN)
  928. $forum_page['crumbs'][] = array($lang_admin_common['Users'], forum_link($forum_url['admin_users']));
  929. $forum_page['crumbs'][] = array($lang_admin_common['Searches'], forum_link($forum_url['admin_users']));
  930. ($hook = get_hook('aus_search_form_pre_header_load')) ? eval($hook) : null;
  931. define('FORUM_PAGE_SECTION', 'users');
  932. define('FORUM_PAGE', 'admin-users');
  933. require FORUM_ROOT.'header.php';
  934. // START SUBST - <!-- forum_main -->
  935. ob_start();
  936. ($hook = get_hook('aus_search_form_output_start')) ? eval($hook) : null;
  937. ?>
  938. <div class="main-subhead">
  939. <h2 class="hn"><span><?php echo $lang_admin_users['Search head'] ?></span></h2>
  940. </div>
  941. <div class="main-content main-frm">
  942. <form class="frm-form" method="get" accept-charset="utf-8" action="<?php echo forum_link($forum_url['admin_users']) ?>">
  943. <div class="hidden">
  944. <input type="hidden" name="csrf_token" value="<?php echo generate_form_token(forum_link($forum_url['admin_users']).'?action=find_user') ?>" />
  945. </div>
  946. <div class="content-head">
  947. <h3 class="hn"><span><?php echo $lang_admin_users['User search head'] ?></span></h3>
  948. </div>
  949. <?php ($hook = get_hook('aus_search_form_pre_user_details_fieldset')) ? eval($hook) : null; ?>
  950. <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
  951. <legend class="group-legend"><strong><?php echo $lang_admin_users['Searches personal legend'] ?></strong></legend>
  952. <?php ($hook = get_hook('aus_search_form_pre_username')) ? eval($hook) : null; ?>
  953. <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  954. <div class="sf-box text">
  955. <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_users['Username label'] ?></span></label><br />
  956. <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['…

Large files files are truncated, but you can click here to view the full file