From a8b82783524f840c2f9dd12335223c00b0b6d402 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 27 Jan 2024 19:55:47 +0700 Subject: [PATCH] Fixed broken user dl status (#1351) * Fixed broken user dl status * Update viewtopic_torrent.tpl * Update displaying_torrent.php * Update displaying_torrent.php * Update displaying_torrent.php * Updated * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 4 ++ filelist.php | 3 +- library/attach_mod/displaying_torrent.php | 45 +++++++++---------- styles/templates/default/css/alert.css | 12 ++--- styles/templates/default/css/globals.css | 19 +++++--- styles/templates/default/css/main_content.css | 4 +- styles/templates/default/css/page_content.css | 3 +- styles/templates/default/css/top.css | 9 ++-- .../templates/default/viewtopic_torrent.tpl | 4 +- 9 files changed, 56 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91b65aecd..30bd16d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - Release 2.4.1 🦉 ([belomaxorka](https://github.com/belomaxorka), [kovalensky](https://github.com/kovalensky)) - Timeline — 2.4.1 [\#1340](https://github.com/torrentpier/torrentpier/pull/1340), [\#1341](https://github.com/torrentpier/torrentpier/pull/1341), [\#1342](https://github.com/torrentpier/torrentpier/pull/1342), [\#1343](https://github.com/torrentpier/torrentpier/pull/1343) ([kovalensky](https://github.com/kovalensky)) +- [BEP47] sha1 hash files are binary by default [\#1348](https://github.com/torrentpier/torrentpier/pull/1348) ([kovalensky](https://github.com/kovalensky)) +- Extend css contrast attributes [\#1349](https://github.com/torrentpier/torrentpier/pull/1349) ([kovalensky](https://github.com/kovalensky)) +- Flatten file list for hybrid files [\#1350](https://github.com/torrentpier/torrentpier/pull/1350) ([kovalensky](https://github.com/kovalensky)) - Added new flag 🕊 [\#1347](https://github.com/torrentpier/torrentpier/pull/1347) ([belomaxorka](https://github.com/belomaxorka)) - Added ability to view "Watching topics" of other people's (For admins only) [\#1336](https://github.com/torrentpier/torrentpier/pull/1336) ([belomaxorka](https://github.com/belomaxorka)) - Added `bt_announce_url` autofill [\#1331](https://github.com/torrentpier/torrentpier/pull/1331) ([belomaxorka](https://github.com/belomaxorka)) @@ -19,6 +22,7 @@ - Some enhancements in default template [\#1312](https://github.com/torrentpier/torrentpier/pull/1312) ([belomaxorka](https://github.com/belomaxorka)) - Some enhancements in default template (Part 2) [\#1322](https://github.com/torrentpier/torrentpier/pull/1322) ([belomaxorka](https://github.com/belomaxorka)) - Set response code in some cases [\#1319](https://github.com/torrentpier/torrentpier/pull/1319) ([belomaxorka](https://github.com/belomaxorka)) +- Fixed broken user dl status [\#1351](https://github.com/torrentpier/torrentpier/pull/1351) ([belomaxorka](https://github.com/belomaxorka)) - Fixed auth(): empty $f_access [\#1329](https://github.com/torrentpier/torrentpier/pull/1329) ([belomaxorka](https://github.com/belomaxorka)) - Fixed download counter for torrents [\#1346](https://github.com/torrentpier/torrentpier/pull/1346) ([belomaxorka](https://github.com/belomaxorka)) - Fixed HTTP 500 while cron running in server-side [\#1321](https://github.com/torrentpier/torrentpier/pull/1321) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/filelist.php b/filelist.php index 58d7e7c92..a93a3953d 100644 --- a/filelist.php +++ b/filelist.php @@ -56,8 +56,7 @@ if ($bb_cfg['flist_max_files']) { if ($filetree_pos) { $file_count = substr_count($file_contents, '6:length', $filetree_pos, ($files_pos ? ($files_pos - $filetree_pos) : null)); - } - else { + } else { $file_count = substr_count($file_contents, '6:length', $files_pos); } diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index fc425855c..cd7d58af4 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -148,40 +148,38 @@ if ($tor_reged && $tor_info) { $tor_magnet = create_magnet($tor_info['info_hash'], $tor_info['info_hash_v2'], $user_passkey, html_ent_decode($t_data['topic_title'])); // ratio limits + $min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; + $min_ratio_warn = $bb_cfg['bt_min_ratio_warning']; $dl_allowed = true; $user_ratio = 0; - if ($bt_user_id != $poster_id && $bt_user_id != GUEST_UID) { - $min_ratio_dl = $bb_cfg['bt_min_ratio_allow_dl_tor']; - $min_ratio_warn = $bb_cfg['bt_min_ratio_warning']; - - if ($min_ratio_dl || $min_ratio_warn) { - $sql = "SELECT u.*, dl.user_status + if (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id) { + $sql = "SELECT u.*, dl.user_status FROM " . BB_BT_USERS . " u LEFT JOIN " . BB_BT_DLSTATUS . " dl ON dl.user_id = $bt_user_id AND dl.topic_id = $bt_topic_id WHERE u.user_id = $bt_user_id LIMIT 1"; - } else { - $sql = "SELECT user_status + } else { + $sql = "SELECT user_status FROM " . BB_BT_DLSTATUS . " WHERE user_id = $bt_user_id AND topic_id = $bt_topic_id LIMIT 1"; + } + + $bt_userdata = DB()->fetch_row($sql); + $user_status = $bt_userdata['user_status'] ?? null; + + if (($min_ratio_dl || $min_ratio_warn) && (isset($user_status) && $user_status != DL_STATUS_COMPLETE) && ($bt_user_id != $poster_id && $bt_user_id != GUEST_UID) && $tor_type != TOR_TYPE_GOLD) { + if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) { + $dl_allowed = ($user_ratio > $min_ratio_dl); } - if ($bt_userdata = DB()->fetch_row($sql)) { - if (($min_ratio_dl || $min_ratio_warn) && (isset($bt_userdata['user_status']) && $bt_userdata['user_status'] != DL_STATUS_COMPLETE) && $tor_type != TOR_TYPE_GOLD) { - if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) { - $dl_allowed = ($user_ratio > $min_ratio_dl); - } - - if ((isset($user_ratio, $min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) { - $template->assign_vars([ - 'SHOW_RATIO_WARN' => true, - 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']) - ]); - } - } + if ((isset($user_ratio, $min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) { + $template->assign_vars([ + 'SHOW_RATIO_WARN' => true, + 'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']), + ]); } } @@ -375,8 +373,7 @@ if ($tor_reged && $tor_info) { if ($s_mode == 'full') { if (!empty($peer['ip']) && !empty($peer['ipv6'])) { $ip = bt_show_ip($peer['ipv6']) . ' (' . bt_show_ip($peer['ip']) . ')'; - } - else { + } else { $ip = bt_show_ip(!empty($peer['ipv6']) ? $peer['ipv6'] : $peer['ip']); } $port = bt_show_port($peer['port']); @@ -543,5 +540,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' => ($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'] < (TIMENOW - 86400)), ]); diff --git a/styles/templates/default/css/alert.css b/styles/templates/default/css/alert.css index 9693416c3..8ef9fd6ba 100644 --- a/styles/templates/default/css/alert.css +++ b/styles/templates/default/css/alert.css @@ -23,11 +23,11 @@ font-weight: bold; } -.alert>p, .alert>ul { +.alert > p, .alert > ul { margin: 0 0 1px 15px; } -.alert>p+p { +.alert > p + p { margin-top: 5px; } @@ -116,7 +116,7 @@ .alert-success { background-image: -webkit-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%); background-image: linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%); - filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0); background-repeat: repeat-x; border-color: #b2dba1; } @@ -124,7 +124,7 @@ .alert-info { background-image: -webkit-linear-gradient(top, #d9edf7 0%, #b9def0 100%); background-image: linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%); - filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0); background-repeat: repeat-x; border-color: #9acfea; } @@ -132,7 +132,7 @@ .alert-warning { background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%); background-image: linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%); - filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0); background-repeat: repeat-x; border-color: #f0d575; } @@ -140,7 +140,7 @@ .alert-danger { background-image: -webkit-linear-gradient(top, #f2dede 0%, #e7c3c3 100%); background-image: linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%); - filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0); background-repeat: repeat-x; border-color: #dca7a7; } diff --git a/styles/templates/default/css/globals.css b/styles/templates/default/css/globals.css index 95f95de51..5c8900467 100644 --- a/styles/templates/default/css/globals.css +++ b/styles/templates/default/css/globals.css @@ -537,7 +537,8 @@ input, textarea, select { font-family: Verdana, sans-serif; } -input.post, textarea.post {} +input.post, textarea.post { +} select, input { font-size: 11px; @@ -647,11 +648,12 @@ legend a { text-decoration: none; } -fieldset>legend { +fieldset > legend { margin-left: 6px; } -.root_forum {} +.root_forum { +} .has_sf { color: #333333; @@ -693,7 +695,7 @@ textarea.editor { margin-bottom: 1px; } -.fieldsets div>p { +.fieldsets div > p { margin-bottom: 2px; } @@ -701,11 +703,14 @@ textarea.editor { margin-bottom: 3px; } -.fieldsets .radio {} +.fieldsets .radio { +} -.fieldsets .chbox {} +.fieldsets .chbox { +} -.fieldsets .input {} +.fieldsets .input { +} table.my_downloads { margin-bottom: 2px; diff --git a/styles/templates/default/css/main_content.css b/styles/templates/default/css/main_content.css index bfefe9dad..6cc1a9eb8 100644 --- a/styles/templates/default/css/main_content.css +++ b/styles/templates/default/css/main_content.css @@ -613,8 +613,8 @@ table.peers td { .clients { width: auto; height: auto; - display: inline!important; - vertical-align:middle; + display: inline !important; + vertical-align: middle; } .dl_list { diff --git a/styles/templates/default/css/page_content.css b/styles/templates/default/css/page_content.css index 8b1ccde4a..1c6a5c84f 100644 --- a/styles/templates/default/css/page_content.css +++ b/styles/templates/default/css/page_content.css @@ -97,7 +97,8 @@ font-size: 11px; } -#tr_main_cats {} +#tr_main_cats { +} /* Main tracker categories list */ #tr_main_cats ul { diff --git a/styles/templates/default/css/top.css b/styles/templates/default/css/top.css index ecff113be..5d7256804 100644 --- a/styles/templates/default/css/top.css +++ b/styles/templates/default/css/top.css @@ -43,7 +43,8 @@ body, th, td, font { position: relative; } -#sidebar1 {} +#sidebar1 { +} #sidebar2 { padding: 0 3px 0 6px; @@ -56,13 +57,15 @@ body, th, td, font { width: 210px; } -#sidebar2-wrap {} +#sidebar2-wrap { +} #main_content { vertical-align: top; } -#main_content_wrap {} +#main_content_wrap { +} #page_footer { clear: both; diff --git a/styles/templates/default/viewtopic_torrent.tpl b/styles/templates/default/viewtopic_torrent.tpl index 6d2d54413..2eee2b4dd 100644 --- a/styles/templates/default/viewtopic_torrent.tpl +++ b/styles/templates/default/viewtopic_torrent.tpl @@ -242,9 +242,9 @@ ajax.callback.callseed = function (data) { + -  
{DL_HIDDEN_FIELDS}   @@ -254,9 +254,9 @@ ajax.callback.callseed = function (data) {
  -   +