diff --git a/CHANGELOG.md b/CHANGELOG.md index b119edb39..c97921db5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - search.php parameter sanitizing [\#1213](https://github.com/torrentpier/torrentpier/pull/1213) ([kovalensky](https://github.com/kovalensky), [belomaxorka](https://github.com/belomaxorka)) - Limit execution time for forum file-listing [\#1211](https://github.com/torrentpier/torrentpier/pull/1211) ([kovalensky](https://github.com/kovalensky), [belomaxorka](https://github.com/belomaxorka)) - Some reported bugfixes [\#1214](https://github.com/torrentpier/torrentpier/pull/1214), [\#1275](https://github.com/torrentpier/torrentpier/pull/1275) ([belomaxorka](https://github.com/belomaxorka)) -- Minor improvements [\#1206](https://github.com/torrentpier/torrentpier/pull/1206), [\#1215](https://github.com/torrentpier/torrentpier/pull/1215), [\#1217](https://github.com/torrentpier/torrentpier/pull/1217), [\#1219](https://github.com/torrentpier/torrentpier/pull/1219), [\#1220](https://github.com/torrentpier/torrentpier/pull/1220), [\#1224](https://github.com/torrentpier/torrentpier/pull/1224), [\#1228](https://github.com/torrentpier/torrentpier/pull/1228), [\#1229](https://github.com/torrentpier/torrentpier/pull/1229), [\#1230](https://github.com/torrentpier/torrentpier/pull/1230), [\#1234](https://github.com/torrentpier/torrentpier/pull/1234), [\#1236](https://github.com/torrentpier/torrentpier/pull/1236), [\#1243](https://github.com/torrentpier/torrentpier/pull/1243), [\#1248](https://github.com/torrentpier/torrentpier/pull/1248), [\#1253](https://github.com/torrentpier/torrentpier/pull/1253), [\#1254](https://github.com/torrentpier/torrentpier/pull/1254), [\#1259](https://github.com/torrentpier/torrentpier/pull/1259), [\#1263](https://github.com/torrentpier/torrentpier/pull/1263), [\#1265](https://github.com/torrentpier/torrentpier/pull/1265), [\#1266](https://github.com/torrentpier/torrentpier/pull/1266), [\#1271](https://github.com/torrentpier/torrentpier/pull/1271), [\#1273](https://github.com/torrentpier/torrentpier/pull/1273) ([belomaxorka](https://github.com/belomaxorka)) +- Minor improvements [\#1206](https://github.com/torrentpier/torrentpier/pull/1206), [\#1215](https://github.com/torrentpier/torrentpier/pull/1215), [\#1217](https://github.com/torrentpier/torrentpier/pull/1217), [\#1219](https://github.com/torrentpier/torrentpier/pull/1219), [\#1220](https://github.com/torrentpier/torrentpier/pull/1220), [\#1224](https://github.com/torrentpier/torrentpier/pull/1224), [\#1228](https://github.com/torrentpier/torrentpier/pull/1228), [\#1229](https://github.com/torrentpier/torrentpier/pull/1229), [\#1230](https://github.com/torrentpier/torrentpier/pull/1230), [\#1234](https://github.com/torrentpier/torrentpier/pull/1234), [\#1236](https://github.com/torrentpier/torrentpier/pull/1236), [\#1243](https://github.com/torrentpier/torrentpier/pull/1243), [\#1248](https://github.com/torrentpier/torrentpier/pull/1248), [\#1253](https://github.com/torrentpier/torrentpier/pull/1253), [\#1254](https://github.com/torrentpier/torrentpier/pull/1254), [\#1259](https://github.com/torrentpier/torrentpier/pull/1259), [\#1263](https://github.com/torrentpier/torrentpier/pull/1263), [\#1265](https://github.com/torrentpier/torrentpier/pull/1265), [\#1266](https://github.com/torrentpier/torrentpier/pull/1266), [\#1271](https://github.com/torrentpier/torrentpier/pull/1271), [\#1273](https://github.com/torrentpier/torrentpier/pull/1273), [\#1279](https://github.com/torrentpier/torrentpier/pull/1279) ([belomaxorka](https://github.com/belomaxorka)) - Fixed extensions issue [\#1218](https://github.com/torrentpier/torrentpier/pull/1218) ([belomaxorka](https://github.com/belomaxorka)) - Fixed broken sorting in group.php [\#1221](https://github.com/torrentpier/torrentpier/pull/1221) ([belomaxorka](https://github.com/belomaxorka)) - Code re-formatting [\#1225](https://github.com/torrentpier/torrentpier/pull/1225) ([kovalensky](https://github.com/kovalensky)) diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index 289d54435..8cfa32d7e 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -148,39 +148,40 @@ 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 (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id) { - $sql = "SELECT u.*, dl.user_status + 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 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) && $user_status != DL_STATUS_COMPLETE && ($bt_user_id != ($poster_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 ((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 ($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']) + ]); + } + } } } @@ -197,9 +198,10 @@ if ($tor_reged && $tor_info) { 'ATTACH_ID' => $attach_id, 'TOR_SILVER_GOLD' => $tor_type, 'TOR_TYPE' => is_gold($tor_type), + 'TOR_AUTHOR' => $bt_user_id == $poster_id && $bt_user_id != GUEST_UID, // torrent status mod - 'TOR_FROZEN' => (!IS_AM) ? (isset($bb_cfg['tor_frozen'][$tor_info['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id'])) ? true : '' : '', + 'TOR_FROZEN' => !IS_AM ? (isset($bb_cfg['tor_frozen'][$tor_info['tor_status']]) && !(isset($bb_cfg['tor_frozen_author_download'][$tor_info['tor_status']]) && $userdata['user_id'] == $tor_info['poster_id'])) ? true : '' : '', 'TOR_STATUS_TEXT' => $lang['TOR_STATUS_NAME'][$tor_info['tor_status']], 'TOR_STATUS_ICON' => $bb_cfg['tor_icons'][$tor_info['tor_status']], 'TOR_STATUS_BY' => ($tor_info['checked_user_id'] && ($is_auth['auth_mod'] || $tor_status_by_for_all)) ? (' · ' . profile_url($tor_info) . ' · ' . delta_time($tor_info['checked_time']) . $lang['TOR_BACK'] . '') : '', @@ -209,8 +211,8 @@ if ($tor_reged && $tor_info) { 'S_UPLOAD_IMAGE' => $upload_image, 'U_DOWNLOAD_LINK' => $download_link, - 'DL_LINK_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed', - 'DL_TITLE_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_status_css[$bt_userdata['user_status']] : 'gen', + 'DL_LINK_CLASS' => isset($bt_userdata['user_status']) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed', + 'DL_TITLE_CLASS' => isset($bt_userdata['user_status']) ? $dl_status_css[$bt_userdata['user_status']] : 'gen', 'FILESIZE' => $tor_file_size, 'MAGNET' => $tor_magnet, 'HASH' => !empty($tor_info['info_hash']) ? strtoupper(bin2hex($tor_info['info_hash'])) : false, @@ -247,9 +249,7 @@ if ($tor_reged && $tor_info) { $full_mode_order = 'tr.remain'; $full_mode_sort_dir = 'ASC'; - if (isset($_REQUEST['psortasc'])) { - $full_mode_sort_dir = 'ASC'; - } elseif (isset($_REQUEST['psortdesc'])) { + if (isset($_REQUEST['psortdesc'])) { $full_mode_sort_dir = 'DESC'; } diff --git a/styles/templates/default/viewtopic_attach.tpl b/styles/templates/default/viewtopic_attach.tpl index aae739429..59bf63bbe 100644 --- a/styles/templates/default/viewtopic_attach.tpl +++ b/styles/templates/default/viewtopic_attach.tpl @@ -460,7 +460,7 @@ $('#tor-filelist-btn').click(function () { }
- +