From a8735c03aa0847dcf14cb3e3e93674425d2b38fd Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 11 Oct 2016 01:20:32 -0600 Subject: [PATCH] Add giveitem.php --- getstats.php | 4 ++-- giveitem.php | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 giveitem.php diff --git a/getstats.php b/getstats.php index efb629d..534a751 100644 --- a/getstats.php +++ b/getstats.php @@ -8,11 +8,11 @@ if (is_empty($VARS['user'])) { sendError("Missing data.", true); } -$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'teamid', 'lastping'], ['uuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])])[0]; +$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'teamid', 'lastping'], ['uuid' => $_SESSION['uuid']])[0]; $out = []; $out['status'] = 'OK'; $out['stats'] = $stats; $out['stats']['lastping'] = 0; -echo json_encode($out); \ No newline at end of file +echo json_encode($out); diff --git a/giveitem.php b/giveitem.php new file mode 100644 index 0000000..ed934fe --- /dev/null +++ b/giveitem.php @@ -0,0 +1,20 @@ +has('inventory', ["AND" => ['itemuuid' => $itemuuid, 'playeruuid' => $_SESSION['uuid']]])) { + sendError("Invalid itemuuid.", true); +} + +if (is_empty($player) || !$database->has('players', ['nickname' => $player])) { + sendError("Invalid nickname.", true); +} + +$playeruuid = $database->select('players', ['uuid'], ['nickname' => $player])[0]; + + +$database->update('inventory', ['playeruuid' => $playeruuid], ['itemuuid' => $itemuuid]);