plugins/SpecialUserFuncs.php
changeset 326 ab66d6d1f1f4
parent 304 e2cb5f1432c8
parent 324 16d0c9f33466
child 334 c72b545f1304
equal deleted inserted replaced
314:474f8be55943 326:ab66d6d1f1f4
     2 /*
     2 /*
     3 Plugin Name: Special user/login-related pages
     3 Plugin Name: Special user/login-related pages
     4 Plugin URI: http://enanocms.org/
     4 Plugin URI: http://enanocms.org/
     5 Description: Provides the pages Special:Login, Special:Logout, Special:Register, and Special:Preferences.
     5 Description: Provides the pages Special:Login, Special:Logout, Special:Register, and Special:Preferences.
     6 Author: Dan Fuhry
     6 Author: Dan Fuhry
     7 Version: 1.0.2
     7 Version: 1.0.3
     8 Author URI: http://enanocms.org/
     8 Author URI: http://enanocms.org/
     9 */
     9 */
    10 
    10 
    11 /*
    11 /*
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    13  * Version 1.0.2
    13  * Version 1.0.3
    14  * Copyright (C) 2006-2007 Dan Fuhry
    14  * Copyright (C) 2006-2007 Dan Fuhry
    15  *
    15  *
    16  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    16  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    17  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    17  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    18  *
    18  *
   148     $db->free_result();
   148     $db->free_result();
   149   }
   149   }
   150   
   150   
   151   if ( isset($_GET['act']) && $_GET['act'] == 'getkey' )
   151   if ( isset($_GET['act']) && $_GET['act'] == 'getkey' )
   152   {
   152   {
       
   153     header('Content-type: application/json');
   153     $username = ( $session->user_logged_in ) ? $session->username : false;
   154     $username = ( $session->user_logged_in ) ? $session->username : false;
   154     $response = Array(
   155     $response = Array(
   155       'username' => $username,
   156       'username' => $username,
   156       'key' => $pubkey,
   157       'key' => $pubkey,
   157       'challenge' => $challenge,
   158       'challenge' => $challenge,
  1502                             $_GET['finduser']);
  1503                             $_GET['finduser']);
  1503     $finduser = str_replace(array('*', '?'),
  1504     $finduser = str_replace(array('*', '?'),
  1504                             array('%', '_'),
  1505                             array('%', '_'),
  1505                             $finduser);
  1506                             $finduser);
  1506     $finduser = $db->escape($finduser);
  1507     $finduser = $db->escape($finduser);
  1507     $username_where = 'u.username LIKE "' . $finduser . '"';
  1508     $username_where = ENANO_SQLFUNC_LOWERCASE . '(u.username) LIKE \'%' . strtolower($finduser) . '%\'';
  1508     $finduser_url = 'finduser=' . rawurlencode($_GET['finduser']) . '&';
  1509     $finduser_url = 'finduser=' . rawurlencode($_GET['finduser']) . '&';
  1509   }
  1510   }
  1510   else
  1511   else
  1511   {
  1512   {
  1512     $username_where = 'u.username REGEXP "^' . $startletter_sql . '"';
  1513     if ( ENANO_DBLAYER == 'MYSQL' )
       
  1514       $username_where = 'lcase(u.username) REGEXP lcase("^' . $startletter_sql . '")';
       
  1515     else if ( ENANO_DBLAYER == 'PGSQL' )
       
  1516       $username_where = 'lower(u.username) ~ lower(\'^' . $startletter_sql . '\')';
  1513     $finduser_url = '';
  1517     $finduser_url = '';
  1514   }
  1518   }
  1515   
  1519   
  1516   // Column markers
  1520   // Column markers
  1517   $headings = '<tr>
  1521   $headings = '<tr>
  1531                    <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=regist&orderby=' . $sortorders['regist'], true) . '">Registered</a>
  1535                    <a href="' . makeUrlNS('Special', 'Memberlist', $finduser_url . 'letter=' . $startletter . '&sort=regist&orderby=' . $sortorders['regist'], true) . '">Registered</a>
  1532                  </th>
  1536                  </th>
  1533                </tr>';
  1537                </tr>';
  1534                
  1538                
  1535   // determine number of rows
  1539   // determine number of rows
  1536   $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE ' . $username_where . ' AND u.username != "Anonymous";');
  1540   $q = $db->sql_query('SELECT u.user_id FROM '.table_prefix.'users AS u WHERE ' . $username_where . ' AND u.username != \'Anonymous\';');
  1537   if ( !$q )
  1541   if ( !$q )
  1538     $db->_die();
  1542     $db->_die();
  1539   
  1543   
  1540   $num_rows = $db->numrows();
  1544   $num_rows = $db->numrows();
  1541   $db->free_result();
  1545   $db->free_result();
  1548   
  1552   
  1549   // main selector
  1553   // main selector
  1550   $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
  1554   $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
  1551                                     LEFT JOIN '.table_prefix.'users_extra AS x
  1555                                     LEFT JOIN '.table_prefix.'users_extra AS x
  1552                                       ON ( u.user_id = x.user_id )
  1556                                       ON ( u.user_id = x.user_id )
  1553                                     WHERE ' . $username_where . ' AND u.username != "Anonymous"
  1557                                     WHERE ' . $username_where . ' AND u.username != \'Anonymous\'
  1554                                     ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';');
  1558                                     ORDER BY ' . $sort_sqllet . ' ' . $target_order . ';');
  1555   if ( !$q )
  1559   if ( !$q )
  1556     $db->_die();
  1560     $db->_die();
  1557   
  1561   
  1558   $html = paginate(
  1562   $html = paginate(
  1578                  </table>
  1582                  </table>
  1579               </div>
  1583               </div>
  1580               ' .
  1584               ' .
  1581               '<div style="float: left;">
  1585               '<div style="float: left;">
  1582                 <form action="' . makeUrlNS('Special', 'Memberlist') . '" method="get" onsubmit="if ( !submitAuthorized ) return false;">'
  1586                 <form action="' . makeUrlNS('Special', 'Memberlist') . '" method="get" onsubmit="if ( !submitAuthorized ) return false;">'
  1583                . ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->nslist[$paths->namespace] . $paths->cpage['urlname_nons'] ) . '" />' : '' )
  1587                . ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->page ) . '" />' : '' )
  1584                . ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : '')
  1588                . ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : '')
  1585                . '<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>'
  1589                . '<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>'
  1586                . '</form>
  1590                . '</form>
  1587                </div>'                                                                                                // Footer (printed after rows)
  1591                </div>'                                                                                                // Footer (printed after rows)
  1588           );
  1592           );