diff --git a/api/actions/setprofile.php b/api/actions/setprofile.php new file mode 100644 index 0000000..191aac3 --- /dev/null +++ b/api/actions/setprofile.php @@ -0,0 +1,27 @@ +get("accounts", ["[>]authkeys" => ["accountid"]], ["accounts.accountid","name", "bio"], ["key" => $VARS["key"]]); + +if (!empty($VARS["name"])) { + if (strlen($VARS["name"]) > 200) { + sendJsonResp($Strings->get("Name is too long (max 200 characters)."), "ERROR"); + } + $profile["name"] = htmlentities($VARS["name"]); +} + +if (!empty($VARS["bio"])) { + $profile["bio"] = htmlentities($VARS["bio"]); +} + +$database->update("accounts", [ + "name" => $profile["name"], + "bio" => $profile["bio"], +], ["accountid" => $profile["accountid"]]); + +sendJsonResp(); \ No newline at end of file diff --git a/api/apisettings.php b/api/apisettings.php index a97ec6f..db981c0 100644 --- a/api/apisettings.php +++ b/api/apisettings.php @@ -66,6 +66,14 @@ $APIS = [ "id (optional)" => "/[0-9a-z]+/" ] ], + "setprofile" => [ + "load" => "setprofile.php", + "vars" => [ + "key" => $keyregex, + "name (optional)" => "string", + "bio (optional)" => "string" + ] + ], "getnearby" => [ "load" => "nearby.php", "vars" => [