diff --git a/include/functions.php b/include/functions.php index 2517c4f9..561f6c6d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -4959,12 +4959,24 @@ function get_user_class_image($class){ } function user_can_upload($where = "torrents"){ - global $CURUSER,$upload_class,$enablespecial,$uploadspecial_class; - - if ($CURUSER["uploadpos"] != 'yes') - return false; + global $CURUSER,$upload_class,$enablespecial,$uploadspecial_class, $lang_functions; + if ($CURUSER["uploadpos"] != 'yes') { + return false; + } + $uploadDenyApprovalDenyCount = get_setting('main.upload_deny_approval_deny_count'); + $approvalDenyCount = \App\Models\Torrent::query()->where('owner', $CURUSER['id']) + ->where('approval_status', \App\Models\Torrent::APPROVAL_STATUS_DENY) + ->count() + ; + if ($uploadDenyApprovalDenyCount > 0 && $approvalDenyCount >= $uploadDenyApprovalDenyCount) { + stderr($lang_functions['std_sorry'], sprintf($lang_functions['approval_deny_reach_upper_limit'], $uploadDenyApprovalDenyCount),false); + } if ($where == "torrents") { + $offerSkipApprovedCount = get_setting('main.offer_skip_approved_count'); + if ($CURUSER['offer_allowed_count'] >= $offerSkipApprovedCount) { + return true; + } if (user_can('upload')) return true; if (get_if_restricted_is_open()) diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php index b55f6d5e..b4188be8 100644 --- a/lang/chs/lang_functions.php +++ b/lang/chs/lang_functions.php @@ -330,6 +330,7 @@ $lang_functions = array 'input_uncheck_all' => "全不选", 'select_at_least_one_record' => '至少选择一条记录!', 'text_seed_box_record_to_approval' => '有 %s%u 条待审核的 SeedBox 记录%s', + 'approval_deny_reach_upper_limit' => '当前审核被拒绝的种子数:%s 达到上限,不允许发布。', ); ?> diff --git a/lang/chs/lang_upload.php b/lang/chs/lang_upload.php index 172beca0..773cc5af 100644 --- a/lang/chs/lang_upload.php +++ b/lang/chs/lang_upload.php @@ -41,7 +41,6 @@ $lang_upload = array 'text_english_title' => "英文名:", 'text_titles_note' => "(如果英文名不存在,使用拼音或不填写)", 'fill_quality' => '填写质量', - 'approval_deny_reach_upper_limit' => '当前审核被拒绝的种子数:%s 达到上限,不允许发布。', ); ?> diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php index f7429a4a..7d23af48 100644 --- a/lang/cht/lang_functions.php +++ b/lang/cht/lang_functions.php @@ -337,6 +337,7 @@ $lang_functions = array 'input_uncheck_all' => "全不選", 'select_at_least_one_record' => '至少選擇一條記錄!', 'text_seed_box_record_to_approval' => '有 %s%u 條待審核的 SeedBox 記錄%s', + 'approval_deny_reach_upper_limit' => '當前審核被拒絕的種子數:%s 達到上限,不允許發布。', ); ?> diff --git a/lang/cht/lang_upload.php b/lang/cht/lang_upload.php index d8e870b1..705d00ca 100644 --- a/lang/cht/lang_upload.php +++ b/lang/cht/lang_upload.php @@ -41,7 +41,6 @@ $lang_upload = array 'text_english_title' => "英文名:", 'text_titles_note' => "(如果英文名不存在,請使用拼音或不填寫)", 'fill_quality' => '填寫質量', - 'approval_deny_reach_upper_limit' => '當前審核被拒絕的種子數:%s 達到上限,不允許發布。', ); ?> diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php index 2f8d66ec..c9febfd7 100644 --- a/lang/en/lang_functions.php +++ b/lang/en/lang_functions.php @@ -338,6 +338,7 @@ $lang_functions = array 'input_uncheck_all' => "Uncheck All", 'select_at_least_one_record' => 'Select at least one record!', 'text_seed_box_record_to_approval' => 'There %s%u not approval seed box record%s.', + 'approval_deny_reach_upper_limit' => 'The number of torrents whose current approval was denied: %s reached the upper limit and is not allowed to be upload.', ); ?> diff --git a/lang/en/lang_upload.php b/lang/en/lang_upload.php index ae6125d1..341b9f8f 100644 --- a/lang/en/lang_upload.php +++ b/lang/en/lang_upload.php @@ -41,7 +41,6 @@ $lang_upload = array 'text_english_title' => "English Name:", 'text_titles_note' => "(If no English Name exists, use pinyin or leave it blank)", 'fill_quality' => 'Fill quality', - 'approval_deny_reach_upper_limit' => 'The number of torrents whose current approval was denied: %s reached the upper limit and is not allowed to be upload.', ); ?> diff --git a/public/upload.php b/public/upload.php index 52efb6a9..3a087c79 100644 --- a/public/upload.php +++ b/public/upload.php @@ -5,7 +5,6 @@ require_once(get_langfile_path()); require_once(get_langfile_path('edit.php')); loggedinorreturn(); parked(); -$userInfo = \App\Models\User::query()->findOrFail($CURUSER['id']); if ($CURUSER["uploadpos"] == 'no') stderr($lang_upload['std_sorry'], $lang_upload['std_unauthorized_to_upload'],false); @@ -13,16 +12,9 @@ if ($enableoffer == 'yes') $has_allowed_offer = get_row_count("offers","WHERE allowed='allowed' AND userid = ". sqlesc($CURUSER["id"])); else $has_allowed_offer = 0; $uploadfreely = user_can_upload("torrents"); -$offerSkipApprovedCount = get_setting('main.offer_skip_approved_count'); -$uploadDenyApprovalDenyCount = get_setting('main.upload_deny_approval_deny_count'); -$approvalDenyCount = \App\Models\Torrent::query()->where('owner', $CURUSER['id'])->where('approval_status', \App\Models\Torrent::APPROVAL_STATUS_DENY)->count(); -do_log("uploadfreely: $uploadfreely, has_allowed_offer: $has_allowed_offer, offerSkipApprovedCount: $offerSkipApprovedCount, uploadDenyApprovalDenyCount: $uploadDenyApprovalDenyCount, approvalDenyCount: $approvalDenyCount"); -$allowtorrents = ($has_allowed_offer || $uploadfreely || ($userInfo->offer_allowed_count >= $offerSkipApprovedCount)); +$allowtorrents = ($has_allowed_offer || $uploadfreely); $allowspecial = user_can_upload("music"); -if ($uploadDenyApprovalDenyCount > 0 && $approvalDenyCount >= $uploadDenyApprovalDenyCount) { - stderr($lang_upload['std_sorry'],sprintf($lang_upload['approval_deny_reach_upper_limit'], $uploadDenyApprovalDenyCount),false); -} if (!$allowtorrents && !$allowspecial) stderr($lang_upload['std_sorry'],$lang_upload['std_please_offer'],false); $allowtwosec = ($allowtorrents && $allowspecial);