plugins/SpecialUserFuncs.php
changeset 261 5f1cd51bf1be
parent 256 f8356d9c3481
child 263 16d0c9f33466
equal deleted inserted replaced
259:112debff64bd 261:5f1cd51bf1be
  1340                             $_GET['finduser']);
  1340                             $_GET['finduser']);
  1341     $finduser = str_replace(array('*', '?'),
  1341     $finduser = str_replace(array('*', '?'),
  1342                             array('%', '_'),
  1342                             array('%', '_'),
  1343                             $finduser);
  1343                             $finduser);
  1344     $finduser = $db->escape($finduser);
  1344     $finduser = $db->escape($finduser);
  1345     $username_where = 'u.username LIKE "' . $finduser . '"';
  1345     $username_where = ENANO_SQLFUNC_LOWERCASE . '(u.username) LIKE \'%' . strtolower($finduser) . '%\'';
  1346     $finduser_url = 'finduser=' . rawurlencode($_GET['finduser']) . '&';
  1346     $finduser_url = 'finduser=' . rawurlencode($_GET['finduser']) . '&';
  1347   }
  1347   }
  1348   else
  1348   else
  1349   {
  1349   {
  1350     $username_where = 'u.username REGEXP "^' . $startletter_sql . '"';
  1350     if ( ENANO_DBLAYER == 'MYSQL' )
       
  1351       $username_where = 'lcase(u.username) REGEXP lcase("^' . $startletter_sql . '")';
       
  1352     else if ( ENANO_DBLAYER == 'PGSQL' )
       
  1353       $username_where = 'lower(u.username) ~ lower(\'^' . $startletter_sql . '\')';
  1351     $finduser_url = '';
  1354     $finduser_url = '';
  1352   }
  1355   }
  1353   
  1356   
  1354   // Column markers
  1357   // Column markers
  1355   $headings = '<tr>
  1358   $headings = '<tr>
  1369                    <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=regist&orderby=' . $sortorders['regist'], true) . '">Registered</a>
  1372                    <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=regist&orderby=' . $sortorders['regist'], true) . '">Registered</a>
  1370                  </th>
  1373                  </th>
  1371                </tr>';
  1374                </tr>';
  1372                
  1375                
  1373   // determine number of rows
  1376   // determine number of rows
  1374   $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE ' . $username_where . ' AND u.username != "Anonymous";');
  1377   $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE ' . $username_where . ' AND u.username != \'Anonymous\';');
  1375   if ( !$q )
  1378   if ( !$q )
  1376     $db->_die();
  1379     $db->_die();
  1377   
  1380   
  1378   $num_rows = $db->numrows();
  1381   $num_rows = $db->numrows();
  1379   $db->free_result();
  1382   $db->free_result();
  1386   
  1389   
  1387   // main selector
  1390   // main selector
  1388   $q = $db->sql_unbuffered_query('SELECT u.user_id, u.username, u.reg_time, u.email, u.user_level, u.reg_time, x.email_public FROM '.table_prefix.'users AS u
  1391   $q = $db->sql_unbuffered_query('SELECT u.user_id, u.username, u.reg_time, u.email, u.user_level, u.reg_time, x.email_public FROM '.table_prefix.'users AS u
  1389                                     LEFT JOIN '.table_prefix.'users_extra AS x
  1392                                     LEFT JOIN '.table_prefix.'users_extra AS x
  1390                                       ON ( u.user_id = x.user_id )
  1393                                       ON ( u.user_id = x.user_id )
  1391                                     WHERE ' . $username_where . ' AND u.username != "Anonymous"
  1394                                     WHERE ' . $username_where . ' AND u.username != \'Anonymous\'
  1392                                     ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';');
  1395                                     ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';');
  1393   if ( !$q )
  1396   if ( !$q )
  1394     $db->_die();
  1397     $db->_die();
  1395   
  1398   
  1396   $html = paginate(
  1399   $html = paginate(
  1416                  </table>
  1419                  </table>
  1417               </div>
  1420               </div>
  1418               ' .
  1421               ' .
  1419               '<div style="float: left;">
  1422               '<div style="float: left;">
  1420                 <form action="' . makeUrlNS('Special', 'Memberlist') . '" method="get" onsubmit="if ( !submitAuthorized ) return false;">'
  1423                 <form action="' . makeUrlNS('Special', 'Memberlist') . '" method="get" onsubmit="if ( !submitAuthorized ) return false;">'
  1421                . ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->nslist[$paths->namespace] . $paths->cpage['urlname_nons'] ) . '" />' : '' )
  1424                . ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->page ) . '" />' : '' )
  1422                . ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : '')
  1425                . ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : '')
  1423                . '<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>'
  1426                . '<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>'
  1424                . '</form>
  1427                . '</form>
  1425                </div>'                                                                                                // Footer (printed after rows)
  1428                </div>'                                                                                                // Footer (printed after rows)
  1426           );
  1429           );