From cc59866fcc0d7243e655d59bccc218c9299c716f Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 1 Nov 2016 21:40:25 -0600 Subject: [PATCH] Fix date/timezone bugs with the admin reports --- admin/dashboard_stats.php | 1 - admin/pages/locations.php | 2 +- admin/pages/players/active.php | 57 +++++++++++++++++++++------------ admin/pages/players/default.php | 4 +-- admin/players.php | 2 +- admin/required.php | 9 +++--- 6 files changed, 45 insertions(+), 30 deletions(-) diff --git a/admin/dashboard_stats.php b/admin/dashboard_stats.php index e878016..0444e00 100644 --- a/admin/dashboard_stats.php +++ b/admin/dashboard_stats.php @@ -22,7 +22,6 @@ if (!isAdmin()) {
count("players", ['lastping[>]' => date('Y-m-d H:i:s', strtotime('-1 minute'))]); ?>
diff --git a/admin/pages/locations.php b/admin/pages/locations.php index ead038d..588744c 100644 --- a/admin/pages/locations.php +++ b/admin/pages/locations.php @@ -76,7 +76,7 @@ if (!is_empty($_GET['addr'])) {
-

Locations

+

Locations

diff --git a/admin/pages/players/active.php b/admin/pages/players/active.php index 4dd6981..855aadd 100644 --- a/admin/pages/players/active.php +++ b/admin/pages/players/active.php @@ -2,17 +2,42 @@ if (IN_ADMIN !== true) { die("Error."); } + +$update_success = 0; + +// Handle updating +if ($_SERVER['REQUEST_METHOD'] === 'POST' && !is_empty($_POST['msg']) && !is_empty($_POST['uuid'])) { + if (!$database->has("players", ['uuid' => $_POST['uuid']])) { + $update_success = -1; + } else { + $database->update("players", ["kick" => $_POST['msg']], ["uuid" => $_POST['uuid']]); + $update_success = 1; + } +} ?>
-

Active Sessions

+

Active Sessions

- + +
+ + The user does not exist. +
+ +
+ + User kicked from the server. +
+
@@ -27,15 +52,18 @@ if (IN_ADMIN !== true) { select("players", "*", ['lastping[>]' => date('Y-m-d H:i:s', strtotime('-30 seconds'))]); + $players = $database->select("players", "*", ['lastping[>]' => date('Y-m-d H:i:s', strtotime('-1 minute'))]); foreach ($players as $player) { - $lastping = date_tz('Y-m-d h:i:s A', $player['lastping']); + $lastping = date('Y-m-d h:i:s A', strtotime($player['lastping'])); echo "\n" . " \n" . " \n" . " \n" . " \n" . " \n" @@ -52,15 +80,4 @@ if (IN_ADMIN !== true) { $(document).ready(function () { $('#player-list').dataTable(); }); - - function kickPlayer(uuid, name) { - var kick_reason = $('#' + uuid + "-kickmsg").val(); - $.post("kickplayer.php", { - uuid: uuid, - msg: kick_reason - }, function () { - $('#kickusername').text(name); - $('#kicksuccessmsg').css('display', 'block'); - }); - } \ No newline at end of file diff --git a/admin/pages/players/default.php b/admin/pages/players/default.php index ed94edf..d302d6b 100644 --- a/admin/pages/players/default.php +++ b/admin/pages/players/default.php @@ -35,7 +35,7 @@ if (IN_ADMIN !== true) {
-

Players

+

Players

@@ -66,7 +66,7 @@ if ($_GET['msg'] == 'success') { select("players", "*"); foreach ($players as $player) { - $lastping = date_tz('Y-m-d h:i:s A', $player['lastping']); + $lastping = date('Y-m-d h:i:s A', strtotime($player['lastping'])); echo "\n" . " \n" . "
" . $player['nickname'] . "\n" - . " \n" - . " Kick\n" + . "
" + . " \n" + . " \n" + . " \n" + . "
\n" . "
" . $player['level'] . "" . getTeamNameFromId($player['teamid']) . "
" diff --git a/admin/players.php b/admin/players.php index 50eb5bd..ca9e07a 100644 --- a/admin/players.php +++ b/admin/players.php @@ -18,7 +18,7 @@ $out = [ ]; foreach ($players as $player) { // Format stuff - $lastping = date_tz('Y-m-d h:i:s A', $player['lastping']); + $lastping = date('Y-m-d h:i:s A', strtotime($player['lastping'])); $level = floatval($player['level']); $energy = intval($player['energy']); diff --git a/admin/required.php b/admin/required.php index 9282dfa..e99e313 100644 --- a/admin/required.php +++ b/admin/required.php @@ -21,8 +21,6 @@ try { die("Database error."); } -date_default_timezone_set('UTC'); - /** * Convert a UTC datetime to local time. * @param String $format see date() @@ -30,9 +28,10 @@ date_default_timezone_set('UTC'); * @return output of date() */ function date_tz($format, $date = 'NOW', $intz = 'UTC', $outtz = TIMEZONE) { - $d = new DateTime($date, new DateTimeZone($intz)); - $d->setTimezone(new DateTimeZone($outtz)); - return $d->format($format); + return date($format, strtotime($date)); + //$d = new DateTime($date, new DateTimeZone($intz)); + //$d->setTimezone(new DateTimeZone($outtz)); + //return $d->format($format); } /**