diff --git a/.gitignore b/.gitignore index 45b1e23..d4aa1a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -error/ -stats/ -vendor/ -settings.php -*.log +error/ +stats/ +vendor/ +settings.php +*.log database.mwb.bak \ No newline at end of file diff --git a/database.mwb b/database.mwb index bbc2593..7ef72d2 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/ping.php b/ping.php index 8b4a688..8766e2d 100644 --- a/ping.php +++ b/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(); \ No newline at end of file +sendOK(); diff --git a/places.php b/places.php index 7a434a1..d8fe957 100644 --- a/places.php +++ b/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" => [ diff --git a/required.php b/required.php index 388711d..4b07ded 100644 --- a/required.php +++ b/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 diff --git a/settings.template.php b/settings.template.php index f897d56..2927ab8 100644 --- a/settings.template.php +++ b/settings.template.php @@ -24,4 +24,15 @@ define("GIS_API_KEY", ""); define("GOOGLEPLAY_PUBLICKEY", ""); define("APP_STORE_SANDBOX", true); -define("DARKSKY_APIKEY", ""); \ No newline at end of file +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"); \ No newline at end of file