Support custom date format

Resolves #121.
This commit is contained in:
Trevor Slocum 2020-09-14 20:40:13 -07:00
parent 53091b261b
commit ef4b8c0adf
4 changed files with 8 additions and 4 deletions

View File

@ -52,6 +52,9 @@ if (!defined('TINYIB_CATALOG')) {
if (!defined('TINYIB_JSON')) { if (!defined('TINYIB_JSON')) {
define('TINYIB_JSON', true); define('TINYIB_JSON', true);
} }
if (!defined('TINYIB_DATEFMT')) {
define('TINYIB_DATEFMT', 'y/m/d(D)H:i:s');
}
if (!defined('TINYIB_DBMIGRATE')) { if (!defined('TINYIB_DBMIGRATE')) {
define('TINYIB_DBMIGRATE', false); define('TINYIB_DBMIGRATE', false);
} }

View File

@ -223,7 +223,7 @@ function nameBlock($name, $tripcode, $email, $timestamp, $rawposttext) {
$output = '<a href="mailto:' . $email . '">' . $output . '</a>'; $output = '<a href="mailto:' . $email . '">' . $output . '</a>';
} }
return $output . $rawposttext . ' ' . date('y/m/d(D)H:i:s', $timestamp); return $output . $rawposttext . ' ' . date(TINYIB_DATEFMT, $timestamp);
} }
function writePage($filename, $contents) { function writePage($filename, $contents) {
@ -331,7 +331,7 @@ function checkBanned() {
$ban = banByIP($_SERVER['REMOTE_ADDR']); $ban = banByIP($_SERVER['REMOTE_ADDR']);
if ($ban) { if ($ban) {
if ($ban['expire'] == 0 || $ban['expire'] > time()) { if ($ban['expire'] == 0 || $ban['expire'] > time()) {
$expire = ($ban['expire'] > 0) ? ('<br>This ban will expire ' . date('y/m/d(D)H:i:s', $ban['expire'])) : '<br>This ban is permanent and will not expire.'; $expire = ($ban['expire'] > 0) ? ('<br>This ban will expire ' . date(TINYIB_DATEFMT, $ban['expire'])) : '<br>This ban is permanent and will not expire.';
$reason = ($ban['reason'] == '') ? '' : ('<br>Reason: ' . $ban['reason']); $reason = ($ban['reason'] == '') ? '' : ('<br>Reason: ' . $ban['reason']);
fancyDie('Your IP address ' . $ban['ip'] . ' has been banned from posting on this image board. ' . $expire . $reason); fancyDie('Your IP address ' . $ban['ip'] . ' has been banned from posting on this image board. ' . $expire . $reason);
} else { } else {

View File

@ -791,9 +791,9 @@ function manageBansTable() {
if (count($allbans) > 0) { 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>'; $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) { foreach ($allbans as $ban) {
$expire = ($ban['expire'] > 0) ? date('y/m/d(D)H:i:s', $ban['expire']) : __('Does not expire'); $expire = ($ban['expire'] > 0) ? date(TINYIB_DATEFMT, $ban['expire']) : __('Does not expire');
$reason = ($ban['reason'] == '') ? '&nbsp;' : htmlentities($ban['reason']); $reason = ($ban['reason'] == '') ? '&nbsp;' : htmlentities($ban['reason']);
$text .= '<tr><td>' . $ban['ip'] . '</td><td>' . date('y/m/d(D)H:i:s', $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>' . date(TINYIB_DATEFMT, $ban['timestamp']) . '</td><td>' . $expire . '</td><td>' . $reason . '</td><td><a href="?manage&bans&lift=' . $ban['id'] . '">' . __('lift') . '</a></td></tr>';
} }
$text .= '</table>'; $text .= '</table>';
} }

View File

@ -35,6 +35,7 @@ define('TINYIB_WORDBREAK', 80); // Words longer than this many characters
define('TINYIB_TIMEZONE', 'UTC'); // See https://secure.php.net/manual/en/timezones.php - e.g. America/Los_Angeles define('TINYIB_TIMEZONE', 'UTC'); // See https://secure.php.net/manual/en/timezones.php - e.g. America/Los_Angeles
define('TINYIB_CATALOG', true); // Generate catalog page define('TINYIB_CATALOG', true); // Generate catalog page
define('TINYIB_JSON', true); // Generate JSON files define('TINYIB_JSON', true); // Generate JSON files
define('TINYIB_DATEFMT', 'y/m/d(D)H:i:s'); // Date format (see php.net/date)
$tinyib_hidefieldsop = array(); // Fields to hide when creating a new thread - e.g. array('name', 'email', 'subject', 'message', 'file', 'embed', 'password') $tinyib_hidefieldsop = array(); // Fields to hide when creating a new thread - e.g. array('name', 'email', 'subject', 'message', 'file', 'embed', 'password')
$tinyib_hidefields = array(); // Fields to hide when replying $tinyib_hidefields = array(); // Fields to hide when replying
$tinyib_capcodes = array(array('Admin', 'red'), array('Mod', 'purple')); // Administrator and moderator capcode label and color $tinyib_capcodes = array(array('Admin', 'red'), array('Mod', 'purple')); // Administrator and moderator capcode label and color