Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -31,19 +31,8 @@ class AppSettingsCommand extends Command
|
|||
'sync' => 'Sync',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Console\Kernel
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Configure basic environment settings for the Panel.';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:environment:setup
|
||||
{--new-salt : Whether or not to generate a new salt for Hashids.}
|
||||
{--author= : The email that services created on this instance should be linked to.}
|
||||
|
@ -57,19 +46,14 @@ class AppSettingsCommand extends Command
|
|||
{--redis-port= : Port to connect to redis over.}
|
||||
{--settings-ui= : Enable or disable the settings UI.}';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $variables = [];
|
||||
protected array $variables = [];
|
||||
|
||||
/**
|
||||
* AppSettingsCommand constructor.
|
||||
*/
|
||||
public function __construct(Kernel $command)
|
||||
public function __construct(private Kernel $console)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +61,7 @@ class AppSettingsCommand extends Command
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\PterodactylException
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
if (empty(config('hashids.salt')) || $this->option('new-salt')) {
|
||||
$this->variables['HASHIDS_SALT'] = str_random(20);
|
||||
|
@ -98,13 +82,13 @@ class AppSettingsCommand extends Command
|
|||
$this->output->comment('The application URL MUST begin with https:// or http:// depending on if you are using SSL or not. If you do not include the scheme your emails and other content will link to the wrong location.');
|
||||
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
|
||||
'Application URL',
|
||||
config('app.url', 'http://example.org')
|
||||
config('app.url', 'https://example.com')
|
||||
);
|
||||
|
||||
$this->output->comment('The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference http://php.net/manual/en/timezones.php.');
|
||||
$this->output->comment('The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference https://php.net/manual/en/timezones.php.');
|
||||
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
|
||||
'Application Timezone',
|
||||
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
|
||||
DateTimeZone::listIdentifiers(),
|
||||
config('app.timezone')
|
||||
);
|
||||
|
||||
|
@ -136,14 +120,16 @@ class AppSettingsCommand extends Command
|
|||
}
|
||||
|
||||
// Make sure session cookies are set as "secure" when using HTTPS
|
||||
if (strpos($this->variables['APP_URL'], 'https://') === 0) {
|
||||
if (str_starts_with($this->variables['APP_URL'], 'https://')) {
|
||||
$this->variables['SESSION_SECURE_COOKIE'] = 'true';
|
||||
}
|
||||
|
||||
$this->checkForRedis();
|
||||
$this->writeToEnvironment($this->variables);
|
||||
|
||||
$this->info($this->command->output());
|
||||
$this->info($this->console->output());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,24 +12,8 @@ class DatabaseSettingsCommand extends Command
|
|||
{
|
||||
use EnvironmentWriterTrait;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Console\Kernel
|
||||
*/
|
||||
protected $console;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\DatabaseManager
|
||||
*/
|
||||
protected $database;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Configure database settings for the Panel.';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:environment:database
|
||||
{--host= : The connection address for the MySQL server.}
|
||||
{--port= : The connection port for the MySQL server.}
|
||||
|
@ -37,30 +21,22 @@ class DatabaseSettingsCommand extends Command
|
|||
{--username= : Username to use when connecting.}
|
||||
{--password= : Password to use for this database.}';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $variables = [];
|
||||
protected array $variables = [];
|
||||
|
||||
/**
|
||||
* DatabaseSettingsCommand constructor.
|
||||
*/
|
||||
public function __construct(DatabaseManager $database, Kernel $console)
|
||||
public function __construct(private DatabaseManager $database, private Kernel $console)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->console = $console;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle command execution.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\PterodactylException
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$this->output->note('It is highly recommended to not use "localhost" as your database host as we have seen frequent socket connection issues. If you want to use a local connection you should be using "127.0.0.1".');
|
||||
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\Environment;
|
||||
|
||||
|
@ -17,19 +10,8 @@ class EmailSettingsCommand extends Command
|
|||
{
|
||||
use EnvironmentWriterTrait;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Set or update the email sending configuration for the Panel.';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:environment:mail
|
||||
{--driver= : The mail driver to use.}
|
||||
{--email= : Email address that messages from the Panel will originate from.}
|
||||
|
@ -41,19 +23,14 @@ class EmailSettingsCommand extends Command
|
|||
{--username=}
|
||||
{--password=}';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $variables = [];
|
||||
protected array $variables = [];
|
||||
|
||||
/**
|
||||
* EmailSettingsCommand constructor.
|
||||
*/
|
||||
public function __construct(ConfigRepository $config)
|
||||
public function __construct(private ConfigRepository $config)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +47,7 @@ class EmailSettingsCommand extends Command
|
|||
'mail' => 'PHP\'s Internal Mail Function',
|
||||
'mailgun' => 'Mailgun Transactional Email',
|
||||
'mandrill' => 'Mandrill Transactional Email',
|
||||
'postmark' => 'Postmarkapp Transactional Email',
|
||||
'postmark' => 'Postmark Transactional Email',
|
||||
],
|
||||
$this->config->get('mail.driver', 'smtp')
|
||||
);
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
|
@ -15,35 +8,16 @@ use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|||
|
||||
class InfoCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Displays the application, database, and email configurations along with the panel version.';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:info';
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
protected $versionService;
|
||||
|
||||
/**
|
||||
* VersionCommand constructor.
|
||||
*/
|
||||
public function __construct(ConfigRepository $config, SoftwareVersionService $versionService)
|
||||
public function __construct(private ConfigRepository $config, private SoftwareVersionService $versionService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->config = $config;
|
||||
$this->versionService = $versionService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,10 +52,10 @@ class InfoCommand extends Command
|
|||
$driver = $this->config->get('database.default');
|
||||
$this->table([], [
|
||||
['Driver', $driver],
|
||||
['Host', $this->config->get("database.connections.{$driver}.host")],
|
||||
['Port', $this->config->get("database.connections.{$driver}.port")],
|
||||
['Database', $this->config->get("database.connections.{$driver}.database")],
|
||||
['Username', $this->config->get("database.connections.{$driver}.username")],
|
||||
['Host', $this->config->get("database.connections.$driver.host")],
|
||||
['Port', $this->config->get("database.connections.$driver.port")],
|
||||
['Database', $this->config->get("database.connections.$driver.database")],
|
||||
['Username', $this->config->get("database.connections.$driver.username")],
|
||||
], 'compact');
|
||||
|
||||
$this->output->title('Email Configuration');
|
||||
|
@ -98,13 +72,8 @@ class InfoCommand extends Command
|
|||
|
||||
/**
|
||||
* Format output in a Name: Value manner.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $opts
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function formatText($value, $opts = '')
|
||||
private function formatText(string $value, string $opts = ''): string
|
||||
{
|
||||
return sprintf('<%s>%s</>', $opts, $value);
|
||||
}
|
||||
|
|
|
@ -1,56 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\Location;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Services\Locations\LocationDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||
|
||||
class DeleteLocationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Deletes a location from the Panel.';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Support\Collection
|
||||
*/
|
||||
protected $locations;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:location:delete {--short= : The short code of the location to delete.}';
|
||||
|
||||
protected Collection $locations;
|
||||
|
||||
/**
|
||||
* DeleteLocationCommand constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
LocationDeletionService $deletionService,
|
||||
LocationRepositoryInterface $repository
|
||||
private LocationDeletionService $deletionService,
|
||||
private LocationRepositoryInterface $repository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\Location;
|
||||
|
||||
|
@ -14,31 +7,18 @@ use Pterodactyl\Services\Locations\LocationCreationService;
|
|||
|
||||
class MakeLocationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:location:make
|
||||
{--short= : The shortcode name of this location (ex. us1).}
|
||||
{--long= : A longer description of this location.}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Creates a new location on the system via the CLI.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct(LocationCreationService $creationService)
|
||||
public function __construct(private LocationCreationService $creationService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,27 +5,19 @@ namespace Pterodactyl\Console\Commands\Maintenance;
|
|||
use SplFileInfo;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
|
||||
|
||||
class CleanServiceBackupFilesCommand extends Command
|
||||
{
|
||||
public const BACKUP_THRESHOLD_MINUTES = 5;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clean orphaned .bak files created when modifying services.';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected $disk;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:maintenance:clean-service-backups';
|
||||
|
||||
protected Filesystem $disk;
|
||||
|
||||
/**
|
||||
* CleanServiceBackupFilesCommand constructor.
|
||||
*/
|
||||
|
|
|
@ -9,24 +9,26 @@ use Pterodactyl\Repositories\Eloquent\BackupRepository;
|
|||
|
||||
class PruneOrphanedBackupsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:maintenance:prune-backups {--prune-age=}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Marks all backups that have not completed in the last "n" minutes as being failed.';
|
||||
|
||||
public function handle(BackupRepository $repository)
|
||||
/**
|
||||
* PruneOrphanedBackupsCommand constructor.
|
||||
*/
|
||||
public function __construct(private BackupRepository $backupRepository)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$since = $this->option('prune-age') ?? config('backups.prune_age', 360);
|
||||
if (!$since || !is_digit($since)) {
|
||||
throw new InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
|
||||
}
|
||||
|
||||
$query = $repository->getBuilder()
|
||||
$query = $this->backupRepository->getBuilder()
|
||||
->whereNull('completed_at')
|
||||
->where('created_at', '<=', CarbonImmutable::now()->subMinutes($since)->toDateTimeString());
|
||||
|
||||
|
@ -37,7 +39,7 @@ class PruneOrphanedBackupsCommand extends Command
|
|||
return;
|
||||
}
|
||||
|
||||
$this->warn("Marking {$count} backups that have not been marked as completed in the last {$since} minutes as failed.");
|
||||
$this->warn("Marking $count backups that have not been marked as completed in the last $since minutes as failed.");
|
||||
|
||||
$query->update([
|
||||
'is_successful' => false,
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\Node;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -15,14 +7,6 @@ use Pterodactyl\Services\Nodes\NodeCreationService;
|
|||
|
||||
class MakeNodeCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:node:make
|
||||
{--name= : A name to identify the node.}
|
||||
{--description= : A description to identify the node.}
|
||||
|
@ -41,20 +25,23 @@ class MakeNodeCommand extends Command
|
|||
{--daemonSFTPPort= : Enter the wings SFTP listening port.}
|
||||
{--daemonBase= : Enter the base folder.}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Creates a new node on the system via the CLI.';
|
||||
|
||||
/**
|
||||
* MakeNodeCommand constructor.
|
||||
*/
|
||||
public function __construct(private NodeCreationService $creationService)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the command execution process.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function handle(NodeCreationService $creationService)
|
||||
public function handle()
|
||||
{
|
||||
$this->creationService = $creationService;
|
||||
|
||||
$data['name'] = $this->option('name') ?? $this->ask('Enter a short identifier used to distinguish this node from others');
|
||||
$data['description'] = $this->option('description') ?? $this->ask('Enter a description to identify the node');
|
||||
$data['location_id'] = $this->option('locationId') ?? $this->ask('Enter a valid location id');
|
||||
|
|
|
@ -13,7 +13,7 @@ class NodeConfigurationCommand extends Command
|
|||
|
||||
protected $description = 'Displays the configuration for the specified node.';
|
||||
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$column = ctype_digit((string) $this->argument('node')) ? 'id' : 'uuid';
|
||||
|
||||
|
@ -28,7 +28,7 @@ class NodeConfigurationCommand extends Command
|
|||
if (!in_array($format, ['yaml', 'yml', 'json'])) {
|
||||
$this->error('Invalid format specified. Valid options are "yaml" and "json".');
|
||||
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($format === 'json') {
|
||||
|
|
|
@ -9,7 +9,7 @@ class NodeListCommand extends Command
|
|||
{
|
||||
protected $signature = 'p:node:list {--format=text : The output format: "text" or "json". }';
|
||||
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$nodes = Node::query()->with('location')->get()->map(function (Node $node) {
|
||||
return [
|
||||
|
|
|
@ -13,14 +13,14 @@ class SeedCommand extends BaseSeedCommand
|
|||
* Block someone from running this seed command if they have not completed
|
||||
* the migration process.
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
if (!$this->hasCompletedMigrations()) {
|
||||
$this->showMigrationWarning();
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
parent::handle();
|
||||
return parent::handle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@ class UpCommand extends BaseUpCommand
|
|||
* Block someone from running this up command if they have not completed
|
||||
* the migration process.
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
if (!$this->hasCompletedMigrations()) {
|
||||
$this->showMigrationWarning();
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
parent::handle();
|
||||
return parent::handle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,20 +12,14 @@ use Pterodactyl\Services\Schedules\ProcessScheduleService;
|
|||
|
||||
class ProcessRunnableCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:schedule:process';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process schedules in the database and determine which are ready to run.';
|
||||
|
||||
/**
|
||||
* Handle command execution.
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$schedules = Schedule::query()
|
||||
->with('tasks')
|
||||
|
@ -38,7 +32,7 @@ class ProcessRunnableCommand extends Command
|
|||
if ($schedules->count() < 1) {
|
||||
$this->line('There are no scheduled tasks for servers that need to be run.');
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
$bar = $this->output->createProgressBar(count($schedules));
|
||||
|
@ -50,6 +44,8 @@ class ProcessRunnableCommand extends Command
|
|||
}
|
||||
|
||||
$this->line('');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +71,7 @@ class ProcessRunnableCommand extends Command
|
|||
} catch (Throwable|Exception $exception) {
|
||||
Log::error($exception, ['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->error("An error was encountered while processing Schedule #{$schedule->id}: " . $exception->getMessage());
|
||||
$this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Pterodactyl\Console\Commands\Server;
|
|||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Validation\Factory as ValidatorFactory;
|
||||
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
|
||||
|
@ -11,31 +12,33 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|||
|
||||
class BulkPowerActionCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:server:bulk-power
|
||||
{action : The action to perform (start, stop, restart, kill)}
|
||||
{--servers= : A comma separated list of servers.}
|
||||
{--nodes= : A comma separated list of nodes.}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Perform bulk power management on large groupings of servers or nodes at once.';
|
||||
|
||||
/**
|
||||
* BulkPowerActionCommand constructor.
|
||||
*/
|
||||
public function __construct(private DaemonPowerRepository $powerRepository, private ValidatorFactory $validator)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the bulk power request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator)
|
||||
public function handle()
|
||||
{
|
||||
$action = $this->argument('action');
|
||||
$nodes = empty($this->option('nodes')) ? [] : explode(',', $this->option('nodes'));
|
||||
$servers = empty($this->option('servers')) ? [] : explode(',', $this->option('servers'));
|
||||
|
||||
$validator = $validator->make([
|
||||
$validator = $this->validator->make([
|
||||
'action' => $action,
|
||||
'nodes' => $nodes,
|
||||
'servers' => $servers,
|
||||
|
@ -61,6 +64,7 @@ class BulkPowerActionCommand extends Command
|
|||
}
|
||||
|
||||
$bar = $this->output->createProgressBar($count);
|
||||
$powerRepository = $this->powerRepository;
|
||||
$this->getQueryBuilder($servers, $nodes)->each(function (Server $server) use ($action, $powerRepository, &$bar) {
|
||||
$bar->clear();
|
||||
|
||||
|
@ -84,10 +88,8 @@ class BulkPowerActionCommand extends Command
|
|||
|
||||
/**
|
||||
* Returns the query builder instance that will return the servers that should be affected.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function getQueryBuilder(array $servers, array $nodes)
|
||||
protected function getQueryBuilder(array $servers, array $nodes): Builder
|
||||
{
|
||||
$instance = Server::query()->whereNull('status');
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ class UpgradeCommand extends Command
|
|||
{
|
||||
protected const DEFAULT_URL = 'https://github.com/pterodactyl/panel/releases/%s/panel.tar.gz';
|
||||
|
||||
/** @var string */
|
||||
protected $signature = 'p:upgrade
|
||||
{--user= : The user that PHP runs under. All files will be owned by this user.}
|
||||
{--group= : The group that PHP runs under. All files will be owned by this group.}
|
||||
|
@ -20,7 +19,6 @@ class UpgradeCommand extends Command
|
|||
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
|
||||
{--skip-download : If set no archive will be downloaded.}';
|
||||
|
||||
/** @var string */
|
||||
protected $description = 'Downloads a new archive for Pterodactyl from GitHub and then executes the normal upgrade commands.';
|
||||
|
||||
/**
|
||||
|
@ -92,7 +90,7 @@ class UpgradeCommand extends Command
|
|||
}
|
||||
}
|
||||
|
||||
ini_set('output_buffering', 0);
|
||||
ini_set('output_buffering', '0');
|
||||
$bar = $this->output->createProgressBar($skipDownload ? 9 : 10);
|
||||
$bar->start();
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\User;
|
||||
|
||||
|
@ -16,42 +9,19 @@ use Pterodactyl\Services\Users\UserDeletionService;
|
|||
|
||||
class DeleteUserCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Deletes a user from the Panel if no servers are attached to their account.';
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:user:delete {--user=}';
|
||||
|
||||
/**
|
||||
* DeleteUserCommand constructor.
|
||||
*/
|
||||
public function __construct(UserDeletionService $deletionService)
|
||||
public function __construct(private UserDeletionService $deletionService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->deletionService = $deletionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$search = $this->option('user') ?? $this->ask(trans('command/messages.user.search_users'));
|
||||
Assert::notEmpty($search, 'Search term should be an email address, got: %s.');
|
||||
|
@ -68,7 +38,7 @@ class DeleteUserCommand extends Command
|
|||
return $this->handle();
|
||||
}
|
||||
|
||||
return false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($this->input->isInteractive()) {
|
||||
|
@ -85,7 +55,7 @@ class DeleteUserCommand extends Command
|
|||
if (count($results) > 1) {
|
||||
$this->error(trans('command/messages.user.multiple_found'));
|
||||
|
||||
return false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
$deleteUser = $results->first();
|
||||
|
@ -95,5 +65,7 @@ class DeleteUserCommand extends Command
|
|||
$this->deletionService->handle($deleteUser);
|
||||
$this->info(trans('command/messages.user.deleted'));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\User;
|
||||
|
||||
|
@ -14,29 +7,16 @@ use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|||
|
||||
class DisableTwoFactorCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Disable two-factor authentication for a specific user in the Panel.';
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}';
|
||||
|
||||
/**
|
||||
* DisableTwoFactorCommand constructor.
|
||||
*/
|
||||
public function __construct(UserRepositoryInterface $repository)
|
||||
public function __construct(private UserRepositoryInterface $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\User;
|
||||
|
||||
|
@ -14,29 +7,16 @@ use Pterodactyl\Services\Users\UserCreationService;
|
|||
|
||||
class MakeUserCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Creates a user on the system via the CLI.';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:user:make {--email=} {--username=} {--name-first=} {--name-last=} {--password=} {--admin=} {--no-password}';
|
||||
|
||||
/**
|
||||
* MakeUserCommand constructor.
|
||||
*/
|
||||
public function __construct(UserCreationService $creationService)
|
||||
public function __construct(private UserCreationService $creationService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ trait RequiresDatabaseMigrations
|
|||
* them to properly run the migrations rather than ignoring all of the other previous
|
||||
* errors...
|
||||
*/
|
||||
protected function showMigrationWarning()
|
||||
protected function showMigrationWarning(): void
|
||||
{
|
||||
$this->getOutput()->writeln('<options=bold>
|
||||
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
||||
|
|
|
@ -1,24 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Criteria;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Pterodactyl\Repositories\Repository;
|
||||
|
||||
interface CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* Apply selected criteria to a repository call.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply($model, Repository $repository);
|
||||
public function apply(Model $model, Repository $repository): mixed;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Extensions;
|
||||
|
||||
|
@ -16,12 +9,7 @@ interface HashidsInterface extends VendorHashidsInterface
|
|||
/**
|
||||
* Decode an encoded hashid and return the first result.
|
||||
*
|
||||
* @param string $encoded
|
||||
* @param null $default
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function decodeFirst($encoded, $default = null);
|
||||
public function decodeFirst(string $encoded, string $default = null): mixed;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ interface ClientPermissionsRequest
|
|||
{
|
||||
/**
|
||||
* Returns the permissions string indicating which permission should be used to
|
||||
* validate that the authenticated user has permission to perform this action aganist
|
||||
* validate that the authenticated user has permission to perform this action against
|
||||
* the given resource (server).
|
||||
*/
|
||||
public function permission(): string;
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Allocation;
|
||||
|
||||
interface AllocationRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return all of the allocations that exist for a node that are not currently
|
||||
* Return all the allocations that exist for a node that are not currently
|
||||
* allocated.
|
||||
*/
|
||||
public function getUnassignedAllocationIds(int $node): array;
|
||||
|
||||
/**
|
||||
* Return a single allocation from those meeting the requirements.
|
||||
*
|
||||
* @return \Pterodactyl\Models\Allocation|null
|
||||
*/
|
||||
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false);
|
||||
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false): ?Allocation;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ use Illuminate\Support\Collection;
|
|||
interface ApiKeyRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get all of the account API keys that exist for a specific user.
|
||||
* Get all the account API keys that exist for a specific user.
|
||||
*/
|
||||
public function getAccountKeys(User $user): Collection;
|
||||
|
||||
/**
|
||||
* Get all of the application API keys that exist for a specific user.
|
||||
* Get all the application API keys that exist for a specific user.
|
||||
*/
|
||||
public function getApplicationKeys(User $user): Collection;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Database;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
|
@ -12,10 +11,8 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
|
||||
/**
|
||||
* Set the connection name to execute statements against.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConnection(string $connection);
|
||||
public function setConnection(string $connection): self;
|
||||
|
||||
/**
|
||||
* Return the connection to execute statements against.
|
||||
|
@ -23,12 +20,12 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
public function getConnection(): string;
|
||||
|
||||
/**
|
||||
* Return all of the databases belonging to a server.
|
||||
* Return all the databases belonging to a server.
|
||||
*/
|
||||
public function getDatabasesForServer(int $server): Collection;
|
||||
|
||||
/**
|
||||
* Return all of the databases for a given host with the server relationship loaded.
|
||||
* Return all the databases for a given host with the server relationship loaded.
|
||||
*/
|
||||
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
|
||||
|
||||
|
@ -39,10 +36,8 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
|
||||
/**
|
||||
* Create a new database user on a given connection.
|
||||
*
|
||||
* @param $max_connections
|
||||
*/
|
||||
public function createUser(string $username, string $remote, string $password, string $max_connections): bool;
|
||||
public function createUser(string $username, string $remote, string $password, ?int $max_connections): bool;
|
||||
|
||||
/**
|
||||
* Give a specific user access to a given database.
|
||||
|
@ -61,8 +56,6 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
|
|||
|
||||
/**
|
||||
* Drop a given user on a specific connection.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function dropUser(string $username, string $remote): bool;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
|
@ -28,13 +21,11 @@ interface EggRepositoryInterface extends RepositoryInterface
|
|||
|
||||
/**
|
||||
* Return an egg with the scriptFrom and configFrom relations loaded onto the model.
|
||||
*
|
||||
* @param int|string $value
|
||||
*/
|
||||
public function getWithCopyAttributes($value, string $column = 'id'): Egg;
|
||||
public function getWithCopyAttributes(int|string $value, string $column = 'id'): Egg;
|
||||
|
||||
/**
|
||||
* Return all of the data needed to export a service.
|
||||
* Return all the data needed to export a service.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
|
|
|
@ -13,14 +13,12 @@ interface LocationRepositoryInterface extends RepositoryInterface
|
|||
public function getAllWithDetails(): Collection;
|
||||
|
||||
/**
|
||||
* Return all of the available locations with the nodes as a relationship.
|
||||
* Return all the available locations with the nodes as a relationship.
|
||||
*/
|
||||
public function getAllWithNodes(): Collection;
|
||||
|
||||
/**
|
||||
* Return all of the nodes and their respective count of servers for a location.
|
||||
*
|
||||
* @return mixed
|
||||
* Return all the nodes and their respective count of servers for a location.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
@ -29,8 +27,6 @@ interface LocationRepositoryInterface extends RepositoryInterface
|
|||
/**
|
||||
* Return a location and the count of nodes in that location.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithNodeCount(int $id): Location;
|
||||
|
|
|
@ -1,37 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
interface NestRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return a nest or all nests with their associated eggs and variables.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithEggs(int $id = null);
|
||||
public function getWithEggs(int $id = null): Collection|Nest;
|
||||
|
||||
/**
|
||||
* Return a nest or all nests and the count of eggs and servers for that nest.
|
||||
*
|
||||
* @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getWithCounts(int $id = null);
|
||||
public function getWithCounts(int $id = null): Collection|Nest;
|
||||
|
||||
/**
|
||||
* Return a nest along with its associated eggs and the servers relation on those eggs.
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
|
|
|
@ -3,87 +3,67 @@
|
|||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
interface RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return an identifier or Model object to be used by the repository.
|
||||
*
|
||||
* @return string|\Closure|object
|
||||
*/
|
||||
public function model();
|
||||
public function model(): string;
|
||||
|
||||
/**
|
||||
* Return the model being used for this repository instance.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getModel();
|
||||
public function getModel(): Model;
|
||||
|
||||
/**
|
||||
* Returns an instance of a query builder.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getBuilder();
|
||||
public function getBuilder(): Builder;
|
||||
|
||||
/**
|
||||
* Returns the columns to be selected or returned by the query.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getColumns();
|
||||
public function getColumns(): array;
|
||||
|
||||
/**
|
||||
* An array of columns to filter the response by.
|
||||
*
|
||||
* @param array|string $columns
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumns($columns = ['*']);
|
||||
public function setColumns(array|string $columns = ['*']): self;
|
||||
|
||||
/**
|
||||
* Stop repository update functions from returning a fresh
|
||||
* model when changes are committed.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withoutFreshModel();
|
||||
public function withoutFreshModel(): self;
|
||||
|
||||
/**
|
||||
* Return a fresh model with a repository updates a model.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withFreshModel();
|
||||
public function withFreshModel(): self;
|
||||
|
||||
/**
|
||||
* Set whether or not the repository should return a fresh model
|
||||
* Set whether the repository should return a fresh model
|
||||
* when changes are committed.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreshModel(bool $fresh = true);
|
||||
public function setFreshModel(bool $fresh = true): self;
|
||||
|
||||
/**
|
||||
* Create a new model instance and persist it to the database.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function create(array $fields, bool $validate = true, bool $force = false);
|
||||
public function create(array $fields, bool $validate = true, bool $force = false): mixed;
|
||||
|
||||
/**
|
||||
* Find a model that has the specific ID passed.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function find(int $id);
|
||||
public function find(int $id): mixed;
|
||||
|
||||
/**
|
||||
* Find a model matching an array of where clauses.
|
||||
|
@ -93,11 +73,9 @@ interface RepositoryInterface
|
|||
/**
|
||||
* Find and return the first matching instance for the given fields.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function findFirstWhere(array $fields);
|
||||
public function findFirstWhere(array $fields): mixed;
|
||||
|
||||
/**
|
||||
* Return a count of records matching the passed arguments.
|
||||
|
@ -117,14 +95,10 @@ interface RepositoryInterface
|
|||
/**
|
||||
* Update a given ID with the passed array of fields.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update($id, array $fields, bool $validate = true, bool $force = false);
|
||||
public function update(int $id, array $fields, bool $validate = true, bool $force = false): mixed;
|
||||
|
||||
/**
|
||||
* Perform a mass update where matching records are updated using whereIn.
|
||||
|
@ -135,11 +109,9 @@ interface RepositoryInterface
|
|||
/**
|
||||
* Update a record if it exists in the database, otherwise create it.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function updateOrCreate(array $where, array $fields, bool $validate = true, bool $force = false);
|
||||
public function updateOrCreate(array $where, array $fields, bool $validate = true, bool $force = false): mixed;
|
||||
|
||||
/**
|
||||
* Return all records associated with the given model.
|
||||
|
|
|
@ -8,12 +8,12 @@ use Illuminate\Support\Collection;
|
|||
interface ScheduleRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return all of the schedules for a given server.
|
||||
* Return all the schedules for a given server.
|
||||
*/
|
||||
public function findServerSchedules(int $server): Collection;
|
||||
|
||||
/**
|
||||
* Return a schedule model with all of the associated tasks as a relationship.
|
||||
* Return a schedule model with all the associated tasks as a relationship.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
|
|
@ -67,7 +67,7 @@ interface ServerRepositoryInterface extends RepositoryInterface
|
|||
public function isUniqueUuidCombo(string $uuid, string $short): bool;
|
||||
|
||||
/**
|
||||
* Returns all of the servers that exist for a given node in a paginated response.
|
||||
* Returns all the servers that exist for a given node in a paginated response.
|
||||
*/
|
||||
public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,12 @@ use Illuminate\Support\Collection;
|
|||
interface SessionRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return all of the active sessions for a user.
|
||||
* Return all the active sessions for a user.
|
||||
*/
|
||||
public function getUserSessions(int $user): Collection;
|
||||
|
||||
/**
|
||||
* Delete a session for a given user.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function deleteUserSession(int $user, string $session);
|
||||
public function deleteUserSession(int $user, string $session): ?int;
|
||||
}
|
||||
|
|
|
@ -14,12 +14,8 @@ interface SettingsRepositoryInterface extends RepositoryInterface
|
|||
|
||||
/**
|
||||
* Retrieve a persistent setting from the database.
|
||||
*
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $key, $default);
|
||||
public function get(string $key, mixed $default): mixed;
|
||||
|
||||
/**
|
||||
* Remove a key from the database cache.
|
||||
|
|
|
@ -15,8 +15,6 @@ interface TaskRepositoryInterface extends RepositoryInterface
|
|||
|
||||
/**
|
||||
* Returns the next task in a schedule.
|
||||
*
|
||||
* @return \Pterodactyl\Models\Task|null
|
||||
*/
|
||||
public function getNextTask(int $schedule, int $index);
|
||||
public function getNextTask(int $schedule, int $index): ?Task;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class ActivityLogged extends Event
|
||||
{
|
||||
public ActivityLog $model;
|
||||
|
||||
public function __construct(ActivityLog $model)
|
||||
public function __construct(public ActivityLog $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function is(string $event): bool
|
||||
|
@ -25,12 +22,12 @@ class ActivityLogged extends Event
|
|||
return $this->isSystem() ? null : $this->model->actor;
|
||||
}
|
||||
|
||||
public function isServerEvent()
|
||||
public function isServerEvent(): bool
|
||||
{
|
||||
return Str::startsWith($this->model->event, 'server:');
|
||||
}
|
||||
|
||||
public function isSystem()
|
||||
public function isSystem(): bool
|
||||
{
|
||||
return is_null($this->model->actor_id);
|
||||
}
|
||||
|
|
13
app/Events/Auth/DirectLogin.php
Normal file
13
app/Events/Auth/DirectLogin.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Events\Auth;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Events\Event;
|
||||
|
||||
class DirectLogin extends Event
|
||||
{
|
||||
public function __construct(public User $user, public bool $remember)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,43 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Auth;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FailedCaptcha
|
||||
class FailedCaptcha extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The IP that the request originated from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $ip;
|
||||
|
||||
/**
|
||||
* The domain that was used to try to verify the request with recaptcha api.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $domain;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $ip
|
||||
* @param string $domain
|
||||
*/
|
||||
public function __construct($ip, $domain)
|
||||
public function __construct(public string $ip, public string $domain)
|
||||
{
|
||||
$this->ip = $ip;
|
||||
$this->domain = $domain;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Auth;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FailedPasswordReset
|
||||
class FailedPasswordReset extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The IP that the request originated from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $ip;
|
||||
|
||||
/**
|
||||
* The email address that was used when the reset request failed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $ip
|
||||
* @param string $email
|
||||
*/
|
||||
public function __construct($ip, $email)
|
||||
public function __construct(public string $ip, public string $email)
|
||||
{
|
||||
$this->ip = $ip;
|
||||
$this->email = $email;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,11 @@
|
|||
namespace Pterodactyl\Events\Auth;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Events\Event;
|
||||
|
||||
class ProvidedAuthenticationToken
|
||||
class ProvidedAuthenticationToken extends Event
|
||||
{
|
||||
public User $user;
|
||||
|
||||
public bool $recovery;
|
||||
|
||||
public function __construct(User $user, bool $recovery = false)
|
||||
public function __construct(public User $user, public bool $recovery = false)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->recovery = $recovery;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Created
|
||||
class Created extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Creating
|
||||
class Creating extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Deleted
|
||||
class Deleted extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Deleting
|
||||
class Deleting extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,18 +10,10 @@ class Installed extends Event
|
|||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Saved
|
||||
class Saved extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Saving
|
||||
class Saving extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Updated
|
||||
class Updated extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Server;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Updating
|
||||
class Updating extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Server $server)
|
||||
public function __construct(public Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Subuser;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Created
|
||||
class Created extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Subuser
|
||||
*/
|
||||
public $subuser;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Subuser $subuser)
|
||||
public function __construct(public Subuser $subuser)
|
||||
{
|
||||
$this->subuser = $subuser;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Subuser;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Creating
|
||||
class Creating extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Subuser
|
||||
*/
|
||||
public $subuser;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Subuser $subuser)
|
||||
public function __construct(public Subuser $subuser)
|
||||
{
|
||||
$this->subuser = $subuser;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Subuser;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Deleted
|
||||
class Deleted extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Subuser
|
||||
*/
|
||||
public $subuser;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Subuser $subuser)
|
||||
public function __construct(public Subuser $subuser)
|
||||
{
|
||||
$this->subuser = $subuser;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\Subuser;
|
||||
|
||||
use Pterodactyl\Events\Event;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Deleting
|
||||
class Deleting extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\Subuser
|
||||
*/
|
||||
public $subuser;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Subuser $subuser)
|
||||
public function __construct(public Subuser $subuser)
|
||||
{
|
||||
$this->subuser = $subuser;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\User;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Created
|
||||
class Created extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\User;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Creating
|
||||
class Creating extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\User;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Deleted
|
||||
class Deleted extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events\User;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Deleting
|
||||
class Deleting extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Eloquent model of the server.
|
||||
*
|
||||
* @var \Pterodactyl\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
|
|
|
@ -4,9 +4,12 @@ namespace Pterodactyl\Exceptions;
|
|||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Illuminate\Http\Request;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
|
@ -18,44 +21,24 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
|
|||
public const LEVEL_ERROR = 'error';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* DisplayException constructor.
|
||||
*/
|
||||
protected $level;
|
||||
|
||||
/**
|
||||
* Exception constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $level
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct($message, Throwable $previous = null, $level = self::LEVEL_ERROR, $code = 0)
|
||||
public function __construct(string $message, ?Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorLevel()
|
||||
public function getErrorLevel(): string
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return Response::HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
@ -64,12 +47,8 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
|
|||
* Render the exception to the user by adding a flashed message to the session
|
||||
* and then redirecting them back to the page that they came from. If the
|
||||
* request originated from an API hit, return the error in JSONAPI spec format.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function render($request)
|
||||
public function render(Request $request): JsonResponse|RedirectResponse
|
||||
{
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders());
|
||||
|
@ -84,9 +63,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
|
|||
* Log the exception to the logs using the defined error level only if the previous
|
||||
* exception is set.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function report()
|
||||
{
|
||||
|
@ -96,7 +73,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
|
|||
|
||||
try {
|
||||
$logger = Container::getInstance()->make(LoggerInterface::class);
|
||||
} catch (Exception $ex) {
|
||||
} catch (Exception) {
|
||||
throw $this->getPrevious();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,18 +7,20 @@ use Throwable;
|
|||
use PDOException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Swift_TransportException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Mailer\Exception\TransportException;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
@ -26,7 +28,7 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
|||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* Laravel's validation parser formats custom rules using the class name
|
||||
* The validation parser in Laravel formats custom rules using the class name
|
||||
* resulting in some weird rule names. This string will be parsed out and
|
||||
* replaced with 'p_' in the response code.
|
||||
*/
|
||||
|
@ -34,8 +36,6 @@ class Handler extends ExceptionHandler
|
|||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
AuthenticationException::class,
|
||||
|
@ -50,8 +50,6 @@ class Handler extends ExceptionHandler
|
|||
/**
|
||||
* Maps exceptions to a specific response code. This handles special exception
|
||||
* types that don't have a defined response code.
|
||||
*
|
||||
* @var array<string, int>
|
||||
*/
|
||||
protected static array $exceptionResponseCodes = [
|
||||
AuthenticationException::class => 401,
|
||||
|
@ -61,8 +59,6 @@ class Handler extends ExceptionHandler
|
|||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'token',
|
||||
|
@ -89,7 +85,7 @@ class Handler extends ExceptionHandler
|
|||
$ex = $this->generateCleanedExceptionStack($ex);
|
||||
});
|
||||
|
||||
$this->reportable(function (Swift_TransportException $ex) {
|
||||
$this->reportable(function (TransportException $ex) {
|
||||
$ex = $this->generateCleanedExceptionStack($ex);
|
||||
});
|
||||
}
|
||||
|
@ -125,11 +121,9 @@ class Handler extends ExceptionHandler
|
|||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
$connections = $this->container->make(Connection::class);
|
||||
|
||||
|
@ -146,7 +140,7 @@ class Handler extends ExceptionHandler
|
|||
$connections->rollBack(0);
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,10 +148,8 @@ class Handler extends ExceptionHandler
|
|||
* calls to the API.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function invalidJson($request, ValidationException $exception)
|
||||
public function invalidJson($request, ValidationException $exception): JsonResponse
|
||||
{
|
||||
$codes = Collection::make($exception->validator->failed())->mapWithKeys(function ($reasons, $field) {
|
||||
$cleaned = [];
|
||||
|
@ -197,21 +189,21 @@ class Handler extends ExceptionHandler
|
|||
/**
|
||||
* Return the exception as a JSONAPI representation for use on API requests.
|
||||
*/
|
||||
protected function convertExceptionToArray(Throwable $exception, array $override = []): array
|
||||
protected function convertExceptionToArray(Throwable $e, array $override = []): array
|
||||
{
|
||||
$match = self::$exceptionResponseCodes[get_class($exception)] ?? null;
|
||||
$match = self::$exceptionResponseCodes[get_class($e)] ?? null;
|
||||
|
||||
$error = [
|
||||
'code' => class_basename($exception),
|
||||
'status' => method_exists($exception, 'getStatusCode')
|
||||
? strval($exception->getStatusCode())
|
||||
'code' => class_basename($e),
|
||||
'status' => method_exists($e, 'getStatusCode')
|
||||
? strval($e->getStatusCode())
|
||||
: strval($match ?? '500'),
|
||||
'detail' => $exception instanceof HttpExceptionInterface || !is_null($match)
|
||||
? $exception->getMessage()
|
||||
'detail' => $e instanceof HttpExceptionInterface || !is_null($match)
|
||||
? $e->getMessage()
|
||||
: 'An unexpected error was encountered while processing this request, please try again.',
|
||||
];
|
||||
|
||||
if ($exception instanceof ModelNotFoundException || $exception->getPrevious() instanceof ModelNotFoundException) {
|
||||
if ($e instanceof ModelNotFoundException || $e->getPrevious() instanceof ModelNotFoundException) {
|
||||
// Show a nicer error message compared to the standard "No query results for model"
|
||||
// response that is normally returned. If we are in debug mode this will get overwritten
|
||||
// with a more specific error message to help narrow down things.
|
||||
|
@ -220,17 +212,17 @@ class Handler extends ExceptionHandler
|
|||
|
||||
if (config('app.debug')) {
|
||||
$error = array_merge($error, [
|
||||
'detail' => $exception->getMessage(),
|
||||
'detail' => $e->getMessage(),
|
||||
'source' => [
|
||||
'line' => $exception->getLine(),
|
||||
'file' => str_replace(Application::getInstance()->basePath(), '', $exception->getFile()),
|
||||
'line' => $e->getLine(),
|
||||
'file' => str_replace(Application::getInstance()->basePath(), '', $e->getFile()),
|
||||
],
|
||||
'meta' => [
|
||||
'trace' => Collection::make($exception->getTrace())
|
||||
'trace' => Collection::make($e->getTrace())
|
||||
->map(fn ($trace) => Arr::except($trace, ['args']))
|
||||
->all(),
|
||||
'previous' => Collection::make($this->extractPrevious($exception))
|
||||
->map(fn ($exception) => $exception->getTrace())
|
||||
'previous' => Collection::make($this->extractPrevious($e))
|
||||
->map(fn ($exception) => $e->getTrace())
|
||||
->map(fn ($trace) => Arr::except($trace, ['args']))
|
||||
->all(),
|
||||
],
|
||||
|
@ -252,10 +244,8 @@ class Handler extends ExceptionHandler
|
|||
* Convert an authentication exception into an unauthenticated response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse
|
||||
{
|
||||
if ($request->expectsJson()) {
|
||||
return new JsonResponse($this->convertExceptionToArray($exception), JsonResponse::HTTP_UNAUTHORIZED);
|
||||
|
@ -265,7 +255,7 @@ class Handler extends ExceptionHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Extracts all of the previous exceptions that lead to the one passed into this
|
||||
* Extracts all the previous exceptions that lead to the one passed into this
|
||||
* function being thrown.
|
||||
*
|
||||
* @return \Throwable[]
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Http\Base;
|
||||
|
||||
|
|
|
@ -12,20 +12,15 @@ use Pterodactyl\Exceptions\DisplayException;
|
|||
*/
|
||||
class DaemonConnectionException extends DisplayException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode = Response::HTTP_GATEWAY_TIMEOUT;
|
||||
private int $statusCode = Response::HTTP_GATEWAY_TIMEOUT;
|
||||
|
||||
/**
|
||||
* Every request to the Wings instance will return a unique X-Request-Id header
|
||||
* which allows for all errors to be efficiently tied to a specific request that
|
||||
* triggered them, and gives users a more direct method of informing hosts when
|
||||
* something goes wrong.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $requestId;
|
||||
private ?string $requestId;
|
||||
|
||||
/**
|
||||
* Throw a displayable exception caused by a daemon connection error.
|
||||
|
@ -34,7 +29,7 @@ class DaemonConnectionException extends DisplayException
|
|||
{
|
||||
/** @var \GuzzleHttp\Psr7\Response|null $response */
|
||||
$response = method_exists($previous, 'getResponse') ? $previous->getResponse() : null;
|
||||
$this->requestId = $response ? $response->getHeaderLine('X-Request-Id') : null;
|
||||
$this->requestId = $response?->getHeaderLine('X-Request-Id');
|
||||
|
||||
if ($useStatusCode) {
|
||||
$this->statusCode = is_null($response) ? $this->statusCode : $response->getStatusCode();
|
||||
|
@ -72,8 +67,6 @@ class DaemonConnectionException extends DisplayException
|
|||
/**
|
||||
* Override the default reporting method for DisplayException by just logging immediately
|
||||
* here and including the specific X-Request-Id header that was returned by the call.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function report()
|
||||
{
|
||||
|
@ -84,18 +77,13 @@ class DaemonConnectionException extends DisplayException
|
|||
|
||||
/**
|
||||
* Return the HTTP status code for this exception.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRequestId()
|
||||
public function getRequestId(): ?string
|
||||
{
|
||||
return $this->requestId;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Http\Server;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Exceptions\Model;
|
||||
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Pterodactyl\Exceptions\PterodactylException;
|
||||
|
@ -10,20 +11,10 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
|||
|
||||
class DataValidationException extends PterodactylException implements HttpExceptionInterface, MessageProvider
|
||||
{
|
||||
/**
|
||||
* The validator instance.
|
||||
*/
|
||||
protected Validator $validator;
|
||||
|
||||
/**
|
||||
* The underlying model instance that triggered this exception.
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* DataValidationException constructor.
|
||||
*/
|
||||
public function __construct(Validator $validator, Model $model)
|
||||
public function __construct(protected Validator $validator, protected Model $model)
|
||||
{
|
||||
$message = sprintf(
|
||||
'Could not save %s[%s]: failed to validate data: %s',
|
||||
|
@ -33,35 +24,25 @@ class DataValidationException extends PterodactylException implements HttpExcept
|
|||
);
|
||||
|
||||
parent::__construct($message);
|
||||
|
||||
$this->validator = $validator;
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the validator message bag.
|
||||
*
|
||||
* @return \Illuminate\Support\MessageBag
|
||||
*/
|
||||
public function getMessageBag()
|
||||
public function getMessageBag(): MessageBag
|
||||
{
|
||||
return $this->validator->errors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the status code for this request.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -9,20 +9,16 @@ class RecordNotFoundException extends RepositoryException implements HttpExcepti
|
|||
{
|
||||
/**
|
||||
* Returns the status code.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return Response::HTTP_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns response headers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -8,10 +8,8 @@ class InvalidPortMappingException extends DisplayException
|
|||
{
|
||||
/**
|
||||
* InvalidPortMappingException constructor.
|
||||
*
|
||||
* @param mixed $port
|
||||
*/
|
||||
public function __construct($port)
|
||||
public function __construct(mixed $port)
|
||||
{
|
||||
parent::__construct(trans('exceptions.allocations.invalid_mapping', ['port' => $port]));
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/*
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Egg;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Egg;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Egg;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Egg\Variable;
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@ use Pterodactyl\Exceptions\DisplayException;
|
|||
|
||||
class HasActiveServersException extends DisplayException
|
||||
{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return Response::HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Helper;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service;
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@ use Pterodactyl\Exceptions\DisplayException;
|
|||
|
||||
class HasActiveNodesException extends DisplayException
|
||||
{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return Response::HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Schedule\Task;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Server;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Subuser;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions\Service\Subuser;
|
||||
|
||||
|
|
|
@ -9,64 +9,45 @@ use Illuminate\Support\Str;
|
|||
use Webmozart\Assert\Assert;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Foundation\Application;
|
||||
use League\Flysystem\AdapterInterface;
|
||||
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
||||
use League\Flysystem\Memory\MemoryAdapter;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use League\Flysystem\FilesystemAdapter;
|
||||
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
|
||||
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
|
||||
class BackupManager
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
protected ConfigRepository $config;
|
||||
|
||||
/**
|
||||
* The array of resolved backup drivers.
|
||||
*
|
||||
* @var \League\Flysystem\AdapterInterface[]
|
||||
*/
|
||||
protected $adapters = [];
|
||||
protected array $adapters = [];
|
||||
|
||||
/**
|
||||
* The registered custom driver creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators;
|
||||
protected array $customCreators;
|
||||
|
||||
/**
|
||||
* BackupManager constructor.
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
public function __construct(protected Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->config = $app->make(Repository::class);
|
||||
$this->config = $app->make(ConfigRepository::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a backup adapter instance.
|
||||
*
|
||||
* @return \League\Flysystem\AdapterInterface
|
||||
*/
|
||||
public function adapter(string $name = null)
|
||||
public function adapter(string $name = null): FilesystemAdapter
|
||||
{
|
||||
return $this->get($name ?: $this->getDefaultAdapter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given backup adapter instance.
|
||||
*
|
||||
* @param \League\Flysystem\AdapterInterface $disk
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function set(string $name, $disk)
|
||||
public function set(string $name, FilesystemAdapter $disk): self
|
||||
{
|
||||
$this->adapters[$name] = $disk;
|
||||
|
||||
|
@ -75,25 +56,21 @@ class BackupManager
|
|||
|
||||
/**
|
||||
* Gets a backup adapter.
|
||||
*
|
||||
* @return \League\Flysystem\AdapterInterface
|
||||
*/
|
||||
protected function get(string $name)
|
||||
protected function get(string $name): FilesystemAdapter
|
||||
{
|
||||
return $this->adapters[$name] = $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given backup disk.
|
||||
*
|
||||
* @return \League\Flysystem\AdapterInterface
|
||||
*/
|
||||
protected function resolve(string $name)
|
||||
protected function resolve(string $name): FilesystemAdapter
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (empty($config['adapter'])) {
|
||||
throw new InvalidArgumentException("Backup disk [{$name}] does not have a configured adapter.");
|
||||
throw new InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
|
||||
}
|
||||
|
||||
$adapter = $config['adapter'];
|
||||
|
@ -106,44 +83,34 @@ class BackupManager
|
|||
if (method_exists($this, $adapterMethod)) {
|
||||
$instance = $this->{$adapterMethod}($config);
|
||||
|
||||
Assert::isInstanceOf($instance, AdapterInterface::class);
|
||||
Assert::isInstanceOf($instance, FilesystemAdapter::class);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Adapter [{$adapter}] is not supported.");
|
||||
throw new InvalidArgumentException("Adapter [$adapter] is not supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a custom creator for a given adapter type.
|
||||
*
|
||||
* @return \League\Flysystem\AdapterInterface
|
||||
*/
|
||||
protected function callCustomCreator(array $config)
|
||||
protected function callCustomCreator(array $config): mixed
|
||||
{
|
||||
$adapter = $this->customCreators[$config['adapter']]($this->app, $config);
|
||||
|
||||
Assert::isInstanceOf($adapter, AdapterInterface::class);
|
||||
|
||||
return $adapter;
|
||||
return $this->customCreators[$config['adapter']]($this->app, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new wings adapter.
|
||||
*
|
||||
* @return \League\Flysystem\AdapterInterface
|
||||
* Creates a new Wings adapter.
|
||||
*/
|
||||
public function createWingsAdapter(array $config)
|
||||
public function createWingsAdapter(array $config): FilesystemAdapter
|
||||
{
|
||||
return new MemoryAdapter(null);
|
||||
return new InMemoryFilesystemAdapter(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new S3 adapter.
|
||||
*
|
||||
* @return \League\Flysystem\AdapterInterface
|
||||
*/
|
||||
public function createS3Adapter(array $config)
|
||||
public function createS3Adapter(array $config): FilesystemAdapter
|
||||
{
|
||||
$config['version'] = 'latest';
|
||||
|
||||
|
@ -153,25 +120,21 @@ class BackupManager
|
|||
|
||||
$client = new S3Client($config);
|
||||
|
||||
return new AwsS3Adapter($client, $config['bucket'], $config['prefix'] ?? '', $config['options'] ?? []);
|
||||
return new S3Filesystem($client, $config['bucket'], $config['prefix'] ?? '', $config['options'] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration associated with a given backup type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig(string $name)
|
||||
protected function getConfig(string $name): array
|
||||
{
|
||||
return $this->config->get("backups.disks.{$name}") ?: [];
|
||||
return $this->config->get("backups.disks.$name") ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default backup driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultAdapter()
|
||||
public function getDefaultAdapter(): string
|
||||
{
|
||||
return $this->config->get('backups.default');
|
||||
}
|
||||
|
@ -179,7 +142,7 @@ class BackupManager
|
|||
/**
|
||||
* Set the default session driver name.
|
||||
*/
|
||||
public function setDefaultAdapter(string $name)
|
||||
public function setDefaultAdapter(string $name): void
|
||||
{
|
||||
$this->config->set('backups.default', $name);
|
||||
}
|
||||
|
@ -188,13 +151,11 @@ class BackupManager
|
|||
* Unset the given adapter instances.
|
||||
*
|
||||
* @param string|string[] $adapter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forget($adapter)
|
||||
public function forget(array|string $adapter): self
|
||||
{
|
||||
foreach ((array) $adapter as $adapterName) {
|
||||
unset($this->adapters[$adapter]);
|
||||
unset($this->adapters[$adapterName]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -202,10 +163,8 @@ class BackupManager
|
|||
|
||||
/**
|
||||
* Register a custom adapter creator closure.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function extend(string $adapter, Closure $callback)
|
||||
public function extend(string $adapter, Closure $callback): self
|
||||
{
|
||||
$this->customCreators[$adapter] = $callback;
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Extensions;
|
||||
|
||||
|
@ -20,44 +13,22 @@ class DynamicDatabaseConnection
|
|||
public const DB_COLLATION = 'utf8_unicode_ci';
|
||||
public const DB_DRIVER = 'mysql';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
protected $encrypter;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* DynamicDatabaseConnection constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ConfigRepository $config,
|
||||
DatabaseHostRepositoryInterface $repository,
|
||||
Encrypter $encrypter
|
||||
protected ConfigRepository $config,
|
||||
protected Encrypter $encrypter,
|
||||
protected DatabaseHostRepositoryInterface $repository
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->encrypter = $encrypter;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a dynamic database connection entry to the runtime config.
|
||||
*
|
||||
* @param string $connection
|
||||
* @param \Pterodactyl\Models\DatabaseHost|int $host
|
||||
* @param string $database
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function set($connection, $host, $database = 'mysql')
|
||||
public function set(string $connection, DatabaseHost|int $host, string $database = 'mysql'): void
|
||||
{
|
||||
if (!$host instanceof DatabaseHost) {
|
||||
$host = $this->repository->find($host);
|
||||
|
|
|
@ -6,10 +6,7 @@ use Illuminate\Support\Facades\Facade;
|
|||
|
||||
class Theme extends Facade
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return 'extensions.themes';
|
||||
}
|
||||
|
|
35
app/Extensions/Filesystem/S3Filesystem.php
Normal file
35
app/Extensions/Filesystem/S3Filesystem.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Extensions\Filesystem;
|
||||
|
||||
use Aws\S3\S3ClientInterface;
|
||||
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
|
||||
|
||||
class S3Filesystem extends AwsS3V3Adapter
|
||||
{
|
||||
public function __construct(
|
||||
private S3ClientInterface $client,
|
||||
private string $bucket,
|
||||
string $prefix = '',
|
||||
array $options = [],
|
||||
) {
|
||||
parent::__construct(
|
||||
$client,
|
||||
$bucket,
|
||||
$prefix,
|
||||
null,
|
||||
null,
|
||||
$options,
|
||||
);
|
||||
}
|
||||
|
||||
public function getClient(): S3ClientInterface
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
public function getBucket(): string
|
||||
{
|
||||
return $this->bucket;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Extensions;
|
||||
|
||||
|
@ -17,7 +10,7 @@ class Hashids extends VendorHashids implements HashidsInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function decodeFirst($encoded, $default = null)
|
||||
public function decodeFirst(string $encoded, string $default = null): mixed
|
||||
{
|
||||
$result = $this->decode($encoded);
|
||||
if (!is_array($result)) {
|
||||
|
|
|
@ -8,10 +8,8 @@ class Builder extends EloquentBuilder
|
|||
{
|
||||
/**
|
||||
* Do nothing.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function search()
|
||||
public function search(): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Extensions\Spatie\Fractalistic;
|
||||
|
||||
use League\Fractal\Scope;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Spatie\Fractal\Fractal as SpatieFractal;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
@ -13,12 +14,10 @@ class Fractal extends SpatieFractal
|
|||
/**
|
||||
* Create fractal data.
|
||||
*
|
||||
* @return \League\Fractal\Scope
|
||||
*
|
||||
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
|
||||
* @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified
|
||||
*/
|
||||
public function createData()
|
||||
public function createData(): Scope
|
||||
{
|
||||
// Set the serializer by default.
|
||||
if (is_null($this->serializer)) {
|
||||
|
|
|
@ -4,17 +4,17 @@ namespace Pterodactyl\Extensions\Themes;
|
|||
|
||||
class Theme
|
||||
{
|
||||
public function js($path)
|
||||
public function js($path): string
|
||||
{
|
||||
return sprintf('<script src="%s"></script>' . PHP_EOL, $this->getUrl($path));
|
||||
}
|
||||
|
||||
public function css($path)
|
||||
public function css($path): string
|
||||
{
|
||||
return sprintf('<link media="all" type="text/css" rel="stylesheet" href="%s"/>' . PHP_EOL, $this->getUrl($path));
|
||||
}
|
||||
|
||||
protected function getUrl($path)
|
||||
protected function getUrl($path): string
|
||||
{
|
||||
return '/themes/pterodactyl/' . ltrim($path, '/');
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use Pterodactyl\Services\Activity\ActivityLogService;
|
|||
|
||||
class Activity extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return ActivityLogService::class;
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
namespace Pterodactyl\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use Pterodactyl\Services\Activity\AcitvityLogBatchService;
|
||||
use Pterodactyl\Services\Activity\ActivityLogBatchService;
|
||||
|
||||
class LogBatch extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return AcitvityLogBatchService::class;
|
||||
return ActivityLogBatchService::class;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use Pterodactyl\Services\Activity\ActivityLogTargetableService;
|
|||
|
||||
class LogTarget extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return ActivityLogTargetableService::class;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ final class Time
|
|||
{
|
||||
$offset = round(CarbonImmutable::now($timezone)->getTimezone()->getOffset(CarbonImmutable::now('UTC')) / 3600);
|
||||
|
||||
return sprintf('%s%s:00', $offset > 0 ? '+' : '-', str_pad(abs($offset), 2, '0', STR_PAD_LEFT));
|
||||
return sprintf('%s%s:00', $offset > 0 ? '+' : '-', str_pad((string) abs($offset), 2, '0', STR_PAD_LEFT));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class Utilities
|
|||
{
|
||||
/**
|
||||
* Generates a random string and injects special characters into it, in addition to
|
||||
* the randomness of the alpha-numeric default response.
|
||||
* the randomness of the alphanumeric default response.
|
||||
*/
|
||||
public static function randomStringWithSpecialCharacters(int $length = 16): string
|
||||
{
|
||||
|
@ -36,21 +36,16 @@ class Utilities
|
|||
/**
|
||||
* Converts schedule cron data into a carbon object.
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek)
|
||||
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek): Carbon
|
||||
{
|
||||
return Carbon::instance(CronExpression::factory(
|
||||
return Carbon::instance((new CronExpression(
|
||||
sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek)
|
||||
)->getNextRunDate());
|
||||
))->getNextRunDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function checked(string $name, $default)
|
||||
public static function checked(string $name, mixed $default): string
|
||||
{
|
||||
$errors = session('errors');
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use Pterodactyl\Models\ApiKey;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Api\KeyCreationService;
|
||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||
|
@ -17,31 +18,14 @@ use Pterodactyl\Http\Requests\Admin\Api\StoreApplicationApiKeyRequest;
|
|||
class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Api\KeyCreationService
|
||||
*/
|
||||
private $keyCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ApplicationApiController constructor.
|
||||
* ApiController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
ApiKeyRepositoryInterface $repository,
|
||||
KeyCreationService $keyCreationService
|
||||
private AlertsMessageBag $alert,
|
||||
private ApiKeyRepositoryInterface $repository,
|
||||
private KeyCreationService $keyCreationService,
|
||||
private ViewFactory $view,
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->keyCreationService = $keyCreationService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +33,7 @@ class ApiController extends Controller
|
|||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
return view('admin.api.index', [
|
||||
return $this->view->make('admin.api.index', [
|
||||
'keys' => $this->repository->getApplicationKeys($request->user()),
|
||||
]);
|
||||
}
|
||||
|
@ -64,7 +48,7 @@ class ApiController extends Controller
|
|||
$resources = AdminAcl::getResourceList();
|
||||
sort($resources);
|
||||
|
||||
return view('admin.api.new', [
|
||||
return $this->view->make('admin.api.new', [
|
||||
'resources' => $resources,
|
||||
'permissions' => [
|
||||
'r' => AdminAcl::READ,
|
||||
|
|
|
@ -3,22 +3,17 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* BaseController constructor.
|
||||
*/
|
||||
public function __construct(SoftwareVersionService $version)
|
||||
public function __construct(private SoftwareVersionService $version, private ViewFactory $view)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,6 +21,6 @@ class BaseController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.index', ['version' => $this->version]);
|
||||
return $this->view->make('admin.index', ['version' => $this->version]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Illuminate\View\View;
|
|||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Databases\Hosts\HostUpdateService;
|
||||
use Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest;
|
||||
|
@ -19,60 +20,19 @@ use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
|||
|
||||
class DatabaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
||||
*/
|
||||
private $databaseRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
private $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
|
||||
/**
|
||||
* DatabaseController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
DatabaseHostRepositoryInterface $repository,
|
||||
DatabaseRepositoryInterface $databaseRepository,
|
||||
HostCreationService $creationService,
|
||||
HostDeletionService $deletionService,
|
||||
HostUpdateService $updateService,
|
||||
LocationRepositoryInterface $locationRepository
|
||||
private AlertsMessageBag $alert,
|
||||
private DatabaseHostRepositoryInterface $repository,
|
||||
private DatabaseRepositoryInterface $databaseRepository,
|
||||
private HostCreationService $creationService,
|
||||
private HostDeletionService $deletionService,
|
||||
private HostUpdateService $updateService,
|
||||
private LocationRepositoryInterface $locationRepository,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->databaseRepository = $databaseRepository;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +40,7 @@ class DatabaseController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.databases.index', [
|
||||
return $this->view->make('admin.databases.index', [
|
||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||
'hosts' => $this->repository->getWithViewDetails(),
|
||||
]);
|
||||
|
@ -93,7 +53,7 @@ class DatabaseController extends Controller
|
|||
*/
|
||||
public function view(int $host): View
|
||||
{
|
||||
return view('admin.databases.view', [
|
||||
return $this->view->make('admin.databases.view', [
|
||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||
'host' => $this->repository->find($host),
|
||||
'databases' => $this->databaseRepository->getDatabasesForHost($host),
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Admin\LocationFormRequest;
|
||||
|
@ -21,56 +17,25 @@ use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
|||
|
||||
class LocationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* LocationController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
LocationCreationService $creationService,
|
||||
LocationDeletionService $deletionService,
|
||||
LocationRepositoryInterface $repository,
|
||||
LocationUpdateService $updateService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected LocationCreationService $creationService,
|
||||
protected LocationDeletionService $deletionService,
|
||||
protected LocationRepositoryInterface $repository,
|
||||
protected LocationUpdateService $updateService,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the location overview page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.locations.index', [
|
||||
return $this->view->make('admin.locations.index', [
|
||||
'locations' => $this->repository->getAllWithDetails(),
|
||||
]);
|
||||
}
|
||||
|
@ -78,15 +43,11 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Return the location view page.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view($id)
|
||||
public function view(int $id): View
|
||||
{
|
||||
return view('admin.locations.view', [
|
||||
return $this->view->make('admin.locations.view', [
|
||||
'location' => $this->repository->getWithNodes($id),
|
||||
]);
|
||||
}
|
||||
|
@ -94,11 +55,9 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Handle request to create new location.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function create(LocationFormRequest $request)
|
||||
public function create(LocationFormRequest $request): RedirectResponse
|
||||
{
|
||||
$location = $this->creationService->handle($request->normalize());
|
||||
$this->alert->success('Location was created successfully.')->flash();
|
||||
|
@ -109,11 +68,9 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Handle request to update or delete location.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function update(LocationFormRequest $request, Location $location)
|
||||
public function update(LocationFormRequest $request, Location $location): RedirectResponse
|
||||
{
|
||||
if ($request->input('action') === 'delete') {
|
||||
return $this->delete($location);
|
||||
|
@ -128,12 +85,10 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Delete a location from the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete(Location $location)
|
||||
public function delete(Location $location): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->deletionService->handle($location->id);
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Admin\MountFormRequest;
|
||||
use Pterodactyl\Repositories\Eloquent\MountRepository;
|
||||
|
@ -16,49 +20,24 @@ use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
|||
|
||||
class MountController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $nestRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
protected $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\MountRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* MountController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
NestRepositoryInterface $nestRepository,
|
||||
LocationRepositoryInterface $locationRepository,
|
||||
MountRepository $repository
|
||||
protected AlertsMessageBag $alert,
|
||||
protected NestRepositoryInterface $nestRepository,
|
||||
protected LocationRepositoryInterface $locationRepository,
|
||||
protected MountRepository $repository,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mount overview page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.mounts.index', [
|
||||
return $this->view->make('admin.mounts.index', [
|
||||
'mounts' => $this->repository->getAllWithDetails(),
|
||||
]);
|
||||
}
|
||||
|
@ -66,18 +45,14 @@ class MountController extends Controller
|
|||
/**
|
||||
* Return the mount view page.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view($id)
|
||||
public function view(string $id): View
|
||||
{
|
||||
$nests = Nest::query()->with('eggs')->get();
|
||||
$locations = Location::query()->with('nodes')->get();
|
||||
|
||||
return view('admin.mounts.view', [
|
||||
return $this->view->make('admin.mounts.view', [
|
||||
'mount' => $this->repository->getWithRelations($id),
|
||||
'nests' => $nests,
|
||||
'locations' => $locations,
|
||||
|
@ -87,11 +62,9 @@ class MountController extends Controller
|
|||
/**
|
||||
* Handle request to create new mount.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function create(MountFormRequest $request)
|
||||
public function create(MountFormRequest $request): RedirectResponse
|
||||
{
|
||||
$model = (new Mount())->fill($request->validated());
|
||||
$model->forceFill(['uuid' => Uuid::uuid4()->toString()]);
|
||||
|
@ -107,11 +80,9 @@ class MountController extends Controller
|
|||
/**
|
||||
* Handle request to update or delete location.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function update(MountFormRequest $request, Mount $mount)
|
||||
public function update(MountFormRequest $request, Mount $mount): RedirectResponse
|
||||
{
|
||||
if ($request->input('action') === 'delete') {
|
||||
return $this->delete($mount);
|
||||
|
@ -127,11 +98,9 @@ class MountController extends Controller
|
|||
/**
|
||||
* Delete a location from the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(Mount $mount)
|
||||
public function delete(Mount $mount): RedirectResponse
|
||||
{
|
||||
$mount->delete();
|
||||
|
||||
|
@ -139,11 +108,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds eggs to the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Adds eggs to the mount's many-to-many relation.
|
||||
*/
|
||||
public function addEggs(Request $request, Mount $mount)
|
||||
public function addEggs(Request $request, Mount $mount): RedirectResponse
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'eggs' => 'required|exists:eggs,id',
|
||||
|
@ -160,11 +127,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds nodes to the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Adds nodes to the mount's many-to-many relation.
|
||||
*/
|
||||
public function addNodes(Request $request, Mount $mount)
|
||||
public function addNodes(Request $request, Mount $mount): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['nodes' => 'required|exists:nodes,id']);
|
||||
|
||||
|
@ -179,11 +144,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes an egg from the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* Deletes an egg from the mount's many-to-many relation.
|
||||
*/
|
||||
public function deleteEgg(Mount $mount, int $egg_id)
|
||||
public function deleteEgg(Mount $mount, int $egg_id): Response
|
||||
{
|
||||
$mount->eggs()->detach($egg_id);
|
||||
|
||||
|
@ -191,11 +154,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes an node from the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* Deletes a node from the mount's many-to-many relation.
|
||||
*/
|
||||
public function deleteNode(Mount $mount, int $node_id)
|
||||
public function deleteNode(Mount $mount, int $node_id): Response
|
||||
{
|
||||
$mount->nodes()->detach($node_id);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue