From aae45835ee9987c83fb1701779ef1545ef5cdbfe Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 24 Jun 2022 14:55:10 +0800 Subject: [PATCH] add configuration: torrent.approval_status_none_visible --- README.md | 4 +--- app/Console/Commands/NexusUpdate.php | 24 ++++++++++++++++++-- app/Console/Commands/Test.php | 9 ++++++-- app/Repositories/TorrentRepository.php | 31 ++++++++++++++++++++++++++ app/Repositories/TrackerRepository.php | 11 ++++++--- include/constants.php | 2 +- include/functions.php | 9 +++----- lang/chs/lang_settings.php | 6 +++-- lang/cht/lang_settings.php | 6 +++-- lang/en/lang_settings.php | 6 +++-- nexus/Install/Update.php | 29 ++++++++++++++---------- nexus/Install/settings.default.php | 1 + nexus/Torrent/Torrent.php | 5 ----- public/announce.php | 9 ++++++-- public/details.php | 3 ++- public/download.php | 5 +++-- public/getusertorrentlistajax.php | 17 +++++++++----- public/settings.php | 3 ++- public/torrentrss.php | 7 ++++++ public/torrents.php | 6 +++++ resources/lang/en/torrent.php | 8 +++---- 21 files changed, 145 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index f2badbc0..7ff59dab 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ 安装 docker。 其中 DOMAIN 是你要使用的域名,先做好解析。 没有域名使用 IP 亦可。 端口按需要指定,如果本地 80 端口已经使用,请更换,保证端口对外开放。 -第2步创建 .env 选择正确的时区 TIMEZONE,其他默认即可。 +第 2 步创建 .env 选择正确的时区 TIMEZONE,其他默认即可。 ``` docker pull xiaomlove/nexusphp:latest docker run --name my-nexusphp -e DOMAIN=xxx.com -p 80:80 xiaomlove/nexusphp:latest @@ -46,8 +46,6 @@ docker run --name my-nexusphp -e DOMAIN=xxx.com -p 80:80 xiaomlove/nexusphp:late QQ群: [764452568](https://jq.qq.com/?_wv=1027&k=IbltZcIx) Telegram: [https://t.me/nexusphp](https://t.me/nexusphp) B站: [xiaomlove](https://space.bilibili.com/1319303059) -微信公众号: -![扫码关注](https://nexusphp.org/wp-content/uploads/2022/03/wechat_official_account.png) ## Project supported by JetBrains Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects. diff --git a/app/Console/Commands/NexusUpdate.php b/app/Console/Commands/NexusUpdate.php index 5fc7205c..391a6b20 100644 --- a/app/Console/Commands/NexusUpdate.php +++ b/app/Console/Commands/NexusUpdate.php @@ -12,14 +12,14 @@ class NexusUpdate extends Command * * @var string */ - protected $signature = 'nexus:update'; + protected $signature = 'nexus:update {--tag=} {--keep_tmp}'; /** * The console command description. * * @var string */ - protected $description = 'Update nexusphp after code updated, remember run `composer update` first.'; + protected $description = 'Update nexusphp after code updated, remember run `composer update` first. Options: --tag=, --keep_tmp'; private $update; @@ -43,6 +43,17 @@ class NexusUpdate extends Command { define('WITH_LARAVEL', true); require ROOT_PATH . 'nexus/Database/helpers.php'; + $tag = $this->option('tag'); + $keepTmp = $this->option('keep_tmp'); + if ($tag !== null) { + if ($tag === 'dev') { + $url = "https://github.com/xiaomlove/nexusphp/archive/refs/heads/php8.zip"; + } else { + $url = "https://api.github.com/repos/xiaomlove/nexusphp/tarball/v$tag"; + } + $this->doLog("Specific tag: '$tag', download from '$url' and extra code..."); + $tmpPath = $this->update->downAndExtractCode($url); + } //Step 1 $step = $this->update->currentStep(); $log = sprintf('Step %s, %s...', $step, $this->update->getStepName($step)); @@ -108,6 +119,15 @@ class NexusUpdate extends Command $this->doLog("All done!"); + if (isset($tmpPath)) { + if (!$keepTmp) { + $this->doLog("Delete tmp files in: $tmpPath"); + $this->update->executeCommand("rm -rf " . rtrim($tmpPath, '/')); + } else { + $this->doLog("Keep tmp files in: $tmpPath"); + } + } + return 0; } diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index ab43adf2..304f2568 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -78,8 +78,13 @@ class Test extends Command */ public function handle() { - $r = Carbon::parse(null); - dd($r); + $a = 2; + $b = 2; + if ($a != 1 && $b == 2) { + echo "OK"; + } else { + echo 'Bad'; + } } diff --git a/app/Repositories/TorrentRepository.php b/app/Repositories/TorrentRepository.php index 3f7923bb..bab2a9b9 100644 --- a/app/Repositories/TorrentRepository.php +++ b/app/Repositories/TorrentRepository.php @@ -533,5 +533,36 @@ class TorrentRepository extends BaseRepository } + public function renderApprovalStatus($approvalStatus, $show = null): string + { + if ($show === null) { + $show = $this->shouldShowApprovalStatusIcon($approvalStatus); + } + if ($show) { + return sprintf( + '%s', + nexus_trans("torrent.approval.status_text.$approvalStatus"), + \App\Models\Torrent::$approvalStatus[$approvalStatus]['icon'] + ); + } + return ''; + } + + public function shouldShowApprovalStatusIcon($approvalStatus): bool + { + if (get_setting('torrent.approval_status_icon_enabled') == 'yes') { + //启用审核状态图标,肯定显示 + return true; + } + if ( + $approvalStatus != \App\Models\Torrent::APPROVAL_STATUS_ALLOW + && get_setting('torrent.approval_status_none_visible') == 'no' + ) { + //不启用审核状态图标,尽量不显示。在种子不是审核通过状态,而审核不通过又不能被用户看到时,显示 + return true; + } + return false; + } + } diff --git a/app/Repositories/TrackerRepository.php b/app/Repositories/TrackerRepository.php index dc8f0579..cb6c5dd3 100644 --- a/app/Repositories/TrackerRepository.php +++ b/app/Repositories/TrackerRepository.php @@ -382,8 +382,13 @@ class TrackerRepository extends BaseRepository throw new TrackerException('Torrent not registered with this tracker.'); } - if ($torrent->banned == 'yes' && $user->class < Setting::get('authority.seebanned')) { - throw new TrackerException("torrent banned"); + if ($user->class < Setting::get('authority.seebanned')) { + if ($torrent->banned == 'yes') { + throw new TrackerException("torrent banned"); + } + if ($torrent->approval_status != Torrent::APPROVAL_STATUS_ALLOW && Setting::get('torrent.approval_status_none_visible') == 'no') { + throw new TrackerException("torrent review not approved"); + } } return $torrent; } @@ -1066,7 +1071,7 @@ class TrackerRepository extends BaseRepository { $cacheKey = __METHOD__ . bin2hex($infoHash); return Cache::remember($cacheKey, 60, function () use ($infoHash, $cacheKey) { - $fieldRaw = 'id, owner, sp_state, seeders, leechers, added, banned, hr, visible, last_action, times_completed'; + $fieldRaw = 'id, owner, sp_state, seeders, leechers, added, banned, hr, visible, last_action, times_completed, approval_status'; $torrent = Torrent::query()->where('info_hash', $infoHash)->selectRaw($fieldRaw)->first(); do_log("[getTorrentByInfoHash] cache miss [$cacheKey], from database, and get: " . ($torrent->id ?? '')); return $torrent; diff --git a/include/constants.php b/include/constants.php index e7164fc7..9eb9835f 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ listLeechingSeedingStatus($CURUSER['id'], $torrentIdArr); $tagRep = new \App\Repositories\TagRepository(); @@ -3259,7 +3260,6 @@ function torrenttable($rows, $variant = "torrent") { $torrentTagCollection = \App\Models\TorrentTag::query()->whereIn('torrent_id', $torrentIdArr)->orderByRaw("field(tag_id,$tagIdStr)")->get(); $tagKeyById = $tagCollection->keyBy('id'); $torrentTagResult = $torrentTagCollection->groupBy('torrent_id'); - $approvalStatusIconEnabled = \App\Models\Setting::get('torrent.approval_status_icon_enabled') == 'yes'; $last_browse = $CURUSER['last_browse']; // if ($variant == "torrent"){ @@ -3453,10 +3453,7 @@ foreach ($rows as $row) $banned_torrent = ($row["banned"] == 'yes' ? " (".$lang_functions['text_banned'].")" : ""); $sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false); - $approvalStatusIcon = ''; - if ($approvalStatusIconEnabled) { - $approvalStatusIcon = $torrent->renderApprovalStatus($row['approval_status']); - } + $approvalStatusIcon = $torrentRep->renderApprovalStatus($row['approval_status']); $titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $approvalStatusIcon; $titleSuffix = apply_filter('torrent_title_suffix', $titleSuffix, $row); print($titleSuffix); diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index c8d6aeb9..455c6124 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -758,8 +758,10 @@ $lang_settings = array 'text_misc_settings_note' => '配置其他杂项。', 'row_misc_donation_custom' => '捐赠自定义内容', 'text_donation_custom_note' => '捐赠页自定义的内容,展示于支付宝、PayPal上面。支持 bbcode 标签', - 'row_approval_status_icon_enabled' => '审核状态图标', - 'text_approval_status_icon_enabled_note' => "是否在种子列表展示审核状态图标,默认: '否'。" + 'row_approval_status_icon_enabled' => '显示审核状态图标', + 'text_approval_status_icon_enabled_note' => "是否在种子列表展示审核状态图标,默认: '否'。", + 'row_approval_status_none_visible' => '未审核种子是否可见', + 'text_approval_status_none_visible_note' => "默认:'是'。若改为'否',审核不为[通过]状态时强制显示审核状态图标。", ); ?> diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index faaf0246..d6eccc36 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -758,8 +758,10 @@ $lang_settings = array 'text_misc_settings_note' => '配置其他雜項。', 'row_misc_donation_custom' => '捐贈自定義內容', 'text_donation_custom_note' => '捐贈頁自定義的內容,展示於支付寶、PayPal上面。支持 bbcode 標簽', - 'row_approval_status_icon_enabled' => '審核狀態圖標', - 'text_approval_status_icon_enabled_note' => "是否在種子列表展示審核狀態圖標,默認: '否'。" + 'row_approval_status_icon_enabled' => '顯示審核狀態圖標', + 'text_approval_status_icon_enabled_note' => "是否在種子列表展示審核狀態圖標,默認: '否'。", + 'row_approval_status_none_visible' => '未審核種子是否可見', + 'text_approval_status_none_visible_note' => "默認:'是'。若改為'否',審核不為[通過]狀態時強製顯示審核狀態圖標。", ); ?> diff --git a/lang/en/lang_settings.php b/lang/en/lang_settings.php index e8758434..6e832e57 100644 --- a/lang/en/lang_settings.php +++ b/lang/en/lang_settings.php @@ -758,8 +758,10 @@ $lang_settings = array 'text_misc_settings_note' => 'Misc settings', 'row_misc_donation_custom' => 'Donation custom', 'text_donation_custom_note' => 'Donation page custom content, displayed above Alipay, PayPal. Support bbcode tag', - 'row_approval_status_icon_enabled' => 'Approval status icon', - 'text_approval_status_icon_enabled_note' => "Whether to show the approval status icon in the torrent list, default: 'No'." + 'row_approval_status_icon_enabled' => 'Show approval status icon', + 'text_approval_status_icon_enabled_note' => "Whether to show the approval status icon in the torrent list, default: 'No'.", + 'row_approval_status_none_visible' => 'Visibility of not reviewed torrents', + 'text_approval_status_none_visible_note' => "Default: 'Yes'. If change to 'No', force to show approval status icon when audit is not [allow] status.", ); ?> diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 4f8d31f0..5660d111 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -295,24 +295,24 @@ class Update extends Install public function requestGithub($url) { $client = new Client(); - $logPrefix = "请求 github: $url"; + $logPrefix = "Request github: $url"; $response = $client->get($url, ['timeout' => 10,]); if (($statusCode = $response->getStatusCode()) != 200) { - throw new \RuntimeException("$logPrefix 失败,状态码:$statusCode"); + throw new \RuntimeException("$logPrefix fail, status code:$statusCode"); } if ($response->getBody()->getSize() <= 0) { - throw new \RuntimeException("$logPrefix 失败,结果为空"); + throw new \RuntimeException("$logPrefix fail, response empty"); } $bodyString = $response->getBody()->getContents(); $this->doLog("[REQUEST_GITHUB_RESPONSE]: $bodyString"); $results = json_decode($bodyString, true); if (empty($results) || !is_array($results)) { - throw new \RuntimeException("$logPrefix 结果异常"); + throw new \RuntimeException("$logPrefix response invalid"); } return $results; } - public function downAndExtractCode($url): bool + public function downAndExtractCode($url): string { $arr = explode('/', $url); $basename = last($arr); @@ -329,16 +329,16 @@ class Update extends Install $client = new Client(); $response = $client->request('GET', $url, ['sink' => $filename]); if (($statusCode = $response->getStatusCode()) != 200) { - throw new \RuntimeException("下载错误,状态码:$statusCode"); + throw new \RuntimeException("Download fail, status code:$statusCode"); } if (($bodySize = $response->getBody()->getSize()) <= 0) { - throw new \RuntimeException("下载错误,文件体积:$bodySize"); + throw new \RuntimeException("Download fail, file size:$bodySize"); } if (!file_exists($filename)) { - throw new \RuntimeException("下载错误,文件不存在:$filename"); + throw new \RuntimeException("Download fail, file not exists:$filename"); } if (filesize($filename) <= 0) { - throw new \RuntimeException("下载错误,文件大小为0"); + throw new \RuntimeException("Download fail, file: $filename size = 0"); } $this->doLog('SUCCESS_DOWNLOAD'); $extractDir = str_replace($suffix, "", $filename); @@ -346,7 +346,7 @@ class Update extends Install $this->executeCommand($command); if ($isZip) { - $command = "unzip $filename -d $extractDir"; + $command = "unzip -q $filename -d $extractDir"; } else { $command = "tar -xf $filename -C $extractDir"; } @@ -354,13 +354,18 @@ class Update extends Install foreach (glob("$extractDir/*") as $path) { if (is_dir($path)) { - $command = sprintf('cp -Rf %s/* %s', $path, ROOT_PATH); + $excludes = ['.git', 'composer.lock', 'composer.json', 'public/favicon.ico', '.env']; +// $command = sprintf('cp -raf %s/. %s', $path, ROOT_PATH); + $command = "rsync -rvq $path/ " . ROOT_PATH; + foreach ($excludes as $exclude) { + $command .= " --exclude=$exclude"; + } $this->executeCommand($command); break; } } $this->doLog('SUCCESS_EXTRACT'); - return true; + return $extractDir; } public function initSeedPoints(): int diff --git a/nexus/Install/settings.default.php b/nexus/Install/settings.default.php index 8625c19c..38a495f2 100644 --- a/nexus/Install/settings.default.php +++ b/nexus/Install/settings.default.php @@ -333,6 +333,7 @@ return array ( 'claim_reach_standard_seed_time' => \App\Models\Claim::STANDARD_SEED_TIME_HOURS, 'claim_reach_standard_uploaded' => \App\Models\Claim::STANDARD_UPLOADED_TIMES, 'approval_status_icon_enabled' => 'no', + 'approval_status_none_visible' => 'yes', ), 'attachment' => array ( diff --git a/nexus/Torrent/Torrent.php b/nexus/Torrent/Torrent.php index 7a02b6d5..c2427110 100644 --- a/nexus/Torrent/Torrent.php +++ b/nexus/Torrent/Torrent.php @@ -86,9 +86,4 @@ class Torrent return $ptGen->buildRatingSpan($siteIdAndRating); } - public function renderApprovalStatus($status): string - { - return sprintf('%s', \App\Models\Torrent::$approvalStatus[$status]['icon']); - } - } diff --git a/public/announce.php b/public/announce.php index 8b5a78ad..9efa66fe 100644 --- a/public/announce.php +++ b/public/announce.php @@ -152,7 +152,7 @@ elseif ($az['showclienterror'] == 'yes'){ } // check torrent based on info_hash -$checkTorrentSql = "SELECT id, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr FROM torrents WHERE " . hash_where("info_hash", $info_hash); +$checkTorrentSql = "SELECT id, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, banned, hr, approval_status FROM torrents WHERE " . hash_where("info_hash", $info_hash); if (!$torrent = $Cache->get_value('torrent_hash_'.$info_hash.'_content')){ $res = sql_query($checkTorrentSql); $torrent = mysql_fetch_array($res); @@ -168,8 +168,13 @@ if (!$torrent) { do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode", 'error'); err("torrent not registered with this tracker"); +} elseif ($az['class'] < $seebanned_class) { + if ($torrent['banned'] == 'yes') { + err("torrent banned"); + } elseif ($torrent['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no') { + err("torrent review not approved"); + } } -elseif ($torrent['banned'] == 'yes' && $az['class'] < $seebanned_class) err("torrent banned"); // select peers info from peers table for this torrent $torrentid = $torrent["id"]; $numpeers = $torrent["seeders"]+$torrent["leechers"]; diff --git a/public/details.php b/public/details.php index 063d904e..9280ecc2 100644 --- a/public/details.php +++ b/public/details.php @@ -71,7 +71,8 @@ if (!$row) { $sp_torrent = get_torrent_promotion_append($row['sp_state'],'word', false, '', 0, '', $row['__ignore_global_sp_state'] ?? false); $sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false); $hrImg = get_hr_img($row); - $s=htmlspecialchars($row["name"]).$banned_torrent.($sp_torrent ? "   ".$sp_torrent : "").($sp_torrent_sub) . $hrImg; + $approvalStatusIcon = $torrentRep->renderApprovalStatus($row["approval_status"]); + $s=htmlspecialchars($row["name"]).$banned_torrent.($sp_torrent ? "   ".$sp_torrent : "").($sp_torrent_sub) . $hrImg . $approvalStatusIcon; print("

".$s."

\n"); //Banned reason diff --git a/public/download.php b/public/download.php index 1420c2f4..8ed7de89 100644 --- a/public/download.php +++ b/public/download.php @@ -88,7 +88,7 @@ $trackerSchemaAndHost = get_tracker_schema_and_host(); $ssl_torrent = $trackerSchemaAndHost['ssl_torrent']; $base_announce_url = $trackerSchemaAndHost['base_announce_url']; -$res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, categories.mode as search_box_id FROM torrents left join categories on torrents.category = categories.id WHERE torrents.id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__); +$res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, torrents.approval_status, categories.mode as search_box_id FROM torrents left join categories on torrents.category = categories.id WHERE torrents.id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__); $row = mysql_fetch_assoc($res); if (!$row) { do_log("[TORRENT_NOT_EXISTS_IN_DATABASE] $id", 'error'); @@ -107,7 +107,8 @@ if (filesize($fn) == 0) { do_log("[TORRENT_NOT_VALID_SIZE_ZERO] $fn",'error'); httperr(); } -if (($row['banned'] == 'yes' && get_user_class() < $seebanned_class) || !can_access_torrent($row)) { +$approvalNotAllowed = $row['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no'; +if ((($row['banned'] == 'yes' || $approvalNotAllowed) && get_user_class() < $seebanned_class) || !can_access_torrent($row)) { denyDownload(); } diff --git a/public/getusertorrentlistajax.php b/public/getusertorrentlistajax.php index 0097a9d4..d695c12c 100644 --- a/public/getusertorrentlistajax.php +++ b/public/getusertorrentlistajax.php @@ -8,9 +8,13 @@ header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); //header("Content-Type: text/xml; charset=utf-8"); + +$torrentRep = new \App\Repositories\TorrentRepository(); + function maketable($res, $mode = 'seeding') { global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions; + global $torrentRep; switch ($mode) { case 'uploaded': { @@ -107,6 +111,7 @@ function maketable($res, $mode = 'seeding') } $hrImg = get_hr_img($arr); + $approvalStatusIcon = $torrentRep->renderApprovalStatus($arr["approval_status"]); //torrent name $dispname = $nametitle = htmlspecialchars($arr["torrentname"]); $count_dispname=mb_strlen($dispname,"UTF-8"); @@ -125,7 +130,7 @@ function maketable($res, $mode = 'seeding') } else $dissmall_descr == ""; $ret .= "".return_category_image($arr['category'], "torrents.php?allsec=1&")."\n" . - "" . $dispname . "". $banned_torrent . $sp_torrent . $hrImg .($dissmall_descr == "" ? "" : "
" . $dissmall_descr) . ""; + "" . $dispname . "". $banned_torrent . $sp_torrent . $hrImg . $approvalStatusIcon .($dissmall_descr == "" ? "" : "
" . $dissmall_descr) . ""; //size if ($showsize) $ret .= "". mksize_compact($arr['size']).""; @@ -184,7 +189,7 @@ switch ($type) { case 'uploaded': { - $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__); + $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__); $count = mysql_num_rows($res); if ($count > 0) { @@ -196,7 +201,7 @@ switch ($type) // Current Seeding case 'seeding': { - $res = sql_query("SELECT torrent,added,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes' ORDER BY torrents.added DESC") or sqlerr(); + $res = sql_query("SELECT torrent,added,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='yes' ORDER BY torrents.added DESC") or sqlerr(); $count = mysql_num_rows($res); if ($count > 0){ list($torrentlist, $total_size) = maketable ( $res, 'seeding' ); @@ -207,7 +212,7 @@ switch ($type) // Current Leeching case 'leeching': { - $res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.added DESC") or sqlerr(); + $res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.added DESC") or sqlerr(); $count = mysql_num_rows($res); if ($count > 0){ list($torrentlist, $total_size) = maketable ( $res, 'leeching' ); @@ -218,7 +223,7 @@ switch ($type) // Completed torrents case 'completed': { - $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, categories.name AS catname, torrents.banned, categories.image, category, sp_state, size, torrents.hr,snatched.uploaded, snatched.seedtime, snatched.leechtime, snatched.completedat FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='yes' AND torrents.owner != $id AND userid=$id ORDER BY snatched.completedat DESC") or sqlerr(); + $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, categories.name AS catname, torrents.banned, torrents.approval_status, categories.image, category, sp_state, size, torrents.hr,snatched.uploaded, snatched.seedtime, snatched.leechtime, snatched.completedat FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='yes' AND torrents.owner != $id AND userid=$id ORDER BY snatched.completedat DESC") or sqlerr(); $count = mysql_num_rows($res); if ($count > 0) { @@ -230,7 +235,7 @@ switch ($type) // Incomplete torrents case 'incomplete': { - $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.startdat DESC") or sqlerr(); + $res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.startdat DESC") or sqlerr(); $count = mysql_num_rows($res); if ($count > 0) { diff --git a/public/settings.php b/public/settings.php index 46da55ca..73ed10d3 100644 --- a/public/settings.php +++ b/public/settings.php @@ -151,7 +151,7 @@ elseif($action == 'savesettings_torrent') // save account 'twoupbecome','twoupfreebecome', 'twouphalfleechbecome','normalbecome','uploaderdouble','deldeadtorrent', 'randomthirtypercentdown', 'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color', 'download_support_passkey', 'claim_enabled', 'claim_torrent_ttl', 'claim_torrent_user_counts_up_limit', 'claim_user_torrent_counts_up_limit', 'claim_remove_deduct_user_bonus', - 'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded', 'approval_status_icon_enabled' + 'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded', 'approval_status_icon_enabled', 'approval_status_none_visible' ); $validConfig = apply_filter('setting_valid_config', $validConfig); GetVar($validConfig); @@ -661,6 +661,7 @@ elseif ($action == 'torrentsettings') tr($lang_settings['row_sticky_second_level_background_color']," ".$lang_settings['text_sticky_second_level_background_color_note'], 1); yesorno($lang_settings['row_download_support_passkey'], 'download_support_passkey', $TORRENT["download_support_passkey"], $lang_settings['text_download_support_passkey_note']); yesorno($lang_settings['row_approval_status_icon_enabled'], 'approval_status_icon_enabled', $TORRENT["approval_status_icon_enabled"], $lang_settings['text_approval_status_icon_enabled_note']); + yesorno($lang_settings['row_approval_status_none_visible'], 'approval_status_none_visible', $TORRENT["approval_status_none_visible"], $lang_settings['text_approval_status_none_visible_note']); yesorno($lang_settings['row_promotion_rules'], 'prorules', $TORRENT["prorules"], $lang_settings['text_promotion_rules_note']); tr($lang_settings['row_random_promotion'], $lang_settings['text_random_promotion_note_one']."".$lang_settings['text_random_promotion_note_two'], 1); tr($lang_settings['row_large_torrent_promotion'], $lang_settings['text_torrent_larger_than']."".$lang_settings['text_gb_promoted_to']."".$lang_settings['text_by_system_upon_uploading']."
".$lang_settings['text_large_torrent_promotion_note'], 1); diff --git a/public/torrentrss.php b/public/torrentrss.php index dd837404..ef56be14 100644 --- a/public/torrentrss.php +++ b/public/torrentrss.php @@ -77,6 +77,13 @@ if($showrows < 1 || $showrows > 50) $showrows = 10; $limit .= $showrows; +$where = ''; +//approval status +$approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible'); +if ($approvalStatusNoneVisible == 'no' && get_user_class() < $staffmem_class) { + $where = "torrents.approval_status = " . \App\Models\Torrent::APPROVAL_STATUS_ALLOW; +} + function get_where($tablename = "sources", $itemname = "source", $getname = "sou") { global $where; diff --git a/public/torrents.php b/public/torrents.php index df650f3a..2ca88545 100644 --- a/public/torrents.php +++ b/public/torrents.php @@ -806,6 +806,12 @@ if (isset($searchstr)) $addparam .= "search_mode=".$search_mode."&"; } +//approval status +$approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible'); +if ($approvalStatusNoneVisible == 'no' && get_user_class() < $staffmem_class) { + $wherea[] = "torrents.approval_status = " . \App\Models\Torrent::APPROVAL_STATUS_ALLOW; +} + $where = implode(" AND ", $wherea); if ($wherecatin) diff --git a/resources/lang/en/torrent.php b/resources/lang/en/torrent.php index d5d1c216..86359f17 100644 --- a/resources/lang/en/torrent.php +++ b/resources/lang/en/torrent.php @@ -68,10 +68,10 @@ return [ 'status_label' => 'Approval status', 'comment_label' => 'Comment(optional)', 'status_text' => [ - \App\Models\Torrent::APPROVAL_STATUS_NONE => 'None', - \App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Allow', - \App\Models\Torrent::APPROVAL_STATUS_DENY => 'Deny', + \App\Models\Torrent::APPROVAL_STATUS_NONE => 'Not reviewed', + \App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Review approved', + \App\Models\Torrent::APPROVAL_STATUS_DENY => 'Review not approved', ], - 'deny_comment_show' => 'Denied, reason: reason', + 'deny_comment_show' => 'Denied, reason: :reason', ], ];