Fix date/timezone bugs with the admin reports
This commit is contained in:
parent
b2b2cae813
commit
cc59866fcc
@ -22,7 +22,6 @@ if (!isAdmin()) {
|
|||||||
<div class="col-xs-9 text-right">
|
<div class="col-xs-9 text-right">
|
||||||
<div class="huge">
|
<div class="huge">
|
||||||
<?php
|
<?php
|
||||||
date_default_timezone_set("UTC");
|
|
||||||
echo $database->count("players", ['lastping[>]' => date('Y-m-d H:i:s', strtotime('-1 minute'))]);
|
echo $database->count("players", ['lastping[>]' => date('Y-m-d H:i:s', strtotime('-1 minute'))]);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,7 +76,7 @@ if (!is_empty($_GET['addr'])) {
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h1 class="page-header">Locations <span class="pull-right"><small><?php echo date_tz('h:i:s a'); ?></small></span></h1>
|
<h1 class="page-header">Locations <span class="pull-right"><small><?php echo date('h:i:s a'); ?></small></span></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -2,17 +2,42 @@
|
|||||||
if (IN_ADMIN !== true) {
|
if (IN_ADMIN !== true) {
|
||||||
die("Error.");
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h1 class="page-header">Active Sessions <span class="pull-right"><small><?php echo date_tz('h:i:s a'); ?></small></span></h1>
|
<h1 class="page-header">Active Sessions <span class="pull-right"><small><?php echo date('h:i:s a'); ?></small></span></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-dismissable alert-success" id="kicksuccessmsg" style="display: none;">
|
<?php
|
||||||
|
if ($update_success == -1) {
|
||||||
|
?>
|
||||||
|
<div class="alert alert-dismissable alert-danger" id="kickerrormsg">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
<i class="fa fa-check"></i> User <span id="kickusername">undefined</span> kicked from the server.
|
<i class="fa fa-times"></i> The user does not exist.
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
} else if ($update_success == 1) {
|
||||||
|
?>
|
||||||
|
<div class="alert alert-dismissable alert-success" id="kicksuccessmsg">
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<i class="fa fa-check"></i> User kicked from the server.
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="player-list">
|
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="player-list">
|
||||||
@ -27,15 +52,18 @@ if (IN_ADMIN !== true) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$players = $database->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) {
|
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"
|
echo "\n"
|
||||||
. " <tr>\n"
|
. " <tr>\n"
|
||||||
. " <td>" . $player['nickname'] . "</td>\n"
|
. " <td>" . $player['nickname'] . "</td>\n"
|
||||||
. " <td>\n"
|
. " <td>\n"
|
||||||
. " <input type='text' class='form-control' id='" . $player['uuid'] . "-kickmsg' placeholder='Enter a kick message.' value='" . $player['kick'] . "' />\n"
|
. " <form method='POST'>"
|
||||||
. " <a class='btn btn-warning' onclick=\"kickPlayer('" . $player['uuid'] . "', '" . $player['nickname'] . "');\">Kick</a>\n"
|
. " <input type='text' class='form-control' name='msg' placeholder='Enter a kick message.' value='" . $player['kick'] . "' />\n"
|
||||||
|
. " <input type='hidden' name='uuid' value='" . $player['uuid'] . "' />\n"
|
||||||
|
. " <input type='submit' class='btn btn-warning' value='Kick' />\n"
|
||||||
|
. " </form>\n"
|
||||||
. " </td>\n"
|
. " </td>\n"
|
||||||
. " <td>" . $player['level'] . "</td>\n"
|
. " <td>" . $player['level'] . "</td>\n"
|
||||||
. " <td>" . getTeamNameFromId($player['teamid']) . "</td>\n"
|
. " <td>" . getTeamNameFromId($player['teamid']) . "</td>\n"
|
||||||
@ -52,15 +80,4 @@ if (IN_ADMIN !== true) {
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#player-list').dataTable();
|
$('#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');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
@ -35,7 +35,7 @@ if (IN_ADMIN !== true) {
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h1 class="page-header">Players <span class="pull-right"><small><?php echo date_tz('h:i:s a'); ?></small></span></h1>
|
<h1 class="page-header">Players <span class="pull-right"><small><?php echo date('h:i:s A'); ?></small></span></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ if ($_GET['msg'] == 'success') {
|
|||||||
<?php
|
<?php
|
||||||
$players = $database->select("players", "*");
|
$players = $database->select("players", "*");
|
||||||
foreach ($players as $player) {
|
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"
|
echo "\n"
|
||||||
. " <tr>\n"
|
. " <tr>\n"
|
||||||
. " <td>"
|
. " <td>"
|
||||||
|
@ -18,7 +18,7 @@ $out = [
|
|||||||
];
|
];
|
||||||
foreach ($players as $player) {
|
foreach ($players as $player) {
|
||||||
// Format stuff
|
// 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']);
|
$level = floatval($player['level']);
|
||||||
$energy = intval($player['energy']);
|
$energy = intval($player['energy']);
|
||||||
|
@ -21,8 +21,6 @@ try {
|
|||||||
die("Database error.");
|
die("Database error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a UTC datetime to local time.
|
* Convert a UTC datetime to local time.
|
||||||
* @param String $format see date()
|
* @param String $format see date()
|
||||||
@ -30,9 +28,10 @@ date_default_timezone_set('UTC');
|
|||||||
* @return output of date()
|
* @return output of date()
|
||||||
*/
|
*/
|
||||||
function date_tz($format, $date = 'NOW', $intz = 'UTC', $outtz = TIMEZONE) {
|
function date_tz($format, $date = 'NOW', $intz = 'UTC', $outtz = TIMEZONE) {
|
||||||
$d = new DateTime($date, new DateTimeZone($intz));
|
return date($format, strtotime($date));
|
||||||
$d->setTimezone(new DateTimeZone($outtz));
|
//$d = new DateTime($date, new DateTimeZone($intz));
|
||||||
return $d->format($format);
|
//$d->setTimezone(new DateTimeZone($outtz));
|
||||||
|
//return $d->format($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user