mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
admin add torrents
This commit is contained in:
@@ -12,14 +12,14 @@ class NexusUpdate extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'nexus:update {--tag=} {--keep_tmp}';
|
||||
protected $signature = 'nexus:update {--tag=} {--keep_tmp} {--include_composer}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update nexusphp after code updated, remember run `composer update` first. Options: --tag=, --keep_tmp';
|
||||
protected $description = 'Update nexusphp after code updated, remember run `composer update` first. Options: --tag=, --keep_tmp, --include_composer';
|
||||
|
||||
private $update;
|
||||
|
||||
@@ -45,14 +45,19 @@ class NexusUpdate extends Command
|
||||
require ROOT_PATH . 'nexus/Database/helpers.php';
|
||||
$tag = $this->option('tag');
|
||||
$keepTmp = $this->option('keep_tmp');
|
||||
$includeComposer = $this->option('include_composer');
|
||||
$includes = [];
|
||||
if ($includeComposer) {
|
||||
$includes[] = 'composer';
|
||||
}
|
||||
if ($tag !== null) {
|
||||
if ($tag === 'dev') {
|
||||
$url = "https://github.com/xiaomlove/nexusphp/archive/refs/heads/php8.zip";
|
||||
} else {
|
||||
$url = "https://api.github.com/repos/xiaomlove/nexusphp/tarball/v$tag";
|
||||
}
|
||||
$this->doLog("Specific tag: '$tag', download from '$url' and extra code...");
|
||||
$tmpPath = $this->update->downAndExtractCode($url);
|
||||
$this->doLog("Specific tag: '$tag', download from '$url' and extra code, includes: " . implode(', ', $includes));
|
||||
$tmpPath = $this->update->downAndExtractCode($url, $includes);
|
||||
}
|
||||
//Step 1
|
||||
$step = $this->update->currentStep();
|
||||
|
||||
@@ -78,8 +78,8 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$r = User::query()->find(10003, ['id', 'added', 'donoruntil']);
|
||||
dd($r->donoruntil->toDateTimeString() < '1978');
|
||||
$r = Carbon::parse('2022-07-03 04:00:00')->diffInSeconds();
|
||||
dd($r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class TagResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
|
||||
198
app/Filament/Resources/Torrent/TorrentResource.php
Normal file
198
app/Filament/Resources/Torrent/TorrentResource.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Torrent;
|
||||
|
||||
use App\Filament\Resources\Torrent\TorrentResource\Pages;
|
||||
use App\Filament\Resources\Torrent\TorrentResource\RelationManagers;
|
||||
use App\Models\Tag;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\TorrentTag;
|
||||
use App\Repositories\TagRepository;
|
||||
use App\Repositories\TorrentRepository;
|
||||
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\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TorrentResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Torrent::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static ?string $navigationGroup = 'Torrent';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.torrent_list');
|
||||
}
|
||||
|
||||
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\BadgeColumn::make('basic_category.name')->label(__('label.torrent.category')),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label(__('label.name'))
|
||||
->limit(30)
|
||||
->url(fn ($record) => sprintf('/details.php?id=%s', $record->id))
|
||||
->openUrlInNewTab(true)
|
||||
,
|
||||
Tables\Columns\BadgeColumn::make('posStateText')->label(__('label.torrent.pos_state')),
|
||||
Tables\Columns\BadgeColumn::make('spStateText')->label(__('label.torrent.sp_state')),
|
||||
Tables\Columns\TextColumn::make('tagsFormatted')->label(__('label.tag.label'))->html(),
|
||||
Tables\Columns\TextColumn::make('size')->label(__('label.torrent.size'))->formatStateUsing(fn ($state) => mksize($state)),
|
||||
Tables\Columns\TextColumn::make('seeders')->label(__('label.torrent.seeders')),
|
||||
Tables\Columns\TextColumn::make('leechers')->label(__('label.torrent.leechers')),
|
||||
Tables\Columns\BadgeColumn::make('approval_status')
|
||||
->label(__('label.torrent.approval_status'))
|
||||
->colors(array_flip(Torrent::listApprovalStatus(true, 'badge_color')))
|
||||
->formatStateUsing(fn ($record) => $record->approvalStatusText),
|
||||
Tables\Columns\TextColumn::make('added')->label(__('label.added'))->dateTime(),
|
||||
Tables\Columns\TextColumn::make('user.username')
|
||||
->label(__('label.user.label'))
|
||||
->url(fn ($record) => sprintf('/userdetails.php?id=%s', $record->owner))
|
||||
->openUrlInNewTab(true)
|
||||
,
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('approval_status')
|
||||
->options(Torrent::listApprovalStatus(true))
|
||||
->label(__('label.torrent.approval_status')),
|
||||
|
||||
Tables\Filters\SelectFilter::make('pos_state')
|
||||
->options(Torrent::listPosStates(true))
|
||||
->label(__('label.torrent.pos_state')),
|
||||
|
||||
Tables\Filters\SelectFilter::make('sp_state')
|
||||
->options(Torrent::listPromotionTypes(true))
|
||||
->label(__('label.torrent.sp_state')),
|
||||
])
|
||||
->actions([
|
||||
// Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\Action::make('approval')
|
||||
->label(__('admin.resources.torrent.action_approval'))
|
||||
->form([
|
||||
Forms\Components\Radio::make('approval_status')
|
||||
->label(__('label.torrent.approval_status'))
|
||||
->inline()
|
||||
->required()
|
||||
->options(Torrent::listApprovalStatus(true))
|
||||
,
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
|
||||
])
|
||||
->icon('heroicon-o-check')
|
||||
->color('success')
|
||||
->action(function (Torrent $record, array $data) {
|
||||
$torrentRep = new TorrentRepository();
|
||||
try {
|
||||
$data['torrent_id'] = $record->id;
|
||||
$torrentRep->approval(Auth::user(), $data);
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage(), 'error');
|
||||
}
|
||||
})
|
||||
])
|
||||
->bulkActions([
|
||||
// Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\BulkAction::make('posState')
|
||||
->label(__('admin.resources.torrent.bulk_action_pos_state'))
|
||||
->form([
|
||||
Forms\Components\Select::make('pos_state')
|
||||
->label(__('label.torrent.pos_state'))
|
||||
->options(Torrent::listPosStates(true))
|
||||
])
|
||||
->icon('heroicon-o-arrow-circle-up')
|
||||
->action(function (Collection $records, array $data) {
|
||||
$idArr = $records->pluck('id')->toArray();
|
||||
Torrent::query()->whereIn('id', $idArr)->update(['pos_state' => $data['pos_state']]);
|
||||
})
|
||||
->deselectRecordsAfterCompletion(),
|
||||
|
||||
Tables\Actions\BulkAction::make('remove_tag')
|
||||
->label(__('admin.resources.torrent.bulk_action_remove_tag'))
|
||||
->requiresConfirmation()
|
||||
->icon('heroicon-o-minus-circle')
|
||||
->action(function (Collection $records) {
|
||||
$idArr = $records->pluck('id')->toArray();
|
||||
TorrentTag::query()->whereIn('torrent_id', $idArr)->delete();
|
||||
})
|
||||
->deselectRecordsAfterCompletion(),
|
||||
|
||||
Tables\Actions\BulkAction::make('attach_tag')
|
||||
->label(__('admin.resources.torrent.bulk_action_attach_tag'))
|
||||
->form([
|
||||
Forms\Components\CheckboxList::make('tags')
|
||||
->label(__('label.tag.label'))
|
||||
->columns(4)
|
||||
->options(TagRepository::createBasicQuery()->pluck('name', 'id')->toArray()),
|
||||
])
|
||||
->icon('heroicon-o-tag')
|
||||
->action(function (Collection $records, array $data) {
|
||||
if (empty($data['tags'])) {
|
||||
return;
|
||||
}
|
||||
$insert = $torrentIdArr = [];
|
||||
$time = now()->toDateTimeString();
|
||||
foreach ($records as $torrent) {
|
||||
$torrentIdArr[] = $torrent->id;
|
||||
foreach ($data['tags'] as $tagId) {
|
||||
$insert[] = [
|
||||
'torrent_id' => $torrent->id,
|
||||
'tag_id' => $tagId,
|
||||
'created_at' => $time,
|
||||
'updated_at' => $time,
|
||||
];
|
||||
}
|
||||
}
|
||||
TorrentTag::query()->whereIn('torrent_id', $torrentIdArr)->delete();
|
||||
TorrentTag::query()->insert($insert);
|
||||
})
|
||||
->deselectRecordsAfterCompletion(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->with(['user', 'basic_category', 'tags']);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTorrents::route('/'),
|
||||
'create' => Pages\CreateTorrent::route('/create'),
|
||||
'edit' => Pages\EditTorrent::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TorrentResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Torrent\TorrentResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTorrent extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TorrentResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TorrentResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Torrent\TorrentResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTorrent extends EditRecord
|
||||
{
|
||||
protected static string $resource = TorrentResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Torrent\TorrentResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Torrent\TorrentResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTorrents extends PageList
|
||||
{
|
||||
protected static string $resource = TorrentResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ClaimResource extends Resource
|
||||
@@ -48,8 +49,8 @@ class ClaimResource extends Resource
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->label(__('label.user.label'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('torrent.name')->limit(50)->label(__('label.torrent.label'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('torrent.size')->label(__('label.torrent.size'))->formatStateUsing(fn ($record) => mksize($record->size)),
|
||||
Tables\Columns\TextColumn::make('torrent.added')->label(__('label.torrent.ttl'))->formatStateUsing(fn ($record) => mkprettytime($record->added)),
|
||||
Tables\Columns\TextColumn::make('torrent.size')->label(__('label.torrent.size'))->formatStateUsing(fn (Model $record) => mksize($record->torrent->size)),
|
||||
Tables\Columns\TextColumn::make('torrent.added')->label(__('label.torrent.ttl'))->formatStateUsing(fn (Model $record) => mkprettytime($record->torrent->added->diffInSeconds())),
|
||||
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at'))->dateTime(),
|
||||
Tables\Columns\TextColumn::make('last_settle_at')->label(__('label.claim.last_settle_at'))->dateTime(),
|
||||
Tables\Columns\TextColumn::make('seedTimeThisMonth')->label(__('label.claim.seed_time_this_month')),
|
||||
|
||||
@@ -138,14 +138,17 @@ class Torrent extends NexusModel
|
||||
public static array $approvalStatus = [
|
||||
self::APPROVAL_STATUS_NONE => [
|
||||
'text' => 'None',
|
||||
'badge_color' => 'primary',
|
||||
'icon' => '<svg t="1655184824967" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="34118" width="16" height="16"><path d="M450.267 772.245l0 92.511 92.511 0 0-92.511L450.267 772.245zM689.448 452.28c13.538-24.367 20.311-50.991 20.311-79.875 0-49.938-19.261-92.516-57.765-127.713-38.517-35.197-90.114-52.8-154.797-52.8-61.077 0-110.191 16.4-147.342 49.188-37.16 32.798-59.497 80.032-67.014 141.703l83.486 9.927c7.218-46.025 22.41-79.875 45.576-101.533 23.166-21.665 52.047-32.494 86.647-32.494 35.802 0 66.038 11.957 90.711 35.874 24.667 23.92 37.01 51.675 37.01 83.266 0 17.451-4.222 33.55-12.642 48.284-8.425 14.747-26.698 34.526-54.83 59.346s-47.607 43.701-58.442 56.637c-14.741 17.754-25.424 35.354-32.037 52.797-9.028 23.172-13.537 50.701-13.537 82.584 0 5.418 0.146 13.539 0.45 24.374l78.069 0c0.599-32.495 2.855-55.966 6.772-70.4 3.903-14.44 9.926-27.229 18.047-38.363 8.127-11.123 25.425-28.43 51.901-51.895C649.43 506.288 675.908 476.656 689.448 452.28L689.448 452.28z" p-id="34119" fill="#e78d0f"></path></svg>',
|
||||
],
|
||||
self::APPROVAL_STATUS_ALLOW => [
|
||||
'text' => 'Allow',
|
||||
'badge_color' => 'success',
|
||||
'icon' => '<svg t="1655145688503" class="icon" viewBox="0 0 1413 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16225" width="16" height="16"><path d="M1381.807797 107.47394L1274.675044 0.438669 465.281736 809.880718l-322.665524-322.714266L35.434718 594.152982l430.041982 430.041982 107.084012-107.035271-0.243705-0.292446z" fill="#1afa29" p-id="16226"></path></svg>',
|
||||
],
|
||||
self::APPROVAL_STATUS_DENY => [
|
||||
'text' => 'Deny',
|
||||
'badge_color' => 'danger',
|
||||
'icon' => '<svg t="1655184952662" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35029" width="16" height="16"><path d="M220.8 812.8l22.4 22.4 272-272 272 272 48-44.8-275.2-272 275.2-272-48-48-272 275.2-272-275.2-22.4 25.6-22.4 22.4 272 272-272 272z" fill="#d81e06" p-id="35030"></path></svg>',
|
||||
],
|
||||
];
|
||||
@@ -190,13 +193,27 @@ class Torrent extends NexusModel
|
||||
return $spState;
|
||||
}
|
||||
|
||||
public function posStateText(): Attribute
|
||||
protected function posStateText(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn($value, $attributes) => nexus_trans('torrent.pos_state_' . $attributes['pos_state'])
|
||||
);
|
||||
}
|
||||
|
||||
protected function approvalStatusText(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn($value, $attributes) => nexus_trans('torrent.approval.status_text.' . $attributes['approval_status'])
|
||||
);
|
||||
}
|
||||
|
||||
protected function spStateText(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn($value, $attributes) => self::$promotionTypes[$this->sp_state]['text'] ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
public static function getGlobalPromotionState()
|
||||
{
|
||||
if (is_null(self::$globalPromotionState)) {
|
||||
@@ -221,14 +238,29 @@ class Torrent extends NexusModel
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public static function listApprovalStatus($onlyKeyValue = false): array
|
||||
public static function listApprovalStatus($onlyKeyValue = false, $valueField = 'text'): array
|
||||
{
|
||||
$result = self::$approvalStatus;
|
||||
$keyValue = [];
|
||||
foreach ($result as $status => &$info) {
|
||||
$text = nexus_trans("torrent.approval.status_text.$status");
|
||||
$info['text'] = $text;
|
||||
$keyValue[$status] = $text;
|
||||
$keyValue[$status] = $info[$valueField];
|
||||
}
|
||||
if ($onlyKeyValue) {
|
||||
return $keyValue;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function listPromotionTypes($onlyKeyValue = false, $valueField = 'text'): array
|
||||
{
|
||||
$result = self::$promotionTypes;
|
||||
$keyValue = [];
|
||||
foreach ($result as $status => &$info) {
|
||||
$text = $info['text'];
|
||||
$info['text'] = $text;
|
||||
$keyValue[$status] = $info[$valueField];
|
||||
}
|
||||
if ($onlyKeyValue) {
|
||||
return $keyValue;
|
||||
@@ -253,6 +285,18 @@ class Torrent extends NexusModel
|
||||
return self::$hrStatus[$this->hr] ?? '';
|
||||
}
|
||||
|
||||
public function getTagsFormattedAttribute(): string
|
||||
{
|
||||
$html = [];
|
||||
foreach ($this->tags as $tag) {
|
||||
$html[] = sprintf(
|
||||
'<span style="color: %s;background-color: %s;border-radius: %s;font-size: %s;padding: %s;margin: %s">%s</span>',
|
||||
$tag->font_color, $tag->color, $tag->border_radius, $tag->font_size, $tag->padding, $tag->margin, $tag->name
|
||||
);
|
||||
}
|
||||
return implode('', $html);
|
||||
}
|
||||
|
||||
public static function getBasicInfo(): array
|
||||
{
|
||||
$result = [];
|
||||
@@ -262,11 +306,16 @@ class Torrent extends NexusModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function listPosStates(): array
|
||||
public static function listPosStates($onlyKeyValue = false, $valueField = 'text'): array
|
||||
{
|
||||
$result = self::$posStates;
|
||||
$keyValues = [];
|
||||
foreach ($result as $key => &$value) {
|
||||
$value['text'] = nexus_trans('torrent.pos_state_' . $key);
|
||||
$keyValues[$key] = $value[$valueField];
|
||||
}
|
||||
if ($onlyKeyValue) {
|
||||
return $keyValues;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -64,5 +64,6 @@ class TorrentOperationLog extends NexusModel
|
||||
Message::query()->insert($message);
|
||||
NexusDB::cache_del("user_{$receiver->id}_unread_message_count");
|
||||
NexusDB::cache_del("user_{$receiver->id}_inbox_count");
|
||||
do_log("notify user: {$receiver->id}, $subject");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DashboardRepository extends BaseRepository
|
||||
{
|
||||
const FILAMENT_VERSION = '2.13.15';
|
||||
|
||||
public function getSystemInfo(): array
|
||||
{
|
||||
$result = [];
|
||||
@@ -37,7 +39,7 @@ class DashboardRepository extends BaseRepository
|
||||
$result[$name] = [
|
||||
'name' => $name,
|
||||
'text' => nexus_trans("dashboard.system_info.$name"),
|
||||
'value' => "2.13.14",
|
||||
'value' => self::FILAMENT_VERSION,
|
||||
];
|
||||
$name = 'php_version';
|
||||
$result[$name] = [
|
||||
|
||||
@@ -521,11 +521,11 @@ class TorrentRepository extends BaseRepository
|
||||
NexusDB::transaction(function () use ($torrent, $torrentOperationLog, $torrentUpdate, $notifyUser) {
|
||||
$log = "torrent: " . $torrent->id;
|
||||
if (!empty($torrentUpdate)) {
|
||||
$log .= "[UPDATE_TORRENT]: " . nexus_json_encode($torrentUpdate);
|
||||
$log .= ", [UPDATE_TORRENT]: " . nexus_json_encode($torrentUpdate);
|
||||
$torrent->update($torrentUpdate);
|
||||
}
|
||||
if (!empty($torrentOperationLog)) {
|
||||
$log .= "[ADD_TORRENT_OPERATION_LOG]: " . nexus_json_encode($torrentOperationLog);
|
||||
$log .= ", [ADD_TORRENT_OPERATION_LOG]: " . nexus_json_encode($torrentOperationLog);
|
||||
TorrentOperationLog::add($torrentOperationLog, $notifyUser);
|
||||
}
|
||||
do_log($log);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.17');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-02');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-03');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -17,5 +17,6 @@ $lang_getusertorrentlistajax = array
|
||||
'text_record' => " 条记录",
|
||||
'text_no_record' => "没有记录",
|
||||
'text_total_size' => " | 总大小:",
|
||||
'col_added' => "发布时间",
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -16,5 +16,7 @@ $lang_getusertorrentlistajax = array
|
||||
'col_le_time' => "下載時間",
|
||||
'text_record' => "條記錄",
|
||||
'text_no_record' => "沒有記錄",
|
||||
'text_total_size' => " | 總大小:",
|
||||
'col_added' => "發布時間",
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -16,5 +16,7 @@ $lang_getusertorrentlistajax = array
|
||||
'col_le_time' => "Le. Time",
|
||||
'text_record' => " record",
|
||||
'text_no_record' => "No record.",
|
||||
'text_total_size' => " | Total size: ",
|
||||
'col_added' => "Added",
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -312,7 +312,7 @@ class Update extends Install
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function downAndExtractCode($url): string
|
||||
public function downAndExtractCode($url, array $includes = []): string
|
||||
{
|
||||
$arr = explode('/', $url);
|
||||
$basename = last($arr);
|
||||
@@ -354,7 +354,11 @@ class Update extends Install
|
||||
|
||||
foreach (glob("$extractDir/*") as $path) {
|
||||
if (is_dir($path)) {
|
||||
$excludes = ['.git', 'composer.lock', 'composer.json', 'public/favicon.ico', '.env'];
|
||||
$excludes = ['.git', 'public/favicon.ico', '.env'];
|
||||
if (!in_array('composer', $includes)) {
|
||||
$excludes[] = 'composer.lock';
|
||||
$excludes[] = 'composer.json';
|
||||
}
|
||||
// $command = sprintf('cp -raf %s/. %s', $path, ROOT_PATH);
|
||||
$command = "rsync -rvq $path/ " . ROOT_PATH;
|
||||
foreach ($excludes as $exclude) {
|
||||
|
||||
@@ -116,7 +116,7 @@ function maketable($res, $mode = 'seeding')
|
||||
->keyBy('torrentid');
|
||||
}
|
||||
|
||||
$ret = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"800\"><tr><td class=\"colhead\" style=\"padding: 0px\">".$lang_getusertorrentlistajax['col_type']."</td><td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_name']."</td>".
|
||||
$ret = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" width=\"900px\"><tr><td class=\"colhead\" style=\"padding: 0px\">".$lang_getusertorrentlistajax['col_type']."</td><td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_name']."</td><td class=\"colhead\" align=\"center\"> ".$lang_getusertorrentlistajax['col_added']." </td>".
|
||||
($showsize ? "<td class=\"colhead\" align=\"center\"><img class=\"size\" src=\"pic/trans.gif\" alt=\"size\" title=\"".$lang_getusertorrentlistajax['title_size']."\" /></td>" : "").($showsenum ? "<td class=\"colhead\" align=\"center\"><img class=\"seeders\" src=\"pic/trans.gif\" alt=\"seeders\" title=\"".$lang_getusertorrentlistajax['title_seeders']."\" /></td>" : "").($showlenum ? "<td class=\"colhead\" align=\"center\"><img class=\"leechers\" src=\"pic/trans.gif\" alt=\"leechers\" title=\"".$lang_getusertorrentlistajax['title_leechers']."\" /></td>" : "").($showuploaded ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_uploaded']."</td>" : "") . ($showdownloaded ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_downloaded']."</td>" : "").($showratio ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_ratio']."</td>" : "").($showsetime ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_se_time']."</td>" : "").($showletime ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_le_time']."</td>" : "").($showcotime ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_time_completed']."</td>" : "").($showanonymous ? "<td class=\"colhead\" align=\"center\">".$lang_getusertorrentlistajax['col_anonymous']."</td>" : "")."</tr>\n";
|
||||
$total_size = 0;
|
||||
foreach ($results as $arr)
|
||||
@@ -158,6 +158,7 @@ function maketable($res, $mode = 'seeding')
|
||||
else $dissmall_descr == "";
|
||||
$ret .= "<tr" . $sphighlight . "><td class=\"rowfollow nowrap\" valign=\"middle\" style='padding: 0px'>".return_category_image($arr['category'], "torrents.php?allsec=1&")."</td>\n" .
|
||||
"<td class=\"rowfollow\" width=\"100%\" align=\"left\"><a href=\"".htmlspecialchars("details.php?id=".$arr['torrent']."&hit=1")."\" title=\"".$nametitle."\"><b>" . $dispname . "</b></a>". $banned_torrent . $sp_torrent . $hrImg . $approvalStatusIcon .($dissmall_descr == "" ? "" : "<br />" . $dissmall_descr) . "</td>";
|
||||
$ret .= sprintf('<td class="rowfollow" align="center">%s<br/>%s</td>', substr($arr['added'], 0, 10), substr($arr['added'], 11));
|
||||
//size
|
||||
if ($showsize)
|
||||
$ret .= "<td class=\"rowfollow\" align=\"center\">". mksize_compact($arr['size'])."</td>";
|
||||
@@ -210,7 +211,7 @@ switch ($type)
|
||||
case 'uploaded':
|
||||
{
|
||||
// $res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, snatched.seedtime, snatched.uploaded FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id AND snatched.userid=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr FROM torrents LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name as torrentname, small_descr, seeders, leechers, anonymous, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added FROM torrents LEFT JOIN categories ON torrents.category = categories.id WHERE torrents.owner=$id " . (($CURUSER["id"] != $id)?((get_user_class() < $viewanonymous_class) ? " AND anonymous = 'no'":""):"") ." ORDER BY torrents.added DESC") or sqlerr(__FILE__, __LINE__);
|
||||
$count = mysql_num_rows($res);
|
||||
if ($count > 0)
|
||||
{
|
||||
@@ -233,7 +234,7 @@ switch ($type)
|
||||
// Current Leeching
|
||||
case 'leeching':
|
||||
{
|
||||
$res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.added DESC") or sqlerr();
|
||||
$res = sql_query("SELECT torrent,snatched.uploaded,snatched.downloaded,torrents.name as torrentname, torrents.small_descr, torrents.sp_state, torrents.banned, torrents.approval_status, categories.name as catname,size,torrents.hr,image,category,seeders,leechers, torrents.added FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN snatched ON torrents.id = snatched.torrentid WHERE peers.userid=$id AND snatched.userid = $id AND peers.seeder='no' ORDER BY torrents.added DESC") or sqlerr();
|
||||
$count = mysql_num_rows($res);
|
||||
if ($count > 0){
|
||||
list($torrentlist, $total_size) = maketable ( $res, 'leeching' );
|
||||
@@ -244,7 +245,7 @@ switch ($type)
|
||||
// Completed torrents
|
||||
case 'completed':
|
||||
{
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, categories.name AS catname, torrents.banned, torrents.approval_status, categories.image, category, sp_state, size, torrents.hr,snatched.uploaded, snatched.seedtime, snatched.leechtime, snatched.completedat FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='yes' AND torrents.owner != $id AND userid=$id ORDER BY snatched.completedat DESC") or sqlerr();
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, categories.name AS catname, torrents.banned, torrents.approval_status, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.seedtime, snatched.leechtime, snatched.completedat FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='yes' AND torrents.owner != $id AND userid=$id ORDER BY snatched.completedat DESC") or sqlerr();
|
||||
$count = mysql_num_rows($res);
|
||||
if ($count > 0)
|
||||
{
|
||||
@@ -256,7 +257,7 @@ switch ($type)
|
||||
// Incomplete torrents
|
||||
case 'incomplete':
|
||||
{
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.startdat DESC") or sqlerr();
|
||||
$res = sql_query("SELECT torrents.id AS torrent, torrents.name AS torrentname, small_descr, torrents.banned, torrents.approval_status, categories.name AS catname, categories.image, category, sp_state, size, torrents.hr, torrents.added,snatched.uploaded, snatched.downloaded, snatched.leechtime FROM torrents LEFT JOIN snatched ON torrents.id = snatched.torrentid LEFT JOIN categories on torrents.category = categories.id WHERE snatched.finished='no' AND userid=$id AND torrents.owner != $id ORDER BY snatched.startdat DESC") or sqlerr();
|
||||
$count = mysql_num_rows($res);
|
||||
if ($count > 0)
|
||||
{
|
||||
@@ -273,7 +274,7 @@ switch ($type)
|
||||
}
|
||||
|
||||
if (isset($total_size) && $total_size){
|
||||
echo "<br /><b>" . $count . "</b>" . $lang_getusertorrentlistajax ['text_record'] . add_s ( $count ) . $lang_getusertorrentlistajax['text_total_size'] . mksize($total_size) . "<br /><br />" . $torrentlist;
|
||||
echo "<br /><b>" . $count . "</b>" . $lang_getusertorrentlistajax['text_record'] . add_s ( $count ) . $lang_getusertorrentlistajax['text_total_size'] . mksize($total_size) . "<br /><br />" . $torrentlist;
|
||||
} elseif ($count){
|
||||
echo "<br /><b>".$count."</b>".$lang_getusertorrentlistajax['text_record'].add_s($count)."<br /><br />".$torrentlist;
|
||||
} else {
|
||||
|
||||
@@ -174,7 +174,7 @@ if ($showlastxforumposts_main == "yes" && $CURUSER)
|
||||
// ------------- start: latest torrents ------------------//
|
||||
|
||||
if ($showlastxtorrents_main == "yes") {
|
||||
$result = sql_query("SELECT id,name,leechers,seeders FROM torrents where visible='yes' ORDER BY id DESC LIMIT 5") or sqlerr(__FILE__, __LINE__);
|
||||
$result = sql_query("SELECT id,name,small_descr,leechers,seeders FROM torrents where visible='yes' ORDER BY id DESC LIMIT 5") or sqlerr(__FILE__, __LINE__);
|
||||
if(mysql_num_rows($result) != 0 )
|
||||
{
|
||||
print ("<h2>".$lang_index['text_last_five_torrent']."</h2>");
|
||||
@@ -182,7 +182,7 @@ if ($showlastxtorrents_main == "yes") {
|
||||
|
||||
while( $row = mysql_fetch_assoc($result) )
|
||||
{
|
||||
print ("<tr><a href=\"details.php?id=". $row['id'] ."&hit=1\"><td><a href=\"details.php?id=". $row['id'] ."&hit=1\"><b>" . htmlspecialchars($row['name']) . "</b></td></a><td align=\"center\">" . $row['seeders'] . "</td><td align=\"center\">" . $row['leechers'] . "</td></tr>");
|
||||
print ("<tr><a href=\"details.php?id=". $row['id'] ."&hit=1\"><td><a href=\"details.php?id=". $row['id'] ."&hit=1\"><b>" . htmlspecialchars($row['name']) . "</b><br/>" . htmlspecialchars($row['small_descr']) ."</td></a><td align=\"center\">" . $row['seeders'] . "</td><td align=\"center\">" . $row['leechers'] . "</td></tr>");
|
||||
}
|
||||
print ("</table>");
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ return [
|
||||
'settings' => 'Settings',
|
||||
'users_medals' => 'User medals',
|
||||
'claims' => 'User claims',
|
||||
'torrent_list' => 'Torrents',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
@@ -64,5 +65,11 @@ return [
|
||||
'bulk_action_pardon' => 'Bulk pardon',
|
||||
'action_pardon' => 'Pardon',
|
||||
],
|
||||
'torrent' => [
|
||||
'bulk_action_pos_state' => 'Sticky',
|
||||
'bulk_action_remove_tag' => 'Remove tag',
|
||||
'bulk_action_attach_tag' => 'Attach tag',
|
||||
'action_approval' => 'Approval',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
@@ -111,11 +111,19 @@ return [
|
||||
'label' => 'Torrent',
|
||||
'size' => 'Size',
|
||||
'ttl' => 'TTL',
|
||||
'seeders' => 'Seeders',
|
||||
'leechers' => 'Leechers',
|
||||
'times_completed' => 'Complete',
|
||||
'category' => 'Category',
|
||||
'approval_status' => 'Approval status',
|
||||
'pos_state' => 'Pos state',
|
||||
'sp_state' => 'Promotion',
|
||||
],
|
||||
'hit_and_run' => [
|
||||
|
||||
],
|
||||
'tag' => [
|
||||
'label' => 'Tag',
|
||||
'color' => 'Background color',
|
||||
'font_color' => 'Font color',
|
||||
'font_size' => 'Font size',
|
||||
|
||||
@@ -69,8 +69,8 @@ return [
|
||||
'comment_label' => 'Comment(optional)',
|
||||
'status_text' => [
|
||||
\App\Models\Torrent::APPROVAL_STATUS_NONE => 'Not reviewed',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Review approved',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_DENY => 'Review not approved',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Approved',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_DENY => 'Not approved',
|
||||
],
|
||||
'deny_comment_show' => 'Denied, reason: :reason',
|
||||
],
|
||||
|
||||
@@ -13,6 +13,7 @@ return [
|
||||
'settings' => '设置',
|
||||
'users_medals' => '用户勋章',
|
||||
'claims' => '用户认领',
|
||||
'torrent_list' => '种子',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
@@ -64,5 +65,11 @@ return [
|
||||
'bulk_action_pardon' => '批量免罪',
|
||||
'action_pardon' => '免罪',
|
||||
],
|
||||
'torrent' => [
|
||||
'bulk_action_pos_state' => '置顶',
|
||||
'bulk_action_remove_tag' => '清除标签',
|
||||
'bulk_action_attach_tag' => '设置标签',
|
||||
'action_approval' => '审核',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
@@ -108,13 +108,21 @@ return [
|
||||
],
|
||||
'torrent' => [
|
||||
'label' => '种子',
|
||||
'size' => '体积',
|
||||
'size' => '大小',
|
||||
'ttl' => '存活时间',
|
||||
'seeders' => '做种',
|
||||
'leechers' => '下载',
|
||||
'times_completed' => '完成次数',
|
||||
'category' => '类型',
|
||||
'approval_status' => '审核状态',
|
||||
'pos_state' => '置顶',
|
||||
'sp_state' => '优惠',
|
||||
],
|
||||
'hit_and_run' => [
|
||||
|
||||
],
|
||||
'tag' => [
|
||||
'label' => '标签',
|
||||
'color' => '背景颜色',
|
||||
'font_color' => '字体颜色',
|
||||
'font_size' => '字体大小',
|
||||
|
||||
@@ -13,6 +13,7 @@ return [
|
||||
'settings' => '設置',
|
||||
'users_medals' => '用戶勛章',
|
||||
'claims' => '用戶認領',
|
||||
'torrent_list' => '種子',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
@@ -64,5 +65,11 @@ return [
|
||||
'bulk_action_pardon' => '批量免罪',
|
||||
'action_pardon' => '免罪',
|
||||
],
|
||||
'torrent' => [
|
||||
'bulk_action_pos_state' => '置頂',
|
||||
'bulk_action_remove_tag' => '清除標簽',
|
||||
'bulk_action_attach_tag' => '設置標簽',
|
||||
'action_approval' => '審核',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
@@ -109,13 +109,21 @@ return [
|
||||
],
|
||||
'torrent' => [
|
||||
'label' => '種子',
|
||||
'size' => '體積',
|
||||
'size' => '大小',
|
||||
'ttl' => '存活時間',
|
||||
'seeders' => '做种',
|
||||
'leechers' => '下载',
|
||||
'times_completed' => '完成次數',
|
||||
'category' => '類型',
|
||||
'approval_status' => '審核狀態',
|
||||
'pos_state' => '置頂',
|
||||
'sp_state' => '優惠',
|
||||
],
|
||||
'hit_and_run' => [
|
||||
|
||||
],
|
||||
'tag' => [
|
||||
'label' => '標簽',
|
||||
'color' => '背景顏色',
|
||||
'font_color' => '字體顏色',
|
||||
'font_size' => '字體大小',
|
||||
|
||||
Reference in New Issue
Block a user