getstats.php 769 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. require 'required.php';
  3. require 'onlyloggedin.php';
  4. if (is_empty($VARS['user'])) {
  5. sendError("Missing data.", true);
  6. }
  7. $stats = $database->select('players', ['level', 'energy', 'maxenergy', 'teamid', 'lastping', 'kick'], ['nickname' => $VARS['user']])[0];
  8. $uuid = $_SESSION['uuid'];
  9. $kick = $database->select('players', ['kick'], ['uuid' => $uuid])[0]['kick'];
  10. if (!is_empty($kick)) {
  11. $_SESSION['loggedin'] = false;
  12. session_unset();
  13. session_destroy();
  14. $database->update('players', ['kick' => ''], ['uuid' => $uuid]);
  15. die(json_encode(['status' => 'ERROR', 'kick' => 1, 'message' => $kick]));
  16. }
  17. $out = [];
  18. $out['status'] = 'OK';
  19. $out['stats'] = $stats;
  20. $out['stats']['lastping'] = 0;
  21. echo json_encode($out);