mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
paid torrent
This commit is contained in:
111
app/Filament/Resources/User/TorrentBuyLogResource.php
Normal file
111
app/Filament/Resources/User/TorrentBuyLogResource.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User;
|
||||
|
||||
use App\Filament\Resources\User\TorrentBuyLogResource\Pages;
|
||||
use App\Filament\Resources\User\TorrentBuyLogResource\RelationManagers;
|
||||
use App\Models\TorrentBuyLog;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TorrentBuyLogResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TorrentBuyLog::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static ?string $navigationGroup = 'User';
|
||||
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.torrent_buy_log');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\TorrentBuyLogResource\Pages;
|
||||
|
||||
use App\Filament\Resources\User\TorrentBuyLogResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTorrentBuyLog extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TorrentBuyLogResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\TorrentBuyLogResource\Pages;
|
||||
|
||||
use App\Filament\Resources\User\TorrentBuyLogResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTorrentBuyLog extends EditRecord
|
||||
{
|
||||
protected static string $resource = TorrentBuyLogResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\TorrentBuyLogResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\User\TorrentBuyLogResource;
|
||||
use App\Models\TorrentBuyLog;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListTorrentBuyLogs extends PageList
|
||||
{
|
||||
protected static string $resource = TorrentBuyLogResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return TorrentBuyLog::query()->with(['user', 'torrent']);
|
||||
}
|
||||
}
|
||||
@@ -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')),
|
||||
];
|
||||
|
||||
@@ -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')),
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
23
app/Models/TorrentBuyLog.php
Normal file
23
app/Models/TorrentBuyLog.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentBuyLog extends NexusModel
|
||||
{
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['uid', 'torrent_id', 'price', 'channel'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uid');
|
||||
}
|
||||
|
||||
public function torrent()
|
||||
{
|
||||
return $this->belongsTo(Torrent::class, 'torrent_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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])) {
|
||||
|
||||
@@ -711,4 +711,12 @@ HTML;
|
||||
}
|
||||
}
|
||||
|
||||
public function getPaidIcon(array $torrentInfo, $size = 16, $verticalAlign = 'sub')
|
||||
{
|
||||
if (!isset($torrentInfo['price']) || $torrentInfo['price'] <= 0) {
|
||||
return '';
|
||||
}
|
||||
return sprintf('<span title="%s" style="vertical-align: %s"><svg t="1676058062789" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3406" width="%s" height="%s"><path d="M554.666667 810.666667v42.666666h-85.333334v-42.666666c-93.866667 0-170.666667-76.8-170.666666-170.666667h85.333333c0 46.933333 38.4 85.333333 85.333333 85.333333v-170.666666c-93.866667 0-170.666667-76.8-170.666666-170.666667s76.8-170.666667 170.666666-170.666667V170.666667h85.333334v42.666666c93.866667 0 170.666667 76.8 170.666666 170.666667h-85.333333c0-46.933333-38.4-85.333333-85.333333-85.333333v170.666666h17.066666c29.866667 0 68.266667 17.066667 98.133334 42.666667 34.133333 29.866667 59.733333 76.8 59.733333 128-4.266667 93.866667-81.066667 170.666667-174.933333 170.666667z m0-85.333334c46.933333 0 85.333333-38.4 85.333333-85.333333s-38.4-85.333333-85.333333-85.333333v170.666666zM469.333333 298.666667c-46.933333 0-85.333333 38.4-85.333333 85.333333s38.4 85.333333 85.333333 85.333333V298.666667z" fill="#CD7F32" p-id="3407"></path></svg></span>', nexus_trans('torrent.paid_torrent'), $verticalAlign, $size, $size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('torrents', function (Blueprint $table) {
|
||||
$table->integer('price')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('torrents', function (Blueprint $table) {
|
||||
$table->dropColumn('price');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('torrent_buy_logs', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-02-10');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-02-11');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -3642,7 +3642,8 @@ foreach ($rows as $row)
|
||||
} else {
|
||||
$seedBoxIcon = '';
|
||||
}
|
||||
$titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $seedBoxIcon . $approvalStatusIcon;
|
||||
$paidIcon = $torrentRep->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(
|
||||
'<div class="text-primary-600 transition hover:underline hover:text-primary-500 focus:underline focus:text-primary-500"><a href="/details.php?id=%s" target="_blank" title="%s">%s</a></div>',
|
||||
$torrent->id, $torrent->name, Str::limit($torrent->name, 40)
|
||||
$torrent->id, $torrent->name, Str::limit($torrent->name, $length)
|
||||
);
|
||||
$tags = '';
|
||||
if ($withTags) {
|
||||
|
||||
@@ -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' => "当没有种子时请求完成者续种",
|
||||
|
||||
@@ -41,6 +41,10 @@ $lang_getrss = array
|
||||
'text_mode' => "",
|
||||
'text_keyword_note' => "只订阅标题中包含此关键字的项目",
|
||||
'row_sticky' => '置顶',
|
||||
'row_paid' => '收费',
|
||||
'paid_no' => '免费',
|
||||
'paid_yes' => '收费',
|
||||
'paid_all' => '全部',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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。',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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' => "當沒有種子時要求完成者續種",
|
||||
|
||||
@@ -42,6 +42,10 @@ $lang_getrss = array
|
||||
'text_mode' => "",
|
||||
'text_keyword_note' => "只訂閱標題中包含此關鍵字的項目",
|
||||
'row_sticky' => '置頂',
|
||||
'row_paid' => '收費',
|
||||
'paid_no' => '免費',
|
||||
'paid_yes' => '收費',
|
||||
'paid_all' => '全部',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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。',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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.',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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"];
|
||||
|
||||
@@ -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("<h1 align=\"center\" id=\"top\">".$s."</h1>\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[] = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" /> <b><font class=\"small\">".$lang_details['text_download_torrent']."</font></b></a>";
|
||||
$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[] = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" /> <b><font class=\"small\">".$downloadBtn."</font></b></a>";
|
||||
}
|
||||
if ($owned == 1) {
|
||||
$actions[] = "<$editlink><img class=\"dt_edit\" src=\"pic/trans.gif\" alt=\"edit\" /> <b><font class=\"small\">".(user_can('torrentmanage') ? $lang_details['text_edit_and_delete_torrent'] : $lang_details['text_edit_torrent']). "</font></b></a>";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -73,7 +73,13 @@ else {
|
||||
tr($lang_edit['row_nfo_file'], "<font class=\"medium\"><input type=\"radio\" name=\"nfoaction\" value=\"keep\" checked=\"checked\" />".$lang_edit['radio_keep_current'].
|
||||
"<input type=\"radio\" name=\"nfoaction\" value=\"remove\" />".$lang_edit['radio_remove'].
|
||||
"<input id=\"nfoupdate\" type=\"radio\" name=\"nfoaction\" value=\"update\" />".$lang_edit['radio_update']."</font><br /><input type=\"file\" name=\"nfo\" onchange=\"document.getElementById('nfoupdate').checked=true\" />", 1);
|
||||
print("<tr><td class=\"rowhead\">".$lang_edit['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");
|
||||
|
||||
//price
|
||||
if (user_can('torrent-set-price')) {
|
||||
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" value="'.$row['price'].'" /> ' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1);
|
||||
}
|
||||
|
||||
print("<tr><td class=\"rowhead\">".$lang_edit['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");
|
||||
textbbcode("edittorrent","descr",($row["descr"]), false, 130, true);
|
||||
print("</td></tr>");
|
||||
|
||||
|
||||
@@ -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') {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td class="rowhead"><?php echo $lang_getrss['row_paid']?>
|
||||
</td>
|
||||
<td class="rowfollow" align="left">
|
||||
<label><input type="radio" name="paid" value="0" checked><?php echo $lang_getrss['paid_no']?></label>
|
||||
<label><input type="radio" name="paid" value="1"><?php echo $lang_getrss['paid_yes']?></label>
|
||||
<label><input type="radio" name="paid" value="2"><?php echo $lang_getrss['paid_all']?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<td class="rowhead"><?php echo $lang_getrss['row_item_title_type']?>
|
||||
</td>
|
||||
<td class="rowfollow" align="left">
|
||||
|
||||
@@ -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'],"<input type='text' name=tax_factor style=\"width: 100px\" value={$TORRENT['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']."<ul><li><input type='text' style=\"width: 50px\" name=randomhalfleech value='".(isset($TORRENT["randomhalfleech"]) ? $TORRENT["randomhalfleech"] : 5 )."'>".$lang_settings['text_halfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomfree value='".(isset($TORRENT["randomfree"]) ? $TORRENT["randomfree"] : 2 )."'>".$lang_settings['text_free_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoup value='".(isset($TORRENT["randomtwoup"]) ? $TORRENT["randomtwoup"] : 2 )."'>".$lang_settings['text_twoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoupfree value='".(isset($TORRENT["randomtwoupfree"]) ? $TORRENT["randomtwoupfree"] : 1 )."'>".$lang_settings['text_freetwoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwouphalfdown value='".(isset($TORRENT["randomtwouphalfdown"]) ? $TORRENT["randomtwouphalfdown"] : 0 )."'>".$lang_settings['text_twouphalfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomthirtypercentdown value='".(isset($TORRENT["randomthirtypercentdown"]) ? $TORRENT["randomthirtypercentdown"] : 0 )."'>".$lang_settings['text_thirtypercentleech_chance_becoming']."</li></ul>".$lang_settings['text_random_promotion_note_two'], 1);
|
||||
tr($lang_settings['row_large_torrent_promotion'], $lang_settings['text_torrent_larger_than']."<input type='text' style=\"width: 50px\" name=largesize value='".(isset($TORRENT["largesize"]) ? $TORRENT["largesize"] : 20 )."'>".$lang_settings['text_gb_promoted_to']."<select name=largepro>".promotion_selection((isset($TORRENT['largepro']) ? $TORRENT['largepro'] : 2), 1)."</select>".$lang_settings['text_by_system_upon_uploading']."<br />".$lang_settings['text_large_torrent_promotion_note'], 1);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
@@ -73,6 +73,11 @@ stdhead($lang_upload['head_upload']);
|
||||
if ($enablenfo_main=='yes') {
|
||||
tr($lang_upload['row_nfo_file'], "<input type=\"file\" class=\"file\" name=\"nfo\" /><br /><font class=\"medium\">".$lang_upload['text_only_viewed_by'].get_user_class_name($viewnfo_class,false,true,true).$lang_upload['text_or_above']."</font>", 1);
|
||||
}
|
||||
//price
|
||||
if (user_can('torrent-set-price')) {
|
||||
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" /> ' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1);
|
||||
}
|
||||
|
||||
print("<tr><td class=\"rowhead\" style='padding: 3px' valign=\"top\">".$lang_upload['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");
|
||||
textbbcode("upload","descr", "", false, 130, true);
|
||||
print("</td></tr>\n");
|
||||
|
||||
@@ -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' => [
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -34,6 +34,7 @@ return [
|
||||
'user_props' => '用户道具',
|
||||
'login_log' => '登录记录',
|
||||
'bonus_log' => '魔力记录',
|
||||
'torrent_buy_log' => '种子购买',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -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' => '业务类型',
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
|
||||
@@ -176,6 +176,8 @@ return [
|
||||
'added_end' => '发布时间小于',
|
||||
'size_begin' => '体积大于',
|
||||
'size_end' => '体积小于',
|
||||
'price' => '价格',
|
||||
'price_help' => '用户下载种子时,发布者将获得收入,但要扣除相应税率,当前税率::tax_factor',
|
||||
],
|
||||
'hit_and_run' => [
|
||||
'label' => '用户 H&R',
|
||||
|
||||
@@ -13,6 +13,10 @@ return [
|
||||
'text' => '种子自动通过审核',
|
||||
'desc' => '种子发布即为审核通过状态',
|
||||
],
|
||||
'torrent-set-price' => [
|
||||
'text' => '设置种子收费',
|
||||
'desc' => '设置种子收费',
|
||||
],
|
||||
'defaultclass' => [
|
||||
'text' => '默认等级',
|
||||
'desc' => '注册时获得的等级',
|
||||
|
||||
@@ -91,4 +91,5 @@ return [
|
||||
\App\Models\Torrent::PROMOTION_TIME_TYPE_PERMANENT => '永久',
|
||||
\App\Models\Torrent::PROMOTION_TIME_TYPE_DEADLINE => '直到',
|
||||
],
|
||||
'paid_torrent' => '收费种子',
|
||||
];
|
||||
|
||||
@@ -36,6 +36,7 @@ return [
|
||||
'user_props' => '用戶道具',
|
||||
'login_log' => '登錄記錄',
|
||||
'bonus_log' => '魔力記錄',
|
||||
'torrent_buy_log' => '種子購買',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -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' => '業務類型',
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
|
||||
@@ -13,6 +13,10 @@ return [
|
||||
'text' => '種子自動通過審核',
|
||||
'desc' => '種子發布即為審核通過狀態',
|
||||
],
|
||||
'torrent-set-price' => [
|
||||
'text' => '設置種子收費',
|
||||
'desc' => '設置種子收費',
|
||||
],
|
||||
'defaultclass' => [
|
||||
'text' => '預設等級',
|
||||
'desc' => '註冊時獲得的等級',
|
||||
|
||||
Reference in New Issue
Block a user