Remove more unnecessary translations

This commit is contained in:
DaneEveritt 2022-05-12 17:53:29 -04:00
parent 0e3e14aa93
commit 100d4ee726
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 58 additions and 126 deletions

View file

@ -1,32 +1,23 @@
<?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;
use DateTimeZone;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Validation\Factory as ValidatorFactory;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class AppSettingsCommand extends Command
{
use EnvironmentWriterTrait;
public const ALLOWED_CACHE_DRIVERS = [
public const CACHE_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
'file' => 'Filesystem',
];
public const ALLOWED_SESSION_DRIVERS = [
public const SESSION_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
'database' => 'MySQL Database',
@ -34,7 +25,7 @@ class AppSettingsCommand extends Command
'cookie' => 'Cookie',
];
public const ALLOWED_QUEUE_DRIVERS = [
public const QUEUE_DRIVERS = [
'redis' => 'Redis (recommended)',
'database' => 'MySQL Database',
'sync' => 'Sync',
@ -45,11 +36,6 @@ class AppSettingsCommand extends Command
*/
protected $command;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var string
*/
@ -79,13 +65,11 @@ class AppSettingsCommand extends Command
/**
* AppSettingsCommand constructor.
*/
public function __construct(ConfigRepository $config, Kernel $command, ValidatorFactory $validator)
public function __construct(Kernel $command)
{
parent::__construct();
$this->config = $config;
$this->command = $command;
$this->validator = $validator;
}
/**
@ -95,67 +79,60 @@ class AppSettingsCommand extends Command
*/
public function handle()
{
if (empty($this->config->get('hashids.salt')) || $this->option('new-salt')) {
if (empty(config('hashids.salt')) || $this->option('new-salt')) {
$this->variables['HASHIDS_SALT'] = str_random(20);
}
$this->output->comment(trans('command/messages.environment.app.author_help'));
$this->output->comment('Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.');
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
trans('command/messages.environment.app.author'),
$this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
'Egg Author Email',
config('pterodactyl.service.author', 'unknown@unknown.com')
);
$validator = $this->validator->make(
['email' => $this->variables['APP_SERVICE_AUTHOR']],
['email' => 'email']
);
if ($validator->fails()) {
foreach ($validator->errors()->all() as $error) {
$this->output->error($error);
}
if (!filter_var($this->variables['APP_SERVICE_AUTHOR'], FILTER_VALIDATE_EMAIL)) {
$this->output->error('The service author email provided is invalid.');
return 1;
}
$this->output->comment(trans('command/messages.environment.app.app_url_help'));
$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(
trans('command/messages.environment.app.app_url'),
$this->config->get('app.url', 'http://example.org')
'Application URL',
config('app.url', 'http://example.org')
);
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
$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->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
trans('command/messages.environment.app.timezone'),
'Application Timezone',
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
$this->config->get('app.timezone')
config('app.timezone')
);
$selected = $this->config->get('cache.default', 'redis');
$selected = config('cache.default', 'redis');
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
trans('command/messages.environment.app.cache_driver'),
self::ALLOWED_CACHE_DRIVERS,
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
'Cache Driver',
self::CACHE_DRIVERS,
array_key_exists($selected, self::CACHE_DRIVERS) ? $selected : null
);
$selected = $this->config->get('session.driver', 'redis');
$selected = config('session.driver', 'redis');
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
trans('command/messages.environment.app.session_driver'),
self::ALLOWED_SESSION_DRIVERS,
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
'Session Driver',
self::SESSION_DRIVERS,
array_key_exists($selected, self::SESSION_DRIVERS) ? $selected : null
);
$selected = $this->config->get('queue.default', 'redis');
$selected = config('queue.default', 'redis');
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
trans('command/messages.environment.app.queue_driver'),
self::ALLOWED_QUEUE_DRIVERS,
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
'Queue Driver',
self::QUEUE_DRIVERS,
array_key_exists($selected, self::QUEUE_DRIVERS) ? $selected : null
);
if (!is_null($this->option('settings-ui'))) {
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
} else {
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm('Enable UI based settings editor?', true) ? 'false' : 'true';
}
// Make sure session cookies are set as "secure" when using HTTPS
@ -183,22 +160,22 @@ class AppSettingsCommand extends Command
return;
}
$this->output->note(trans('command/messages.environment.app.using_redis'));
$this->output->note('You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.');
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
trans('command/messages.environment.app.redis_host'),
$this->config->get('database.redis.default.host')
'Redis Host',
config('database.redis.default.host')
);
$askForRedisPassword = true;
if (!empty($this->config->get('database.redis.default.password'))) {
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
if (!empty(config('database.redis.default.password'))) {
$this->variables['REDIS_PASSWORD'] = config('database.redis.default.password');
$askForRedisPassword = $this->confirm('It seems a password is already defined for Redis, would you like to change it?');
}
if ($askForRedisPassword) {
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
$this->output->comment('By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.');
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
trans('command/messages.environment.app.redis_password')
'Redis Password'
);
}
@ -207,8 +184,8 @@ class AppSettingsCommand extends Command
}
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
trans('command/messages.environment.app.redis_port'),
$this->config->get('database.redis.default.port')
'Redis Port',
config('database.redis.default.port')
);
}
}

View file

@ -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;
@ -14,17 +7,11 @@ use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Database\DatabaseManager;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class DatabaseSettingsCommand extends Command
{
use EnvironmentWriterTrait;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Illuminate\Contracts\Console\Kernel
*/
@ -58,11 +45,10 @@ class DatabaseSettingsCommand extends Command
/**
* DatabaseSettingsCommand constructor.
*/
public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console)
public function __construct(DatabaseManager $database, Kernel $console)
{
parent::__construct();
$this->config = $config;
$this->console = $console;
$this->database = $database;
}
@ -76,45 +62,45 @@ class DatabaseSettingsCommand extends Command
*/
public function handle()
{
$this->output->note(trans('command/messages.environment.database.host_warning'));
$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(
trans('command/messages.environment.database.host'),
$this->config->get('database.connections.mysql.host', '127.0.0.1')
'Database Host',
config('database.connections.mysql.host', '127.0.0.1')
);
$this->variables['DB_PORT'] = $this->option('port') ?? $this->ask(
trans('command/messages.environment.database.port'),
$this->config->get('database.connections.mysql.port', 3306)
'Database Port',
config('database.connections.mysql.port', 3306)
);
$this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask(
trans('command/messages.environment.database.database'),
$this->config->get('database.connections.mysql.database', 'panel')
'Database Name',
config('database.connections.mysql.database', 'panel')
);
$this->output->note(trans('command/messages.environment.database.username_warning'));
$this->output->note('Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.');
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.database.username'),
$this->config->get('database.connections.mysql.username', 'pterodactyl')
'Database Username',
config('database.connections.mysql.username', 'pterodactyl')
);
$askForMySQLPassword = true;
if (!empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
if (!empty(config('database.connections.mysql.password')) && $this->input->isInteractive()) {
$this->variables['DB_PASSWORD'] = config('database.connections.mysql.password');
$askForMySQLPassword = $this->confirm('It appears you already have a MySQL connection password defined, would you like to change it?');
}
if ($askForMySQLPassword) {
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret(trans('command/messages.environment.database.password'));
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret('Database Password');
}
try {
$this->testMySQLConnection();
} catch (PDOException $exception) {
$this->output->error(trans('command/messages.environment.database.connection_error', ['error' => $exception->getMessage()]));
$this->output->error(trans('command/messages.environment.database.creds_not_saved'));
$this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
$this->output->error('Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.');
if ($this->confirm(trans('command/messages.environment.database.try_again'))) {
if ($this->confirm('Go back and try again?')) {
$this->database->disconnect('_pterodactyl_command_test');
return $this->handle();
@ -135,7 +121,7 @@ class DatabaseSettingsCommand extends Command
*/
private function testMySQLConnection()
{
$this->config->set('database.connections._pterodactyl_command_test', [
config()->set('database.connections._pterodactyl_command_test', [
'driver' => 'mysql',
'host' => $this->variables['DB_HOST'],
'port' => $this->variables['DB_PORT'],

View file

@ -62,36 +62,5 @@ return [
'ask_mail_name' => 'Name that emails should appear from',
'ask_encryption' => 'Encryption method to use',
],
'database' => [
'host_warning' => '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".',
'host' => 'Database Host',
'port' => 'Database Port',
'database' => 'Database Name',
'username_warning' => 'Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.',
'username' => 'Database Username',
'password_defined' => 'It appears you already have a MySQL connection password defined, would you like to change it?',
'password' => 'Database Password',
'connection_error' => 'Unable to connect to the MySQL server using the provided credentials. The error returned was ":error".',
'creds_not_saved' => 'Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.',
'try_again' => 'Go back and try again?',
],
'app' => [
'settings' => 'Enable UI based settings editor?',
'author' => 'Egg Author Email',
'author_help' => 'Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.',
'app_url_help' => '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.',
'app_url' => 'Application URL',
'timezone_help' => 'The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference http://php.net/manual/en/timezones.php.',
'timezone' => 'Application Timezone',
'cache_driver' => 'Cache Driver',
'session_driver' => 'Session Driver',
'queue_driver' => 'Queue Driver',
'using_redis' => 'You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.',
'redis_host' => 'Redis Host',
'redis_password' => 'Redis Password',
'redis_pass_help' => 'By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.',
'redis_port' => 'Redis Port',
'redis_pass_defined' => 'It seems a password is already defined for Redis, would you like to change it?',
],
],
];