Browse Source

Add giveitem.php

Skylar Ittner 2 years ago
parent
commit
a8735c03aa
2 changed files with 22 additions and 2 deletions
  1. 2
    2
      getstats.php
  2. 20
    0
      giveitem.php

+ 2
- 2
getstats.php View File

@@ -8,11 +8,11 @@ if (is_empty($VARS['user'])) {
8 8
     sendError("Missing data.", true);
9 9
 }
10 10
 
11
-$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'teamid', 'lastping'], ['uuid' => file_get_contents("https://sso.netsyms.com/api/getguid.php?user=" . $VARS['user'])])[0];
11
+$stats = $database->select('players', ['level', 'energy', 'maxenergy', 'teamid', 'lastping'], ['uuid' => $_SESSION['uuid']])[0];
12 12
 
13 13
 
14 14
 $out = [];
15 15
 $out['status'] = 'OK';
16 16
 $out['stats'] = $stats;
17 17
 $out['stats']['lastping'] = 0;
18
-echo json_encode($out);
18
+echo json_encode($out);

+ 20
- 0
giveitem.php View File

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+require 'required.php';
4
+require 'onlyloggedin.php';
5
+
6
+$itemuuid = $VARS['itemuuid'];
7
+$player = $VARS['giveto'];
8
+
9
+if (is_empty($itemuuid) || !is_numeric($itemuuid) || !$database->has('inventory', ["AND" => ['itemuuid' => $itemuuid, 'playeruuid' => $_SESSION['uuid']]])) {
10
+    sendError("Invalid itemuuid.", true);
11
+}
12
+
13
+if (is_empty($player) || !$database->has('players', ['nickname' => $player])) {
14
+    sendError("Invalid nickname.", true);
15
+}
16
+
17
+$playeruuid = $database->select('players', ['uuid'], ['nickname' => $player])[0];
18
+
19
+
20
+$database->update('inventory', ['playeruuid' => $playeruuid], ['itemuuid' => $itemuuid]);

Loading…
Cancel
Save