author | Dan |
Thu, 12 Jul 2007 15:00:35 -0400 | |
changeset 3 | c0c445d4a13e |
parent 2 | a8a21e1c7afa |
child 4 | eb9ed4c366d0 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/*********************************************************************** |
|
3 |
||
4 |
Copyright (C) 2002-2005 Rickard Andersson (rickard@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 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
26 |
//define('PUN_ROOT', './'); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
27 |
//require PUN_ROOT.'include/common.php'; |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
28 |
|
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
29 |
global $pun_db, $pun_user, $pun_config, $lang_common; |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
30 |
|
0 | 31 |
|
32 |
||
33 |
if ($pun_user['g_read_board'] == '0') |
|
34 |
message($lang_common['No view']); |
|
35 |
||
36 |
||
37 |
// Load the userlist.php language file |
|
38 |
require PUN_ROOT.'lang/'.$pun_user['language'].'/userlist.php'; |
|
39 |
||
40 |
// Load the search.php language file |
|
41 |
require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php'; |
|
42 |
||
43 |
||
44 |
// Determine if we are allowed to view post counts |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
45 |
$show_post_count = ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] >= USER_LEVEL_MEMBER) ? true : false; |
0 | 46 |
|
47 |
$username = (isset($_GET['username']) && $pun_user['g_search_users'] == '1') ? pun_trim($_GET['username']) : ''; |
|
48 |
$show_group = (!isset($_GET['show_group']) || intval($_GET['show_group']) < -1 && intval($_GET['show_group']) > 2) ? -1 : intval($_GET['show_group']); |
|
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']; |
|
50 |
$sort_dir = (!isset($_GET['sort_dir']) || $_GET['sort_dir'] != 'ASC' && $_GET['sort_dir'] != 'DESC') ? 'ASC' : strtoupper($_GET['sort_dir']); |
|
51 |
||
52 |
||
53 |
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['User list']; |
|
54 |
if ($pun_user['g_search_users'] == '1') |
|
55 |
$focus_element = array('userlist', 'username'); |
|
56 |
||
57 |
define('PUN_ALLOW_INDEX', 1); |
|
58 |
require PUN_ROOT.'header.php'; |
|
59 |
||
60 |
?> |
|
61 |
<div class="blockform"> |
|
62 |
<h2><span><?php echo $lang_search['User search'] ?></span></h2> |
|
63 |
<div class="box"> |
|
64 |
<form id="userlist" method="get" action="userlist.php"> |
|
65 |
<div class="inform"> |
|
66 |
<fieldset> |
|
67 |
<legend><?php echo $lang_ul['User find legend'] ?></legend> |
|
68 |
<div class="infldset"> |
|
69 |
<?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> |
|
70 |
<?php endif; ?> <label class="conl"><?php echo $lang_ul['User group']."\n" ?> |
|
71 |
<br /><select name="show_group"> |
|
72 |
<option value="-1"<?php if ($show_group == -1) echo ' selected="selected"' ?>><?php echo $lang_ul['All users'] ?></option> |
|
73 |
<?php |
|
74 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
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()); |
0 | 76 |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
77 |
while ($cur_group = $pun_db->fetch_assoc($result)) |
0 | 78 |
{ |
79 |
if ($cur_group['g_id'] == $show_group) |
|
80 |
echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
|
81 |
else |
|
82 |
echo "\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
|
83 |
} |
|
84 |
||
85 |
?> |
|
86 |
</select> |
|
87 |
<br /></label> |
|
88 |
<label class="conl"><?php echo $lang_search['Sort by']."\n" ?> |
|
89 |
<br /><select name="sort_by"> |
|
90 |
<option value="username"<?php if ($sort_by == 'username') echo ' selected="selected"' ?>><?php echo $lang_common['Username'] ?></option> |
|
91 |
<option value="registered"<?php if ($sort_by == 'registered') echo ' selected="selected"' ?>><?php echo $lang_common['Registered'] ?></option> |
|
92 |
<?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> |
|
93 |
<?php endif; ?> </select> |
|
94 |
<br /></label> |
|
95 |
<label class="conl"><?php echo $lang_search['Sort order']."\n" ?> |
|
96 |
<br /><select name="sort_dir"> |
|
97 |
<option value="ASC"<?php if ($sort_dir == 'ASC') echo ' selected="selected"' ?>><?php echo $lang_search['Ascending'] ?></option> |
|
98 |
<option value="DESC"<?php if ($sort_dir == 'DESC') echo ' selected="selected"' ?>><?php echo $lang_search['Descending'] ?></option> |
|
99 |
</select> |
|
100 |
<br /></label> |
|
101 |
<p class="clearb"><?php echo $lang_ul['User search info'] ?></p> |
|
102 |
</div> |
|
103 |
</fieldset> |
|
104 |
</div> |
|
105 |
<p><input type="submit" name="search" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" /></p> |
|
106 |
</form> |
|
107 |
</div> |
|
108 |
</div> |
|
109 |
<?php |
|
110 |
||
111 |
||
112 |
// Create any SQL for the WHERE clause |
|
113 |
$where_sql = array(); |
|
114 |
$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
|
115 |
||
116 |
if ($pun_user['g_search_users'] == '1' && $username != '') |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
117 |
$where_sql[] = 'eu.username '.$like_command.' \''.$pun_db->escape(str_replace('*', '%', $username)).'\''; |
0 | 118 |
if ($show_group > -1) |
119 |
$where_sql[] = 'u.group_id='.$show_group; |
|
120 |
||
121 |
// Fetch user count |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
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()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
123 |
$num_users = $pun_db->result($result); |
0 | 124 |
|
125 |
||
126 |
// Determine the user offset (based on $_GET['p']) |
|
127 |
$num_pages = ceil($num_users / 50); |
|
128 |
||
129 |
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; |
|
130 |
$start_from = 50 * ($p - 1); |
|
131 |
||
132 |
// Generate paging links |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
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)); |
0 | 134 |
|
135 |
||
136 |
?> |
|
137 |
<div class="linkst"> |
|
138 |
<div class="inbox"> |
|
139 |
<p class="pagelink"><?php echo $paging_links ?></p> |
|
140 |
</div> |
|
141 |
</div> |
|
142 |
||
143 |
<div id="users1" class="blocktable"> |
|
144 |
<h2><span><?php echo $lang_common['User list'] ?></span></h2> |
|
145 |
<div class="box"> |
|
146 |
<div class="inbox"> |
|
147 |
<table cellspacing="0"> |
|
148 |
<thead> |
|
149 |
<tr> |
|
150 |
<th class="tcl" scope="col"><?php echo $lang_common['Username'] ?></th> |
|
151 |
<th class="tc2" scope="col"><?php echo $lang_common['Title'] ?></th> |
|
152 |
<?php if ($show_post_count): ?> <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th> |
|
153 |
<?php endif; ?> <th class="tcr" scope="col"><?php echo $lang_common['Registered'] ?></th> |
|
154 |
</tr> |
|
155 |
</thead> |
|
156 |
<tbody> |
|
157 |
<?php |
|
158 |
||
159 |
// Grab the users |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
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()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
161 |
if ($pun_db->num_rows($result)) |
0 | 162 |
{ |
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
163 |
while ($user_data = $pun_db->fetch_assoc($result)) |
0 | 164 |
{ |
165 |
$user_title_field = get_title($user_data); |
|
166 |
||
167 |
?> |
|
168 |
<tr> |
|
169 |
<td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td> |
|
170 |
<td class="tc2"><?php echo $user_title_field ?></td> |
|
171 |
<?php if ($show_post_count): ?> <td class="tc3"><?php echo $user_data['num_posts'] ?></td> |
|
172 |
<?php endif; ?> |
|
173 |
<td class="tcr"><?php echo format_time($user_data['registered'], true) ?></td> |
|
174 |
</tr> |
|
175 |
<?php |
|
176 |
||
177 |
} |
|
178 |
} |
|
179 |
else |
|
180 |
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"; |
|
181 |
||
182 |
?> |
|
183 |
</tbody> |
|
184 |
</table> |
|
185 |
</div> |
|
186 |
</div> |
|
187 |
</div> |
|
188 |
||
189 |
<div class="linksb"> |
|
190 |
<div class="inbox"> |
|
191 |
<p class="pagelink"><?php echo $paging_links ?></p> |
|
192 |
</div> |
|
193 |
</div> |
|
194 |
<?php |
|
195 |
||
196 |
require PUN_ROOT.'footer.php'; |