forked from pouetnet/pouet2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_users.php
34 lines (31 loc) · 842 Bytes
/
ajax_users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once("bootstrap.inc.php");
header("Content-type: application/json; charset=utf-8");
$sql = new SQLSelect();
$sql->AddField("id");
$sql->AddField("nickname as name");
$sql->AddField("avatar");
$sql->AddField("glops");
$sql->AddTable("users");
$r = array();
if (@$_POST["search"])
{
$terms = split_search_terms( $_POST["search"] );
foreach($terms as $term)
{
$sql->AddWhere(sprintf_esc("nickname like '%%%s%%'",_like($term)));
}
$sql->AddOrder(sprintf_esc("if(nickname='%s',1,2)",$_POST["search"]));
$sql->AddOrder("nickname");
$sql->AddOrder("lastLogin DESC");
$sql->SetLimit(10);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
else if (@$_POST["id"])
{
$sql->AddWhere(sprintf_esc("id = %d",$_POST["id"]));
$sql->SetLimit(1);
$r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>