SHARE
TWEET

Untitled

a guest Oct 16th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * Copyright (C) 2008-2012 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. define('PUN_ROOT', dirname(__FILE__).'/');
  10. require PUN_ROOT.'include/common.php';
  11.  
  12.  
  13. if ($pun_user['g_read_board'] == '0')
  14.     message($lang_common['No view'], false, '403 Forbidden');
  15. else if ($pun_user['g_view_users'] == '0')
  16.     message($lang_common['No permission'], false, '403 Forbidden');
  17.  
  18. // Load the userlist.php language file
  19. require PUN_ROOT.'lang/'.$pun_user['language'].'/userlist.php';
  20.  
  21. // Load the search.php language file
  22. require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';
  23.  
  24.  
  25. // Determine if we are allowed to view post counts
  26. $show_post_count = ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod']) ? true : false;
  27.  
  28. $username = isset($_GET['username']) && $pun_user['g_search_users'] == '1' ? pun_trim($_GET['username']) : '';
  29. $show_group = isset($_GET['show_group']) ? intval($_GET['show_group']) : -1;
  30. $sort_by = isset($_GET['sort_by']) && (in_array($_GET['sort_by'], array('username', 'registered')) || ($_GET['sort_by'] == 'num_posts' && $show_post_count)) ? $_GET['sort_by'] : 'username';
  31. $sort_dir = isset($_GET['sort_dir']) && $_GET['sort_dir'] == 'DESC' ? 'DESC' : 'ASC';
  32.  
  33. // Create any SQL for the WHERE clause
  34. $where_sql = array();
  35. $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
  36.  
  37. if ($username != '')
  38.     $where_sql[] = 'u.username '.$like_command.' \''.$db->escape(str_replace('*', '%', $username)).'\'';
  39. if ($show_group > -1)
  40.     $where_sql[] = 'u.group_id='.$show_group;
  41.  
  42. // Fetch user count
  43. $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users AS u WHERE u.id>1 AND u.group_id!='.PUN_UNVERIFIED.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '')) or error('Unable to fetch user list count', __FILE__, __LINE__, $db->error());
  44. $num_users = $db->result($result);
  45.  
  46. // Determine the user offset (based on $_GET['p'])
  47. $num_pages = ceil($num_users / 50);
  48.  
  49. $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
  50. $start_from = 50 * ($p - 1);
  51.  
  52. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['User list']);
  53. if ($pun_user['g_search_users'] == '1')
  54.     $focus_element = array('userlist', 'username');
  55.  
  56. // Generate paging links
  57. $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'userlist.php?username='.urlencode($username).'&amp;show_group='.$show_group.'&amp;sort_by='.$sort_by.'&amp;sort_dir='.$sort_dir);
  58.  
  59.  
  60. define('PUN_ALLOW_INDEX', 1);
  61. define('PUN_ACTIVE_PAGE', 'userlist');
  62. require PUN_ROOT.'header.php';
  63.  
  64. ?>
  65. <div class="blockform">
  66.     <h2><span><?php echo $lang_search['User search'] ?></span></h2>
  67.     <div class="box">
  68.         <form id="userlist" method="get" action="userlist.php">
  69.             <div class="inform">
  70.                 <fieldset>
  71.                     <legend><?php echo $lang_ul['User find legend'] ?></legend>
  72.                     <div class="infldset">
  73. <?php if ($pun_user['g_search_users'] == '1'): ?>                       <label class="conl"><?php echo $lang_common['Username'] ?><br /><input type="text" name="username" value="<?php echo pun_htmlspecialchars($username) ?>" size="25" maxlength="25" /><br /></label>
  74. <?php endif; ?>                     <label class="conl"><?php echo $lang_ul['User group']."\n" ?>
  75.                         <br /><select name="show_group">
  76.                             <option value="-1"<?php if ($show_group == -1) echo ' selected="selected"' ?>><?php echo $lang_ul['All users'] ?></option>
  77. <?php
  78.  
  79. $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_id') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
  80.  
  81. while ($cur_group = $db->fetch_assoc($result))
  82. {
  83.     if ($cur_group['g_id'] == $show_group)
  84.         echo "\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
  85.     else
  86.         echo "\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
  87. }
  88.  
  89. ?>
  90.                         </select>
  91.                         <br /></label>
  92.                         <label class="conl"><?php echo $lang_search['Sort by']."\n" ?>
  93.                         <br /><select name="sort_by">
  94.                             <option value="username"<?php if ($sort_by == 'username') echo ' selected="selected"' ?>><?php echo $lang_common['Username'] ?></option>
  95.                             <option value="registered"<?php if ($sort_by == 'registered') echo ' selected="selected"' ?>><?php echo $lang_common['Registered'] ?></option>
  96. <?php if ($show_post_count): ?>                         <option value="num_posts"<?php if ($sort_by == 'num_posts') echo ' selected="selected"' ?>><?php echo $lang_ul['No of posts'] ?></option>
  97. <?php endif; ?>                     </select>
  98.                         <br /></label>
  99.                         <label class="conl"><?php echo $lang_search['Sort order']."\n" ?>
  100.                         <br /><select name="sort_dir">
  101.                             <option value="ASC"<?php if ($sort_dir == 'ASC') echo ' selected="selected"' ?>><?php echo $lang_search['Ascending'] ?></option>
  102.                             <option value="DESC"<?php if ($sort_dir == 'DESC') echo ' selected="selected"' ?>><?php echo $lang_search['Descending'] ?></option>
  103.                         </select>
  104.                         <br /></label>
  105.                         <p class="clearb"><?php echo ($pun_user['g_search_users'] == '1' ? $lang_ul['User search info'].' ' : '').$lang_ul['User sort info']; ?></p>
  106.                     </div>
  107.                 </fieldset>
  108.             </div>
  109.             <p class="buttons"><input type="submit" name="search" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" /></p>
  110.         </form>
  111.     </div>
  112. </div>
  113.  
  114. <div class="linkst">
  115.     <div class="inbox">
  116.         <p class="pagelink"><?php echo $paging_links ?></p>
  117.         <div class="clearer"></div>
  118.     </div>
  119. </div>
  120.  
  121. <div id="users1" class="blocktable">
  122.     <h2><span><?php echo $lang_common['User list'] ?></span></h2>
  123.     <div class="box">
  124.         <div class="inbox">
  125.             <table cellspacing="0">
  126.             <thead>
  127.                 <tr>
  128.                     <th class="tcl" scope="col"><?php echo $lang_common['Username'] ?></th>
  129.                     <th class="tc2" scope="col"><?php echo $lang_common['Title'] ?></th>
  130. <?php if ($show_post_count): ?>                 <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
  131. <?php endif; ?>                 <th class="tcr" scope="col"><?php echo $lang_common['Registered'] ?></th>
  132.                 </tr>
  133.             </thead>
  134.             <tbody>
  135. <?php
  136.  
  137. // Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
  138. $result = $db->query('SELECT u.id FROM '.$db->prefix.'users AS u WHERE u.id>1 AND u.group_id!='.PUN_UNVERIFIED.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.', u.id ASC LIMIT '.$start_from.', 50') or error('Unable to fetch user IDs', __FILE__, __LINE__, $db->error());
  139.  
  140. if ($db->num_rows($result))
  141. {
  142.     $user_ids = array();
  143.     for ($i = 0;$cur_user_id = $db->result($result, $i);$i++)
  144.         $user_ids[] = $cur_user_id;
  145.  
  146.     // Grab the users
  147.     $result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, 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 IN('.implode(',', $user_ids).') ORDER BY '.$sort_by.' '.$sort_dir.', u.id ASC') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());
  148.  
  149.     while ($user_data = $db->fetch_assoc($result))
  150.     {
  151.         $user_title_field = get_title($user_data);
  152.  
  153. ?>
  154.                 <tr>
  155.                     <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td>
  156.                     <td class="tc2"><?php echo $user_title_field ?></td>
  157. <?php if ($show_post_count): ?>                 <td class="tc3"><?php echo forum_number_format($user_data['num_posts']) ?></td>
  158. <?php endif; ?>
  159.                     <td class="tcr"><?php echo format_time($user_data['registered'], true) ?></td>
  160.                 </tr>
  161. <?php
  162.  
  163.     }
  164. }
  165. else
  166.     echo "\t\t\t".'<tr>'."\n\t\t\t\t\t".'<td class="tcl" colspan="'.(($show_post_count) ? 4 : 3).'">'.$lang_search['No hits'].'</td></tr>'."\n";
  167.  
  168. ?>
  169.             </tbody>
  170.             </table>
  171.         </div>
  172.     </div>
  173. </div>
  174.  
  175. <div class="linksb">
  176.     <div class="inbox">
  177.         <p class="pagelink"><?php echo $paging_links ?></p>
  178.         <div class="clearer"></div>
  179.     </div>
  180. </div>
  181. <?php
  182.  
  183. require PUN_ROOT.'footer.php';
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top