diff --git a/inc/bans.php b/inc/bans.php index 8ea3b921..126d38b8 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -1,5 +1,6 @@ execute() or error(db_error($query)); if (isset($mod['id']) && $mod['id'] == $mod_id) { modLog('Created a new ' . - ($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . + ($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', Format\until($length)) : 'permanent') . ' ban on ' . ($ban_board ? '/' . $ban_board . '/' : 'all boards') . ' for ' . diff --git a/inc/functions.php b/inc/functions.php index 71231203..c18ca57e 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -797,42 +797,6 @@ function listBoards($just_uri = false) { return $boards; } -function until($timestamp) { - $difference = $timestamp - time(); - switch(TRUE){ - case ($difference < 60): - return $difference . ' ' . ngettext('second', 'seconds', $difference); - case ($difference < 3600): //60*60 = 3600 - return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num); - case ($difference < 86400): //60*60*24 = 86400 - return ($num = round($difference/(3600))) . ' ' . ngettext('hour', 'hours', $num); - case ($difference < 604800): //60*60*24*7 = 604800 - return ($num = round($difference/(86400))) . ' ' . ngettext('day', 'days', $num); - case ($difference < 31536000): //60*60*24*365 = 31536000 - return ($num = round($difference/(604800))) . ' ' . ngettext('week', 'weeks', $num); - default: - return ($num = round($difference/(31536000))) . ' ' . ngettext('year', 'years', $num); - } -} - -function ago($timestamp) { - $difference = time() - $timestamp; - switch(TRUE){ - case ($difference < 60) : - return $difference . ' ' . ngettext('second', 'seconds', $difference); - case ($difference < 3600): //60*60 = 3600 - return ($num = round($difference/(60))) . ' ' . ngettext('minute', 'minutes', $num); - case ($difference < 86400): //60*60*24 = 86400 - return ($num = round($difference/(3600))) . ' ' . ngettext('hour', 'hours', $num); - case ($difference < 604800): //60*60*24*7 = 604800 - return ($num = round($difference/(86400))) . ' ' . ngettext('day', 'days', $num); - case ($difference < 31536000): //60*60*24*365 = 31536000 - return ($num = round($difference/(604800))) . ' ' . ngettext('week', 'weeks', $num); - default: - return ($num = round($difference/(31536000))) . ' ' . ngettext('year', 'years', $num); - } -} - function displayBan($ban) { global $config, $board; diff --git a/inc/functions/format.php b/inc/functions/format.php new file mode 100644 index 00000000..79a71021 --- /dev/null +++ b/inc/functions/format.php @@ -0,0 +1,28 @@ + time() - $config['delete_time'] && (!$thread || $thread['password'] != $password)) { - error(sprintf($config['error']['delete_too_soon'], until($post['time'] + $config['delete_time']))); + error(sprintf($config['error']['delete_too_soon'], Format\until($post['time'] + $config['delete_time']))); } $ip = $_SERVER['REMOTE_ADDR'];