From 1e2b5d7e7f142d665bff70d57c5119dbef6c95ec Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 5 May 2017 17:13:55 -0600 Subject: [PATCH] Add userexists by UID API --- api.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api.php b/api.php index e34958a..adce940 100644 --- a/api.php +++ b/api.php @@ -69,6 +69,13 @@ switch ($VARS['action']) { } break; case "userexists": + if (!is_empty($VARS['uid'])) { + if ($database->has('accounts', ['uid' => $VARS['uid']])) { + exit(json_encode(["status" => "OK", "exists" => true])); + } else { + exit(json_encode(["status" => "OK", "exists" => false])); + } + } if (user_exists($VARS['username'])) { exit(json_encode(["status" => "OK", "exists" => true])); } else { @@ -196,7 +203,7 @@ switch ($VARS['action']) { if (is_empty($VARS['search']) || strlen($VARS['search']) < 3) { exit(json_encode(["status" => "OK", "result" => []])); } - $data = $database->select('accounts', ['uid', 'username', 'realname (name)'], ["OR" => ['username[~]' => $VARS['search'], 'realname[~]' => $VARS['search']], "LIMIT" => QUERY_LIMIT]); + $data = $database->select('accounts', ['uid', 'username', 'realname (name)'], ["OR" => ['username[~]' => $VARS['search'], 'realname[~]' => $VARS['search']], "LIMIT" => 10]); exit(json_encode(["status" => "OK", "result" => $data])); break; default: