<?php
require_once __DIR__ . '/config.php';
$me = must_auth();
ensure_app_schema();
$u  = isset($_GET['username']) ? trim($_GET['username']) : '';
if (!$u) fail('Missing username');
$st = db()->prepare("SELECT username,IF(display_name='',username,display_name) AS display_name,public_key,avatar,about,timezone,country FROM users WHERE username=? LIMIT 1");
$st->execute(array($u));
$r = $st->fetch();
if (!$r) fail('User not found', 404);
ok(array(
    'username'     => $r['username'],
    'display_name' => $r['display_name'],
    'publicKey'    => $r['public_key'],
    'avatar'       => $r['avatar'],
    'about'        => $r['about'],
    'timezone'     => $r['timezone'],
    'country'      => $r['country']
));
