diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index b8604757f..add1296e6 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -65,14 +65,14 @@ class EmailSettingsCommand extends Command public function handle() { $this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice( - trans('command/messages.environment.mail.ask_driver'), [ + trans('command/messages.environment.mail.ask_driver'), [ 'smtp' => 'SMTP Server', 'mail' => 'PHP\'s Internal Mail Function', 'mailgun' => 'Mailgun Transactional Email', 'mandrill' => 'Mandrill Transactional Email', 'postmark' => 'Postmarkapp Transactional Email', ], $this->config->get('mail.driver', 'smtp') - ); + ); $method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables'; if (method_exists($this, $method)) { diff --git a/app/Contracts/Repository/UserRepositoryInterface.php b/app/Contracts/Repository/UserRepositoryInterface.php index 41649f48b..f5ba47b4b 100644 --- a/app/Contracts/Repository/UserRepositoryInterface.php +++ b/app/Contracts/Repository/UserRepositoryInterface.php @@ -22,4 +22,12 @@ interface UserRepositoryInterface extends RepositoryInterface, SearchableInterfa * @return \Illuminate\Support\Collection */ public function filterUsersByQuery(?string $query): Collection; + + /** + * Returns a user with the given id in a format that can be used for dropdowns. + * + * @param int $id + * @return \Pterodactyl\Models\Model + */ + public function filterById(int $id): \Pterodactyl\Models\Model; } diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php index 2a0689124..d900425d9 100644 --- a/app/Helpers/Utilities.php +++ b/app/Helpers/Utilities.php @@ -6,6 +6,7 @@ use Exception; use Carbon\Carbon; use Cron\CronExpression; use Illuminate\Support\Facades\Log; +use Illuminate\Support\ViewErrorBag; class Utilities { @@ -50,4 +51,15 @@ class Utilities sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek) )->getNextRunDate()); } + + public static function checked($name, $default) + { + $errors = session('errors'); + + if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) { + return old($name) ? 'checked' : ''; + } + + return ($default) ? 'checked' : ''; + } } diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php index 569fec1d7..0aee86806 100644 --- a/app/Http/Controllers/Admin/DatabaseController.php +++ b/app/Http/Controllers/Admin/DatabaseController.php @@ -165,6 +165,7 @@ class DatabaseController extends Controller $this->alert->danger( sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) )->flash(); + return $redirect->withInput($request->normalize()); } else { throw $exception; diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 14b3b594f..18e7e3b43 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -177,10 +177,15 @@ class UserController extends Controller * Get a JSON response of users on the system. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection|\Pterodactyl\Models\Model */ public function json(Request $request) { + // Handle single user requests. + if ($request->query('user_id')) { + return $this->repository->filterById($request->input('user_id')); + } + return $this->repository->filterUsersByQuery($request->input('q')); } } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php index 340e2541a..7461a950a 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php @@ -86,7 +86,7 @@ class ScheduleTaskController extends ClientApiController } $this->repository->update($task->id, [ - 'action' => $request->input('action'), + 'action' => $request->input('action'), 'payload' => $request->input('payload'), 'time_offset' => $request->input('time_offset'), ]); diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php b/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php index b4599ee0a..8daee56af 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php @@ -3,8 +3,6 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Servers; use Carbon\Carbon; -use Illuminate\Http\Request; -use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\BackupRepository; diff --git a/app/Repositories/Eloquent/UserRepository.php b/app/Repositories/Eloquent/UserRepository.php index 1ed6c5b74..b6468b5bb 100644 --- a/app/Repositories/Eloquent/UserRepository.php +++ b/app/Repositories/Eloquent/UserRepository.php @@ -54,4 +54,22 @@ class UserRepository extends EloquentRepository implements UserRepositoryInterfa return $item; }); } + + /** + * Returns a user with the given id in a format that can be used for dropdowns. + * + * @param int $id + * @return \Pterodactyl\Models\Model + */ + public function filterById(int $id): \Pterodactyl\Models\Model + { + $this->setColumns([ + 'id', 'email', 'username', 'name_first', 'name_last', + ]); + + $model = $this->getBuilder()->findOrFail($id, $this->getColumns())->getModel(); + $model->md5 = md5(strtolower($model->email)); + + return $model; + } } diff --git a/config/ide-helper.php b/config/ide-helper.php index 9f10873f6..5922f533c 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -168,8 +168,8 @@ return [ | Cast the given "real type" to the given "type". | */ - 'type_overrides' => [ + 'type_overrides' => [ 'integer' => 'int', 'boolean' => 'bool', - ], + ], ]; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 3b2d3e728..93fbac555 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -3,8 +3,8 @@ use Ramsey\Uuid\Uuid; use Cake\Chronos\Chronos; use Illuminate\Support\Str; -use Faker\Generator as Faker; use Pterodactyl\Models\Node; +use Faker\Generator as Faker; use Pterodactyl\Models\ApiKey; /* diff --git a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php b/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php index 6bb36813d..dffa7687a 100644 --- a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php +++ b/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php @@ -26,8 +26,8 @@ class ChangeServicesToUseAMoreUniqueIdentifier extends Migration DB::table('services')->get(['id', 'author', 'uuid'])->each(function ($service) { DB::table('services')->where('id', $service->id)->update([ - 'author' => ($service->author === 'ptrdctyl-v040-11e6-8b77-86f30ca893d3') ? 'support@pterodactyl.io' : 'unknown@unknown-author.com', - 'uuid' => Uuid::uuid4()->toString(), + 'author' => ($service->author === 'ptrdctyl-v040-11e6-8b77-86f30ca893d3') ? 'support@pterodactyl.io' : 'unknown@unknown-author.com', + 'uuid' => Uuid::uuid4()->toString(), ]); }); diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 7cd0c5fce..621c9526b 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -44,12 +44,12 @@ class MergePermissionsTableIntoSubusers extends Migration { foreach (DB::select('SELECT id, permissions FROM subusers') as $datum) { $values = []; - foreach(json_decode($datum->permissions, true) as $permission) { + foreach (json_decode($datum->permissions, true) as $permission) { $values[] = $datum->id; $values[] = $permission; } - if (!empty($values)) { + if (! empty($values)) { $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); diff --git a/database/migrations/2020_04_03_230614_create_backups_table.php b/database/migrations/2020_04_03_230614_create_backups_table.php index 63dad39a0..ead68105c 100644 --- a/database/migrations/2020_04_03_230614_create_backups_table.php +++ b/database/migrations/2020_04_03_230614_create_backups_table.php @@ -1,8 +1,8 @@ \ - \ - \ - ' + data.name_first + ' ' + data.name_last +' \ - \ - ' + data.email + ' - ' + data.username + ' \ - '; - }, - templateSelection: function (data) { - return '
Character limits: a-z A-Z 0-9 _ - .
and [Space]
(max 200 characters).
A brief description of this server.
The node which this server will be deployed to.
The main allocation that will be assigned to this server.
Additional allocations to assign to this server on creation.
The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.
The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.
If you do not want to limit CPU usage, set the value to 0
. To determine a value, take the number of physical cores and multiply it by 100. For example, on a quad core system (4 * 100 = 400)
there is 400%
available. To limit a server to using half of a single core, you would set the value to 50
. To allow a server to use up to two physical cores, set the value to 200
. BlockIO should be a value between 10
and 1000
. Please see this documentation for more information about it.
+ +
If you do not want to limit CPU usage, set the value to 0
. To determine a value, take the number of physical cores and multiply it by 100. For example, on a quad core system (4 * 100 = 400)
there is 400%
available. To limit a server to using half of a single core, you would set the value to 50
. To allow a server to use up to two physical cores, set the value to 200
. BlockIO should be a value between 10
and 1000
. Please see this documentation for more information about it.
Advanced: Enter the specific CPU cores that this process can run on, or leave blank to allow all cores. This can be a single number, or a comma seperated list. Example: 0
, 0-1,3
, or 0,1,3,4
.
Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10
and 1000
.
Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10
and 1000
.
Select the Egg that will define how this server should operate.
Select a data pack to be automatically installed on this server when first created.
If the selected Egg has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.
The following data substitutes are available for the startup command: @{{SERVER_MEMORY}}
, @{{SERVER_IP}}
, and @{{SERVER_PORT}}
. They will be replaced with the allocated memory, server IP, and server port respectively.