Browse Source

Suppress strftime deprecation warning

Relates to #254.
pull/257/head
Trevor Slocum 5 months ago
parent
commit
2805934548
  1. 4
      imgboard.php
  2. 8
      inc/functions.php
  3. 8
      inc/html.php

4
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'] != '') {

8
inc/functions.php

@ -149,7 +149,7 @@ function nameBlock($name, $tripcode, $email, $timestamp, $capcode) {
$output = '<a href="mailto:' . $email . '">' . $output . '</a>';
}
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) ? ('<br>This ban will expire ' . strftime(TINYIB_DATEFMT, $ban['expire'])) : '<br>This ban is permanent and will not expire.';
$expire = ($ban['expire'] > 0) ? ('<br>This ban will expire ' . formatDate($ban['expire'])) : '<br>This ban is permanent and will not expire.';
$reason = ($ban['reason'] == '') ? '' : ('<br>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'];

8
inc/html.php

@ -1006,7 +1006,7 @@ function manageModerationLog($offset) {
}
$u[$log['account']] = $username;
}
$text .= '<tr><td>' . strftime(TINYIB_DATEFMT, $log['timestamp']) . '</td><td>' . htmlentities($u[$log['account']]) . '</td><td>' . $log['message'] . '</td></tr>';
$text .= '<tr><td>' . formatDate($log['timestamp']) . '</td><td>' . htmlentities($u[$log['account']]) . '</td><td>' . $log['message'] . '</td></tr>';
}
if ($text == '') {
@ -1179,7 +1179,7 @@ function manageAccountsTable() {
if (count($allaccounts) > 0) {
$text .= '<table border="1"><tr><th>' . __('Username') . '</th><th>' . __('Role') . '</th><th>' . __('Last active') . '</th><th>&nbsp;</th></tr>';
foreach ($allaccounts as $account) {
$lastactive = ($account['lastactive'] > 0) ? strftime(TINYIB_DATEFMT, $account['lastactive']) : __('Never');
$lastactive = ($account['lastactive'] > 0) ? formatDate($account['lastactive']) : __('Never');
$text .= '<tr><td>' . htmlentities($account['username']) . '</td><td>';
switch (intval($account['role'])) {
case TINYIB_SUPER_ADMINISTRATOR:
@ -1246,9 +1246,9 @@ function manageBansTable() {
if (count($allbans) > 0) {
$text .= '<table border="1"><tr><th>' . __('IP Address') . '</th><th>' . __('Set At') . '</th><th>' . __('Expires') . '</th><th>' . __('Reason') . '</th><th>&nbsp;</th></tr>';
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'] == '') ? '&nbsp;' : htmlentities($ban['reason']);
$text .= '<tr><td>' . $ban['ip'] . '</td><td>' . strftime(TINYIB_DATEFMT, $ban['timestamp']) . '</td><td>' . $expire . '</td><td>' . $reason . '</td><td><a href="?manage&bans&lift=' . $ban['id'] . '">' . __('lift') . '</a></td></tr>';
$text .= '<tr><td>' . $ban['ip'] . '</td><td>' . formatDate($ban['timestamp']) . '</td><td>' . $expire . '</td><td>' . $reason . '</td><td><a href="?manage&bans&lift=' . $ban['id'] . '">' . __('lift') . '</a></td></tr>';
}
$text .= '</table>';
}

Loading…
Cancel
Save