|
1 <?php |
|
2 /*********************************************************************** |
|
3 |
|
4 Copyright (C) 2002-2008 PunBB.org |
|
5 |
|
6 This file is part of PunBB. |
|
7 |
|
8 PunBB is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published |
|
10 by the Free Software Foundation; either version 2 of the License, |
|
11 or (at your option) any later version. |
|
12 |
|
13 PunBB is distributed in the hope that it will be useful, but |
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program; if not, write to the Free Software |
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 MA 02111-1307 USA |
|
22 |
|
23 ************************************************************************/ |
|
24 |
|
25 |
|
26 // if (!defined('PUN_ROOT')) |
|
27 // define('PUN_ROOT', './'); |
|
28 // require PUN_ROOT.'include/common.php'; |
|
29 |
|
30 // import globals (I really hope this isn't dangerous) |
|
31 foreach ( $GLOBALS as $key => $_ ) |
|
32 { |
|
33 $$key =& $GLOBALS[$key]; |
|
34 } |
|
35 |
|
36 ($hook = get_hook('ul_start')) ? eval($hook) : null; |
|
37 |
|
38 if ($pun_user['g_read_board'] == '0') |
|
39 message($lang_common['No view']); |
|
40 else if ($pun_user['g_view_users'] == '0') |
|
41 message($lang_common['No permission']); |
|
42 |
|
43 // Load the userlist.php language file |
|
44 require PUN_ROOT.'lang/'.$pun_user['language'].'/userlist.php'; |
|
45 |
|
46 // Load the search.php language file |
|
47 require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php'; |
|
48 |
|
49 |
|
50 // Miscellaneous setup |
|
51 $pun_page['show_post_count'] = ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod']) ? true : false; |
|
52 $pun_page['username'] = (isset($_GET['username']) && $_GET['username'] != '-' && $pun_user['g_search_users'] == '1') ? $_GET['username'] : ''; |
|
53 $pun_page['show_group'] = (!isset($_GET['show_group']) || intval($_GET['show_group']) < -1 && intval($_GET['show_group']) > 2) ? -1 : intval($_GET['show_group']); |
|
54 $pun_page['sort_by'] = (!isset($_GET['sort_by']) || $_GET['sort_by'] != 'username' && $_GET['sort_by'] != 'registered' && ($_GET['sort_by'] != 'num_posts' || !$pun_page['show_post_count'])) ? 'username' : $_GET['sort_by']; |
|
55 $pun_page['sort_dir'] = (!isset($_GET['sort_dir']) || $_GET['sort_dir'] != 'ASC' && $_GET['sort_dir'] != 'DESC') ? 'ASC' : strtoupper($_GET['sort_dir']); |
|
56 |
|
57 |
|
58 // Create any SQL for the WHERE clause |
|
59 $where_sql = array(); |
|
60 $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
|
61 |
|
62 if ($pun_user['g_search_users'] == '1' && $pun_page['username'] != '') |
|
63 $where_sql[] = 'u.username '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $pun_page['username'])).'\''; |
|
64 if ($pun_page['show_group'] > -1) |
|
65 $where_sql[] = 'u.group_id='.$pun_page['show_group']; |
|
66 |
|
67 |
|
68 // Fetch user count |
|
69 $query = array( |
|
70 'SELECT' => 'COUNT(u.id)', |
|
71 'FROM' => 'users AS u', |
|
72 'WHERE' => 'u.id>1' |
|
73 ); |
|
74 |
|
75 if (!empty($where_sql)) |
|
76 $query['WHERE'] .= ' AND '.implode(' AND ', $where_sql); |
|
77 |
|
78 ($hook = get_hook('ul_qr_get_user_count')) ? eval($hook) : null; |
|
79 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
80 $pun_page['num_users'] = $pun_db->result($result); |
|
81 |
|
82 // Determine the user offset (based on $_GET['p']) |
|
83 $pun_page['num_pages'] = ceil($pun_page['num_users'] / 50); |
|
84 $pun_page['page'] = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $pun_page['num_pages']) ? 1 : $_GET['p']; |
|
85 $pun_page['start_from'] = 50 * ($pun_page['page'] - 1); |
|
86 $pun_page['finish_at'] = min(($pun_page['start_from'] + 50), ($pun_page['num_users'])); |
|
87 |
|
88 // Generate paging links |
|
89 $pun_page['page_post'] = '<div class="paging">'.$lang_common['Pages'].': '.pun_paginate($pun_page['num_pages'], $pun_page['page'], $pun_url['users_browse'], array($pun_page['show_group'], $pun_page['sort_by'], strtoupper($pun_page['sort_dir']), ($pun_page['username'] != '') ? urlencode($pun_page['username']) : '-')).'</div>'; |
|
90 |
|
91 // Navigation links for header and page numbering for title/meta description |
|
92 if ($pun_page['page'] < $pun_page['num_pages']) |
|
93 { |
|
94 $pun_page['nav'][] = '<link rel="last" href="'.pun_sublink($pun_url['users_browse'], $pun_url['page'], $pun_page['num_pages'], array($pun_page['show_group'], $pun_page['sort_by'], strtoupper($pun_page['sort_dir']), ($pun_page['username'] != '') ? urlencode($pun_page['username']) : '-')).'" title="'.$lang_common['Page'].' '.$pun_page['num_pages'].'" />'; |
|
95 $pun_page['nav'][] = '<link rel="next" href="'.pun_sublink($pun_url['users_browse'], $pun_url['page'], ($pun_page['page'] + 1), array($pun_page['show_group'], $pun_page['sort_by'], strtoupper($pun_page['sort_dir']), ($pun_page['username'] != '') ? urlencode($pun_page['username']) : '-')).'" title="'.$lang_common['Page'].' '.($pun_page['page'] + 1).'" />'; |
|
96 } |
|
97 if ($pun_page['page'] > 1) |
|
98 { |
|
99 $pun_page['nav'][] = '<link rel="prev" href="'.pun_sublink($pun_url['users_browse'], $pun_url['page'], ($pun_page['page'] - 1), array($pun_page['show_group'], $pun_page['sort_by'], strtoupper($pun_page['sort_dir']), ($pun_page['username'] != '') ? urlencode($pun_page['username']) : '-')).'" title="'.$lang_common['Page'].' '.($pun_page['page'] - 1).'" />'; |
|
100 $pun_page['nav'][] = '<link rel="first" href="'.pun_link($pun_url['users_browse'], array($pun_page['show_group'], $pun_page['sort_by'], strtoupper($pun_page['sort_dir']), ($pun_page['username'] != '') ? urlencode($pun_page['username']) : '-')).'" title="'.$lang_common['Page'].' 1" />'; |
|
101 } |
|
102 |
|
103 $pun_page['main_foot_options'] = array( |
|
104 '<a href="'.pun_link($pun_url['users']).'"><span>'.$lang_ul['Perform new search'].'</span></a>' |
|
105 ); |
|
106 |
|
107 // Generate page information |
|
108 if (($pun_user['g_search_users'] == '1' && $pun_page['username'] != '') || ($pun_page['show_group'] > -1)) |
|
109 $pun_page['main_info'] = (($pun_page['num_pages'] > 1) ? '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_ul['Users found'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $pun_page['num_users']) : sprintf($lang_common['Page info'], $lang_ul['Users found'], $pun_page['num_users'])); |
|
110 else |
|
111 $pun_page['main_info'] = (($pun_page['num_pages'] > 1) ? '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_ul['Users'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $pun_page['num_users'], $pun_page['page']) : sprintf($lang_common['Page info'], $lang_ul['Users'], $pun_page['num_users'])); |
|
112 |
|
113 // Setup form |
|
114 $pun_page['set_count'] = $pun_page['fld_count'] = 0; |
|
115 $pun_page['form_action'] = $base_url.'/userlist.php'; |
|
116 |
|
117 // Setup breadcrumbs |
|
118 $pun_page['crumbs'] = array( |
|
119 array($pun_config['o_board_title'], pun_link($pun_url['index'])), $lang_common['User list'] |
|
120 ); |
|
121 |
|
122 ($hook = get_hook('ul_pre_header_load')) ? eval($hook) : null; |
|
123 |
|
124 define('PUN_ALLOW_INDEX', 1); |
|
125 define('PUN_PAGE', 'userlist'); |
|
126 require PUN_ROOT.'header.php'; |
|
127 |
|
128 ?> |
|
129 <div id="pun-main" class="main paged"> |
|
130 |
|
131 <h1><span><?php echo end($pun_page['crumbs']) ?></span></h1> |
|
132 |
|
133 <div class="paged-head"> |
|
134 <?php echo $pun_page['page_post']."\n" ?> |
|
135 </div> |
|
136 |
|
137 <div class="main-head"> |
|
138 <h2><span><?php echo $pun_page['main_info'] ?></span></h2> |
|
139 </div> |
|
140 |
|
141 <div class="main-content frm"> |
|
142 <form class="frm-form" id="afocus" method="get" accept-charset="utf-8" action="<?php echo $pun_page['form_action'] ?>"> |
|
143 <fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>"> |
|
144 <legend class="frm-legend"><strong><?php echo $lang_ul['User find legend'] ?></strong></legend> |
|
145 <?php if ($pun_user['g_search_users'] == '1'): ?> <div class="frm-fld text"> |
|
146 <label for="fld<?php echo ++$pun_page['fld_count'] ?>"> |
|
147 <span class="fld-label"><?php echo $lang_ul['Search for username'] ?></span><br /> |
|
148 <span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="username" value="<?php echo htmlspecialchars($pun_page['username']) ?>" size="35" maxlength="25" /></span><br /> |
|
149 <span class="fld-help"><?php echo $lang_ul['Username help'] ?></span> |
|
150 </label> |
|
151 </div> |
|
152 <?php endif; ?> <div class="frm-fld select"> |
|
153 <label for="fld<?php echo ++$pun_page['fld_count'] ?>"> |
|
154 <span class="fld-label"><?php echo $lang_ul['User group'] ?></span><br /> |
|
155 <span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="show_group"> |
|
156 <option value="-1"<?php if ($pun_page['show_group'] == -1) echo ' selected="selected"' ?>><?php echo $lang_ul['All users'] ?></option> |
|
157 <?php |
|
158 |
|
159 // Get the list of user groups (excluding the guest group) |
|
160 $query = array( |
|
161 'SELECT' => 'g.g_id, g.g_title', |
|
162 'FROM' => 'groups AS g', |
|
163 'WHERE' => 'g.g_id!='.PUN_GUEST, |
|
164 'ORDER BY' => 'g.g_id' |
|
165 ); |
|
166 |
|
167 ($hook = get_hook('ul_qr_get_groups')) ? eval($hook) : null; |
|
168 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
169 |
|
170 while ($cur_group = $pun_db->fetch_assoc($result)) |
|
171 { |
|
172 if ($cur_group['g_id'] == $pun_page['show_group']) |
|
173 echo "\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
|
174 else |
|
175 echo "\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
|
176 } |
|
177 |
|
178 ?> |
|
179 </select></span> |
|
180 </label> |
|
181 </div> |
|
182 <div class="frm-fld select"> |
|
183 <label for="fld<?php echo ++$pun_page['fld_count'] ?>"> |
|
184 <span class="fld-label"><?php echo $lang_search['Sort by'] ?></span><br /> |
|
185 <span class="fld-input"><select id="fld<?php echo $pun_page['fld_count'] ?>" name="sort_by"> |
|
186 <option value="username"<?php if ($pun_page['sort_by'] == 'username') echo ' selected="selected"' ?>><?php echo $lang_common['Username'] ?></option> |
|
187 <option value="registered"<?php if ($pun_page['sort_by'] == 'registered') echo ' selected="selected"' ?>><?php echo $lang_common['Registered'] ?></option> |
|
188 <?php if ($pun_page['show_post_count']): ?> <option value="num_posts"<?php if ($pun_page['sort_by'] == 'num_posts') echo ' selected="selected"' ?>><?php echo $lang_ul['No of posts'] ?></option> |
|
189 <?php endif; ?> </select></span> |
|
190 </label> |
|
191 </div> |
|
192 <fieldset class="frm-group"> |
|
193 <legend><span><?php echo $lang_search['Sort order'] ?></span></legend> |
|
194 <div class="radbox frm-yesno"> <label for="fld<?php echo ++$pun_page['fld_count'] ?>"><input type="radio" id="fld<?php echo $pun_page['fld_count'] ?>" name="sort_dir" value="ASC"<?php if ($pun_page['sort_dir'] == 'ASC') echo ' checked="checked"' ?> /> <?php echo $lang_search['Ascending'] ?></label> <label for="fld<?php echo ++$pun_page['fld_count'] ?>"><input type="radio" id="fld<?php echo $pun_page['fld_count'] ?>" name="sort_dir" value="DESC"<?php if ($pun_page['sort_dir'] == 'DESC') echo ' checked="checked"' ?> /> <?php echo $lang_search['Descending'] ?></label></div> |
|
195 </fieldset> |
|
196 </fieldset> |
|
197 <div class="frm-buttons"> |
|
198 <span class="submit"><input type="submit" name="search" value="<?php echo $lang_search['Submit search'] ?>" accesskey="s" title="<?php echo $lang_common['Submit title'] ?>" /></span> |
|
199 </div> |
|
200 </form> |
|
201 <div class="frm-form"> |
|
202 <?php |
|
203 |
|
204 // Grab the users |
|
205 $query = array( |
|
206 'SELECT' => 'u.id, eu.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title', |
|
207 'FROM' => $pun_db->prefix . 'users AS u', |
|
208 'JOINS' => array( |
|
209 array( |
|
210 'LEFT JOIN' => $pun_db->prefix . 'groups AS g', |
|
211 'ON' => 'g.g_id=u.group_id' |
|
212 ), |
|
213 array( |
|
214 'LEFT JOIN' => table_prefix . 'users AS eu', |
|
215 'ON' => 'eu.user_id = u.id' |
|
216 ) |
|
217 ), |
|
218 'WHERE' => 'u.id>1', |
|
219 'ORDER BY' => $pun_page['sort_by'].' '.$pun_page['sort_dir'], |
|
220 'LIMIT' => $pun_page['start_from'].', 50', |
|
221 'PARAMS' => array( |
|
222 'NO_PREFIX' => '' |
|
223 ) |
|
224 ); |
|
225 |
|
226 if (!empty($where_sql)) |
|
227 $query['WHERE'] .= ' AND '.implode(' AND ', $where_sql); |
|
228 |
|
229 ($hook = get_hook('ul_qr_get_users')) ? eval($hook) : null; |
|
230 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
231 $pun_page['item_count'] = 0; |
|
232 |
|
233 if ($pun_db->num_rows($result)) |
|
234 { |
|
235 |
|
236 ?> |
|
237 <table cellspacing="0" summary="<?php echo $lang_ul['Table summary'] ?>"> |
|
238 <thead> |
|
239 <tr> |
|
240 <th class="tcl" scope="col"><?php echo $lang_common['Username'] ?></th> |
|
241 <th class="tc2" scope="col"><?php echo $lang_common['Title'] ?></th> |
|
242 <?php if ($pun_page['show_post_count']): ?> <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th> |
|
243 <?php endif; ($hook = get_hook('ul_table_header_after_num_posts')) ? eval($hook) : null; ?> <th class="tcr" scope="col"><?php echo $lang_common['Registered'] ?></th> |
|
244 <?php ($hook = get_hook('ul_table_header_after_registered')) ? eval($hook) : null; ?> |
|
245 </tr> |
|
246 </thead> |
|
247 <tbody> |
|
248 <?php |
|
249 |
|
250 while ($user_data = $pun_db->fetch_assoc($result)) |
|
251 { |
|
252 ++$pun_page['item_count']; |
|
253 |
|
254 ?> |
|
255 <tr class="<?php echo ($pun_page['item_count'] % 2 != 0) ? 'odd' : 'even' ?>"> |
|
256 <td class="tcl"><a href="<?php echo pun_link($pun_url['user'], $user_data['id']) ?>"><?php echo htmlspecialchars($user_data['username']) ?></a></td> |
|
257 <td class="tc2"><?php echo get_title($user_data) ?></td> |
|
258 <?php if ($pun_page['show_post_count']): ?> <td class="tc3"><?php echo $user_data['num_posts'] ?></td> |
|
259 <?php endif; ($hook = get_hook('ul_table_contents_after_num_posts')) ? eval($hook) : null; ?> <td class="tcr"><?php echo format_time($user_data['registered'], true) ?></td> |
|
260 <?php ($hook = get_hook('ul_table_contents_after_registered')) ? eval($hook) : null; ?> |
|
261 </tr> |
|
262 <?php |
|
263 |
|
264 } |
|
265 |
|
266 ?> |
|
267 </tbody> |
|
268 </table> |
|
269 <?php |
|
270 |
|
271 } |
|
272 else |
|
273 echo "\t\t\t".'<div class="frm-info">'."\n\t\t\t\t".'<p><strong>'.$lang_ul['No users found'].'</strong></p>'."\n\t\t\t".'</div>'."\n"; |
|
274 |
|
275 ?> |
|
276 </div> |
|
277 </div> |
|
278 |
|
279 <div class="main-foot"> |
|
280 <p class="h2"><strong><?php echo $pun_page['main_info'] ?></strong></p> |
|
281 <?php if (!empty($pun_page['main_foot_options'])) echo "\t\t\t".'<p class="main-options">'.implode(' ', $pun_page['main_foot_options']).'</p>'."\n" ?> |
|
282 </div> |
|
283 |
|
284 <div class="paged-foot"> |
|
285 <?php echo $pun_page['page_post']."\n" ?> |
|
286 </div> |
|
287 |
|
288 </div> |
|
289 |
|
290 <div id="pun-crumbs-foot"> |
|
291 <p class="crumbs"><?php echo generate_crumbs(false) ?></p> |
|
292 </div> |
|
293 <?php |
|
294 |
|
295 ($hook = get_hook('ul_end')) ? eval($hook) : null; |
|
296 |
|
297 require PUN_ROOT.'footer.php'; |