Refactoring: Created constants for datetime values (#1648)

* Refactoring: Created constants for datetime values

* Updated

* Updated

* Update tracker.php

* Update tracker.php

* Update index.php

* Update admin_log.php

* Update viewtopic.php

* Updated

* Update Poll.php

* Updated

* Updated

* Update viewtopic.php

* Update User.php

* Update privmsg.php

* Update poll.php

* Update tr_make_snapshot.php

* Update displaying_torrent.php

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-09-27 18:22:41 +07:00 committed by GitHub
commit 6eca29714a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 58 additions and 52 deletions

View file

@ -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']) {

View file

@ -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));
}

View file

@ -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) {

View file

@ -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']));
}
}

View file

@ -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");

View file

@ -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 . "

View file

@ -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 = [];

View file

@ -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)

View file

@ -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