From 3c64e76011a3197eda2475f2a781d0611415e818 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sat, 11 Feb 2023 16:08:48 +0800 Subject: [PATCH] paid torrent --- .../Resources/User/TorrentBuyLogResource.php | 111 ++++++++++++++ .../Pages/CreateTorrentBuyLog.php | 12 ++ .../Pages/EditTorrentBuyLog.php | 19 +++ .../Pages/ListTorrentBuyLogs.php | 27 ++++ app/Filament/Widgets/LatestTorrents.php | 10 +- app/Filament/Widgets/LatestUsers.php | 5 +- app/Models/BonusLogs.php | 4 + app/Models/Torrent.php | 6 +- app/Models/TorrentBuyLog.php | 23 +++ app/Repositories/BonusRepository.php | 53 +++++++ app/Repositories/TorrentRepository.php | 8 ++ ..._11_024403_add_price_to_torrents_table.php | 32 +++++ ...1_042230_create_torrent_buy_logs_table.php | 35 +++++ include/cleanup.php | 136 +++++++++--------- include/constants.php | 2 +- include/functions.php | 7 +- lang/chs/lang_details.php | 2 + lang/chs/lang_getrss.php | 4 + lang/chs/lang_settings.php | 2 + lang/cht/lang_details.php | 2 + lang/cht/lang_getrss.php | 4 + lang/cht/lang_settings.php | 2 + lang/en/lang_details.php | 2 + lang/en/lang_getrss.php | 4 + lang/en/lang_settings.php | 2 + nexus/Install/settings.default.php | 2 + public/announce.php | 8 +- public/details.php | 17 ++- public/download.php | 14 +- public/edit.php | 8 +- public/getrss.php | 12 ++ public/settings.php | 7 +- public/takeedit.php | 7 + public/takeupload.php | 3 + public/torrentrss.php | 11 ++ public/upload.php | 5 + resources/lang/en/admin.php | 3 +- resources/lang/en/bonus-log.php | 2 + resources/lang/en/bonus.php | 3 + resources/lang/en/permission.php | 4 + resources/lang/zh_CN/admin.php | 1 + resources/lang/zh_CN/bonus-log.php | 2 + resources/lang/zh_CN/bonus.php | 3 + resources/lang/zh_CN/label.php | 2 + resources/lang/zh_CN/permission.php | 4 + resources/lang/zh_CN/torrent.php | 1 + resources/lang/zh_TW/admin.php | 1 + resources/lang/zh_TW/bonus-log.php | 2 + resources/lang/zh_TW/bonus.php | 3 + resources/lang/zh_TW/permission.php | 4 + 50 files changed, 556 insertions(+), 87 deletions(-) create mode 100644 app/Filament/Resources/User/TorrentBuyLogResource.php create mode 100644 app/Filament/Resources/User/TorrentBuyLogResource/Pages/CreateTorrentBuyLog.php create mode 100644 app/Filament/Resources/User/TorrentBuyLogResource/Pages/EditTorrentBuyLog.php create mode 100644 app/Filament/Resources/User/TorrentBuyLogResource/Pages/ListTorrentBuyLogs.php create mode 100644 app/Models/TorrentBuyLog.php create mode 100644 database/migrations/2023_02_11_024403_add_price_to_torrents_table.php create mode 100644 database/migrations/2023_02_11_042230_create_torrent_buy_logs_table.php diff --git a/app/Filament/Resources/User/TorrentBuyLogResource.php b/app/Filament/Resources/User/TorrentBuyLogResource.php new file mode 100644 index 00000000..d4ffcaf0 --- /dev/null +++ b/app/Filament/Resources/User/TorrentBuyLogResource.php @@ -0,0 +1,111 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id')->sortable(), + Tables\Columns\TextColumn::make('uid') + ->formatStateUsing(fn ($state) => username_for_admin($state)) + ->label(__('label.username')) + , + Tables\Columns\TextColumn::make('torrent_id') + ->formatStateUsing(fn ($record) => torrent_name_for_admin($record->torrent)) + ->label(__('label.torrent.label')) + , + Tables\Columns\TextColumn::make('price') + ->formatStateUsing(fn ($state) => number_format($state)) + ->label(__('label.price')) + , + Tables\Columns\TextColumn::make('created_at') + ->formatStateUsing(fn ($state) => format_datetime($state)) + ->label(__('label.created_at')) + , + ]) + ->filters([ + Tables\Filters\Filter::make('uid') + ->form([ + Forms\Components\TextInput::make('uid') + ->label(__('label.username')) + ->placeholder('UID') + , + ])->query(function (Builder $query, array $data) { + return $query->when($data['uid'], fn (Builder $query, $value) => $query->where("uid", $value)); + }) + , + Tables\Filters\Filter::make('torrent_id') + ->form([ + Forms\Components\TextInput::make('torrent_id') + ->label(__('label.torrent.label')) + ->placeholder('Torrent ID') + , + ])->query(function (Builder $query, array $data) { + return $query->when($data['torrent_id'], fn (Builder $query, $value) => $query->where("torrent_id", $value)); + }) + , + ]) + ->actions([ +// Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ +// Tables\Actions\DeleteBulkAction::make(), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListTorrentBuyLogs::route('/'), + 'create' => Pages\CreateTorrentBuyLog::route('/create'), + 'edit' => Pages\EditTorrentBuyLog::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/User/TorrentBuyLogResource/Pages/CreateTorrentBuyLog.php b/app/Filament/Resources/User/TorrentBuyLogResource/Pages/CreateTorrentBuyLog.php new file mode 100644 index 00000000..6317547a --- /dev/null +++ b/app/Filament/Resources/User/TorrentBuyLogResource/Pages/CreateTorrentBuyLog.php @@ -0,0 +1,12 @@ +with(['user', 'torrent']); + } +} diff --git a/app/Filament/Widgets/LatestTorrents.php b/app/Filament/Widgets/LatestTorrents.php index af5f8d54..305bc347 100644 --- a/app/Filament/Widgets/LatestTorrents.php +++ b/app/Filament/Widgets/LatestTorrents.php @@ -30,8 +30,14 @@ class LatestTorrents extends BaseWidget protected function getTableColumns(): array { return [ - Tables\Columns\TextColumn::make('name')->limit(30)->label(__('label.name')), - Tables\Columns\TextColumn::make('user.username')->label(__('label.torrent.owner')), + Tables\Columns\TextColumn::make('name') + ->label(__('label.name')) + ->formatStateUsing(fn ($record) => torrent_name_for_admin($record, false, 30)) + , + Tables\Columns\TextColumn::make('owner') + ->label(__('label.torrent.owner')) + ->formatStateUsing(fn ($state) => username_for_admin($state)) + , Tables\Columns\TextColumn::make('size')->formatStateUsing(fn ($state) => mksize($state))->label(__('label.torrent.size')), Tables\Columns\TextColumn::make('added')->dateTime()->label(__('label.added')), ]; diff --git a/app/Filament/Widgets/LatestUsers.php b/app/Filament/Widgets/LatestUsers.php index 683288c9..715fb609 100644 --- a/app/Filament/Widgets/LatestUsers.php +++ b/app/Filament/Widgets/LatestUsers.php @@ -30,7 +30,10 @@ class LatestUsers extends BaseWidget protected function getTableColumns(): array { return [ - Tables\Columns\TextColumn::make('username')->label(__('label.user.username')), + Tables\Columns\TextColumn::make('id') + ->label(__('label.user.username')) + ->formatStateUsing(fn ($state) => username_for_admin($state)) + , Tables\Columns\TextColumn::make('email')->label(__('label.email')), Tables\Columns\BadgeColumn::make('status')->colors(['success' => 'confirmed', 'danger' => 'pending'])->label(__('label.status')), Tables\Columns\TextColumn::make('added')->dateTime()->label(__('label.added')), diff --git a/app/Models/BonusLogs.php b/app/Models/BonusLogs.php index bdc2a91b..22b69f6d 100644 --- a/app/Models/BonusLogs.php +++ b/app/Models/BonusLogs.php @@ -35,8 +35,10 @@ class BonusLogs extends NexusModel const BUSINESS_TYPE_BUY_RAINBOW_ID = 16; const BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD = 17; const BUSINESS_TYPE_GIFT_MEDAL = 18; + const BUSINESS_TYPE_BUY_TORRENT = 19; const BUSINESS_TYPE_ROLE_WORK_SALARY = 1000; + const BUSINESS_TYPE_TORRENT_BE_DOWNLOADED = 1001; public static array $businessTypes = [ self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'], @@ -57,8 +59,10 @@ class BonusLogs extends NexusModel self::BUSINESS_TYPE_BUY_RAINBOW_ID => ['text' => 'Buy rainbow ID'], self::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => ['text' => 'Buy change username card'], self::BUSINESS_TYPE_GIFT_MEDAL => ['text' => 'Gift medal to someone'], + self::BUSINESS_TYPE_BUY_TORRENT => ['text' => 'Buy torrent'], self::BUSINESS_TYPE_ROLE_WORK_SALARY => ['text' => 'Role work salary'], + self::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => ['text' => 'Torrent be downloaded'], ]; public function getBusinessTypeTextAttribute() diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index 95f7e5ca..89d7dafc 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -14,7 +14,7 @@ class Torrent extends NexusModel 'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type', 'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime', 'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover', 'last_action', - 'times_completed', 'approval_status', 'banned', 'visible', 'pos_state_until', + 'times_completed', 'approval_status', 'banned', 'visible', 'pos_state_until', 'price', ]; const VISIBLE_YES = 'yes'; @@ -33,7 +33,7 @@ class Torrent extends NexusModel public static $commentFields = [ 'id', 'name', 'added', 'visible', 'banned', 'owner', 'sp_state', 'pos_state', 'hr', 'picktype', 'picktime', 'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size', 'cover', 'anonymous', 'approval_status', - 'pos_state_until', 'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec', + 'pos_state_until', 'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec', 'price' ]; public static $basicRelations = [ @@ -240,7 +240,7 @@ class Torrent extends NexusModel public static function getFieldsForList($appendTableName = false): array|bool { - $fields = 'id, sp_state, promotion_time_type, promotion_until, banned, picktype, pos_state, category, source, medium, codec, standard, processing, team, audiocodec, leechers, seeders, name, small_descr, times_completed, size, added, comments,anonymous,owner,url,cache_stamp, pt_gen, hr, approval_status, cover'; + $fields = 'id, sp_state, promotion_time_type, promotion_until, banned, picktype, pos_state, category, source, medium, codec, standard, processing, team, audiocodec, leechers, seeders, name, small_descr, times_completed, size, added, comments,anonymous,owner,url,cache_stamp, pt_gen, hr, approval_status, cover, price'; $fields = preg_split('/[,\s]+/', $fields); if ($appendTableName) { foreach ($fields as &$value) { diff --git a/app/Models/TorrentBuyLog.php b/app/Models/TorrentBuyLog.php new file mode 100644 index 00000000..d8e54c17 --- /dev/null +++ b/app/Models/TorrentBuyLog.php @@ -0,0 +1,23 @@ +belongsTo(User::class, 'uid'); + } + + public function torrent() + { + return $this->belongsTo(Torrent::class, 'torrent_id'); + } + +} diff --git a/app/Repositories/BonusRepository.php b/app/Repositories/BonusRepository.php index 32006f6f..dcb729ff 100644 --- a/app/Repositories/BonusRepository.php +++ b/app/Repositories/BonusRepository.php @@ -8,6 +8,8 @@ use App\Models\Invite; use App\Models\Medal; use App\Models\Message; use App\Models\Setting; +use App\Models\Torrent; +use App\Models\TorrentBuyLog; use App\Models\User; use App\Models\UserMedal; use App\Models\UserMeta; @@ -250,6 +252,57 @@ class BonusRepository extends BaseRepository } + public function consumeToBuyTorrent($uid, $torrentId, $channel = 'Web'): bool + { + $user = User::query()->findOrFail($uid); + $torrent = Torrent::query()->findOrFail($torrentId, Torrent::$commentFields); + $requireBonus = $torrent->price; + NexusDB::transaction(function () use ($user, $requireBonus, $torrent, $channel) { + $comment = nexus_trans('bonus.comment_buy_torrent', [ + 'bonus' => $requireBonus, + 'torrent_id' => $torrent->id, + ], $user->locale); + do_log("comment: $comment"); + $this->consumeUserBonus($user, $requireBonus, BonusLogs::BUSINESS_TYPE_BUY_TORRENT, $comment); + TorrentBuyLog::query()->create([ + 'uid' => $user->id, + 'torrent_id' => $torrent->id, + 'price' => $requireBonus, + 'channel' => $channel, + ]); + //increment owner bonus + $taxFactor = Setting::get('torrent.tax_factor'); + if (!is_numeric($taxFactor) || $taxFactor < 0 || $taxFactor > 1) { + throw new \RuntimeException("Invalid tax_factor: $taxFactor"); + } + $increaseBonus = $requireBonus * (1 - $taxFactor); + $owner = $torrent->user; + if ($owner->id) { + $nowStr = now()->toDateTimeString(); + $businessType = BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED; + $owner->increment('seedbonus', $increaseBonus); + $comment = nexus_trans('bonus.comment_torrent_be_downloaded', [ + 'username' => $user->username, + 'uid' => $user->id, + ], $owner->locale); + $bonusLog = [ + 'business_type' => $businessType, + 'uid' => $owner->id, + 'old_total_value' => $owner->seedbonus, + 'value' => $increaseBonus, + 'new_total_value' => bcadd($owner->seedbonus, $increaseBonus), + 'comment' => sprintf('[%s] %s', BonusLogs::$businessTypes[$businessType]['text'], $comment), + 'created_at' => $nowStr, + 'updated_at' => $nowStr, + ]; + BonusLogs::query()->insert($bonusLog); + } + }); + + return true; + + } + public function consumeUserBonus($user, $requireBonus, $logBusinessType, $logComment = '', array $userUpdates = []) { if (!isset(BonusLogs::$businessTypes[$logBusinessType])) { diff --git a/app/Repositories/TorrentRepository.php b/app/Repositories/TorrentRepository.php index d4f189d3..9dc21baa 100644 --- a/app/Repositories/TorrentRepository.php +++ b/app/Repositories/TorrentRepository.php @@ -711,4 +711,12 @@ HTML; } } + public function getPaidIcon(array $torrentInfo, $size = 16, $verticalAlign = 'sub') + { + if (!isset($torrentInfo['price']) || $torrentInfo['price'] <= 0) { + return ''; + } + return sprintf('', nexus_trans('torrent.paid_torrent'), $verticalAlign, $size, $size); + } + } diff --git a/database/migrations/2023_02_11_024403_add_price_to_torrents_table.php b/database/migrations/2023_02_11_024403_add_price_to_torrents_table.php new file mode 100644 index 00000000..1808e635 --- /dev/null +++ b/database/migrations/2023_02_11_024403_add_price_to_torrents_table.php @@ -0,0 +1,32 @@ +integer('price')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('torrents', function (Blueprint $table) { + $table->dropColumn('price'); + }); + } +}; diff --git a/database/migrations/2023_02_11_042230_create_torrent_buy_logs_table.php b/database/migrations/2023_02_11_042230_create_torrent_buy_logs_table.php new file mode 100644 index 00000000..5ebc2bab --- /dev/null +++ b/database/migrations/2023_02_11_042230_create_torrent_buy_logs_table.php @@ -0,0 +1,35 @@ +id(); + $table->integer('uid')->index(); + $table->integer('torrent_id')->index(); + $table->integer('price')->index(); + $table->string('channel'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('torrent_buy_logs'); + } +}; diff --git a/include/cleanup.php b/include/cleanup.php index 2e519821..8d397be0 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -1045,74 +1045,74 @@ function docleanup($forceAll = 0, $printProgress = false) { } //1.delete torrents that doesn't exist any more - do { - $res = sql_query("SELECT id FROM torrents") or sqlerr(__FILE__, __LINE__); - $ar = array(); - while ($row = mysql_fetch_array($res)) { - $id = $row[0]; - $ar[$id] = 1; - } - - if (!count($ar)) - break; - - $dp = @opendir($torrent_dir); - if (!$dp) - break; - - $ar2 = array(); - while (($file = readdir($dp)) !== false) { - if (!preg_match('/^(\d+)\.torrent$/', $file, $m)) - continue; - $id = $m[1]; - $ar2[$id] = 1; - if (isset($ar[$id]) && $ar[$id]) - continue; - $ff = $torrent_dir . "/$file"; - unlink($ff); - } - closedir($dp); - - if (!count($ar2)) - break; - - $delids = array(); - foreach (array_keys($ar) as $k) { - if (isset($ar2[$k]) && $ar2[$k]) - continue; - $delids[] = $k; - unset($ar[$k]); - } - if (count($delids)) - sql_query("DELETE FROM torrents WHERE id IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__); - - $res = sql_query("SELECT torrent FROM peers GROUP BY torrent") or sqlerr(__FILE__, __LINE__); - $delids = array(); - while ($row = mysql_fetch_array($res)) { - $id = $row[0]; - if (isset($ar[$id]) && $ar[$id]) - continue; - $delids[] = $id; - } - if (count($delids)) - sql_query("DELETE FROM peers WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__); - - $res = sql_query("SELECT torrent FROM files GROUP BY torrent") or sqlerr(__FILE__, __LINE__); - $delids = array(); - while ($row = mysql_fetch_array($res)) { - $id = $row[0]; - if ($ar[$id]) - continue; - $delids[] = $id; - } - if (count($delids)) - sql_query("DELETE FROM files WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__); - } while (0); - $log = "delete torrents that doesn't exist any more"; - do_log($log); - if ($printProgress) { - printProgress($log); - } +// do { +// $res = sql_query("SELECT id FROM torrents") or sqlerr(__FILE__, __LINE__); +// $ar = array(); +// while ($row = mysql_fetch_array($res)) { +// $id = $row[0]; +// $ar[$id] = 1; +// } +// +// if (!count($ar)) +// break; +// +// $dp = @opendir($torrent_dir); +// if (!$dp) +// break; +// +// $ar2 = array(); +// while (($file = readdir($dp)) !== false) { +// if (!preg_match('/^(\d+)\.torrent$/', $file, $m)) +// continue; +// $id = $m[1]; +// $ar2[$id] = 1; +// if (isset($ar[$id]) && $ar[$id]) +// continue; +// $ff = $torrent_dir . "/$file"; +// unlink($ff); +// } +// closedir($dp); +// +// if (!count($ar2)) +// break; +// +// $delids = array(); +// foreach (array_keys($ar) as $k) { +// if (isset($ar2[$k]) && $ar2[$k]) +// continue; +// $delids[] = $k; +// unset($ar[$k]); +// } +// if (count($delids)) +// sql_query("DELETE FROM torrents WHERE id IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__); +// +// $res = sql_query("SELECT torrent FROM peers GROUP BY torrent") or sqlerr(__FILE__, __LINE__); +// $delids = array(); +// while ($row = mysql_fetch_array($res)) { +// $id = $row[0]; +// if (isset($ar[$id]) && $ar[$id]) +// continue; +// $delids[] = $id; +// } +// if (count($delids)) +// sql_query("DELETE FROM peers WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__); +// +// $res = sql_query("SELECT torrent FROM files GROUP BY torrent") or sqlerr(__FILE__, __LINE__); +// $delids = array(); +// while ($row = mysql_fetch_array($res)) { +// $id = $row[0]; +// if ($ar[$id]) +// continue; +// $delids[] = $id; +// } +// if (count($delids)) +// sql_query("DELETE FROM files WHERE torrent IN (" . join(",", $delids) . ")") or sqlerr(__FILE__, __LINE__); +// } while (0); +// $log = "delete torrents that doesn't exist any more"; +// do_log($log); +// if ($printProgress) { +// printProgress($log); +// } //8.lock topics where last post was made more than x days ago $secs = 365*24*60*60; diff --git a/include/constants.php b/include/constants.php index 9453d93e..595b5004 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ getPaidIcon($row); + $titleSuffix = $banned_torrent.$paidIcon.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $seedBoxIcon . $approvalStatusIcon; $titleSuffix = apply_filter('torrent_title_suffix', $titleSuffix, $row); print($titleSuffix); //$tags = torrentTags($row['tags'], 'span'); @@ -6385,14 +6386,14 @@ function build_search_area($searchArea, array $options = []) return $result; } -function torrent_name_for_admin(\App\Models\Torrent|null $torrent, $withTags = false) +function torrent_name_for_admin(\App\Models\Torrent|null $torrent, $withTags = false, $length = 40) { if (empty($torrent)) { return ''; } $name = sprintf( '
%s
', - $torrent->id, $torrent->name, Str::limit($torrent->name, 40) + $torrent->id, $torrent->name, Str::limit($torrent->name, $length) ); $tags = ''; if ($withTags) { diff --git a/lang/chs/lang_details.php b/lang/chs/lang_details.php index e9d12c43..a89ed755 100644 --- a/lang/chs/lang_details.php +++ b/lang/chs/lang_details.php @@ -123,6 +123,8 @@ $lang_details = array 'text_hide_list' => "[隐藏列表]", 'row_action' => "行为", 'text_download_torrent' => "下载种子", + 'text_download_paid_torrent' => "下载种子(扣除魔力:%s)", + 'text_download_bought_torrent' => "下载种子(已购买)", 'title_download_torrent' => "下载种子", 'text_ask_for_reseed' => "请求续种", 'title_ask_for_reseed' => "当没有种子时请求完成者续种", diff --git a/lang/chs/lang_getrss.php b/lang/chs/lang_getrss.php index 3e482004..d030750f 100644 --- a/lang/chs/lang_getrss.php +++ b/lang/chs/lang_getrss.php @@ -41,6 +41,10 @@ $lang_getrss = array 'text_mode' => "", 'text_keyword_note' => "只订阅标题中包含此关键字的项目", 'row_sticky' => '置顶', + 'row_paid' => '收费', + 'paid_no' => '免费', + 'paid_yes' => '收费', + 'paid_all' => '全部', ); ?> diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index 89091f27..da328edf 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -807,6 +807,8 @@ $lang_settings = array 'text_buy_change_username_card_note' => "个魔力值,如果他选择交换一个改名卡,永久有效。默认'100,000'。", 'row_initial_tmp_invites' => '初始临时邀请名额', 'text_initial_tmp_invites_note' => "新注册用户的初始临时邀请名额,有效期 7 天。默认'0'。", + 'row_tax_factor' => '收费种子收税系数', + 'text_tax_factor_note' => '假如价格100, 此系数为 0.1,发布者实际收入为 100 - 100 x 0.1 = 90,注意不要大于 1 或小于 0。', ); ?> diff --git a/lang/cht/lang_details.php b/lang/cht/lang_details.php index 30a723fe..39645109 100644 --- a/lang/cht/lang_details.php +++ b/lang/cht/lang_details.php @@ -123,6 +123,8 @@ $lang_details = array 'text_hide_list' => "[隱藏清單]", 'row_action' => "行為", 'text_download_torrent' => "下載種子", + 'text_download_paid_torrent' => "下載種子(扣除魔力:%s)", + 'text_download_bought_torrent' => "下載種子(已購買)", 'title_download_torrent' => "下載種子", 'text_ask_for_reseed' => "要求續種", 'title_ask_for_reseed' => "當沒有種子時要求完成者續種", diff --git a/lang/cht/lang_getrss.php b/lang/cht/lang_getrss.php index e90d51a2..0ce8ef76 100644 --- a/lang/cht/lang_getrss.php +++ b/lang/cht/lang_getrss.php @@ -42,6 +42,10 @@ $lang_getrss = array 'text_mode' => "", 'text_keyword_note' => "只訂閱標題中包含此關鍵字的項目", 'row_sticky' => '置頂', + 'row_paid' => '收費', + 'paid_no' => '免費', + 'paid_yes' => '收費', + 'paid_all' => '全部', ); ?> diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index cb62a8e9..fcce624c 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -807,6 +807,8 @@ $lang_settings = array 'text_buy_change_username_card_note' => "個魔力值,如果他選擇交換一個改名卡,永久有效。默認'100,000'。", 'row_initial_tmp_invites' => '初始臨時邀請名額', 'text_initial_tmp_invites_note' => "新註冊用戶的初始臨時邀請名額,有效期 7 天。默認'0'。", + 'row_tax_factor' => '收費種子收稅系數', + 'text_tax_factor_note' => '假如價格100, 此系數為 0.1,發布者實際收入為 100 - 100 x 0.1 = 90,註意不要大於 1 或小於 0。', ); ?> diff --git a/lang/en/lang_details.php b/lang/en/lang_details.php index 7a193e4e..e961f2f6 100644 --- a/lang/en/lang_details.php +++ b/lang/en/lang_details.php @@ -122,6 +122,8 @@ $lang_details = array 'text_hide_list' => "[Hide list]", 'row_action' => "Action", 'text_download_torrent' => "Download torrent", + 'text_download_paid_torrent' => "Download torrent(deduct bonus: %s)", + 'text_download_bought_torrent' => "Download torrent(bought)", 'title_download_torrent' => "Download torrent", 'text_ask_for_reseed' => "Ask for a reseed", 'title_ask_for_reseed' => "Ask snatched users for reseeding when there's no seeder", diff --git a/lang/en/lang_getrss.php b/lang/en/lang_getrss.php index b53a6f44..26b20289 100644 --- a/lang/en/lang_getrss.php +++ b/lang/en/lang_getrss.php @@ -41,6 +41,10 @@ $lang_getrss = array 'text_mode' => "matching mode ", 'text_keyword_note' => "Ony subscribe to items with these keywords in titles.", 'row_sticky' => 'Sticky', + 'row_paid' => 'Paid', + 'paid_no' => 'Free', + 'paid_yes' => 'Paid', + 'paid_all' => 'All', ); ?> diff --git a/lang/en/lang_settings.php b/lang/en/lang_settings.php index 7725b464..e05104eb 100644 --- a/lang/en/lang_settings.php +++ b/lang/en/lang_settings.php @@ -807,6 +807,8 @@ $lang_settings = array 'text_buy_change_username_card_note' => " bonus points to get a Change username card, valid forever. Default '100,000'.", 'row_initial_tmp_invites' => "Initial Number of Temporary Invites", 'text_initial_tmp_invites_note' => "How many temporary invites should each user be given upon registration? Default '0'.", + 'row_tax_factor' => 'Tax factor for paid torrents', + 'text_tax_factor_note' => 'If the price is 100, this factor is 0.1 and the actual revenue of the uploader is 100 - 100 x 0.1 = 90, note that it should not be greater than 1 or less than 0.', ); ?> diff --git a/nexus/Install/settings.default.php b/nexus/Install/settings.default.php index 02782903..7757ab53 100644 --- a/nexus/Install/settings.default.php +++ b/nexus/Install/settings.default.php @@ -184,6 +184,7 @@ return array ( 'user-change-class' => User::CLASS_ADMINISTRATOR, 'torrent-set-special-tag' => User::CLASS_ADMINISTRATOR, 'torrent-approval-allow-automatic' => User::CLASS_UPLOADER, + 'torrent-set-price' => User::CLASS_UPLOADER, ), 'tweak' => array ( @@ -356,6 +357,7 @@ return array ( 'approval_status_icon_enabled' => 'no', 'approval_status_none_visible' => 'yes', 'nfo_view_style_default' => \App\Models\Torrent::NFO_VIEW_STYLE_DOS, + 'tax_factor' => '0.3', ), 'attachment' => array ( diff --git a/public/announce.php b/public/announce.php index b5ead9b2..124c958d 100644 --- a/public/announce.php +++ b/public/announce.php @@ -126,7 +126,7 @@ elseif ($az['showclienterror'] == 'yes'){ } // check torrent based on info_hash -$checkTorrentSql = "SELECT torrents.id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, added, banned, hr, approval_status, categories.mode FROM torrents left join categories on torrents.category = categories.id WHERE " . hash_where("info_hash", $info_hash); +$checkTorrentSql = "SELECT torrents.id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, added, banned, hr, approval_status, price, categories.mode FROM torrents left join categories on torrents.category = categories.id 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); @@ -152,6 +152,12 @@ if ($torrent['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && err("torrent review not approved"); } } +if (isset($torrent['price']) && $torrent['price'] > 0 && $torrent['owner'] != $userid) { + $hasBuy = \App\Models\TorrentBuyLog::query()->where('uid', $userid)->where('torrent_id', $torrent['id'])->exists(); + if (!$hasBuy) { + err("You have not buy the torrent yet"); + } +} // select peers info from peers table for this torrent $torrentid = $torrent["id"]; diff --git a/public/details.php b/public/details.php index 4f0aab5d..1a759a5c 100644 --- a/public/details.php +++ b/public/details.php @@ -11,7 +11,7 @@ if (!isset($id) || !$id) die(); $taxonomyFields = "sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, teams.name AS team_name, audiocodecs.name AS audiocodec_name"; -$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type, torrents.approval_status, +$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type, torrents.approval_status, torrents.price, categories.name AS cat_name, categories.mode as search_box_id, $taxonomyFields FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN sources ON torrents.source = sources.id @@ -74,7 +74,8 @@ if (!$row) { $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, $row['search_box_id']); $approvalStatusIcon = $torrentRep->renderApprovalStatus($row["approval_status"]); - $s=htmlspecialchars($row["name"]).$banned_torrent.($sp_torrent ? "   ".$sp_torrent : "").($sp_torrent_sub) . $hrImg . $approvalStatusIcon; + $paidIcon = $torrentRep->getPaidIcon($row, 20); + $s=htmlspecialchars($row["name"]).$banned_torrent.$paidIcon.($sp_torrent ? "   ".$sp_torrent : "").($sp_torrent_sub) . $hrImg . $approvalStatusIcon; print("

".$s."

\n"); //Banned reason @@ -162,7 +163,17 @@ if (!$row) { tr($lang_details['row_basic_info'], $size_info.$type_info.$taxonomyRendered, 1); $actions = []; if ($CURUSER["downloadpos"] != "no") { - $actions[] = "\"download\" ".$lang_details['text_download_torrent'].""; + $hasBuy = \App\Models\TorrentBuyLog::query()->where('uid', $CURUSER['id'])->where('torrent_id', $id)->exists(); + if ($row['price'] > 0) { + if ($hasBuy) { + $downloadBtn = $lang_details['text_download_bought_torrent']; + } else { + $downloadBtn = sprintf($lang_details['text_download_paid_torrent'], number_format($row['price'])); + } + } else { + $downloadBtn = $lang_details['text_download_torrent']; + } + $actions[] = "\"download\" ".$downloadBtn.""; } if ($owned == 1) { $actions[] = "<$editlink>\"edit\" ".(user_can('torrentmanage') ? $lang_details['text_edit_and_delete_torrent'] : $lang_details['text_edit_torrent']). ""; diff --git a/public/download.php b/public/download.php index 6bdcd046..bdfaa49a 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, 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__); +$res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, torrents.approval_status, torrents.price, 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,6 +107,7 @@ if (filesize($fn) == 0) { do_log("[TORRENT_NOT_VALID_SIZE_ZERO] $fn",'error'); httperr(); } + $approvalNotAllowed = $row['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no'; $allowOwnerDownload = $row['owner'] == $CURUSER['id']; $canSeedBanned = user_can('seebanned'); @@ -116,6 +117,17 @@ if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload)) denyDownload(); } +if ($row['price'] > 0 && $CURUSER['id'] != $row['owner']) { + $hasBuy = \App\Models\TorrentBuyLog::query()->where('uid', $CURUSER['id'])->where('torrent_id', $id)->exists(); + if (!$hasBuy) { + if ($CURUSER['seedbonus'] < $row['price']) { + stderr('Error', nexus_trans('bonus.not_enough', ['require_bonus' => number_format($row['price']), 'now_bonus' => number_format($CURUSER['seedbonus'])])); + } + $bonusRep = new \App\Repositories\BonusRepository(); + $bonusRep->consumeToBuyTorrent($CURUSER['id'], $id, 'Web'); + } +} + sql_query("UPDATE torrents SET hits = hits + 1 WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__); //require_once "include/benc.php"; diff --git a/public/edit.php b/public/edit.php index d7b9dc23..f27f8385 100644 --- a/public/edit.php +++ b/public/edit.php @@ -73,7 +73,13 @@ else { tr($lang_edit['row_nfo_file'], "".$lang_edit['radio_keep_current']. "".$lang_edit['radio_remove']. "".$lang_edit['radio_update']."
", 1); - print("".$lang_edit['row_description']."*"); + + //price + if (user_can('torrent-set-price')) { + tr(nexus_trans('label.torrent.price'), '  ' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1); + } + + print("".$lang_edit['row_description']."*"); textbbcode("edittorrent","descr",($row["descr"]), false, 130, true); print(""); diff --git a/public/getrss.php b/public/getrss.php index 7c3317df..a0ddd55f 100644 --- a/public/getrss.php +++ b/public/getrss.php @@ -163,6 +163,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } if (!empty($_POST['sticky']) && is_array($_POST['sticky'])) { $query[] = "sticky=" . implode(',', $_POST['sticky']); + } + if (isset($_POST['paid'])) { + $query[] = "paid=" . $_POST['paid']; } $inclbookmarked=intval($_POST['inclbookmarked'] ?? 0); if($inclbookmarked) @@ -337,6 +340,15 @@ if (get_setting('main.spsct') == 'yes') { + + + + + + + + + diff --git a/public/settings.php b/public/settings.php index 1e1cf09e..411f2f1a 100644 --- a/public/settings.php +++ b/public/settings.php @@ -158,7 +158,7 @@ elseif($action == 'savesettings_torrent') // save account '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', 'approval_status_none_visible', - 'nfo_view_style_default', + 'nfo_view_style_default', 'tax_factor', ); $validConfig = apply_filter('setting_valid_config', $validConfig); GetVar($validConfig); @@ -225,7 +225,7 @@ elseif ($action == 'savesettings_authority') // save user authority 'torrentstructure','sendinvite','viewhistory','topten','log','confilog','userprofile', 'torrenthistory','prfmanage', 'cruprfmanage', 'uploadsub','delownsub','submanage','updateextinfo', 'viewanonymous','beanonymous','addoffer','offermanage', 'upload','uploadspecial', 'view_special_torrent','movetorrent','chrmanage','viewinvite', 'buyinvite','seebanned','againstoffer','userbar', 'torrent-approval', - 'torrent-delete', 'user-delete', 'user-change-class', 'torrent-set-special-tag', 'torrent-approval-allow-automatic' + 'torrent-delete', 'user-delete', 'user-change-class', 'torrent-set-special-tag', 'torrent-approval-allow-automatic', 'torrent-set-price' ); GetVar($validConfig); $AUTHORITY = []; @@ -459,6 +459,7 @@ elseif ($action == 'authoritysettings') //Authority settings tr(nexus_trans('permission.torrent-set-special-tag.text'), $lang_settings['text_minimum_class'].classlist('torrent-set-special-tag',$maxclass,$AUTHORITY['torrent-set-special-tag'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_ADMINISTRATOR,false,true,true).nexus_trans('permission.torrent-set-special-tag.desc'),1); tr(nexus_trans('permission.torrent-approval.text'), $lang_settings['text_minimum_class'].classlist('torrent-approval',$maxclass,$AUTHORITY['torrent-approval'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_ADMINISTRATOR,false,true,true).nexus_trans('permission.torrent-approval.desc'),1); tr(nexus_trans('permission.torrent-approval-allow-automatic.text'), $lang_settings['text_minimum_class'].classlist('torrent-approval-allow-automatic',$maxclass,$AUTHORITY['torrent-approval-allow-automatic'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_UPLOADER,false,true,true).nexus_trans('permission.torrent-approval-allow-automatic.desc'),1); + tr(nexus_trans('permission.torrent-set-price.text'), $lang_settings['text_minimum_class'].classlist('torrent-set-price',$maxclass,$AUTHORITY['torrent-set-price'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_UPLOADER,false,true,true).nexus_trans('permission.torrent-set-price.desc'),1); tr($lang_settings['row_ask_for_reseed'], $lang_settings['text_minimum_class'].classlist('askreseed',$maxclass,$AUTHORITY['askreseed'],0,true).$lang_settings['text_default'].get_user_class_name(UC_POWER_USER,false,true,true).$lang_settings['text_ask_for_reseed_note'],1); tr($lang_settings['row_view_nfo'], $lang_settings['text_minimum_class'].classlist('viewnfo',$maxclass,$AUTHORITY['viewnfo'],0,true).$lang_settings['text_default'].get_user_class_name(UC_POWER_USER,false,true,true).$lang_settings['text_view_nfo_note'],1); @@ -740,6 +741,8 @@ elseif ($action == 'torrentsettings') } tr($lang_settings['row_' . $name], $nfoViewStyleRadio, 1); + tr($lang_settings['row_tax_factor']," ".$lang_settings['text_tax_factor_note'], 1); + 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/takeedit.php b/public/takeedit.php index 85afc3aa..fd636aa9 100644 --- a/public/takeedit.php +++ b/public/takeedit.php @@ -215,6 +215,13 @@ $updateset[] = "cover = " . sqlesc($cover); if (isset($_POST['hr'][$newcatmode]) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr'][$newcatmode]]) && user_can('torrent_hr')) { $updateset[] = "hr = " . sqlesc($_POST['hr'][$newcatmode]); } +/** + * price + * @since 1.8.0 + */ +if (user_can('torrent-set-price')) { + $updateset[] = "price = " . sqlesc($_POST['price'] ?? 0); +} $sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id"; do_log("[UPDATE_TORRENT]: $sql"); diff --git a/public/takeupload.php b/public/takeupload.php index ed6750ff..bf7aa86c 100644 --- a/public/takeupload.php +++ b/public/takeupload.php @@ -373,6 +373,9 @@ if(user_can('torrentmanage') && ($CURUSER['picker'] == 'yes' || get_user_class() if (user_can('torrent-approval-allow-automatic')) { $insert['approval_status'] = \App\Models\Torrent::APPROVAL_STATUS_ALLOW; } +if (user_can('torrent-set-price')) { + $insert['price'] = $_POST['price'] ?? 0; +} do_log("[INSERT_TORRENT]: " . nexus_json_encode($insert)); $id = \Nexus\Database\NexusDB::insert('torrents', $insert); diff --git a/public/torrentrss.php b/public/torrentrss.php index eeee2b8d..d6f5d12e 100644 --- a/public/torrentrss.php +++ b/public/torrentrss.php @@ -97,6 +97,17 @@ $onlyBrowseSection = get_setting('main.spsct') != 'yes' || !user_can('view_speci if ($onlyBrowseSection) { $where .= ($where ? " AND " : "") . "categories.mode = $browseMode"; } +//check price +if (isset($_GET['paid']) && in_array($_GET['paid'], ['0', '1', '2'], true)) { + $paidFilter = $_GET['paid']; +} else { + $paidFilter = '0'; +} +if ($paidFilter === '0') { + $where .= ($where ? " AND " : "") . "torrents.price = 0"; +} elseif ($paidFilter === '1') { + $where .= ($where ? " AND " : "") . "torrents.price > 0"; +} function get_where($tablename = "sources", $itemname = "source", $getname = "sou") { diff --git a/public/upload.php b/public/upload.php index 984b305a..f3f047de 100644 --- a/public/upload.php +++ b/public/upload.php @@ -73,6 +73,11 @@ stdhead($lang_upload['head_upload']); if ($enablenfo_main=='yes') { tr($lang_upload['row_nfo_file'], "
".$lang_upload['text_only_viewed_by'].get_user_class_name($viewnfo_class,false,true,true).$lang_upload['text_or_above']."", 1); } + //price + if (user_can('torrent-set-price')) { + tr(nexus_trans('label.torrent.price'), '  ' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1); + } + print("".$lang_upload['row_description']."*"); textbbcode("upload","descr", "", false, 130, true); print("\n"); diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index a139a6d4..5b94585d 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -22,7 +22,7 @@ return [ 'download_speed' => 'Download speed', 'isp' => 'ISP', 'menu' => 'Custom menu', - 'username_change_log' => 'Username change log', + 'username_change_log' => 'Username change logs', 'torrent_deny_reason' => 'Deny Reasons', 'roles' => 'Role', 'permissions' => 'Permissions', @@ -36,6 +36,7 @@ return [ 'user_props' => 'User props', 'login_log' => 'Login logs', 'bonus_log' => 'Bonus logs', + 'torrent_buy_log' => 'Torrent buy logs', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/en/bonus-log.php b/resources/lang/en/bonus-log.php index b3997fa4..53ca2d81 100644 --- a/resources/lang/en/bonus-log.php +++ b/resources/lang/en/bonus-log.php @@ -20,8 +20,10 @@ return [ \App\Models\BonusLogs::BUSINESS_TYPE_BUY_RAINBOW_ID => 'Buy rainbow ID', \App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => 'Buy change username card', \App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => 'Gift medal', + \App\Models\BonusLogs::BUSINESS_TYPE_BUY_TORRENT => 'Buy torrent', \App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => 'Role work salary', + \App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => 'Torrent be downloaded', ], 'fields' => [ 'business_type' => 'Business type', diff --git a/resources/lang/en/bonus.php b/resources/lang/en/bonus.php index c939390c..f6e63965 100644 --- a/resources/lang/en/bonus.php +++ b/resources/lang/en/bonus.php @@ -7,6 +7,8 @@ return [ 'comment_buy_rainbow_id' => 'Spend :bonus bonus buy :duration days rainbow ID', 'comment_buy_change_username_card' => 'Spend :bonus bonus buy change username card', 'comment_gift_medal' => 'Spend :bonus bonus buy :medal_name and gift to :to_username', + 'comment_buy_torrent' => 'Spend :bonus bonus buy torrent: :torrent_id', + 'comment_torrent_be_downloaded' => 'Proceeds from torrent downloaded by :username(UID: :uid)', 'table_thead' => [ 'reward_type' => 'Reward type', 'count' => 'Count', @@ -23,4 +25,5 @@ return [ 'official_addition' => 'Official addition', 'medal_addition' => 'Medal addition', ], + 'not_enough' => 'No enough bonus! Requires :require_bonus, you currently only have: :now_bonus', ]; diff --git a/resources/lang/en/permission.php b/resources/lang/en/permission.php index fa0c5a1c..97566b71 100644 --- a/resources/lang/en/permission.php +++ b/resources/lang/en/permission.php @@ -13,6 +13,10 @@ return [ 'text' => 'Torrent approval allow automatically', 'desc' => 'Torrent is the approval allow status after upload automatically', ], + 'torrent-set-price' => [ + 'text' => 'Set torrent paid', + 'desc' => 'Set torrent paid', + ], 'defaultclass' => [ 'text' => 'Default Class', 'desc' => ' Class upon registration', diff --git a/resources/lang/zh_CN/admin.php b/resources/lang/zh_CN/admin.php index f68178da..33d45696 100644 --- a/resources/lang/zh_CN/admin.php +++ b/resources/lang/zh_CN/admin.php @@ -34,6 +34,7 @@ return [ 'user_props' => '用户道具', 'login_log' => '登录记录', 'bonus_log' => '魔力记录', + 'torrent_buy_log' => '种子购买', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_CN/bonus-log.php b/resources/lang/zh_CN/bonus-log.php index 54261612..014c3ac6 100644 --- a/resources/lang/zh_CN/bonus-log.php +++ b/resources/lang/zh_CN/bonus-log.php @@ -20,8 +20,10 @@ return [ \App\Models\BonusLogs::BUSINESS_TYPE_BUY_RAINBOW_ID => '购买彩虹 ID', \App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => '购买改名卡', \App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => '赠送勋章', + \App\Models\BonusLogs::BUSINESS_TYPE_BUY_TORRENT => '购买种子', \App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => '工作组工资', + \App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => '种子被下载', ], 'fields' => [ 'business_type' => '业务类型', diff --git a/resources/lang/zh_CN/bonus.php b/resources/lang/zh_CN/bonus.php index 769dfa4a..6dcd317a 100644 --- a/resources/lang/zh_CN/bonus.php +++ b/resources/lang/zh_CN/bonus.php @@ -7,6 +7,8 @@ return [ 'comment_buy_rainbow_id' => '花费 :bonus 魔力购买了 :duration 天的彩虹 ID', 'comment_buy_change_username_card' => '花费 :bonus 魔力购买了改名卡', 'comment_gift_medal' => '花费 :bonus 魔力购买了 :medal_name 并赠送给 :to_username', + 'comment_buy_torrent' => '花费 :bonus 魔力购买了种子::torrent_id', + 'comment_torrent_be_downloaded' => '收益来自种子被 :username(UID: :uid) 下载', 'table_thead' => [ 'reward_type' => '奖励类型', 'count' => '数量', @@ -23,4 +25,5 @@ return [ 'official_addition' => '官种加成', 'medal_addition' => '勋章加成', ], + 'not_enough' => '魔力不足! 需要 :require_bonus,你当前仅有::now_bonus', ]; diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index d8189242..568002e9 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -176,6 +176,8 @@ return [ 'added_end' => '发布时间小于', 'size_begin' => '体积大于', 'size_end' => '体积小于', + 'price' => '价格', + 'price_help' => '用户下载种子时,发布者将获得收入,但要扣除相应税率,当前税率::tax_factor', ], 'hit_and_run' => [ 'label' => '用户 H&R', diff --git a/resources/lang/zh_CN/permission.php b/resources/lang/zh_CN/permission.php index ba4a205c..cff33bbb 100644 --- a/resources/lang/zh_CN/permission.php +++ b/resources/lang/zh_CN/permission.php @@ -13,6 +13,10 @@ return [ 'text' => '种子自动通过审核', 'desc' => '种子发布即为审核通过状态', ], + 'torrent-set-price' => [ + 'text' => '设置种子收费', + 'desc' => '设置种子收费', + ], 'defaultclass' => [ 'text' => '默认等级', 'desc' => '注册时获得的等级', diff --git a/resources/lang/zh_CN/torrent.php b/resources/lang/zh_CN/torrent.php index 616d904f..82080371 100644 --- a/resources/lang/zh_CN/torrent.php +++ b/resources/lang/zh_CN/torrent.php @@ -91,4 +91,5 @@ return [ \App\Models\Torrent::PROMOTION_TIME_TYPE_PERMANENT => '永久', \App\Models\Torrent::PROMOTION_TIME_TYPE_DEADLINE => '直到', ], + 'paid_torrent' => '收费种子', ]; diff --git a/resources/lang/zh_TW/admin.php b/resources/lang/zh_TW/admin.php index c502a4b5..dab2091a 100644 --- a/resources/lang/zh_TW/admin.php +++ b/resources/lang/zh_TW/admin.php @@ -36,6 +36,7 @@ return [ 'user_props' => '用戶道具', 'login_log' => '登錄記錄', 'bonus_log' => '魔力記錄', + 'torrent_buy_log' => '種子購買', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_TW/bonus-log.php b/resources/lang/zh_TW/bonus-log.php index 8788a121..919c11e5 100644 --- a/resources/lang/zh_TW/bonus-log.php +++ b/resources/lang/zh_TW/bonus-log.php @@ -20,8 +20,10 @@ return [ \App\Models\BonusLogs::BUSINESS_TYPE_BUY_RAINBOW_ID => '購買彩虹 ID', \App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => '購買改名卡', \App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => '贈送勛章', + \App\Models\BonusLogs::BUSINESS_TYPE_BUY_TORRENT => '購買種子', \App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => '工作組工資', + \App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => '種子被下載', ], 'fields' => [ 'business_type' => '業務類型', diff --git a/resources/lang/zh_TW/bonus.php b/resources/lang/zh_TW/bonus.php index 11bf6c25..a3e58f59 100644 --- a/resources/lang/zh_TW/bonus.php +++ b/resources/lang/zh_TW/bonus.php @@ -7,6 +7,8 @@ return [ 'comment_buy_rainbow_id' => '花費 :bonus 魔力購買了 :duration 天的彩虹 ID', 'comment_buy_change_username_card' => '花費 :bonus 魔力購買了改名卡', 'comment_gift_medal' => '花費 :bonus 魔力購買了 :medal_name 並贈送給 :to_username', + 'comment_buy_torrent' => '花費 :bonus 魔力購買了種子::torrent_id', + 'comment_torrent_be_downloaded' => '收益來自種子被 :username(UID: :uid) 下載', 'table_thead' => [ 'reward_type' => '獎勵類型', 'count' => '數量', @@ -23,4 +25,5 @@ return [ 'official_addition' => '官種加成', 'medal_addition' => '勛章加成', ], + 'not_enough' => '魔力不足! 需要 :require_bonus,你當前僅有::now_bonus', ]; diff --git a/resources/lang/zh_TW/permission.php b/resources/lang/zh_TW/permission.php index 95cb74ca..26057fe1 100644 --- a/resources/lang/zh_TW/permission.php +++ b/resources/lang/zh_TW/permission.php @@ -13,6 +13,10 @@ return [ 'text' => '種子自動通過審核', 'desc' => '種子發布即為審核通過狀態', ], + 'torrent-set-price' => [ + 'text' => '設置種子收費', + 'desc' => '設置種子收費', + ], 'defaultclass' => [ 'text' => '預設等級', 'desc' => '註冊時獲得的等級',