mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add uploadspeed + downloadspeed +isp
This commit is contained in:
@@ -88,7 +88,7 @@ class Test extends Command
|
||||
// $ipObj = IPBlock::create($ip);
|
||||
// $ipObj = IP::create($ip);
|
||||
// $r = $ipObj->getVersion();
|
||||
$r = get_ip_location('116.30.133.129');
|
||||
$r = isIPSeedBox('116.30.133.129', 1);
|
||||
// $r = get_ip_location_from_geoip('116.30.133.129');
|
||||
dd($r);
|
||||
}
|
||||
|
||||
36
app/Events/SeedBoxRecordUpdated.php
Normal file
36
app/Events/SeedBoxRecordUpdated.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SeedBoxRecordUpdated
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
69
app/Filament/Resources/System/DownloadSpeedResource.php
Normal file
69
app/Filament/Resources/System/DownloadSpeedResource.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
|
||||
use App\Filament\Resources\System\DownloadSpeedResource\Pages;
|
||||
use App\Filament\Resources\System\DownloadSpeedResource\RelationManagers;
|
||||
use App\Models\DownloadSpeed;
|
||||
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 DownloadSpeedResource extends Resource
|
||||
{
|
||||
protected static ?string $model = DownloadSpeed::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-download';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.download_speed');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label(__('label.name'))
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManageDownloadSpeeds::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\DownloadSpeedResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\DownloadSpeedResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageDownloadSpeeds extends ManageRecords
|
||||
{
|
||||
protected static string $resource = DownloadSpeedResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
69
app/Filament/Resources/System/IspResource.php
Normal file
69
app/Filament/Resources/System/IspResource.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
|
||||
use App\Filament\Resources\System\IspResource\Pages;
|
||||
use App\Filament\Resources\System\IspResource\RelationManagers;
|
||||
use App\Models\Isp;
|
||||
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 IspResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Isp::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-globe-alt';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.isp');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label(__('label.name'))
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManageIsps::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\IspResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\IspResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageIsps extends ManageRecords
|
||||
{
|
||||
protected static string $resource = IspResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
69
app/Filament/Resources/System/UploadSpeedResource.php
Normal file
69
app/Filament/Resources/System/UploadSpeedResource.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
|
||||
use App\Filament\Resources\System\UploadSpeedResource\Pages;
|
||||
use App\Filament\Resources\System\UploadSpeedResource\RelationManagers;
|
||||
use App\Models\UploadSpeed;
|
||||
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 UploadSpeedResource extends Resource
|
||||
{
|
||||
protected static ?string $model = UploadSpeed::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-upload';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.upload_speed');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label(__('label.name'))
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManageUploadSpeeds::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\UploadSpeedResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\UploadSpeedResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageUploadSpeeds extends ManageRecords
|
||||
{
|
||||
protected static string $resource = UploadSpeedResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ class UserProfile extends Page
|
||||
->action(function () {
|
||||
$userRep = new UserRepository();
|
||||
try {
|
||||
$userRep->toggleDownloadPrivileges(Auth::user(), $this->record->id);
|
||||
$userRep->updateDownloadPrivileges(Auth::user(), $this->record->id, $this->record->downloadpos == 'yes' ? 'no' : 'yes');
|
||||
$this->notify('success', 'Success!');
|
||||
$this->emitSelf(self::EVENT_RECORD_UPDATED, $this->record->id);
|
||||
} catch (\Exception $exception) {
|
||||
|
||||
@@ -49,8 +49,8 @@ class Locale
|
||||
public static function getLocaleFromCookie()
|
||||
{
|
||||
if (IN_NEXUS) {
|
||||
$lang = get_langfolder_cookie();
|
||||
$log = "IN_NEXUS, get_langfolder_cookie(): $lang";
|
||||
$lang = IN_TRACKER ? null : get_langfolder_cookie();
|
||||
$log = "IN_NEXUS, get_langfolder_cookie() or IN_TRACKER use null: $lang";
|
||||
} else {
|
||||
$lang = Cookie::get('c_lang_folder');
|
||||
$log = "Cookie::get(): $lang";
|
||||
|
||||
31
app/Listeners/RemoveSeedBoxRecordCache.php
Normal file
31
app/Listeners/RemoveSeedBoxRecordCache.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class RemoveSeedBoxRecordCache implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
NexusDB::cache_del_by_pattern("nexus_is_ip_seed_box:ip:*");
|
||||
}
|
||||
}
|
||||
11
app/Models/DownloadSpeed.php
Normal file
11
app/Models/DownloadSpeed.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class DownloadSpeed extends NexusModel
|
||||
{
|
||||
protected $table = 'downloadspeed';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
}
|
||||
11
app/Models/Isp.php
Normal file
11
app/Models/Isp.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class Isp extends NexusModel
|
||||
{
|
||||
protected $table = 'isp';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
}
|
||||
11
app/Models/UploadSpeed.php
Normal file
11
app/Models/UploadSpeed.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class UploadSpeed extends NexusModel
|
||||
{
|
||||
protected $table = 'uploadspeed';
|
||||
|
||||
protected $fillable = ['name'];
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Events\SeedBoxRecordUpdated;
|
||||
use App\Events\TorrentUpdated;
|
||||
use App\Listeners\RemoveSeedBoxRecordCache;
|
||||
use App\Listeners\SyncTorrentToEs;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
@@ -23,6 +25,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
TorrentUpdated::class => [
|
||||
SyncTorrentToEs::class,
|
||||
],
|
||||
SeedBoxRecordUpdated::class => [
|
||||
RemoveSeedBoxRecordCache::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,10 +39,13 @@ class BaseRepository
|
||||
/**
|
||||
* @param $user
|
||||
* @param null $fields
|
||||
* @return User
|
||||
* @return User|null
|
||||
*/
|
||||
protected function getUser($user, $fields = null): User
|
||||
protected function getUser($user, $fields = null): User|null
|
||||
{
|
||||
if ($user === null) {
|
||||
return null;
|
||||
}
|
||||
if ($user instanceof User) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Events\SeedBoxRecordUpdated;
|
||||
use App\Exceptions\InsufficientPermissionException;
|
||||
use App\Models\Message;
|
||||
use App\Models\Poll;
|
||||
@@ -140,7 +141,8 @@ class SeedBoxRepository extends BaseRepository
|
||||
|
||||
private function clearCache()
|
||||
{
|
||||
NexusDB::redis()->del("nexus_is_ip_seed_box");
|
||||
return true;
|
||||
// SeedBoxRecordUpdated::dispatch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -590,7 +590,7 @@ class TrackerRepository extends BaseRepository
|
||||
$notSeedBoxMaxSpeedMbps = Setting::get('seed_box.not_seed_box_max_speed');
|
||||
do_log("upSpeedMbps: $upSpeedMbps, notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps");
|
||||
if ($upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
|
||||
$user->update(['downloadpos' => 'no']);
|
||||
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $user, 'no');
|
||||
do_log("user: {$user->id} downloading privileges have been disabled! (over speed)", 'error');
|
||||
throw new TrackerException("Your downloading privileges have been disabled! (over speed)");
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ class UserRepository extends BaseRepository
|
||||
UserBanLog::query()->insert($banLog);
|
||||
});
|
||||
do_log("user: $uid, $modCommentText");
|
||||
$this->clearCache($targetUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -199,6 +200,7 @@ class UserRepository extends BaseRepository
|
||||
$modCommentText = sprintf("%s - Enable by %s, reason: %s", now()->format('Y-m-d'), $operator->username, $reason);
|
||||
$targetUser->updateWithModComment($update, $modCommentText);
|
||||
do_log("user: $uid, $modCommentText, update: " . nexus_json_encode($update));
|
||||
$this->clearCache($targetUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -289,16 +291,16 @@ class UserRepository extends BaseRepository
|
||||
}
|
||||
Message::query()->insert($message);
|
||||
});
|
||||
$this->clearCache($targetUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function removeLeechWarn($operator, $uid): bool
|
||||
{
|
||||
$operator = $this->getUser($operator);
|
||||
$classRequire = Setting::get('authority.prfmanage');
|
||||
$user = User::query()->findOrFail($uid, User::$commonFields);
|
||||
$this->checkPermission($operator, $user);
|
||||
NexusDB::cache_del('user_'.$uid.'_content');
|
||||
$this->clearCache($user);
|
||||
$user->leechwarn = 'no';
|
||||
$user->leechwarnuntil = null;
|
||||
return $user->save();
|
||||
@@ -311,33 +313,42 @@ class UserRepository extends BaseRepository
|
||||
}
|
||||
$user = User::query()->findOrFail($uid, User::$commonFields);
|
||||
$this->checkPermission($operator, $user);
|
||||
$this->clearCache($user);
|
||||
$user->two_step_secret = '';
|
||||
return $user->save();
|
||||
}
|
||||
|
||||
|
||||
public function toggleDownloadPrivileges($operator, $id)
|
||||
public function updateDownloadPrivileges($operator, $user, $status)
|
||||
{
|
||||
$targetUser = User::query()->findOrFail($id, User::$commonFields);
|
||||
if (!in_array($status, ['yes', 'no'])) {
|
||||
throw new \InvalidArgumentException("Invalid status: $status");
|
||||
}
|
||||
$targetUser = $this->getUser($user);
|
||||
$operator = $this->getUser($operator);
|
||||
$this->checkPermission($operator, $targetUser);
|
||||
$operatorUsername = 'System';
|
||||
if ($operator) {
|
||||
$operatorUsername = $operator->username;
|
||||
$this->checkPermission($operator, $targetUser);
|
||||
}
|
||||
$message = [
|
||||
'added' => now(),
|
||||
'receiver' => $targetUser->id,
|
||||
];
|
||||
if ($targetUser->downloadpos == 'yes') {
|
||||
if ($status == 'no') {
|
||||
$update = ['downloadpos' => 'no'];
|
||||
$modComment = date('Y-m-d') . " - Download disable by " . $operator->username;
|
||||
$modComment = date('Y-m-d') . " - Download disable by " . $operatorUsername;
|
||||
$message['subject'] = nexus_trans('message.download_disable.subject', [], $targetUser->locale);
|
||||
$message['msg'] = nexus_trans('message.download_disable.body', ['operator' => $operator->username], $targetUser->locale);
|
||||
$message['msg'] = nexus_trans('message.download_disable.body', ['operator' => $operatorUsername], $targetUser->locale);
|
||||
} else {
|
||||
$update = ['downloadpos' => 'yes'];
|
||||
$modComment = date('Y-m-d') . " - Download enable by " . $operator->username;
|
||||
$modComment = date('Y-m-d') . " - Download enable by " . $operatorUsername;
|
||||
$message['subject'] = nexus_trans('message.download_enable.subject', [], $targetUser->locale);
|
||||
$message['msg'] = nexus_trans('message.download_enable.body', ['operator' => $operator->username], $targetUser->locale);
|
||||
$message['msg'] = nexus_trans('message.download_enable.body', ['operator' => $operatorUsername], $targetUser->locale);
|
||||
}
|
||||
return NexusDB::transaction(function () use ($targetUser, $update, $modComment, $message) {
|
||||
Message::add($message);
|
||||
$this->clearCache($targetUser);
|
||||
return $targetUser->updateWithModComment($update, $modComment);
|
||||
});
|
||||
}
|
||||
@@ -352,6 +363,12 @@ class UserRepository extends BaseRepository
|
||||
}
|
||||
}
|
||||
|
||||
private function clearCache(User $user)
|
||||
{
|
||||
\Nexus\Database\NexusDB::cache_del("user_{$user->id}_content");
|
||||
\Nexus\Database\NexusDB::cache_del('user_passkey_'.$user->passkey.'_content');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,75 +14,75 @@ class AdminpanelTableSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
|
||||
|
||||
\DB::table('adminpanel')->delete();
|
||||
|
||||
|
||||
\DB::table('adminpanel')->insert(array (
|
||||
0 =>
|
||||
0 =>
|
||||
array (
|
||||
'id' => 1,
|
||||
'name' => 'Add user',
|
||||
'url' => 'adduser.php',
|
||||
'info' => 'Create new user account',
|
||||
),
|
||||
1 =>
|
||||
1 =>
|
||||
array (
|
||||
'id' => 3,
|
||||
'name' => 'Reset Users Password',
|
||||
'url' => 'reset.php',
|
||||
'info' => 'Rest lost Passwords',
|
||||
),
|
||||
2 =>
|
||||
2 =>
|
||||
array (
|
||||
'id' => 4,
|
||||
'name' => 'Mass PM',
|
||||
'url' => 'staffmess.php',
|
||||
'info' => 'Send PM to all users',
|
||||
),
|
||||
3 =>
|
||||
3 =>
|
||||
array (
|
||||
'id' => 6,
|
||||
'name' => 'Poll overview',
|
||||
'url' => 'polloverview.php',
|
||||
'info' => 'View poll votes',
|
||||
),
|
||||
4 =>
|
||||
4 =>
|
||||
array (
|
||||
'id' => 7,
|
||||
'name' => 'Warned users',
|
||||
'url' => 'warned.php',
|
||||
'info' => 'See all warned users on tracker',
|
||||
),
|
||||
5 =>
|
||||
array (
|
||||
'id' => 8,
|
||||
'name' => 'FreeLeech',
|
||||
'url' => 'freeleech.php',
|
||||
'info' => 'Set ALL Torrents At Special State.',
|
||||
),
|
||||
6 =>
|
||||
// 5 =>
|
||||
// array (
|
||||
// 'id' => 8,
|
||||
// 'name' => 'FreeLeech',
|
||||
// 'url' => 'freeleech.php',
|
||||
// 'info' => 'Set ALL Torrents At Special State.',
|
||||
// ),
|
||||
6 =>
|
||||
array (
|
||||
'id' => 9,
|
||||
'name' => 'FAQ Management',
|
||||
'url' => 'faqmanage.php',
|
||||
'info' => 'Edit/Add/Delete FAQ Page',
|
||||
),
|
||||
7 =>
|
||||
7 =>
|
||||
array (
|
||||
'id' => 10,
|
||||
'name' => 'Rules Management',
|
||||
'url' => 'modrules.php',
|
||||
'info' => 'Edit/Add/Delete RULES Page',
|
||||
),
|
||||
8 =>
|
||||
8 =>
|
||||
array (
|
||||
'id' => 11,
|
||||
'name' => 'Category Manage',
|
||||
'url' => 'catmanage.php',
|
||||
'info' => 'Manage torrents categories at your site',
|
||||
),
|
||||
9 =>
|
||||
9 =>
|
||||
array (
|
||||
'id' => 12,
|
||||
'name' => 'Custom Field Manage',
|
||||
@@ -90,7 +90,7 @@ class AdminpanelTableSeeder extends Seeder
|
||||
'info' => 'Manage custom fields',
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.19');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-25');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-30');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
defined('NEXUSWIKIURL') || define("NEXUSWIKIURL","https://doc.nexusphp.org");
|
||||
|
||||
@@ -3,18 +3,19 @@
|
||||
function get_global_sp_state()
|
||||
{
|
||||
static $global_promotion_state;
|
||||
$cacheKey = 'global_promotion_state';
|
||||
if (!$global_promotion_state) {
|
||||
if (!$global_promotion_state = \Nexus\Database\NexusDB::cache_get('global_promotion_state')){
|
||||
$row = \Nexus\Database\NexusDB::getOne('torrents_state', 1);
|
||||
if (isset($row['deadline']) && $row['deadline'] < date('Y-m-d H:i:s')) {
|
||||
//expired
|
||||
$global_promotion_state = \App\Models\Torrent::PROMOTION_NORMAL;
|
||||
} else {
|
||||
$global_promotion_state = $row["global_sp_state"];
|
||||
}
|
||||
\Nexus\Database\NexusDB::cache_put('global_promotion_state', $global_promotion_state, 600);
|
||||
\Nexus\Database\NexusDB::cache_put('global_promotion_state_deadline', $row['deadline'], 600);
|
||||
}
|
||||
$row = \Nexus\Database\NexusDB::remember($cacheKey, 600, function () use ($cacheKey) {
|
||||
$row = \Nexus\Database\NexusDB::getOne('torrents_state', 1);
|
||||
\Nexus\Database\NexusDB::cache_put($cacheKey . '_deadline', $row['deadline'], 600);
|
||||
return $row;
|
||||
});
|
||||
if (isset($row['deadline']) && $row['deadline'] < date('Y-m-d H:i:s')) {
|
||||
//expired
|
||||
$global_promotion_state = \App\Models\Torrent::PROMOTION_NORMAL;
|
||||
} else {
|
||||
$global_promotion_state = $row["global_sp_state"];
|
||||
}
|
||||
}
|
||||
return $global_promotion_state;
|
||||
}
|
||||
@@ -769,8 +770,8 @@ function isIPSeedBox($ip, $uid = null, $withoutCache = false): bool
|
||||
{
|
||||
$key = "nexus_is_ip_seed_box:ip:$ip:uid:$uid";
|
||||
$cacheData = \Nexus\Database\NexusDB::cache_get($key);
|
||||
if (in_array($cacheData, [0, 1], true) && !$withoutCache) {
|
||||
do_log("$key, get result from cache: $cacheData");
|
||||
if (in_array($cacheData, [0, 1, '0', '1'], true) && !$withoutCache) {
|
||||
do_log("$key, get result from cache: $cacheData(" . gettype($cacheData) . ")");
|
||||
return (bool)$cacheData;
|
||||
}
|
||||
$ipObject = \PhpIP\IP::create($ip);
|
||||
@@ -782,7 +783,7 @@ function isIPSeedBox($ip, $uid = null, $withoutCache = false): bool
|
||||
);
|
||||
$res = \Nexus\Database\NexusDB::select($checkSeedBoxAdminSql);
|
||||
if (!empty($res)) {
|
||||
\Nexus\Database\NexusDB::cache_put($key, 1);
|
||||
\Nexus\Database\NexusDB::cache_put($key, 1, 300);
|
||||
do_log("$key, get result from admin, true");
|
||||
return true;
|
||||
}
|
||||
@@ -793,12 +794,12 @@ function isIPSeedBox($ip, $uid = null, $withoutCache = false): bool
|
||||
);
|
||||
$res = \Nexus\Database\NexusDB::select($checkSeedBoxUserSql);
|
||||
if (!empty($res)) {
|
||||
\Nexus\Database\NexusDB::cache_put($key, 1);
|
||||
\Nexus\Database\NexusDB::cache_put($key, 1, 300);
|
||||
do_log("$key, get result from user, true");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
\Nexus\Database\NexusDB::cache_put($key, 0);
|
||||
\Nexus\Database\NexusDB::cache_put($key, 0, 300);
|
||||
do_log("$key, no result, false");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -371,6 +371,24 @@ class NexusDB
|
||||
}
|
||||
}
|
||||
|
||||
public static function cache_del_by_pattern($pattern)
|
||||
{
|
||||
$redis = self::redis();
|
||||
$it = NULL;
|
||||
do {
|
||||
// Scan for some keys
|
||||
$arr_keys = $redis->scan($it, $pattern);
|
||||
|
||||
// Redis may return empty results, so protect against that
|
||||
if ($arr_keys !== FALSE) {
|
||||
foreach($arr_keys as $str_key) {
|
||||
do_log("[SCAN_KEY] $str_key");
|
||||
self::cache_del($str_key);
|
||||
}
|
||||
}
|
||||
} while ($it > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|\Redis|null
|
||||
*/
|
||||
|
||||
@@ -358,7 +358,7 @@ else // continue an existing session
|
||||
$upSpeedMbps = number_format(($trueupthis / $self['announcetime'] / 1024 / 1024) * 8);
|
||||
do_log("notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps, upSpeedMbps: $upSpeedMbps");
|
||||
if ($isSeedBoxRuleEnabled && !($az['class'] >= \App\Models\User::CLASS_VIP || $isDonor) && !$isIPSeedBox && $upSpeedMbps > $notSeedBoxMaxSpeedMbps) {
|
||||
sql_query("update users set downloadpos = 'no' where id = $userid");
|
||||
(new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $userid, 'no');
|
||||
do_log("user: $userid downloading privileges have been disabled! (over speed)", 'error');
|
||||
err("Your downloading privileges have been disabled! (over speed)");
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ return [
|
||||
|
||||
'download_disable' => [
|
||||
'subject' => 'Download permission cancellation',
|
||||
'body' => 'Administrator: :operator has revoked your download privileges, possibly due to low sharing rates or misbehavior.',
|
||||
'body' => 'Your download privileges has revoked, possibly due to low sharing rates or misbehavior. By: :operator',
|
||||
],
|
||||
'download_enable' => [
|
||||
'subject' => 'Download permission restored',
|
||||
'body' => 'Administrator: :operator restored your download privileges, you can now download torrents.',
|
||||
'body' => 'Your download privileges restored, you can now download torrents. By: :operator',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -18,6 +18,9 @@ return [
|
||||
'roles_list' => '角色',
|
||||
'ability_list' => '权限',
|
||||
'seed_box_records' => 'SeedBox',
|
||||
'upload_speed' => '上行带宽',
|
||||
'download_speed' => '下行带宽',
|
||||
'isp' => 'ISP',
|
||||
],
|
||||
'resources' => [
|
||||
'agent_allow' => [
|
||||
|
||||
@@ -13,10 +13,10 @@ return [
|
||||
|
||||
'download_disable' => [
|
||||
'subject' => '下载权限取消',
|
||||
'body' => '管理员::operator 取消了你的下载权限,可能的原因是过低的分享率或行为不当。',
|
||||
'body' => '你的下载权限被取消,可能的原因是过低的分享率或行为不当。By: :operator',
|
||||
],
|
||||
'download_enable' => [
|
||||
'subject' => '下载权限恢复',
|
||||
'body' => '管理员::operator 恢复了你的下载权限,你现在可以下载种子。',
|
||||
'body' => '你的下载权限恢复,你现在可以下载种子。By: :operator',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -12,10 +12,10 @@ return [
|
||||
'field_value_change_message_subject' => ':field 改變',
|
||||
'download_disable' => [
|
||||
'subject' => '下載權限取消',
|
||||
'body' => '管理員::operator 取消了你的下載權限,可能的原因是過低的分享率或行為不當。',
|
||||
'body' => '你的下載權限被取消,可能的原因是過低的分享率或行為不當。By: :operator',
|
||||
],
|
||||
'download_enable' => [
|
||||
'subject' => '下載權限恢復',
|
||||
'body' => '管理員::operator 恢復了你的下載權限,你現在可以下載種子。',
|
||||
'body' => '你的下載權限恢復,你現在可以下載種子。By: :operator',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user