Fallback to date() if strftime() doesn't work

This commit is contained in:
ruan 2016-08-14 18:50:52 +02:00
parent 54d0ba166e
commit 320aa974bc
2 changed files with 18 additions and 3 deletions

View File

@ -297,7 +297,14 @@ class Page {
* @return string * @return string
*/ */
function millis_to_date($millis) { function millis_to_date($millis) {
return strftime($this->settings->date_format, $millis / 1000); $ts = $millis / 1000;
$result = strftime($this->settings->date_format, $ts);
if ($result === "") {
// Fallback to date() if strftime() doesn't work
return date("F j, Y, g:i A", $ts);
}
return $result;
} }
function active($row, $field = 'active') { function active($row, $field = 'active') {

View File

@ -53,6 +53,7 @@ abstract class Info {
class BanInfo extends Info { class BanInfo extends Info {
function basic_info($row, $player_name) { function basic_info($row, $player_name) {
$page = $this->page; $page = $this->page;
return array( return array(
$page->lang->info_banned_player => $this->punished_avatar($player_name, $row), $page->lang->info_banned_player => $this->punished_avatar($player_name, $row),
$page->lang->info_banned_by => $this->moderator_avatar($row), $page->lang->info_banned_by => $this->moderator_avatar($row),
@ -158,16 +159,23 @@ if ($st->execute(array($id))) {
} }
$page->print_header(); $page->print_header();
$page->table_begin();
$map = $info->basic_info($row, $player_name); $map = $info->basic_info($row, $player_name);
$permanent_val = $info->page->permanent[$type]; $permanent_val = $info->page->permanent[$type];
$page->table_begin();
foreach ($map as $key => $val) { foreach ($map as $key => $val) {
if ($permanent && $key === "Expires" && $val === $permanent_val) { if ($permanent &&
($key === $page->lang->info_banned_expiry || $key === $page->lang->info_muted_expiry || $key === $page->lang->info_warn_expiry) &&
$val === $permanent_val) {
// skip "Expires" row if punishment is permanent // skip "Expires" row if punishment is permanent
continue; continue;
} }
echo "<tr><td>$key</td><td>$val</td></tr>"; echo "<tr><td>$key</td><td>$val</td></tr>";
} }
$page->table_end(false); $page->table_end(false);
$page->print_footer(); $page->print_footer();
} }