diff -r 9c17aacd5515 -r f7750e454168 plugins/SpecialUserFuncs.php --- a/plugins/SpecialUserFuncs.php Sun Aug 26 20:55:12 2007 -0400 +++ b/plugins/SpecialUserFuncs.php Sun Aug 26 22:52:38 2007 -0400 @@ -1092,14 +1092,6 @@ $startletter_sql = '([^a-z])'; } - // determine number of rows - $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE u.username REGEXP "^' . $startletter_sql . '" AND u.username != "Anonymous";'); - if ( !$q ) - $db->_die(); - - $num_rows = $db->numrows(); - $db->free_result(); - // offset $offset = ( isset($_GET['offset']) && strval(intval($_GET['offset'])) === $_GET['offset']) ? intval($_GET['offset']) : 0; @@ -1144,23 +1136,57 @@ 'email' => array($formatter, 'email') ); + // User search + if ( isset($_GET['finduser']) ) + { + $finduser = str_replace(array( '%', '_'), + array('\\%', '\\_'), + $_GET['finduser']); + $finduser = str_replace(array('*', '?'), + array('%', '_'), + $finduser); + $finduser = $db->escape($finduser); + $username_where = 'u.username LIKE "' . $finduser . '"'; + $finduser_url = 'finduser=' . rawurlencode($_GET['finduser']) . '&'; + } + else + { + $username_where = 'u.username REGEXP "^' . $startletter_sql . '"'; + $finduser_url = ''; + } + // Column markers $headings = ' - # + # + + + Username - Username - - - E-mail + E-mail '; + + // determine number of rows + $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE ' . $username_where . ' AND u.username != "Anonymous";'); + if ( !$q ) + $db->_die(); + $num_rows = $db->numrows(); + $db->free_result(); + + if ( !empty($finduser_url) ) + { + $s = ( $num_rows == 1 ) ? '' : 'es'; + echo "

Search returned $num_rows match$s

"; + } + + // main selector $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 LEFT JOIN '.table_prefix.'users_extra AS x ON ( u.user_id = x.user_id ) - WHERE u.username REGEXP "^' . $startletter_sql . '" AND u.username != "Anonymous" + WHERE ' . $username_where . ' AND u.username != "Anonymous" ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';'); if ( !$q ) $db->_die(); @@ -1174,7 +1200,7 @@ ', // TPL code for rows $num_rows, // Number of results - makeUrlNS('Special', 'Memberlist', 'letter=' . $startletter . '&offset=%s&sort=' . $sortby . '&orderby=' . $target_order ), // Result URL + makeUrlNS('Special', 'Memberlist', ( str_replace('%', '%%', $finduser_url) ) . 'letter=' . $startletter . '&offset=%s&sort=' . $sortby . '&orderby=' . $target_order ), // Result URL $offset, // Start at this number 25, // Results per page $formatters, // Formatting hooks @@ -1185,12 +1211,17 @@ ' ' . $headings . ' - ' // Footer (printed after rows) + ' . + '
+
' + . '

Find a member: ' . $template->username_field('finduser') . '
You may use the following wildcards: * to match multiple characters, ? to match a single character.

' + . '
+
' // Footer (printed after rows) ); if ( $num_rows < 1 ) { - echo '

Sorry - no users with usernames that start with that letter could be found.

'; + echo ( isset($_GET['finduser']) ) ? '

Sorry - no users that matched your query could be found. Please try some different search terms.

' : '

Sorry - no users with usernames that start with that letter could be found.

'; } else {