PHP game server for TerranQuest (version 1) https://terranquest.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

37 lines
987 B

<?php
require 'required.php';
if ($_SESSION['loggedin'] != true) {
sendError(SESSION_EXPIRED, true);
} else {
}
if (is_empty($VARS['lat']) || is_empty($VARS['long'])) {
sendOK("Missing data.", true);
}
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['lat'])) {
sendOK("Latitude (lat) is in the wrong format.", true);
}
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['long'])) {
sendOK("Longitude (long) is in the wrong format.", true);
}
$uuid = $_SESSION['uuid'];
// Kick user out of game
$kick = $database->select('players', ['kick'], ['uuid' => $uuid])[0]['kick'];
if (!is_empty($kick)) {
$_SESSION['loggedin'] = false;
session_unset();
session_destroy();
$database->update('players', ['kick' => ''], ['uuid' => $uuid]);
sendError($kick, true);
}
$database->update('players', ['latitude' => $VARS['lat'], 'longitude' => $VARS['long'], '#lastping' => 'NOW()'], ['uuid' => $uuid]);
sendOK();