Add option to get user info by ID, not name
This commit is contained in:
parent
2a9ad78477
commit
0e13f77e05
14
api.php
14
api.php
@ -49,12 +49,24 @@ switch ($VARS['action']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "userinfo":
|
case "userinfo":
|
||||||
|
if (!is_empty($VARS['username'])) {
|
||||||
if (user_exists($VARS['username'])) {
|
if (user_exists($VARS['username'])) {
|
||||||
$data = $database->select("accounts", ["uid", "realname (name)", "email", "phone" => ["phone1 (1)", "phone2 (2)"]], ["username" => $VARS['username']])[0];
|
$data = $database->select("accounts", ["uid", "username", "realname (name)", "email", "phone" => ["phone1 (1)", "phone2 (2)"]], ["username" => $VARS['username']])[0];
|
||||||
exit(json_encode(["status" => "OK", "data" => $data]));
|
exit(json_encode(["status" => "OK", "data" => $data]));
|
||||||
} else {
|
} else {
|
||||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||||
}
|
}
|
||||||
|
} else if (!is_empty($VARS['uid'])) {
|
||||||
|
if ($database->has('accounts', ['uid' => $VARS['uid']])) {
|
||||||
|
$data = $database->select("accounts", ["uid", "username", "realname (name)", "email", "phone" => ["phone1 (1)", "phone2 (2)"]], ["uid" => $VARS['uid']])[0];
|
||||||
|
exit(json_encode(["status" => "OK", "data" => $data]));
|
||||||
|
} else {
|
||||||
|
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header("HTTP/1.1 400 Bad Request");
|
||||||
|
die("\"400 Bad Request\"");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "userexists":
|
case "userexists":
|
||||||
if (user_exists($VARS['username'])) {
|
if (user_exists($VARS['username'])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user