1142 'username' => array($formatter, 'username'), |
1134 'username' => array($formatter, 'username'), |
1143 'user_level' => array($formatter, 'user_level'), |
1135 'user_level' => array($formatter, 'user_level'), |
1144 'email' => array($formatter, 'email') |
1136 'email' => array($formatter, 'email') |
1145 ); |
1137 ); |
1146 |
1138 |
|
1139 // User search |
|
1140 if ( isset($_GET['finduser']) ) |
|
1141 { |
|
1142 $finduser = str_replace(array( '%', '_'), |
|
1143 array('\\%', '\\_'), |
|
1144 $_GET['finduser']); |
|
1145 $finduser = str_replace(array('*', '?'), |
|
1146 array('%', '_'), |
|
1147 $finduser); |
|
1148 $finduser = $db->escape($finduser); |
|
1149 $username_where = 'u.username LIKE "' . $finduser . '"'; |
|
1150 $finduser_url = 'finduser=' . rawurlencode($_GET['finduser']) . '&'; |
|
1151 } |
|
1152 else |
|
1153 { |
|
1154 $username_where = 'u.username REGEXP "^' . $startletter_sql . '"'; |
|
1155 $finduser_url = ''; |
|
1156 } |
|
1157 |
1147 // Column markers |
1158 // Column markers |
1148 $headings = '<tr> |
1159 $headings = '<tr> |
1149 <th style="max-width: 50px;"> |
1160 <th style="max-width: 50px;"> |
1150 <a href="' . makeUrlNS('Special', 'Memberlist', 'letter=' . $startletter . '&sort=uid&orderby=' . $sortorders['uid'], true) . '">#</a> |
1161 <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=uid&orderby=' . $sortorders['uid'], true) . '">#</a> |
1151 </th> |
1162 </th> |
1152 <th> |
1163 <th> |
1153 <a href="' . makeUrlNS('Special', 'Memberlist', 'letter=' . $startletter . '&sort=username&orderby=' . $sortorders['username'], true) . '">Username</a> |
1164 <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=username&orderby=' . $sortorders['username'], true) . '">Username</a> |
1154 </th> |
1165 </th> |
1155 <th> |
1166 <th> |
1156 <a href="' . makeUrlNS('Special', 'Memberlist', 'letter=' . $startletter . '&sort=email&orderby=' . $sortorders['email'], true) . '">E-mail</a> |
1167 <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=email&orderby=' . $sortorders['email'], true) . '">E-mail</a> |
1157 </th> |
1168 </th> |
1158 </tr>'; |
1169 </tr>'; |
1159 |
1170 |
|
1171 // determine number of rows |
|
1172 $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE ' . $username_where . ' AND u.username != "Anonymous";'); |
|
1173 if ( !$q ) |
|
1174 $db->_die(); |
|
1175 |
|
1176 $num_rows = $db->numrows(); |
|
1177 $db->free_result(); |
|
1178 |
|
1179 if ( !empty($finduser_url) ) |
|
1180 { |
|
1181 $s = ( $num_rows == 1 ) ? '' : 'es'; |
|
1182 echo "<h3 style='float: left;'>Search returned $num_rows match$s</h3>"; |
|
1183 } |
|
1184 |
|
1185 // main selector |
1160 $q = $db->sql_unbuffered_query('SELECT u.user_id, u.username, u.reg_time, u.email, u.user_level, x.email_public FROM '.table_prefix.'users AS u |
1186 $q = $db->sql_unbuffered_query('SELECT u.user_id, u.username, u.reg_time, u.email, u.user_level, x.email_public FROM '.table_prefix.'users AS u |
1161 LEFT JOIN '.table_prefix.'users_extra AS x |
1187 LEFT JOIN '.table_prefix.'users_extra AS x |
1162 ON ( u.user_id = x.user_id ) |
1188 ON ( u.user_id = x.user_id ) |
1163 WHERE u.username REGEXP "^' . $startletter_sql . '" AND u.username != "Anonymous" |
1189 WHERE ' . $username_where . ' AND u.username != "Anonymous" |
1164 ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';'); |
1190 ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';'); |
1165 if ( !$q ) |
1191 if ( !$q ) |
1166 $db->_die(); |
1192 $db->_die(); |
1167 |
1193 |
1168 $html = paginate( |
1194 $html = paginate( |
1172 <td class="{_css_class}" style="text-align: left;">{username}<br /><small>{user_level}</small></td> |
1198 <td class="{_css_class}" style="text-align: left;">{username}<br /><small>{user_level}</small></td> |
1173 <td class="{_css_class}">{email}</small></td> |
1199 <td class="{_css_class}">{email}</small></td> |
1174 </tr> |
1200 </tr> |
1175 ', // TPL code for rows |
1201 ', // TPL code for rows |
1176 $num_rows, // Number of results |
1202 $num_rows, // Number of results |
1177 makeUrlNS('Special', 'Memberlist', 'letter=' . $startletter . '&offset=%s&sort=' . $sortby . '&orderby=' . $target_order ), // Result URL |
1203 makeUrlNS('Special', 'Memberlist', ( str_replace('%', '%%', $finduser_url) ) . 'letter=' . $startletter . '&offset=%s&sort=' . $sortby . '&orderby=' . $target_order ), // Result URL |
1178 $offset, // Start at this number |
1204 $offset, // Start at this number |
1179 25, // Results per page |
1205 25, // Results per page |
1180 $formatters, // Formatting hooks |
1206 $formatters, // Formatting hooks |
1181 '<div class="tblholder"> |
1207 '<div class="tblholder"> |
1182 <table border="0" cellspacing="1" cellpadding="4" style="text-align: center;"> |
1208 <table border="0" cellspacing="1" cellpadding="4" style="text-align: center;"> |
1183 ' . $headings . ' |
1209 ' . $headings . ' |
1184 ', // Header (printed before rows) |
1210 ', // Header (printed before rows) |
1185 ' ' . $headings . ' |
1211 ' ' . $headings . ' |
1186 </table> |
1212 </table> |
1187 </div> |
1213 </div> |
1188 ' // Footer (printed after rows) |
1214 ' . |
|
1215 '<div style="float: left;"> |
|
1216 <form action="' . makeUrlNS('Special', 'Memberlist') . '" method="get" onsubmit="if ( !submitAuthorized ) return false;">' |
|
1217 . '<p>Find a member: ' . $template->username_field('finduser') . ' <input type="submit" value="Go" /><br /><small>You may use the following wildcards: * to match multiple characters, ? to match a single character.</small></p>' |
|
1218 . '</form> |
|
1219 </div>' // Footer (printed after rows) |
1189 ); |
1220 ); |
1190 |
1221 |
1191 if ( $num_rows < 1 ) |
1222 if ( $num_rows < 1 ) |
1192 { |
1223 { |
1193 echo '<p>Sorry - no users with usernames that start with that letter could be found.</p>'; |
1224 echo ( isset($_GET['finduser']) ) ? '<p>Sorry - no users that matched your query could be found. Please try some different search terms.</p>' : '<p>Sorry - no users with usernames that start with that letter could be found.</p>'; |
1194 } |
1225 } |
1195 else |
1226 else |
1196 { |
1227 { |
1197 echo $html; |
1228 echo $html; |
1198 } |
1229 } |