# HG changeset patch # User Dan # Date 1190683759 14400 # Node ID 380e55865f86bb43530e25796317ba1f93b095a4 # Parent c8bfd324cb03dc1d3874b111a1a904d31e81064e Improved response time for username autofill; fix JS login box in Safari (bug surfaced only after 1.0.1) diff -r c8bfd324cb03 -r 380e55865f86 ajax.php --- a/ajax.php Sun Sep 23 23:22:25 2007 -0400 +++ b/ajax.php Mon Sep 24 21:29:19 2007 -0400 @@ -12,6 +12,59 @@ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. */ + // fillusername should be done without the help of the rest of Enano - all we need is the DBAL + if ( isset($_GET['_mode']) && $_GET['_mode'] == 'fillusername' ) + { + // setup and load a very basic, specialized instance of the Enano API + function dc_here($m) { return false; } + function dc_dump($a, $g) { return false; } + function dc_watch($n) { return false; } + function dc_start_timer($u) { return false; } + function dc_stop_timer($m) { return false; } + // Determine directory (special case for development servers) + if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') ) + { + $filename = str_replace('/repo/', '/', __FILE__); + } + else + { + $filename = __FILE__; + } + define('ENANO_ROOT', dirname($filename)); + require(ENANO_ROOT.'/includes/functions.php'); + require(ENANO_ROOT.'/includes/dbal.php'); + $db = new mysql(); + $db->connect(); + + // should be connected now + $name = (isset($_GET['name'])) ? $db->escape($_GET['name']) : false; + if ( !$name ) + { + die('userlist = new Array(); errorstring=\'Invalid URI\''); + } + $q = $db->sql_query('SELECT username,user_id FROM '.table_prefix.'users WHERE lcase(username) LIKE lcase(\'%'.$name.'%\');'); + if ( !$q ) + { + die('userlist = new Array(); errorstring=\'MySQL error selecting username data: '.addslashes(mysql_error()).'\''); + } + if($db->numrows() < 1) + { + die('userlist = new Array(); errorstring=\'No usernames found\';'); + } + echo 'var errorstring = false; userlist = new Array();'; + $i = 0; + while($r = $db->fetchrow()) + { + echo "userlist[$i] = '".addslashes($r['username'])."'; "; + $i++; + } + $db->free_result(); + + // all done! :-) + $db->close(); + exit; + } + require('includes/common.php'); global $db, $session, $paths, $template, $plugins; // Common objects @@ -105,28 +158,6 @@ echo PageUtils::setpass($paths->cpage['urlname_nons'], $paths->namespace, $_POST['password']); break; case "fillusername": - $name = (isset($_GET['name'])) ? $db->escape($_GET['name']) : false; - if ( !$name ) - { - die('userlist = new Array(); errorstring=\'Invalid URI\''); - } - $q = $db->sql_query('SELECT username,user_id FROM '.table_prefix.'users WHERE lcase(username) LIKE lcase(\'%'.$name.'%\');'); - if ( !$q ) - { - die('userlist = new Array(); errorstring=\'MySQL error selecting username data: '.addslashes(mysql_error()).'\''); - } - if($db->numrows() < 1) - { - die('userlist = new Array(); errorstring=\'No usernames found\';'); - } - echo 'var errorstring = false; userlist = new Array();'; - $i = 0; - while($r = $db->fetchrow()) - { - echo "userlist[$i] = '".addslashes($r['username'])."'; "; - $i++; - } - $db->free_result(); break; case "fillpagename": $name = (isset($_GET['name'])) ? $_GET['name'] : false; diff -r c8bfd324cb03 -r 380e55865f86 includes/clientside/static/misc.js --- a/includes/clientside/static/misc.js Sun Sep 23 23:22:25 2007 -0400 +++ b/includes/clientside/static/misc.js Mon Sep 24 21:29:19 2007 -0400 @@ -446,14 +446,8 @@ 'level' : ajax_auth_level_cache }; - if ( window.console ) - window.console.debug(json_data); json_data = toJSONString(json_data); - if ( window.console ) - window.console.debug(json_data); json_data = encodeURIComponent(json_data); - if ( window.console ) - window.console.debug(json_data); var loading_win = '
\

Logging in...

\ diff -r c8bfd324cb03 -r 380e55865f86 includes/common.php --- a/includes/common.php Sun Sep 23 23:22:25 2007 -0400 +++ b/includes/common.php Mon Sep 24 21:29:19 2007 -0400 @@ -268,7 +268,7 @@ $text = RenderMan::render($n) . '
- If you have an administrative account, you may log in to the site or use the administration panel. + If you have an administrative account, you may log in to the site.
'; $paths->wiki_mode = 0; die_semicritical('Site disabled', $text);