changeset 2 | a8a21e1c7afa |
parent 0 | f9ffdbd96607 |
child 4 | eb9ed4c366d0 |
1:8f6143115bf5 | 2:a8a21e1c7afa |
---|---|
21 MA 02111-1307 USA |
21 MA 02111-1307 USA |
22 |
22 |
23 ************************************************************************/ |
23 ************************************************************************/ |
24 |
24 |
25 |
25 |
26 define('PUN_ROOT', './'); |
26 //define('PUN_ROOT', './'); |
27 require PUN_ROOT.'include/common.php'; |
27 //require PUN_ROOT.'include/common.php'; |
28 |
|
29 global $pun_db, $pun_user, $pun_config, $lang_common; |
|
30 |
|
28 |
31 |
29 |
32 |
30 if ($pun_user['g_read_board'] == '0') |
33 if ($pun_user['g_read_board'] == '0') |
31 message($lang_common['No view']); |
34 message($lang_common['No view']); |
32 |
35 |
37 // Load the search.php language file |
40 // Load the search.php language file |
38 require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php'; |
41 require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php'; |
39 |
42 |
40 |
43 |
41 // Determine if we are allowed to view post counts |
44 // Determine if we are allowed to view post counts |
42 $show_post_count = ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST) ? true : false; |
45 $show_post_count = ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] >= USER_LEVEL_MEMBER) ? true : false; |
43 |
46 |
44 $username = (isset($_GET['username']) && $pun_user['g_search_users'] == '1') ? pun_trim($_GET['username']) : ''; |
47 $username = (isset($_GET['username']) && $pun_user['g_search_users'] == '1') ? pun_trim($_GET['username']) : ''; |
45 $show_group = (!isset($_GET['show_group']) || intval($_GET['show_group']) < -1 && intval($_GET['show_group']) > 2) ? -1 : intval($_GET['show_group']); |
48 $show_group = (!isset($_GET['show_group']) || intval($_GET['show_group']) < -1 && intval($_GET['show_group']) > 2) ? -1 : intval($_GET['show_group']); |
46 $sort_by = (!isset($_GET['sort_by']) || $_GET['sort_by'] != 'username' && $_GET['sort_by'] != 'registered' && ($_GET['sort_by'] != 'num_posts' || !$show_post_count)) ? 'username' : $_GET['sort_by']; |
49 $sort_by = (!isset($_GET['sort_by']) || $_GET['sort_by'] != 'username' && $_GET['sort_by'] != 'registered' && ($_GET['sort_by'] != 'num_posts' || !$show_post_count)) ? 'username' : $_GET['sort_by']; |
47 $sort_dir = (!isset($_GET['sort_dir']) || $_GET['sort_dir'] != 'ASC' && $_GET['sort_dir'] != 'DESC') ? 'ASC' : strtoupper($_GET['sort_dir']); |
50 $sort_dir = (!isset($_GET['sort_dir']) || $_GET['sort_dir'] != 'ASC' && $_GET['sort_dir'] != 'DESC') ? 'ASC' : strtoupper($_GET['sort_dir']); |
67 <?php endif; ?> <label class="conl"><?php echo $lang_ul['User group']."\n" ?> |
70 <?php endif; ?> <label class="conl"><?php echo $lang_ul['User group']."\n" ?> |
68 <br /><select name="show_group"> |
71 <br /><select name="show_group"> |
69 <option value="-1"<?php if ($show_group == -1) echo ' selected="selected"' ?>><?php echo $lang_ul['All users'] ?></option> |
72 <option value="-1"<?php if ($show_group == -1) echo ' selected="selected"' ?>><?php echo $lang_ul['All users'] ?></option> |
70 <?php |
73 <?php |
71 |
74 |
72 $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()); |
75 $result = $pun_db->query('SELECT g_id, g_title FROM '.$pun_db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_id') or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error()); |
73 |
76 |
74 while ($cur_group = $db->fetch_assoc($result)) |
77 while ($cur_group = $pun_db->fetch_assoc($result)) |
75 { |
78 { |
76 if ($cur_group['g_id'] == $show_group) |
79 if ($cur_group['g_id'] == $show_group) |
77 echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
80 echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
78 else |
81 else |
79 echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
82 echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
109 // Create any SQL for the WHERE clause |
112 // Create any SQL for the WHERE clause |
110 $where_sql = array(); |
113 $where_sql = array(); |
111 $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
114 $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
112 |
115 |
113 if ($pun_user['g_search_users'] == '1' && $username != '') |
116 if ($pun_user['g_search_users'] == '1' && $username != '') |
114 $where_sql[] = 'u.username '.$like_command.' \''.$db->escape(str_replace('*', '%', $username)).'\''; |
117 $where_sql[] = 'eu.username '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $username)).'\''; |
115 if ($show_group > -1) |
118 if ($show_group > -1) |
116 $where_sql[] = 'u.group_id='.$show_group; |
119 $where_sql[] = 'u.group_id='.$show_group; |
117 |
120 |
118 // Fetch user count |
121 // Fetch user count |
119 $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users AS u WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '')) or error('Unable to fetch user list count', __FILE__, __LINE__, $db->error()); |
122 $result = $pun_db->query('SELECT COUNT(id) FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.table_prefix.'users AS eu ON eu.user_id=u.id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '')) or error('Unable to fetch user list count', __FILE__, __LINE__, $pun_db->error()); |
120 $num_users = $db->result($result); |
123 $num_users = $pun_db->result($result); |
121 |
124 |
122 |
125 |
123 // Determine the user offset (based on $_GET['p']) |
126 // Determine the user offset (based on $_GET['p']) |
124 $num_pages = ceil($num_users / 50); |
127 $num_pages = ceil($num_users / 50); |
125 |
128 |
126 $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; |
129 $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; |
127 $start_from = 50 * ($p - 1); |
130 $start_from = 50 * ($p - 1); |
128 |
131 |
129 // Generate paging links |
132 // Generate paging links |
130 $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'userlist.php?username='.urlencode($username).'&show_group='.$show_group.'&sort_by='.$sort_by.'&sort_dir='.strtoupper($sort_dir)); |
133 $paging_links = $lang_common['Pages'].': '.pun_paginate($num_pages, $p, 'userlist.php?username='.urlencode($username).'&show_group='.$show_group.'&sort_by='.$sort_by.'&sort_dir='.strtoupper($sort_dir)); |
131 |
134 |
132 |
135 |
133 ?> |
136 ?> |
134 <div class="linkst"> |
137 <div class="linkst"> |
135 <div class="inbox"> |
138 <div class="inbox"> |
152 </thead> |
155 </thead> |
153 <tbody> |
156 <tbody> |
154 <?php |
157 <?php |
155 |
158 |
156 // Grab the users |
159 // Grab the users |
157 $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>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error()); |
160 $result = $pun_db->query('SELECT u.id, eu.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title FROM '.$pun_db->prefix.'users AS u LEFT JOIN '.table_prefix.'users AS eu ON eu.user_id=u.id LEFT JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $pun_db->error()); |
158 if ($db->num_rows($result)) |
161 if ($pun_db->num_rows($result)) |
159 { |
162 { |
160 while ($user_data = $db->fetch_assoc($result)) |
163 while ($user_data = $pun_db->fetch_assoc($result)) |
161 { |
164 { |
162 $user_title_field = get_title($user_data); |
165 $user_title_field = get_title($user_data); |
163 |
166 |
164 ?> |
167 ?> |
165 <tr> |
168 <tr> |