mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 17:12:30 +01:00
Use env() properly throughout panel to avoid cache issues.
This commit is contained in:
parent
9a581ef536
commit
4f16509447
@ -83,7 +83,7 @@ class AddNode extends Command
|
||||
$selectedLocation = $this->option('location');
|
||||
}
|
||||
|
||||
$this->data['location'] = $locations->where('short', $selectedLocation)->first()->id;
|
||||
$this->data['location_id'] = $locations->where('short', $selectedLocation)->first()->id;
|
||||
|
||||
if (is_null($this->option('fqdn'))) {
|
||||
$this->line('Please enter domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.');
|
||||
|
@ -64,7 +64,7 @@ class ClearTasks extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$entries = Models\TaskLog::where('run_time', '<=', Carbon::now()->subHours(env('APP_CLEAR_TASKLOG', 720))->toAtomString())->get();
|
||||
$entries = Models\TaskLog::where('run_time', '<=', Carbon::now()->subHours(config('pterodactyl.tasks.clear_log'))->toAtomString())->get();
|
||||
|
||||
$this->info(sprintf('Preparing to delete %d old task log entries.', count($entries)));
|
||||
$bar = $this->output->createProgressBar(count($entries));
|
||||
|
@ -72,7 +72,7 @@ class RunTasks extends Command
|
||||
|
||||
foreach ($tasks as &$task) {
|
||||
$bar->advance();
|
||||
$this->dispatch((new SendScheduledTask(Models\Server::findOrFail($task->server), $task))->onQueue(env('QUEUE_LOW', 'low')));
|
||||
$this->dispatch((new SendScheduledTask(Models\Server::findOrFail($task->server), $task))->onQueue(config('pterodactyl.queues.low')));
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
|
@ -100,6 +100,7 @@ class UpdateEmailSettings extends Command
|
||||
'Postmark Transactional Email Service',
|
||||
],
|
||||
]);
|
||||
|
||||
$variables['MAIL_DRIVER'] = is_null($this->option('driver')) ? $this->choice('Which email driver would you like to use?', [
|
||||
'smtp',
|
||||
'mail',
|
||||
@ -110,9 +111,9 @@ class UpdateEmailSettings extends Command
|
||||
|
||||
switch ($variables['MAIL_DRIVER']) {
|
||||
case 'smtp':
|
||||
$variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)') : $this->option('host');
|
||||
$variables['MAIL_PORT'] = is_null($this->option('port')) ? $this->anticipate('SMTP Host Port (e.g 587)', ['587']) : $this->option('port');
|
||||
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username') : $this->option('password');
|
||||
$variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)', config('mail.host')) : $this->option('host');
|
||||
$variables['MAIL_PORT'] = is_null($this->option('port')) ? $this->anticipate('SMTP Host Port (e.g 587)', ['587', config('mail.port')], config('mail.port')) : $this->option('port');
|
||||
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username', config('mail.username')) : $this->option('password');
|
||||
$variables['MAIL_PASSWORD'] = is_null($this->option('password')) ? $this->secret('SMTP Password') : $this->option('password');
|
||||
break;
|
||||
case 'mail':
|
||||
@ -128,7 +129,7 @@ class UpdateEmailSettings extends Command
|
||||
$variables['MAIL_DRIVER'] = 'smtp';
|
||||
$variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
|
||||
$variables['MAIL_PORT'] = 587;
|
||||
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token') : $this->option('username');
|
||||
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token', config('mail.username')) : $this->option('username');
|
||||
$variables['MAIL_PASSWORD'] = $variables['MAIL_USERNAME'];
|
||||
break;
|
||||
default:
|
||||
@ -137,8 +138,9 @@ class UpdateEmailSettings extends Command
|
||||
break;
|
||||
}
|
||||
|
||||
$variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from') : $this->option('email');
|
||||
$variables['MAIL_FROM_NAME'] = is_null($this->option('from-name')) ? $this->ask('Name emails should appear to be from') : $this->option('from-name');
|
||||
$variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from', config('mail.from.address')) : $this->option('email');
|
||||
$variables['MAIL_FROM_NAME'] = is_null($this->option('from-name')) ? $this->ask('Name emails should appear to be from', config('mail.from.name')) : $this->option('from-name');
|
||||
$variables['MAIL_FROM_NAME'] = '"' . $variables['MAIL_FROM_NAME'] . '"';
|
||||
$variables['MAIL_ENCRYPTION'] = 'tls';
|
||||
|
||||
$bar = $this->output->createProgressBar(count($variables));
|
||||
|
@ -77,39 +77,31 @@ class UpdateEnvironment extends Command
|
||||
$envContents = file_get_contents($file);
|
||||
|
||||
$this->info('Simply leave blank and press enter to fields that you do not wish to update.');
|
||||
if (! env('SERVICE_AUTHOR', false)) {
|
||||
if (is_null(config('pterodactyl.service.author', null))) {
|
||||
$this->info('No service author set, setting one now.');
|
||||
$variables['SERVICE_AUTHOR'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
|
||||
}
|
||||
|
||||
if (! env('QUEUE_STANDARD', false) || ! env('QUEUE_DRIVER', false)) {
|
||||
$this->info('Setting default queue settings.');
|
||||
$variables['QUEUE_DRIVER'] = env('QUEUE_DRIVER', 'database');
|
||||
$variables['QUEUE_HIGH'] = env('QUEUE_HIGH', 'high');
|
||||
$variables['QUEUE_STANDARD'] = env('QUEUE_STANDARD', 'standard');
|
||||
$variables['QUEUE_LOW'] = env('QUEUE_LOW', 'low');
|
||||
$variables['SERVICE_AUTHOR'] = (string) Uuid::generate(4);
|
||||
}
|
||||
|
||||
if (is_null($this->option('dbhost'))) {
|
||||
$variables['DB_HOST'] = $this->anticipate('Database Host', ['localhost', '127.0.0.1', env('DB_HOST')], env('DB_HOST'));
|
||||
$variables['DB_HOST'] = $this->anticipate('Database Host', ['localhost', '127.0.0.1', config('database.connections.mysql.host')], config('database.connections.mysql.host'));
|
||||
} else {
|
||||
$variables['DB_HOST'] = $this->option('dbhost');
|
||||
}
|
||||
|
||||
if (is_null($this->option('dbport'))) {
|
||||
$variables['DB_PORT'] = $this->anticipate('Database Port', [3306, env('DB_PORT')], env('DB_PORT'));
|
||||
$variables['DB_PORT'] = $this->anticipate('Database Port', [3306, config('database.connections.mysql.port')], config('database.connections.mysql.port'));
|
||||
} else {
|
||||
$variables['DB_PORT'] = $this->option('dbport');
|
||||
}
|
||||
|
||||
if (is_null($this->option('dbname'))) {
|
||||
$variables['DB_DATABASE'] = $this->anticipate('Database Name', ['pterodactyl', 'homestead', ENV('DB_DATABASE')], env('DB_DATABASE'));
|
||||
$variables['DB_DATABASE'] = $this->anticipate('Database Name', ['pterodactyl', 'homestead', config('database.connections.mysql.database')], config('database.connections.mysql.database'));
|
||||
} else {
|
||||
$variables['DB_DATABASE'] = $this->option('dbname');
|
||||
}
|
||||
|
||||
if (is_null($this->option('dbuser'))) {
|
||||
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [ENV('DB_DATABASE')], env('DB_USERNAME'));
|
||||
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [config('database.connections.mysql.username')], config('database.connections.mysql.username'));
|
||||
} else {
|
||||
$variables['DB_USERNAME'] = $this->option('dbuser');
|
||||
}
|
||||
@ -122,25 +114,23 @@ class UpdateEnvironment extends Command
|
||||
}
|
||||
|
||||
if (is_null($this->option('url'))) {
|
||||
$variables['APP_URL'] = $this->ask('Panel URL (include http(s)://)', env('APP_URL'));
|
||||
$variables['APP_URL'] = $this->ask('Panel URL (include http(s)://)', config('app.url'));
|
||||
} else {
|
||||
$variables['APP_URL'] = $this->option('url');
|
||||
}
|
||||
|
||||
if (is_null($this->option('timezone'))) {
|
||||
$this->line('The timezone should match one of the supported timezones according to http://php.net/manual/en/timezones.php');
|
||||
$variables['APP_TIMEZONE'] = $this->anticipate('Panel Timezone', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL), env('APP_TIMEZONE'));
|
||||
$variables['APP_TIMEZONE'] = $this->anticipate('Panel Timezone', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL), config('app.timezone'));
|
||||
} else {
|
||||
$variables['APP_TIMEZONE'] = $this->option('timezone');
|
||||
}
|
||||
|
||||
$variables['APP_THEME'] = 'pterodactyl';
|
||||
$variables['CACHE_DRIVER'] = 'memcached';
|
||||
$variables['SESSION_DRIVER'] = 'database';
|
||||
|
||||
$bar = $this->output->createProgressBar(count($variables));
|
||||
|
||||
$this->line('Writing new environment configuration to file.');
|
||||
foreach ($variables as $key => $value) {
|
||||
$newValue = $key . '=' . $value;
|
||||
|
||||
@ -155,8 +145,7 @@ class UpdateEnvironment extends Command
|
||||
file_put_contents($file, $envContents);
|
||||
$bar->finish();
|
||||
|
||||
$this->line('Updating evironment configuration cache file.');
|
||||
$this->call('config:cache');
|
||||
echo "\n";
|
||||
$this->line("\n");
|
||||
}
|
||||
}
|
||||
|
@ -32,14 +32,6 @@ use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function getIndex(Request $request)
|
||||
{
|
||||
return view('admin.index');
|
||||
@ -55,8 +47,6 @@ class BaseController extends Controller
|
||||
$validator = Validator::make($request->all(), [
|
||||
'company' => 'required|between:1,256',
|
||||
'default_language' => 'required|alpha_dash|min:2|max:5',
|
||||
'email_from' => 'required|email',
|
||||
'email_sender_name' => 'required|between:1,256',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
@ -65,8 +55,6 @@ class BaseController extends Controller
|
||||
|
||||
Settings::set('company', $request->input('company'));
|
||||
Settings::set('default_language', $request->input('default_language'));
|
||||
Settings::set('email_from', $request->input('email_from'));
|
||||
Settings::set('email_sender_name', $request->input('email_sender_name'));
|
||||
|
||||
Alert::success('Settings have been successfully updated.')->flash();
|
||||
|
||||
|
@ -79,7 +79,7 @@ class ServerObserver
|
||||
{
|
||||
event(new Events\Server\Deleting($server));
|
||||
|
||||
$this->dispatch((new SuspendServer($server->id))->onQueue(env('QUEUE_HIGH', 'high')));
|
||||
$this->dispatch((new SuspendServer($server->id))->onQueue(config('pterodactyl.queues.high')));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,8 +94,8 @@ class ServerObserver
|
||||
|
||||
$this->dispatch(
|
||||
(new DeleteServer($server->id))
|
||||
->delay(Carbon::now()->addMinutes(env('APP_DELETE_MINUTES', 10)))
|
||||
->onQueue(env('QUEUE_STANDARD', 'standard'))
|
||||
->delay(Carbon::now()->addMinutes(config('pterodactyl.tasks.delete_server')))
|
||||
->onQueue(config('pterodactyl.queues.standard'))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ class VersionService
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::$versions = Cache::remember('versions', env('VERSION_CACHE_TIME', 60), function () {
|
||||
self::$versions = Cache::remember('versions', config('pterodactyl.cdn.cache'), function () {
|
||||
$client = new Client();
|
||||
|
||||
try {
|
||||
$response = $client->request('GET', env('VERSION_CHECK_URL', 'https://cdn.pterodactyl.io/releases/latest.json'));
|
||||
$response = $client->request('GET', config('pterodactyl.cdn.url'));
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
return json_decode($response->getBody());
|
||||
@ -52,7 +52,7 @@ class VersionService
|
||||
return (object) [
|
||||
'panel' => 'error',
|
||||
'daemon' => 'error',
|
||||
'discord' => 'https://pterodactyl.io',
|
||||
'discord' => 'https://pterodactyl.io/discord',
|
||||
];
|
||||
}
|
||||
});
|
||||
|
@ -46,12 +46,6 @@ return [
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => storage_path('database.sqlite'),
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
@ -65,27 +59,6 @@ return [
|
||||
'strict' => false,
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'schema' => 'public',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
@ -42,4 +42,41 @@ return [
|
||||
'connect_timeout' => env('GUZZLE_CONNECT_TIMEOUT', 3),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Names
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure the names of queues to be used in the database.
|
||||
*/
|
||||
'queues' => [
|
||||
'low' => env('QUEUE_LOW', 'low'),
|
||||
'standard' => env('QUEUE_STANDARD', 'standard'),
|
||||
'high' => env('QUEUE_HIGH', 'high'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Task Timers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The amount of time in minutes before performing certain actions on the system.
|
||||
*/
|
||||
'tasks' => [
|
||||
'clear_log' => env('PTERODACTYL_CLEAR_TASKLOG', 720),
|
||||
'delete_server' => env('PTERODACTYL_DELETE_MINUTES', 10),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CDN
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Information for the panel to use when contacting the CDN to confirm
|
||||
| if panel is up to date.
|
||||
*/
|
||||
'cdn' => [
|
||||
'cache' => 60,
|
||||
'url' => 'https://cdn.pterodactyl.io/releases/latest.json',
|
||||
],
|
||||
];
|
||||
|
@ -4,14 +4,9 @@ return [
|
||||
'enabled' => true,
|
||||
'themes_path' => realpath(base_path('resources/themes')),
|
||||
'asset_not_found' => 'LOG_ERROR',
|
||||
'active' => ENV('APP_THEME', 'default'),
|
||||
'active' => env('APP_THEME', 'pterodactyl'),
|
||||
|
||||
'themes' => [
|
||||
'default' => [
|
||||
'extends' => null,
|
||||
'views-path' => 'default',
|
||||
'asset-path' => 'themes/default',
|
||||
],
|
||||
'pterodactyl' => [
|
||||
'extends' => null,
|
||||
'views-path' => 'pterodactyl',
|
||||
|
@ -61,7 +61,7 @@
|
||||
<h3 class="box-title">Marked for Deletion</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p>This server is currently marked for deletion by the system <strong>{{ Carbon::parse($server->deleted_at)->addMinutes(env('APP_DELETE_MINUTES', 10))->diffForHumans() }}</strong>.</p>
|
||||
<p>This server is currently marked for deletion by the system <strong>{{ Carbon::parse($server->deleted_at)->addMinutes(config('pterodactyl.tasks.delete_server'))->diffForHumans() }}</strong>.</p>
|
||||
<p class="text-danger small">Deleting a server is an irreversible action. <strong>All server data</strong> (including files and users) will be removed from the system.</p>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
|
@ -69,23 +69,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">In order to modify your SMTP settings for sending mail you will need to edit the <code>.env</code> file in this project's root folder.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label class="control-label">Send Emails From:</label>
|
||||
<div>
|
||||
<input type="text" class="form-control" name="email_from" value="{{ old('email_from', Settings::get('email_from', env('MAIL_FROM', 'you@example.com'))) }}" />
|
||||
<p class="text-muted"><small>The email address that panel emails will be sent from. Note that some SMTP services require this to match for a given API key.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="control-label">Email Sender Name:</label>
|
||||
<div>
|
||||
<input type="text" class="form-control" name="email_sender_name" value="{{ old('email_sender_name', Settings::get('email_sender_name', env('MAIL_FROM_NAME', 'Pterodactyl Panel'))) }}" />
|
||||
<p class="text-muted"><small>The name that emails will appear to come from.</small></p>
|
||||
</div>
|
||||
<div class="alert alert-info">In order to modify your SMTP settings for sending mail you will need to run <code>php artisan pterodactyl:mail</code> in this project's root folder.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -76,7 +76,7 @@
|
||||
</td>
|
||||
<td data-identifier="size" class="hidden-xs">{{ $folder['size'] }}</td>
|
||||
<td data-identifier="modified" class="hidden-xs">
|
||||
<?php $carbon = Carbon::createFromTimestamp($folder['date'])->timezone(env('APP_TIMEZONE', 'America/New_York')); ?>
|
||||
<?php $carbon = Carbon::createFromTimestamp($folder['date'])->timezone(config('app.timezone')); ?>
|
||||
@if($carbon->diffInMinutes(Carbon::now()) > 60)
|
||||
{{ $carbon->format('m/d/y H:i:s') }}
|
||||
@elseif($carbon->diffInSeconds(Carbon::now()) < 5 || $carbon->isFuture())
|
||||
@ -153,7 +153,7 @@
|
||||
</td>
|
||||
<td data-identifier="size" class="hidden-xs">{{ $file['size'] }}</td>
|
||||
<td data-identifier="modified" class="hidden-xs">
|
||||
<?php $carbon = Carbon::createFromTimestamp($file['date'])->timezone(env('APP_TIMEZONE', 'America/New_York')); ?>
|
||||
<?php $carbon = Carbon::createFromTimestamp($file['date'])->timezone(config('app.timezone')); ?>
|
||||
@if($carbon->diffInMinutes(Carbon::now()) > 60)
|
||||
{{ $carbon->format('m/d/y H:i:s') }}
|
||||
@elseif($carbon->diffInSeconds(Carbon::now()) < 5 || $carbon->isFuture())
|
||||
|
Loading…
Reference in New Issue
Block a user