From 2805934548836a23d1bf572f7be5e5eb5c123c12 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Wed, 16 Mar 2022 11:03:05 -0700 Subject: [PATCH] Suppress strftime deprecation warning Relates to #254. --- imgboard.php | 4 ++-- inc/functions.php | 8 ++++++-- inc/html.php | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/imgboard.php b/imgboard.php index cedf9ef..4462a70 100644 --- a/imgboard.php +++ b/imgboard.php @@ -397,7 +397,7 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) insertBan($ban); if ($ban['expire'] > 0) { - $bannedText = sprintf(__('Your IP address (%1$s) is banned until %2$s.'), remoteAddress(), strftime(TINYIB_DATEFMT, $ban['expire'])); + $bannedText = sprintf(__('Your IP address (%1$s) is banned until %2$s.'), remoteAddress(), formatDate($ban['expire'])); } else { $bannedText = sprintf(__('Your IP address (%s) is permanently banned.'), remoteAddress()); } @@ -854,7 +854,7 @@ EOF; $until = __('permanently'); if ($ban['expire'] > 0) { - $until = sprintf(__('until %s'), strftime(TINYIB_DATEFMT, $ban['expire'])); + $until = sprintf(__('until %s'), formatDate($ban['expire'])); } $action = sprintf(__('Banned %s %s'), htmlentities($ban['ip']), $until); if ($ban['reason'] != '') { diff --git a/inc/functions.php b/inc/functions.php index 0c08f54..621edf8 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -149,7 +149,7 @@ function nameBlock($name, $tripcode, $email, $timestamp, $capcode) { $output = '' . $output . ''; } - return $output . $capcode . ' ' . strftime(TINYIB_DATEFMT, $timestamp); + return $output . $capcode . ' ' . formatDate($timestamp); } function writePage($filename, $contents) { @@ -329,7 +329,7 @@ function checkBanned() { $ban = banByIP(remoteAddress()); if ($ban) { if ($ban['expire'] == 0 || $ban['expire'] > time()) { - $expire = ($ban['expire'] > 0) ? ('
This ban will expire ' . strftime(TINYIB_DATEFMT, $ban['expire'])) : '
This ban is permanent and will not expire.'; + $expire = ($ban['expire'] > 0) ? ('
This ban will expire ' . formatDate($ban['expire'])) : '
This ban is permanent and will not expire.'; $reason = ($ban['reason'] == '') ? '' : ('
Reason: ' . $ban['reason']); fancyDie('Your IP address ' . remoteAddress() . ' has been banned from posting on this image board. ' . $expire . $reason); } else { @@ -968,6 +968,10 @@ function stripMetadata($filename) { exec("exiftool -All= -overwrite_original_in_place " . escapeshellarg($filename), $discard, $exit_status); } +function formatDate($timestamp) { + return @strftime(TINYIB_DATEFMT, $timestamp); +} + function remoteAddress() { if (TINYIB_CLOUDFLARE && isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { return $_SERVER['HTTP_CF_CONNECTING_IP']; diff --git a/inc/html.php b/inc/html.php index ef34837..59d5ba2 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1006,7 +1006,7 @@ function manageModerationLog($offset) { } $u[$log['account']] = $username; } - $text .= '' . strftime(TINYIB_DATEFMT, $log['timestamp']) . '' . htmlentities($u[$log['account']]) . '' . $log['message'] . ''; + $text .= '' . formatDate($log['timestamp']) . '' . htmlentities($u[$log['account']]) . '' . $log['message'] . ''; } if ($text == '') { @@ -1179,7 +1179,7 @@ function manageAccountsTable() { if (count($allaccounts) > 0) { $text .= ''; foreach ($allaccounts as $account) { - $lastactive = ($account['lastactive'] > 0) ? strftime(TINYIB_DATEFMT, $account['lastactive']) : __('Never'); + $lastactive = ($account['lastactive'] > 0) ? formatDate($account['lastactive']) : __('Never'); $text .= '
' . __('Username') . '' . __('Role') . '' . __('Last active') . ' 
' . htmlentities($account['username']) . ''; switch (intval($account['role'])) { case TINYIB_SUPER_ADMINISTRATOR: @@ -1246,9 +1246,9 @@ function manageBansTable() { if (count($allbans) > 0) { $text .= ''; foreach ($allbans as $ban) { - $expire = ($ban['expire'] > 0) ? strftime(TINYIB_DATEFMT, $ban['expire']) : __('Does not expire'); + $expire = ($ban['expire'] > 0) ? formatDate($ban['expire']) : __('Does not expire'); $reason = ($ban['reason'] == '') ? ' ' : htmlentities($ban['reason']); - $text .= ''; + $text .= ''; } $text .= '
' . __('IP Address') . '' . __('Set At') . '' . __('Expires') . '' . __('Reason') . ' 
' . $ban['ip'] . '' . strftime(TINYIB_DATEFMT, $ban['timestamp']) . '' . $expire . '' . $reason . '' . __('lift') . '
' . $ban['ip'] . '' . formatDate($ban['timestamp']) . '' . $expire . '' . $reason . '' . __('lift') . '
'; }