mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 09:30:49 +08:00
improve migration file + seedbox management
This commit is contained in:
@@ -46,6 +46,8 @@ use Nexus\Imdb\Imdb;
|
||||
use NexusPlugin\PostLike\PostLikeRepository;
|
||||
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
|
||||
use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator;
|
||||
use PhpIP\IP;
|
||||
use PhpIP\IPBlock;
|
||||
use Rhilip\Bencode\Bencode;
|
||||
|
||||
class Test extends Command
|
||||
@@ -81,11 +83,10 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$r = Str::of(class_basename(\App\Models\AgentAllow::class))
|
||||
->plural()
|
||||
->kebab()
|
||||
->slug();
|
||||
|
||||
$ip = '116.30.133.129';
|
||||
// $ip = '240e:3a1:680c:bb11:211:32ff:fe2c:a603';
|
||||
$ipObj = IPBlock::create($ip);
|
||||
$r = $ipObj->getFirstIp();
|
||||
dd($r);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
|
||||
use App\Filament\Resources\System\SeedBoxRecordResource\Pages;
|
||||
use App\Filament\Resources\System\SeedBoxRecordResource\RelationManagers;
|
||||
use App\Models\SeedBoxRecord;
|
||||
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 SeedBoxRecordResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SeedBoxRecord::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-archive';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 98;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.seedbox_records');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('operator')->label(__('label.seedbox_record.operator')),
|
||||
Forms\Components\TextInput::make('bandwidth')->label(__('label.seedbox_record.bandwidth'))->integer(),
|
||||
Forms\Components\TextInput::make('ip_begin')->label(__('label.seedbox_record.ip_begin')),
|
||||
Forms\Components\TextInput::make('ip_end')->label(__('label.seedbox_record.ip_end')),
|
||||
Forms\Components\TextInput::make('ip')->label(__('label.seedbox_record.ip'))->helperText(__('label.seedbox_record.ip_help')),
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('typeText')->label(__('label.seedbox_record.type')),
|
||||
Tables\Columns\TextColumn::make('user.username')->label(__('label.username')),
|
||||
Tables\Columns\TextColumn::make('operation')->label(__('label.seedbox_record.operator')),
|
||||
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seedbox_record.bandwidth')),
|
||||
Tables\Columns\TextColumn::make('ip')->label(__('label.seedbox_record.ip'))->formatStateUsing(fn ($record) => $record->ip ?: sprintf('%s ~ %s', $record->ip_begin, $record->ip_end)),
|
||||
Tables\Columns\TextColumn::make('comment')->label(__('label.comment')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListSeedBoxRecords::route('/'),
|
||||
'create' => Pages\CreateSeedBoxRecord::route('/create'),
|
||||
'edit' => Pages\EditSeedBoxRecord::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SeedBoxRecordResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\SeedBoxRecordResource;
|
||||
use App\Models\SeedBoxRecord;
|
||||
use App\Repositories\SeedBoxRepository;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateSeedBoxRecord extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SeedBoxRecordResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data['uid'] = auth()->id();
|
||||
$data['type'] = SeedBoxRecord::TYPE_ADMIN;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$seedBoxRep = new SeedBoxRepository();
|
||||
try {
|
||||
return $seedBoxRep->store($data);
|
||||
} catch (\Exception $exception) {
|
||||
//this wont work...
|
||||
$this->notify('danger', $exception->getMessage());
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SeedBoxRecordResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\SeedBoxRecordResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSeedBoxRecord extends EditRecord
|
||||
{
|
||||
protected static string $resource = SeedBoxRecordResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SeedBoxRecordResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\System\SeedBoxRecordResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSeedBoxRecords extends PageList
|
||||
{
|
||||
protected static string $resource = SeedBoxRecordResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class SeedBoxRecord extends NexusModel
|
||||
{
|
||||
protected $table = 'seedbox_records';
|
||||
|
||||
protected $fillable = ['type', 'uid', 'operator', 'bandwidth', 'ip', 'ip_begin', 'ip_end', 'ip_begin_numeric', 'ip_end_numeric', 'comment'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
const TYPE_USER = 1;
|
||||
const TYPE_ADMIN = 2;
|
||||
|
||||
protected function typeText(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn($value, $attributes) => __("seedbox.type_text." . $attributes['type'])
|
||||
);
|
||||
}
|
||||
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'uid');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Poll;
|
||||
use App\Models\SeedBoxRecord;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PhpIP\IP;
|
||||
use PhpIP\IPBlock;
|
||||
|
||||
class SeedBoxRepository extends BaseRepository
|
||||
{
|
||||
public function getList(array $params)
|
||||
{
|
||||
$query = Poll::query();
|
||||
list($sortField, $sortType) = $this->getSortFieldAndType($params);
|
||||
$query->orderBy($sortField, $sortType);
|
||||
return $query->paginate();
|
||||
}
|
||||
|
||||
public function store(array $params)
|
||||
{
|
||||
if (!empty($params['ip']) && empty($params['ip_begin']) && empty($params['ip_end'])) {
|
||||
if (str_contains($params['ip'], '/')) {
|
||||
$ipBlock = IPBlock::create($params['ip']);
|
||||
$params['ip_begin_numeric'] = $ipBlock->getFirstIp()->numeric();
|
||||
$params['ip_end_numeric'] = $ipBlock->getLastIp()->numeric();
|
||||
} else {
|
||||
$ip = IP::create($params['ip']);
|
||||
$params['ip_begin_numeric'] = $ip->numeric();
|
||||
$params['ip_end_numeric'] = $ip->numeric();
|
||||
}
|
||||
} elseif (empty($params['ip']) && !empty($params['ip_begin']) && !empty($params['ip_end'])) {
|
||||
$ipBegin = IP::create($params['ip_begin']);
|
||||
$params['ip_begin_numeric'] = $ipBegin->numeric();
|
||||
|
||||
$ipEnd = IP::create($params['ip_end']);
|
||||
$params['ip_end_numeric'] = $ipEnd->numeric();
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Require ip or ip_begin + ip_end");
|
||||
}
|
||||
|
||||
return SeedBoxRecord::query()->create($params);
|
||||
}
|
||||
|
||||
public function update(array $params, $id)
|
||||
{
|
||||
$model = Poll::query()->findOrFail($id);
|
||||
$model->update($params);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function getDetail($id)
|
||||
{
|
||||
$model = Poll::query()->findOrFail($id);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function delete($id, $uid)
|
||||
{
|
||||
return SeedBoxRecord::query()->whereIn('id', Arr::wrap($id))->where('uid', $uid)->delete();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,6 +49,7 @@
|
||||
"orangehill/iseed": "^3.0",
|
||||
"phpgangsta/googleauthenticator": "dev-master",
|
||||
"rhilip/bencode": "^2.0",
|
||||
"rlanvin/php-ip": "^3.0",
|
||||
"spiral/roadrunner": "^2.8"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
Generated
+45
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f25ef23bbab12c64d2125ead6357473b",
|
||||
"content-hash": "480b59d5b7bde3ea71a3c52e64455c7b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/laravel-money",
|
||||
@@ -5775,6 +5775,50 @@
|
||||
},
|
||||
"time": "2022-07-17T11:19:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rlanvin/php-ip",
|
||||
"version": "v3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rlanvin/php-ip.git",
|
||||
"reference": "7811f12256a5a610ddcb31ed9840179f4dd3784d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rlanvin/php-ip/zipball/7811f12256a5a610ddcb31ed9840179f4dd3784d",
|
||||
"reference": "7811f12256a5a610ddcb31ed9840179f4dd3784d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-gmp": "*",
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.5|^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpIP\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "IPv4/IPv6 manipulation library for PHP",
|
||||
"homepage": "https://github.com/rlanvin/php-ip",
|
||||
"keywords": [
|
||||
"IP",
|
||||
"ipv4",
|
||||
"ipv6"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rlanvin/php-ip/issues",
|
||||
"source": "https://github.com/rlanvin/php-ip/tree/v3.0.0"
|
||||
},
|
||||
"time": "2022-03-02T08:51:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-package-tools",
|
||||
"version": "1.12.1",
|
||||
|
||||
@@ -13,6 +13,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('users', 'attendance_card')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('attendance_card')->default(0);
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('torrents', 'cover')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('torrents', function (Blueprint $table) {
|
||||
$table->string('cover')->default('')->after('save_as');
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('settings', 'autoload')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->enum('autoload', ['yes', 'no'])->default('yes');
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('torrents', 'approval_status')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('torrents', function (Blueprint $table) {
|
||||
$table->integer('approval_status')->default(0);
|
||||
});
|
||||
|
||||
@@ -13,6 +13,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('torrents_state', 'deadline')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('torrents_state', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->dateTime('deadline')->nullable();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('seedbox_records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('type');
|
||||
$table->integer('uid');
|
||||
$table->string('operator')->nullable();
|
||||
$table->integer('bandwidth')->nullable();
|
||||
$table->string('ip')->nullable();
|
||||
$table->string('ip_begin')->nullable();
|
||||
$table->string('ip_end')->nullable();
|
||||
$table->string('ip_begin_numeric', 128)->index();
|
||||
$table->string('ip_end_numeric', 128)->index();
|
||||
$table->string('comment')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('seedbox_records');
|
||||
}
|
||||
};
|
||||
@@ -323,6 +323,7 @@ $lang_functions = array
|
||||
'text_contactstaff' => '联系管理组',
|
||||
'full_site_promotion_in_effect' => '全站 [%s] 生效中!截止时间:%s',
|
||||
'text_torrent_to_approval' => '有 %s%u 个待审核的种子%s',
|
||||
'std_confirm_remove' => '确定要删除吗?',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -252,6 +252,8 @@ $lang_usercp = array
|
||||
'text_two_step_secret_bind_complete_note' => '输入 code 完成两步验证',
|
||||
'text_two_step_secret_unbind_note' => '输入 code 取消两步验证',
|
||||
'row_passkey_login_url' => 'Passkey 登录链接',
|
||||
'row_seed_box' => 'SeedBox',
|
||||
'add_seed_box_btn' => '登记',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -330,6 +330,7 @@ $lang_functions = array
|
||||
'text_contactstaff' => '聯系管理組',
|
||||
'full_site_promotion_in_effect' => '全站 [%s] 生效中!截止時間:%s',
|
||||
'text_torrent_to_approval' => '有 %s%u 個待審核的種子%s',
|
||||
'std_confirm_remove' => '確定要刪除嗎?',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -250,6 +250,8 @@ $lang_usercp = array
|
||||
'text_two_step_secret_bind_complete_note' => '輸入 code 完成兩步驗證',
|
||||
'text_two_step_secret_unbind_note' => '輸入 code 取消兩步驗證',
|
||||
'row_passkey_login_url' => 'Passkey 登錄鏈接',
|
||||
'row_seed_box' => 'SeedBox',
|
||||
'add_seed_box_btn' => '登記',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -331,6 +331,7 @@ $lang_functions = array
|
||||
'text_contactstaff' => 'Contact staff',
|
||||
'full_site_promotion_in_effect' => 'Full site [%s] in effect! Deadline: %s',
|
||||
'text_torrent_to_approval' => 'There %s%u not approval torrent%s.',
|
||||
'std_confirm_remove' => 'Are you sure you want to delete it?',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -252,6 +252,8 @@ $lang_usercp = array
|
||||
'text_two_step_secret_bind_complete_note' => 'Enter code to complete the two-step authentication',
|
||||
'text_two_step_secret_unbind_note' => 'Enter code to cancel two-step authentication',
|
||||
'row_passkey_login_url' => 'Passkey login URL',
|
||||
'row_seed_box' => 'SeedBox',
|
||||
'add_seed_box_btn' => 'Register',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -232,9 +232,12 @@ class Update extends Install
|
||||
$table = 'sysoppanel';
|
||||
$this->addMenu($table, $menus);
|
||||
$menuToDel = ['amountupload.php', 'amountattendancecard.php', 'amountbonus.php', 'deletedisabled.php'];
|
||||
$this->removeMenu('sysoppanel', $menuToDel);
|
||||
$this->removeMenu('adminpanel', $menuToDel);
|
||||
$this->removeMenu('modpanel', $menuToDel);
|
||||
$this->removeMenu($menuToDel);
|
||||
|
||||
/**
|
||||
* @since 1.7.19
|
||||
*/
|
||||
$this->removeMenu(['freeleech.php']);
|
||||
|
||||
}
|
||||
|
||||
@@ -271,10 +274,13 @@ class Update extends Install
|
||||
}
|
||||
}
|
||||
|
||||
private function removeMenu($table, array $menus)
|
||||
private function removeMenu(array $menus, array $tables = ['sysoppanel', 'adminpanel', 'modpanel'])
|
||||
{
|
||||
foreach ($menus as $menu) {
|
||||
NexusDB::delete($table, "url = " . sqlesc($menu));
|
||||
if (empty($menus)) {
|
||||
return;
|
||||
}
|
||||
foreach ($tables as $table) {
|
||||
NexusDB::table($table)->whereIn('url', $menus)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,3 +93,18 @@ function approval($params)
|
||||
return $rep->approval($CURUSER['id'], $params);
|
||||
}
|
||||
|
||||
function addSeedBoxRecord($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
$rep = new \App\Repositories\SeedBoxRepository();
|
||||
$params['uid'] = $CURUSER['id'];
|
||||
$params['type'] = \App\Models\SeedBoxRecord::TYPE_USER;
|
||||
return $rep->store($params);
|
||||
}
|
||||
|
||||
function removeSeedBoxRecord($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
$rep = new \App\Repositories\SeedBoxRepository();
|
||||
return $rep->delete($params['id'], $CURUSER['id']);
|
||||
}
|
||||
|
||||
@@ -945,6 +945,124 @@ if ($prolinkpoint_bonus)
|
||||
tr_small($lang_usercp['row_invitations'],$CURUSER['invites']." [<a href=\"invite.php?id=".$CURUSER['id']."\" title=\"".$lang_usercp['link_send_invitation']."\">".$lang_usercp['text_send']."</a>]",1);
|
||||
tr_small($lang_usercp['row_karma_points'], $CURUSER['seedbonus']." [<a href=\"mybonus.php\" title=\"".$lang_usercp['link_use_karma_points']."\">".$lang_usercp['text_use']."</a>]", 1);
|
||||
tr_small($lang_usercp['row_written_comments'], $commentcount." [<a href=\"userhistory.php?action=viewcomments&id=".$CURUSER['id']."\" title=\"".$lang_usercp['link_view_comments']."\">".$lang_usercp['text_view']."</a>]", 1);
|
||||
|
||||
//start seed box
|
||||
$seedBox = '';
|
||||
$columnOperator = nexus_trans('label.seedbox_record.operator');
|
||||
$columnBandwidth = nexus_trans('label.seedbox_record.bandwidth');
|
||||
$columnIPBegin = nexus_trans('label.seedbox_record.ip_begin');
|
||||
$columnIPEnd = nexus_trans('label.seedbox_record.ip_end');
|
||||
$columnIP = nexus_trans('label.seedbox_record.ip');
|
||||
$columnIPHelp = nexus_trans('label.seedbox_record.ip_help');
|
||||
$columnComment = nexus_trans('label.comment');
|
||||
$res = sql_query(sprintf("SELECT * from seedbox_records where type = %s and uid = %s", \App\Models\SeedBoxRecord::TYPE_USER, $CURUSER['id']));
|
||||
if (mysql_num_rows($res) > 0)
|
||||
{
|
||||
$seedBox .= "<table border='1' cellspacing='0' cellpadding='5' id='seed-box-table'><tr><td class='colhead'>{$columnOperator}</td><td class='colhead'>{$columnBandwidth}</td><td class='colhead'>{$columnIP}</td><td class='colhead'>{$columnComment}</td><td class='colhead'></td></tr>";
|
||||
while($arr = mysql_fetch_assoc($res))
|
||||
{
|
||||
$seedBox .= "<tr>";
|
||||
$seedBox .= sprintf('<td>%s</td>', $arr['operator']);
|
||||
$seedBox .= sprintf('<td>%s</td>', $arr['bandwidth'] ?: '');
|
||||
$seedBox .= sprintf('<td>%s</td>', $arr['ip'] ?: sprintf('%s ~ %s', $arr['ip_begin'], $arr['ip_end']));
|
||||
$seedBox .= sprintf('<td>%s</td>', $arr['comment']);
|
||||
$seedBox .= sprintf('<td><img style="cursor: pointer" class="staff_delete remove-seed-box-btn" src="pic/trans.gif" alt="D" title="%s" data-id="%s"></td>', $lang_functions['text_delete'], $arr['id']);
|
||||
$seedBox .= "</tr>";
|
||||
}
|
||||
$seedBox .= '</table>';
|
||||
}
|
||||
$seedBox .= sprintf('<div><input type="button" id="add-seed-box-btn" value="%s"/></div>', $lang_usercp['add_seed_box_btn']);
|
||||
tr_small($lang_usercp['row_seed_box'], $seedBox, 1);
|
||||
$seedBoxCss = <<<CSS
|
||||
.form-box {
|
||||
padding: 15px;
|
||||
}
|
||||
.form-control-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.form-control-row .label {
|
||||
width: 80px
|
||||
}
|
||||
.form-control-row .field {
|
||||
|
||||
}
|
||||
.form-control-row input,textarea {
|
||||
width: 300px;
|
||||
padding: 4px;
|
||||
}
|
||||
CSS;
|
||||
|
||||
$seedBoxForm = <<<FORM
|
||||
<div class="form-box">
|
||||
<form id="seed-box-form">
|
||||
<div class="form-control-row">
|
||||
<div class="label">{$columnOperator}</div>
|
||||
<div class="field"><input type="text" name="params[operator]"></div>
|
||||
</div>
|
||||
<div class="form-control-row">
|
||||
<div class="label">{$columnBandwidth}</div>
|
||||
<div class="field"><input type="number" name="params[bandwidth]"></div>
|
||||
</div>
|
||||
<div class="form-control-row">
|
||||
<div class="label">{$columnIPBegin}</div>
|
||||
<div class="field"><input type="text" name="params[ip_begin]"></div>
|
||||
</div>
|
||||
<div class="form-control-row">
|
||||
<div class="label">{$columnIPEnd}</div>
|
||||
<div class="field"><input type="text" name="params[ip_end]"></div>
|
||||
</div>
|
||||
<div class="form-control-row">
|
||||
<div class="label">{$columnIP}</div>
|
||||
<div class="field"><input type="text" name="params[ip]"><div><small>{$columnIPHelp}</small></div></div>
|
||||
</div>
|
||||
<div class="form-control-row">
|
||||
<div class="label">{$columnComment}</div>
|
||||
<div class="field"><textarea name="params[comment]" rows="4"></textarea></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
FORM;
|
||||
$seedBoxJs = <<<JS
|
||||
jQuery('#add-seed-box-btn').on('click', function () {
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: "{$lang_usercp['row_seed_box']} {$lang_usercp['add_seed_box_btn']}",
|
||||
content: `$seedBoxForm`,
|
||||
btn: ['OK'],
|
||||
btnAlign: 'c',
|
||||
yes: function () {
|
||||
let params = jQuery('#seed-box-form').serialize()
|
||||
jQuery.post('ajax.php', params + "&action=addSeedBoxRecord", function (response) {
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
layer.alert(response.msg)
|
||||
return
|
||||
}
|
||||
window.location.reload()
|
||||
}, 'json')
|
||||
}
|
||||
})
|
||||
});
|
||||
jQuery('#seed-box-table').on('click', '.remove-seed-box-btn', function () {
|
||||
let params = {action: "removeSeedBoxRecord", params: {id: jQuery(this).attr("data-id")}}
|
||||
layer.confirm("{$lang_functions['std_confirm_remove']}", {btnAlign: 'c'}, function (index) {
|
||||
jQuery.post('ajax.php', params, function (response) {
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
layer.alert(response.msg)
|
||||
return
|
||||
}
|
||||
window.location.reload()
|
||||
}, 'json')
|
||||
})
|
||||
});
|
||||
JS;
|
||||
\Nexus\Nexus::js($seedBoxJs, 'footer', false);
|
||||
\Nexus\Nexus::css($seedBoxCss, 'footer', false);
|
||||
//end seed box
|
||||
|
||||
if ($forumposts)
|
||||
tr($lang_usercp['row_forum_posts'], $forumposts." [<a href=\"userhistory.php?action=viewposts&id=".$CURUSER['id']."\" title=\"".$lang_usercp['link_view_posts']."\">".$lang_usercp['text_view']."</a>] (".$dayposts.$lang_usercp['text_posts_per_day']."; ".$percentages.$lang_usercp['text_of_total_posts'].")", 1);
|
||||
?>
|
||||
|
||||
@@ -17,6 +17,7 @@ return [
|
||||
'torrent_state' => 'Free leach',
|
||||
'roles_list' => 'Roles',
|
||||
'ability_list' => 'Permissions',
|
||||
'seedbox_records' => 'SeedBox',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -172,4 +172,14 @@ return [
|
||||
'role' => [
|
||||
'class' => 'Relate user class',
|
||||
],
|
||||
'seedbox_record' => [
|
||||
'label' => 'SeedBox Records',
|
||||
'type' => 'Add type',
|
||||
'operator' => 'Operator',
|
||||
'bandwidth' => 'Bandwidth(Mbps)',
|
||||
'ip' => 'IP(Block)',
|
||||
'ip_begin' => 'Begin IP',
|
||||
'ip_end' => 'End IP',
|
||||
'ip_help' => 'Begin IP/End IP, IP(Block) Choose one',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'type_text' => [
|
||||
\App\Models\SeedBoxRecord::TYPE_USER => 'User',
|
||||
\App\Models\SeedBoxRecord::TYPE_ADMIN => 'Administrator',
|
||||
],
|
||||
];
|
||||
@@ -17,6 +17,7 @@ return [
|
||||
'torrent_state' => '全站优惠',
|
||||
'roles_list' => '角色',
|
||||
'ability_list' => '权限',
|
||||
'seedbox_records' => 'SeedBox',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -175,4 +175,14 @@ return [
|
||||
'name' => '标识',
|
||||
'title' => '名称',
|
||||
],
|
||||
'seedbox_record' => [
|
||||
'label' => 'SeedBox 记录',
|
||||
'type' => '添加类型',
|
||||
'operator' => '运营商',
|
||||
'bandwidth' => '带宽(Mbps)',
|
||||
'ip' => 'IP(段)',
|
||||
'ip_begin' => '起始 IP',
|
||||
'ip_end' => '结束 IP',
|
||||
'ip_help' => '起始 IP/结束 IP、IP(段) 二选一',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'type_text' => [
|
||||
\App\Models\SeedBoxRecord::TYPE_USER => '用户',
|
||||
\App\Models\SeedBoxRecord::TYPE_ADMIN => '管理员',
|
||||
],
|
||||
];
|
||||
@@ -17,6 +17,7 @@ return [
|
||||
'torrent_state' => '全站優惠',
|
||||
'roles_list' => '角色',
|
||||
'ability_list' => '權限',
|
||||
'seedbox_records' => 'SeedBox',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -172,4 +172,14 @@ return [
|
||||
'role' => [
|
||||
'class' => '關聯用户等級',
|
||||
],
|
||||
'seedbox_record' => [
|
||||
'label' => 'SeedBox 記錄',
|
||||
'type' => '添加類型',
|
||||
'operator' => '運營商',
|
||||
'bandwidth' => '帶寬(Mbps)',
|
||||
'ip' => 'IP(段)',
|
||||
'ip_begin' => '起始 IP',
|
||||
'ip_end' => '結束 IP',
|
||||
'ip_help' => '起始 IP/結束 IP、IP(段) 二選一',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'type_text' => [
|
||||
\App\Models\SeedBoxRecord::TYPE_USER => '用戶',
|
||||
\App\Models\SeedBoxRecord::TYPE_ADMIN => '管理員',
|
||||
],
|
||||
];
|
||||
Reference in New Issue
Block a user