[ticket/10737] Improvements over last commit

PHPBB3-10737
This commit is contained in:
Suhaib Khan 2014-02-06 22:18:48 +05:30 committed by Cesar G
parent dad60045b6
commit bc67377400
3 changed files with 28 additions and 68 deletions

View file

@ -982,37 +982,21 @@ switch ($mode)
break;
case 'livesearch':
$q=request_var('q','');
$q=request_var('q', '', true);
$hint="";
// Get us some users :D
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
$result = $db->sql_query($sql);
$user_list = array();
while ($row = $db->sql_fetchrow($result))
{
$user_list[] = (int) $row['user_id'];
}
$db->sql_freeresult($result);
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_list);
$sql = "SELECT username, user_id
FROM " . USERS_TABLE . " u
WHERE username LIKE '".$q."%' AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
$result = $db->sql_query($sql);
$i=1;
while ($row = $db->sql_fetchrow($result))
{ $j=($i%2)+1;
if(stripos($row['username'],$q)===0)
{
$hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
"' target='_blank'>" .
$row['username'] . "</a></td></tr>";
$i++;
}
else
$hint.="";
while ($i<=10 && $row = $db->sql_fetchrow($result))
{
$j=($i%2)+1;
$hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
"' target='_blank'>" .
$row['username'] . "</a></td></tr>";
$i++;
}
echo $hint;
exit();

View file

@ -1,30 +1,18 @@
<script>
function showHint(str)
{
if (str.length==0)
if (str.length<3)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.border="0px";
}
}
xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
xmlhttp.send();
$.ajax({
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
success:function(result){
$("#livesearch").html(result);
}
});
}
function clearSearch()

View file

@ -67,30 +67,18 @@
<script>
function showHint(str)
{
if (str.length==0)
if (str.length<3)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.border="0px";
}
}
xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
xmlhttp.send();
$.ajax({
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
success:function(result){
$("#livesearch").html(result);
}
});
}
function clearSearch()