ping.php 987 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require 'required.php';
  3. if ($_SESSION['loggedin'] != true) {
  4. sendError(SESSION_EXPIRED, true);
  5. } else {
  6. }
  7. if (is_empty($VARS['lat']) || is_empty($VARS['long'])) {
  8. sendOK("Missing data.", true);
  9. }
  10. if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['lat'])) {
  11. sendOK("Latitude (lat) is in the wrong format.", true);
  12. }
  13. if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['long'])) {
  14. sendOK("Longitude (long) is in the wrong format.", true);
  15. }
  16. $uuid = $_SESSION['uuid'];
  17. // Kick user out of game
  18. $kick = $database->select('players', ['kick'], ['uuid' => $uuid])[0]['kick'];
  19. if (!is_empty($kick)) {
  20. $_SESSION['loggedin'] = false;
  21. session_unset();
  22. session_destroy();
  23. $database->update('players', ['kick' => ''], ['uuid' => $uuid]);
  24. sendError($kick, true);
  25. }
  26. $database->update('players', ['latitude' => $VARS['lat'], 'longitude' => $VARS['long'], '#lastping' => 'NOW()'], ['uuid' => $uuid]);
  27. sendOK();