diff --git a/CHANGELOG.md b/CHANGELOG.md
index a980d7118..ecc563d74 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
- Newtopic: Added configuring robots indexing [\#1599](https://github.com/torrentpier/torrentpier/pull/1599) ([belomaxorka](https://github.com/belomaxorka))
- Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka))
- Improved `filelist.php` [\#1586](https://github.com/torrentpier/torrentpier/pull/1586) ([belomaxorka](https://github.com/belomaxorka))
+- Refactoring: Created constants for datetime values [\#1648](https://github.com/torrentpier/torrentpier/pull/1648) ([belomaxorka](https://github.com/belomaxorka))
- Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka))
- BBCode: Fixed relative links working [\#1613](https://github.com/torrentpier/torrentpier/pull/1613) ([belomaxorka](https://github.com/belomaxorka))
- Fixed template caching issue [\#1622](https://github.com/torrentpier/torrentpier/pull/1622) ([belomaxorka](https://github.com/belomaxorka))
diff --git a/admin/admin_forum_prune.php b/admin/admin_forum_prune.php
index ed722550c..2828f7ae7 100644
--- a/admin/admin_forum_prune.php
+++ b/admin/admin_forum_prune.php
@@ -26,7 +26,7 @@ if (isset($_REQUEST['submit'])) {
bb_die($lang['NOT_DAYS']);
}
- $prunetime = TIMENOW - 86400 * $prunedays;
+ $prunetime = TIME_DAY * $prunedays;
$forum_csv = in_array($all_forums, $f_selected) ? $all_forums : implode(',', $f_selected);
$where_sql = ($forum_csv != $all_forums) ? "WHERE forum_id IN($forum_csv)" : '';
diff --git a/admin/admin_forums.php b/admin/admin_forums.php
index 864350e48..7aaa1362f 100644
--- a/admin/admin_forums.php
+++ b/admin/admin_forums.php
@@ -743,7 +743,7 @@ if (!$mode || $show_main_page) {
'FORUM_DESC' => htmlCHR($forum_rows[$j]['forum_desc']),
'NUM_TOPICS' => $forum_rows[$j]['forum_topics'],
'NUM_POSTS' => $forum_rows[$j]['forum_posts'],
- 'PRUNE_DAYS' => !empty($forum_rows[$j]['prune_days']) ? delta_time((TIMENOW - 86400 * $forum_rows[$j]['prune_days']), TIMENOW, 'days') : $lang['DISABLED'],
+ 'PRUNE_DAYS' => !empty($forum_rows[$j]['prune_days']) ? delta_time((TIME_DAY * $forum_rows[$j]['prune_days']), TIMENOW, 'days') : $lang['DISABLED'],
'ORDER' => $forum_rows[$j]['forum_order'],
'FORUM_ID' => $forum_rows[$j]['forum_id'],
diff --git a/admin/admin_log.php b/admin/admin_log.php
index 6993f02c0..5de3ff168 100644
--- a/admin/admin_log.php
+++ b/admin/admin_log.php
@@ -158,8 +158,8 @@ if ($var =& $_REQUEST[$datetime_key] && $var != $def_datetime) {
}
}
-$time_end_val = 86400 + mktime(0, 0, 0, date('m', $datetime_val), date('d', $datetime_val), date('Y', $datetime_val));
-$time_start_val = $time_end_val - 86400 * $daysback_val;
+$time_end_val = DAY_IN_SECS + mktime(0, 0, 0, date('m', $datetime_val), date('d', $datetime_val), date('Y', $datetime_val));
+$time_start_val = $time_end_val - DAY_IN_SECS * $daysback_val;
// First log time
$row = DB()->fetch_row('SELECT MIN(log_time) AS first_log_time FROM ' . BB_LOG);
diff --git a/admin/admin_user_search.php b/admin/admin_user_search.php
index 810276e09..c8e659790 100644
--- a/admin/admin_user_search.php
+++ b/admin/admin_user_search.php
@@ -84,7 +84,7 @@ if (!isset($_REQUEST['dosearch'])) {
$lastvisited_list = '';
foreach ($lastvisited as $days) {
- $lastvisited_list .= '';
+ $lastvisited_list .= '';
}
$template->assign_vars([
@@ -634,7 +634,7 @@ if (!isset($_REQUEST['dosearch'])) {
switch ($lastvisited_type) {
case 'in':
- $text = sprintf($lang['SEARCH_FOR_LASTVISITED_INTHELAST'], delta_time((TIMENOW - 86400 * $lastvisited_days), TIMENOW, 'days'));
+ $text = sprintf($lang['SEARCH_FOR_LASTVISITED_INTHELAST'], delta_time((TIME_DAY * $lastvisited_days), TIMENOW, 'days'));
$total_sql .= 'SELECT COUNT(user_id) AS total
FROM ' . BB_USERS . "
@@ -645,7 +645,7 @@ if (!isset($_REQUEST['dosearch'])) {
AND u.user_id <> " . GUEST_UID;
break;
case 'after':
- $text = sprintf($lang['SEARCH_FOR_LASTVISITED_AFTERTHELAST'], delta_time((TIMENOW - 86400 * $lastvisited_days), TIMENOW, 'days'));
+ $text = sprintf($lang['SEARCH_FOR_LASTVISITED_AFTERTHELAST'], delta_time((TIME_DAY * $lastvisited_days), TIMENOW, 'days'));
$total_sql .= 'SELECT COUNT(user_id) AS total
FROM ' . BB_USERS . "
diff --git a/admin/index.php b/admin/index.php
index 740afb8b6..47f5dd0a8 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -109,7 +109,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$total_topics = $stats['topiccount'];
$total_users = $stats['usercount'];
$start_date = bb_date($bb_cfg['board_startdate']);
- $boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400;
+ $boarddays = (TIMENOW - $bb_cfg['board_startdate']) / DAY_IN_SECS;
$posts_per_day = sprintf('%.2f', $total_posts / $boarddays);
$topics_per_day = sprintf('%.2f', $total_topics / $boarddays);
diff --git a/library/ajax/callseed.php b/library/ajax/callseed.php
index 21cc1eff8..cd99a6986 100644
--- a/library/ajax/callseed.php
+++ b/library/ajax/callseed.php
@@ -29,8 +29,8 @@ $forum_id = $t_data['forum_id'];
if ($t_data['seeders'] > 2) {
$this->ajax_die(sprintf($lang['CALLSEED_HAVE_SEED'], $t_data['seeders']));
-} elseif ($t_data['call_seed_time'] > (TIMENOW - 86400)) {
- $time_left = delta_time($t_data['call_seed_time'] + 86400, TIMENOW, 'days');
+} elseif ($t_data['call_seed_time'] > TIME_DAY) {
+ $time_left = delta_time($t_data['call_seed_time'] + DAY_IN_SECS, TIMENOW, 'days');
$this->ajax_die(sprintf($lang['CALLSEED_MSG_SPAM'], $time_left));
}
diff --git a/library/attach_mod/attachment_mod.php b/library/attach_mod/attachment_mod.php
index 9ea80f908..b86c6e43f 100644
--- a/library/attach_mod/attachment_mod.php
+++ b/library/attach_mod/attachment_mod.php
@@ -70,7 +70,7 @@ $attach_config = [];
if (!$attach_config = CACHE('bb_cache')->get('attach_config')) {
$attach_config = get_config();
- CACHE('bb_cache')->set('attach_config', $attach_config, 86400);
+ CACHE('bb_cache')->set('attach_config', $attach_config, DAY_IN_SECS);
}
include ATTACH_DIR . '/displaying.php';
diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php
index 2257a0954..138b6aa84 100644
--- a/library/attach_mod/displaying_torrent.php
+++ b/library/attach_mod/displaying_torrent.php
@@ -549,5 +549,5 @@ $template->assign_vars([
'SEED_EXIST' => ($seeders || defined('SEEDER_EXIST')),
'LEECH_EXIST' => ($leechers || defined('LEECHER_EXIST')),
'TOR_HELP_LINKS' => $bb_cfg['tor_help_links'],
- 'CALL_SEED' => (!IS_GUEST && $bb_cfg['callseed'] && $tor_reged && !isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) && $seed_count < 3 && $tor_info['call_seed_time'] < (TIMENOW - 86400)),
+ 'CALL_SEED' => (!IS_GUEST && $bb_cfg['callseed'] && $tor_reged && !isset($bb_cfg['tor_no_tor_act'][$tor_info['tor_status']]) && ($seed_count < 3) && ($tor_info['call_seed_time'] < TIME_DAY)),
]);
diff --git a/library/attach_mod/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php
index 5f5f0a05b..460902c7e 100644
--- a/library/attach_mod/includes/functions_admin.php
+++ b/library/attach_mod/includes/functions_admin.php
@@ -202,7 +202,7 @@ function search_attachments($order_by, &$total_rows)
// Search Attachment Time
$search_days_greater = get_var('search_days_greater', '');
if ($search_days_greater) {
- $where_sql[] = ' (a.filetime < ' . (TIMENOW - ((int)$search_days_greater * 86400)) . ') ';
+ $where_sql[] = ' (a.filetime < ' . (TIME_DAY * (int)$search_days_greater) . ') ';
}
// Search Forum
diff --git a/library/defines.php b/library/defines.php
index 48c2d18ca..d5eca89f5 100644
--- a/library/defines.php
+++ b/library/defines.php
@@ -132,6 +132,11 @@ define('ONLY_NEW_TOPICS', 2);
define('GUEST_UID', -1);
define('BOT_UID', -746);
+// Datetime
+define('DAY_IN_SECS', 86400);
+define('TIME_DAY', TIMENOW - DAY_IN_SECS);
+define('TIME_WEEK', TIME_DAY * 7);
+
// Ratio limits
define('TR_RATING_LIMITS', true); // ON/OFF
define('MIN_DL_FOR_RATIO', 10737418240); // 10 GB in bytes, 0 - disable
diff --git a/library/includes/cron/jobs/board_maintenance.php b/library/includes/cron/jobs/board_maintenance.php
index e83ceac3d..b54a8faa3 100644
--- a/library/includes/cron/jobs/board_maintenance.php
+++ b/library/includes/cron/jobs/board_maintenance.php
@@ -30,7 +30,7 @@ if ($poll_max_days = (int)$bb_cfg['poll_max_days']) {
DB()->query("
DELETE FROM " . BB_POLL_USERS . "
WHERE topic_id BETWEEN $start_id AND $end_id
- AND vote_dt < " . (TIMENOW - 86400 * $poll_max_days) . "
+ AND vote_dt < " . (TIME_DAY * $poll_max_days) . "
");
if ($end_id > $finish_id) {
@@ -42,7 +42,7 @@ if ($poll_max_days = (int)$bb_cfg['poll_max_days']) {
}
// Cleaning user_newpasswd
-DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400));
+DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . TIME_WEEK);
// Cleaning post cache
if ($posts_days = (int)$bb_cfg['posts_cache_days_keep']) {
diff --git a/library/includes/cron/jobs/clean_log.php b/library/includes/cron/jobs/clean_log.php
index ff5bb3e13..4842fef2d 100644
--- a/library/includes/cron/jobs/clean_log.php
+++ b/library/includes/cron/jobs/clean_log.php
@@ -14,5 +14,5 @@ if (!defined('BB_ROOT')) {
$log_days_keep = (int)$bb_cfg['log_days_keep'];
if ($log_days_keep !== 0) {
- DB()->query("DELETE FROM " . BB_LOG . " WHERE log_time < " . (TIMENOW - 86400 * $log_days_keep));
+ DB()->query("DELETE FROM " . BB_LOG . " WHERE log_time < " . (TIME_DAY * $log_days_keep));
}
diff --git a/library/includes/cron/jobs/clean_pm.php b/library/includes/cron/jobs/clean_pm.php
index 788c920ff..1e6206609 100644
--- a/library/includes/cron/jobs/clean_pm.php
+++ b/library/includes/cron/jobs/clean_pm.php
@@ -28,7 +28,7 @@ if ($pm_days_keep !== 0) {
FROM " . BB_PRIVMSGS . " pm
LEFT JOIN " . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)
WHERE pm.privmsgs_id BETWEEN $start_id AND $end_id
- AND pm.privmsgs_date < " . (TIMENOW - 86400 * $pm_days_keep) . "
+ AND pm.privmsgs_date < " . (TIME_DAY * $pm_days_keep) . "
");
if ($end_id > $finish_id) {
diff --git a/library/includes/cron/jobs/prune_forums.php b/library/includes/cron/jobs/prune_forums.php
index 6d7a170f7..1e3e31d2f 100644
--- a/library/includes/cron/jobs/prune_forums.php
+++ b/library/includes/cron/jobs/prune_forums.php
@@ -15,6 +15,6 @@ if ($bb_cfg['prune_enable']) {
$sql = "SELECT forum_id, prune_days FROM " . BB_FORUMS . " WHERE prune_days != 0";
foreach (DB()->fetch_rowset($sql) as $row) {
- \TorrentPier\Legacy\Admin\Common::topic_delete('prune', $row['forum_id'], (TIMENOW - 86400 * $row['prune_days']));
+ \TorrentPier\Legacy\Admin\Common::topic_delete('prune', $row['forum_id'], (TIME_DAY * $row['prune_days']));
}
}
diff --git a/library/includes/cron/jobs/prune_inactive_users.php b/library/includes/cron/jobs/prune_inactive_users.php
index c33fdbf4b..86d41a38c 100644
--- a/library/includes/cron/jobs/prune_inactive_users.php
+++ b/library/includes/cron/jobs/prune_inactive_users.php
@@ -22,7 +22,7 @@ while (true) {
WHERE user_level = 0
AND user_lastvisit = 0
AND user_session_time = 0
- AND user_regdate <= " . (TIMENOW - 86400 * $not_activated_days) . "
+ AND user_regdate <= " . (TIME_DAY * $not_activated_days) . "
AND user_id NOT IN(" . EXCLUDED_USERS . ")
LIMIT $users_per_cycle");
@@ -35,7 +35,7 @@ while (true) {
$sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
WHERE user_level = 0
AND user_posts = 0
- AND user_lastvisit <= " . (TIMENOW - 86400 * $not_active_days) . "
+ AND user_lastvisit <= " . (TIME_DAY * $not_active_days) . "
AND user_id NOT IN(" . EXCLUDED_USERS . ")
LIMIT $users_per_cycle");
diff --git a/library/includes/cron/jobs/prune_topic_moved.php b/library/includes/cron/jobs/prune_topic_moved.php
index ebbdbdc4c..304507ece 100644
--- a/library/includes/cron/jobs/prune_topic_moved.php
+++ b/library/includes/cron/jobs/prune_topic_moved.php
@@ -12,7 +12,7 @@ if (!defined('BB_ROOT')) {
}
if ($bb_cfg['topic_moved_days_keep']) {
- $prune_time = TIMENOW - 86400 * $bb_cfg['topic_moved_days_keep'];
+ $prune_time = TIME_DAY * $bb_cfg['topic_moved_days_keep'];
DB()->query("
DELETE FROM " . BB_TOPICS . "
diff --git a/library/includes/cron/jobs/tr_maintenance.php b/library/includes/cron/jobs/tr_maintenance.php
index de2acd2c5..0e1103493 100644
--- a/library/includes/cron/jobs/tr_maintenance.php
+++ b/library/includes/cron/jobs/tr_maintenance.php
@@ -15,8 +15,8 @@ if (empty($bb_cfg['seeder_last_seen_days_keep']) || empty($bb_cfg['seeder_never_
return;
}
-$last_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_last_seen_days_keep'];
-$never_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_never_seen_days_keep'];
+$last_seen_time = TIME_DAY * $bb_cfg['seeder_last_seen_days_keep'];
+$never_seen_time = TIME_DAY * $bb_cfg['seeder_never_seen_days_keep'];
$limit_sql = 3000;
$topics_sql = $attach_sql = [];
diff --git a/library/includes/cron/jobs/tr_make_snapshot.php b/library/includes/cron/jobs/tr_make_snapshot.php
index edf08cbca..2ab5242f3 100644
--- a/library/includes/cron/jobs/tr_make_snapshot.php
+++ b/library/includes/cron/jobs/tr_make_snapshot.php
@@ -172,7 +172,7 @@ if ($bb_cfg['torhelp_enabled']) {
AND trsn.leechers >= $tor_min_leechers
AND tor.forum_id != " . (int)$bb_cfg['trash_forum_id'] . "
AND tor.complete_count >= $tor_min_completed
- AND tor.seeder_last_seen <= (UNIX_TIMESTAMP() - $tor_seed_last_seen_days*86400)
+ AND tor.seeder_last_seen <= (UNIX_TIMESTAMP() - " . $tor_seed_last_seen_days * DAY_IN_SECS . ")
AND dl.user_id IN($online_users_csv)
AND dl.user_status IN(" . get_id_csv($dl_status_ary) . ")
AND dl.last_modified_dlstatus > DATE_SUB(NOW(), INTERVAL $tor_downloaded_days_ago DAY)
diff --git a/library/includes/cron/jobs/tr_seed_bonus.php b/library/includes/cron/jobs/tr_seed_bonus.php
index d3d7b0311..9958a7926 100644
--- a/library/includes/cron/jobs/tr_seed_bonus.php
+++ b/library/includes/cron/jobs/tr_seed_bonus.php
@@ -49,7 +49,7 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se
$user_points = ($cron_job_last_run < 3600) ? round((float)$points * ($cron_job_last_run / 3600), 2) : 0;
$release = (int)$seed_release[$i];
- $user_regdate = (TIMENOW - $bb_cfg['seed_bonus_user_regdate'] * 86400);
+ $user_regdate = (TIME_DAY * $bb_cfg['seed_bonus_user_regdate']);
DB()->query("
UPDATE " . BB_USERS . " u, " . BB_BT_USERS . " bu, tmp_bonus b
diff --git a/library/includes/datastore/build_stats.php b/library/includes/datastore/build_stats.php
index bd8ef8a4e..bcbc3f2f1 100644
--- a/library/includes/datastore/build_stats.php
+++ b/library/includes/datastore/build_stats.php
@@ -66,7 +66,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
");
$date_today = bb_date(TIMENOW, 'md', false);
- $date_forward = bb_date(TIMENOW + ($bb_cfg['birthday_check_day'] * 86400), 'md', false);
+ $date_forward = bb_date(TIMENOW + ($bb_cfg['birthday_check_day'] * DAY_IN_SECS), 'md', false);
$birthday_today_list = $birthday_week_list = [];
diff --git a/poll.php b/poll.php
index 2397304d6..a15ad6ae4 100644
--- a/poll.php
+++ b/poll.php
@@ -47,7 +47,7 @@ if ($mode != 'poll_vote') {
// Checking the ability to make changes
if ($mode == 'poll_delete') {
- if ($t_data['topic_time'] < TIMENOW - $bb_cfg['poll_max_days'] * 86400) {
+ if ($t_data['topic_time'] < (TIME_DAY * $bb_cfg['poll_max_days'])) {
bb_die(sprintf($lang['NEW_POLL_DAYS'], $bb_cfg['poll_max_days']));
}
if (!IS_ADMIN && ($t_data['topic_vote'] != POLL_FINISHED)) {
diff --git a/privmsg.php b/privmsg.php
index 2d417e876..7a745a28c 100644
--- a/privmsg.php
+++ b/privmsg.php
@@ -1239,7 +1239,7 @@ if ($mode == 'read') {
//
if ($submit_msgdays && (!empty($_POST['msgdays']) || !empty($_GET['msgdays']))) {
$msg_days = (!empty($_POST['msgdays'])) ? (int)$_POST['msgdays'] : (int)$_GET['msgdays'];
- $min_msg_time = TIMENOW - ($msg_days * 86400);
+ $min_msg_time = (TIME_DAY * $msg_days);
$limit_msg_time_total = " AND privmsgs_date > $min_msg_time";
$limit_msg_time = " AND pm.privmsgs_date > $min_msg_time ";
diff --git a/search.php b/search.php
index 029c3a622..05da3e48c 100644
--- a/search.php
+++ b/search.php
@@ -184,23 +184,23 @@ $time_opt = array(
),
1 => array(
'lang' => $lang['BT_1_DAY_FOR'],
- 'sql' => TIMENOW - 86400,
+ 'sql' => TIME_DAY,
),
3 => array(
'lang' => $lang['BT_3_DAY_FOR'],
- 'sql' => TIMENOW - 86400 * 3,
+ 'sql' => TIME_DAY * 3,
),
7 => array(
'lang' => $lang['BT_7_DAYS_FOR'],
- 'sql' => TIMENOW - 86400 * 7,
+ 'sql' => TIME_WEEK,
),
14 => array(
'lang' => $lang['BT_2_WEEKS_FOR'],
- 'sql' => TIMENOW - 86400 * 14,
+ 'sql' => TIME_WEEK * 2,
),
30 => array(
'lang' => $lang['BT_1_MONTH_FOR'],
- 'sql' => TIMENOW - 86400 * 30,
+ 'sql' => TIME_DAY * 30,
),
);
$time_select = [];
diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php
index 33efa5cb2..ed3563a6a 100644
--- a/src/Legacy/Common/User.php
+++ b/src/Legacy/Common/User.php
@@ -290,7 +290,7 @@ class User
$last_visit = TIMENOW;
define('FIRST_LOGON', true);
} elseif ($session_time < (TIMENOW - $bb_cfg['last_visit_update_intrv'])) {
- $last_visit = max($session_time, (TIMENOW - 86400 * $bb_cfg['max_last_visit_days']));
+ $last_visit = max($session_time, (TIME_DAY * $bb_cfg['max_last_visit_days']));
}
if ($last_visit != $this->data['user_lastvisit']) {
@@ -510,7 +510,7 @@ class User
}
if ($autologin_id && $userdata['user_session_time'] && $bb_cfg['max_autologin_time']) {
- if (TIMENOW - $userdata['user_session_time'] > $bb_cfg['max_autologin_time'] * 86400) {
+ if ((TIMENOW - $userdata['user_session_time']) > ($bb_cfg['max_autologin_time'] * DAY_IN_SECS)) {
return $this->create_autologin_id($userdata, $create_new);
}
}
diff --git a/src/Legacy/Poll.php b/src/Legacy/Poll.php
index 1025f51ba..a78e390d1 100644
--- a/src/Legacy/Poll.php
+++ b/src/Legacy/Poll.php
@@ -163,6 +163,6 @@ class Poll
public static function pollIsActive(array $t_data): bool
{
global $bb_cfg;
- return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - $bb_cfg['poll_max_days'] * 86400);
+ return ($t_data['topic_vote'] == 1 && ($t_data['topic_time'] > TIME_DAY * $bb_cfg['poll_max_days']));
}
}
diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php
index 8a832a2be..b0f88e62d 100644
--- a/src/Legacy/Torrent.php
+++ b/src/Legacy/Torrent.php
@@ -490,7 +490,7 @@ class Torrent
}
if ($bb_cfg['tracker']['tor_topic_up']) {
- DB()->query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = GREATEST(topic_last_post_time, " . (TIMENOW - 3 * 86400) . ") WHERE topic_id = $topic_id");
+ DB()->query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = GREATEST(topic_last_post_time, " . (TIME_DAY * 3) . ") WHERE topic_id = $topic_id");
}
if ($reg_mode == 'request' || $reg_mode == 'newtopic') {
diff --git a/tracker.php b/tracker.php
index 7a7e22078..4b0fbe9bb 100644
--- a/tracker.php
+++ b/tracker.php
@@ -163,23 +163,23 @@ $time_opt = array(
),
1 => array(
'lang' => $lang['BT_1_DAY_FOR'],
- 'sql' => TIMENOW - 86400,
+ 'sql' => TIME_DAY,
),
3 => array(
'lang' => $lang['BT_3_DAY_FOR'],
- 'sql' => TIMENOW - 86400 * 3,
+ 'sql' => TIME_DAY * 3,
),
7 => array(
'lang' => $lang['BT_7_DAYS_FOR'],
- 'sql' => TIMENOW - 86400 * 7,
+ 'sql' => TIME_WEEK,
),
14 => array(
'lang' => $lang['BT_2_WEEKS_FOR'],
- 'sql' => TIMENOW - 86400 * 14,
+ 'sql' => TIME_WEEK * 2,
),
30 => array(
'lang' => $lang['BT_1_MONTH_FOR'],
- 'sql' => TIMENOW - 86400 * 30,
+ 'sql' => TIME_DAY * 30,
),
);
$time_select = [];
@@ -195,23 +195,23 @@ $s_not_seen_opt = array(
),
1 => array(
'lang' => $lang['BT_1_DAY'],
- 'sql' => TIMENOW - 86400,
+ 'sql' => TIME_DAY,
),
3 => array(
'lang' => $lang['BT_3_DAYS'],
- 'sql' => TIMENOW - 86400 * 3,
+ 'sql' => TIME_DAY * 3,
),
7 => array(
'lang' => $lang['BT_7_DAYS'],
- 'sql' => TIMENOW - 86400 * 7,
+ 'sql' => TIME_WEEK,
),
14 => array(
'lang' => $lang['BT_2_WEEKS'],
- 'sql' => TIMENOW - 86400 * 14,
+ 'sql' => TIME_WEEK * 2,
),
30 => array(
'lang' => $lang['BT_1_MONTH'],
- 'sql' => TIMENOW - 86400 * 30,
+ 'sql' => TIME_DAY * 30,
),
$never => array(
'lang' => $lang['BT_NEVER'],
diff --git a/viewforum.php b/viewforum.php
index 12dd54e10..929c65906 100644
--- a/viewforum.php
+++ b/viewforum.php
@@ -247,7 +247,7 @@ if (!empty($_REQUEST['topicdays'])) {
SELECT COUNT(*) AS forum_topics
FROM " . BB_TOPICS . "
WHERE forum_id = $forum_id
- AND topic_last_post_time > " . (TIMENOW - 86400 * $req_topic_days) . "
+ AND topic_last_post_time > " . (TIME_DAY * $req_topic_days) . "
";
if ($row = DB()->fetch_row($sql)) {
@@ -274,7 +274,7 @@ $order_method = get_forum_display_sort_option($order_value, 'field', 'order');
$order_sql = "ORDER BY t.topic_type DESC, $sort_method $order_method";
-$limit_topics_time_sql = ($topic_days) ? "AND t.topic_last_post_time > " . (TIMENOW - 86400 * $topic_days) : '';
+$limit_topics_time_sql = ($topic_days) ? "AND t.topic_last_post_time > " . (TIME_DAY * $topic_days) : '';
$select_tor_sql = $join_tor_sql = '';
$join_dl = ($bb_cfg['show_dl_status_in_forum'] && !IS_GUEST);
@@ -517,7 +517,7 @@ $template->assign_vars([
'SESSION_ADMIN' => $userdata['session_admin'],
'MOD_REDIRECT_URL' => $mod_redirect_url,
'MODERATION_ON' => $moderation,
- 'PRUNE_DAYS' => !empty($forum_data['prune_days']) ? delta_time((TIMENOW - 86400 * $forum_data['prune_days']), TIMENOW, 'days') : false,
+ 'PRUNE_DAYS' => !empty($forum_data['prune_days']) ? delta_time((TIME_DAY * $forum_data['prune_days']), TIMENOW, 'days') : false,
'CAT_ID' => $forum_data['cat_id'],
'CAT_TITLE' => $forums['cat_title_html'][$forum_data['cat_id']],
diff --git a/viewtopic.php b/viewtopic.php
index a9d674905..75dde93a0 100644
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -282,7 +282,7 @@ if (!empty($_REQUEST['postdays'])) {
if (!empty($_POST['postdays'])) {
$start = 0;
}
- $min_post_time = TIMENOW - ($post_days * 86400);
+ $min_post_time = TIME_DAY * $post_days;
$sql = "SELECT COUNT(p.post_id) AS num_posts
FROM " . BB_TOPICS . " t, " . BB_POSTS . " p
@@ -446,7 +446,7 @@ $sel_post_order_ary = [
];
$topic_has_poll = $t_data['topic_vote'];
-$poll_time_expired = ($t_data['topic_time'] < TIMENOW - $bb_cfg['poll_max_days'] * 86400);
+$poll_time_expired = ($t_data['topic_time'] < (TIME_DAY * $bb_cfg['poll_max_days']));
$can_manage_poll = ($t_data['topic_poster'] == $userdata['user_id'] || $is_auth['auth_mod']);
$can_add_poll = ($can_manage_poll && !$topic_has_poll && !$poll_time_expired && !$start);