<?php
require_once __DIR__ . '/config.php';
$me = must_auth();
ensure_app_schema();
$q  = isset($_GET['q']) ? trim($_GET['q']) : '';
if (!$q) { ok(array('users'=>array())); exit; }
$st = db()->prepare("SELECT username,IF(display_name='',username,display_name) AS display_name,avatar,about,timezone,country
                     FROM users
                     WHERE username!=? AND (username LIKE ? OR display_name LIKE ?)
                     LIMIT 20");
$like='%'.$q.'%';
$st->execute(array($me,$like,$like));
ok(array('users'=>$st->fetchAll()));
