Browse Source

places.php now has owner data, players can be kicked with a message

master
Skylar Ittner 5 years ago
parent
commit
1ab5de66d9
  1. 10
      .gitignore
  2. BIN
      database.mwb
  3. 24
      ping.php
  4. 6
      places.php
  5. 4
      required.php
  6. 13
      settings.template.php

10
.gitignore

@ -1,6 +1,6 @@
error/
stats/
vendor/
settings.php
*.log
error/
stats/
vendor/
settings.php
*.log
database.mwb.bak

BIN
database.mwb

24
ping.php

@ -2,22 +2,36 @@
require 'required.php';
require 'onlyloggedin.php';
if ($_SESSION['loggedin'] != true) {
sendError('Your session has expired. Please log in again.', true);
} else {
}
if (is_empty($VARS['lat']) || is_empty($VARS['long'])) {
sendError("Missing data.", true);
sendOK("Missing data.", true);
}
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['lat'])) {
sendError("Latitude (lat) is in the wrong format.", true);
sendOK("Latitude (lat) is in the wrong format.", true);
}
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{4,}/', $VARS['long'])) {
sendError("Longitude (long) is in the wrong format.", true);
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();
sendOK();

6
places.php

@ -58,11 +58,13 @@ foreach ($places as $place) {
if (!$database->has('locations', ['osmid' => $osmid])) {
$database->insert('locations', ['osmid' => $osmid, 'teamid' => 0]);
}
$gameinfo = $database->select('locations', ['locationid', 'teamid', 'currentlife', 'maxlife'], ['osmid' => $osmid])[0];
$gameinfo = $database->select('locations', ["[>]players" => ["owneruuid" => "uuid"]], ['locations.locationid', 'players.nickname', 'locations.teamid', 'locations.currentlife', 'locations.maxlife'], ['osmid' => $osmid])[0];
//$gameinfo = $database->select('locations', ['locationid', 'teamid', 'currentlife', 'maxlife'], ['osmid' => $osmid])[0];
// Reset owner info for dead places
if ($gameinfo['currentlife'] <= 0) {
$database->update('locations', ['teamid' => 0, 'owneruuid' => null], ['locationid' => $gameinfo['locationid']]);
$database->update('locations', ['teamid' => 0, 'owneruuid' => null, 'maxlife' => 0], ['locationid' => $gameinfo['locationid']]);
$gameinfo = $database->select('locations', ['locationid', 'teamid', 'currentlife', 'maxlife'], ['osmid' => $osmid])[0];
$gameinfo['nickname'] = "";
}
$geo['features'][] = array("type" => "Feature",
"geometry" => [

4
required.php

@ -11,10 +11,10 @@ header("Access-Control-Allow-Origin: *");
if (strtolower($_GET['format']) == 'plain') {
define("JSON", false);
header('Content-Type: text/plain');
header('Content-Type: text/plain; charset=utf-8');
} else {
define("JSON", true);
header('Content-Type: application/json');
header('Content-Type: application/json; charset=utf-8');
}
// Composer

13
settings.template.php

@ -24,4 +24,15 @@ define("GIS_API_KEY", "");
define("GOOGLEPLAY_PUBLICKEY", "");
define("APP_STORE_SANDBOX", true);
define("DARKSKY_APIKEY", "");
define("DARKSKY_APIKEY", "");
// Admin control panel login
define("ADMIN_USER", "");
define("ADMIN_PASS", "");
// Geocoding API key for admin panel lookups
define("MAPQUEST_KEY", "");
// Used for timestamps in the admin panel.
// For supported values, see http://php.net/manual/en/timezones.php
define("TIMEZONE", "UTC");