Skip to content

Commit 4f16509

Browse files
committed
Use env() properly throughout panel to avoid cache issues.
1 parent 9a581ef commit 4f16509

File tree

14 files changed

+68
-100
lines changed

14 files changed

+68
-100
lines changed

app/Console/Commands/AddNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function handle()
8383
$selectedLocation = $this->option('location');
8484
}
8585

86-
$this->data['location'] = $locations->where('short', $selectedLocation)->first()->id;
86+
$this->data['location_id'] = $locations->where('short', $selectedLocation)->first()->id;
8787

8888
if (is_null($this->option('fqdn'))) {
8989
$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.');

app/Console/Commands/ClearTasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct()
6464
*/
6565
public function handle()
6666
{
67-
$entries = Models\TaskLog::where('run_time', '<=', Carbon::now()->subHours(env('APP_CLEAR_TASKLOG', 720))->toAtomString())->get();
67+
$entries = Models\TaskLog::where('run_time', '<=', Carbon::now()->subHours(config('pterodactyl.tasks.clear_log'))->toAtomString())->get();
6868

6969
$this->info(sprintf('Preparing to delete %d old task log entries.', count($entries)));
7070
$bar = $this->output->createProgressBar(count($entries));

app/Console/Commands/RunTasks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function handle()
7272

7373
foreach ($tasks as &$task) {
7474
$bar->advance();
75-
$this->dispatch((new SendScheduledTask(Models\Server::findOrFail($task->server), $task))->onQueue(env('QUEUE_LOW', 'low')));
75+
$this->dispatch((new SendScheduledTask(Models\Server::findOrFail($task->server), $task))->onQueue(config('pterodactyl.queues.low')));
7676
}
7777

7878
$bar->finish();

app/Console/Commands/UpdateEmailSettings.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function handle()
100100
'Postmark Transactional Email Service',
101101
],
102102
]);
103+
103104
$variables['MAIL_DRIVER'] = is_null($this->option('driver')) ? $this->choice('Which email driver would you like to use?', [
104105
'smtp',
105106
'mail',
@@ -110,9 +111,9 @@ public function handle()
110111

111112
switch ($variables['MAIL_DRIVER']) {
112113
case 'smtp':
113-
$variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)') : $this->option('host');
114-
$variables['MAIL_PORT'] = is_null($this->option('port')) ? $this->anticipate('SMTP Host Port (e.g 587)', ['587']) : $this->option('port');
115-
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username') : $this->option('password');
114+
$variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)', config('mail.host')) : $this->option('host');
115+
$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');
116+
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username', config('mail.username')) : $this->option('password');
116117
$variables['MAIL_PASSWORD'] = is_null($this->option('password')) ? $this->secret('SMTP Password') : $this->option('password');
117118
break;
118119
case 'mail':
@@ -128,7 +129,7 @@ public function handle()
128129
$variables['MAIL_DRIVER'] = 'smtp';
129130
$variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
130131
$variables['MAIL_PORT'] = 587;
131-
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token') : $this->option('username');
132+
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token', config('mail.username')) : $this->option('username');
132133
$variables['MAIL_PASSWORD'] = $variables['MAIL_USERNAME'];
133134
break;
134135
default:
@@ -137,8 +138,9 @@ public function handle()
137138
break;
138139
}
139140

140-
$variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from') : $this->option('email');
141-
$variables['MAIL_FROM_NAME'] = is_null($this->option('from-name')) ? $this->ask('Name emails should appear to be from') : $this->option('from-name');
141+
$variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from', config('mail.from.address')) : $this->option('email');
142+
$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');
143+
$variables['MAIL_FROM_NAME'] = '"' . $variables['MAIL_FROM_NAME'] . '"';
142144
$variables['MAIL_ENCRYPTION'] = 'tls';
143145

144146
$bar = $this->output->createProgressBar(count($variables));

app/Console/Commands/UpdateEnvironment.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,31 @@ public function handle()
7777
$envContents = file_get_contents($file);
7878

7979
$this->info('Simply leave blank and press enter to fields that you do not wish to update.');
80-
if (! env('SERVICE_AUTHOR', false)) {
80+
if (is_null(config('pterodactyl.service.author', null))) {
8181
$this->info('No service author set, setting one now.');
82-
$variables['SERVICE_AUTHOR'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
83-
}
84-
85-
if (! env('QUEUE_STANDARD', false) || ! env('QUEUE_DRIVER', false)) {
86-
$this->info('Setting default queue settings.');
87-
$variables['QUEUE_DRIVER'] = env('QUEUE_DRIVER', 'database');
88-
$variables['QUEUE_HIGH'] = env('QUEUE_HIGH', 'high');
89-
$variables['QUEUE_STANDARD'] = env('QUEUE_STANDARD', 'standard');
90-
$variables['QUEUE_LOW'] = env('QUEUE_LOW', 'low');
82+
$variables['SERVICE_AUTHOR'] = (string) Uuid::generate(4);
9183
}
9284

9385
if (is_null($this->option('dbhost'))) {
94-
$variables['DB_HOST'] = $this->anticipate('Database Host', ['localhost', '127.0.0.1', env('DB_HOST')], env('DB_HOST'));
86+
$variables['DB_HOST'] = $this->anticipate('Database Host', ['localhost', '127.0.0.1', config('database.connections.mysql.host')], config('database.connections.mysql.host'));
9587
} else {
9688
$variables['DB_HOST'] = $this->option('dbhost');
9789
}
9890

9991
if (is_null($this->option('dbport'))) {
100-
$variables['DB_PORT'] = $this->anticipate('Database Port', [3306, env('DB_PORT')], env('DB_PORT'));
92+
$variables['DB_PORT'] = $this->anticipate('Database Port', [3306, config('database.connections.mysql.port')], config('database.connections.mysql.port'));
10193
} else {
10294
$variables['DB_PORT'] = $this->option('dbport');
10395
}
10496

10597
if (is_null($this->option('dbname'))) {
106-
$variables['DB_DATABASE'] = $this->anticipate('Database Name', ['pterodactyl', 'homestead', ENV('DB_DATABASE')], env('DB_DATABASE'));
98+
$variables['DB_DATABASE'] = $this->anticipate('Database Name', ['pterodactyl', 'homestead', config('database.connections.mysql.database')], config('database.connections.mysql.database'));
10799
} else {
108100
$variables['DB_DATABASE'] = $this->option('dbname');
109101
}
110102

111103
if (is_null($this->option('dbuser'))) {
112-
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [ENV('DB_DATABASE')], env('DB_USERNAME'));
104+
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [config('database.connections.mysql.username')], config('database.connections.mysql.username'));
113105
} else {
114106
$variables['DB_USERNAME'] = $this->option('dbuser');
115107
}
@@ -122,25 +114,23 @@ public function handle()
122114
}
123115

124116
if (is_null($this->option('url'))) {
125-
$variables['APP_URL'] = $this->ask('Panel URL (include http(s)://)', env('APP_URL'));
117+
$variables['APP_URL'] = $this->ask('Panel URL (include http(s)://)', config('app.url'));
126118
} else {
127119
$variables['APP_URL'] = $this->option('url');
128120
}
129121

130122
if (is_null($this->option('timezone'))) {
131123
$this->line('The timezone should match one of the supported timezones according to http://php.net/manual/en/timezones.php');
132-
$variables['APP_TIMEZONE'] = $this->anticipate('Panel Timezone', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL), env('APP_TIMEZONE'));
124+
$variables['APP_TIMEZONE'] = $this->anticipate('Panel Timezone', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL), config('app.timezone'));
133125
} else {
134126
$variables['APP_TIMEZONE'] = $this->option('timezone');
135127
}
136128

137-
$variables['APP_THEME'] = 'pterodactyl';
138129
$variables['CACHE_DRIVER'] = 'memcached';
139130
$variables['SESSION_DRIVER'] = 'database';
140131

141132
$bar = $this->output->createProgressBar(count($variables));
142133

143-
$this->line('Writing new environment configuration to file.');
144134
foreach ($variables as $key => $value) {
145135
$newValue = $key . '=' . $value;
146136

@@ -155,8 +145,7 @@ public function handle()
155145
file_put_contents($file, $envContents);
156146
$bar->finish();
157147

158-
$this->line('Updating evironment configuration cache file.');
159148
$this->call('config:cache');
160-
echo "\n";
149+
$this->line("\n");
161150
}
162151
}

app/Http/Controllers/Admin/BaseController.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@
3232

3333
class BaseController extends Controller
3434
{
35-
/**
36-
* Controller Constructor.
37-
*/
38-
public function __construct()
39-
{
40-
//
41-
}
42-
4335
public function getIndex(Request $request)
4436
{
4537
return view('admin.index');
@@ -55,8 +47,6 @@ public function postSettings(Request $request)
5547
$validator = Validator::make($request->all(), [
5648
'company' => 'required|between:1,256',
5749
'default_language' => 'required|alpha_dash|min:2|max:5',
58-
'email_from' => 'required|email',
59-
'email_sender_name' => 'required|between:1,256',
6050
]);
6151

6252
if ($validator->fails()) {
@@ -65,8 +55,6 @@ public function postSettings(Request $request)
6555

6656
Settings::set('company', $request->input('company'));
6757
Settings::set('default_language', $request->input('default_language'));
68-
Settings::set('email_from', $request->input('email_from'));
69-
Settings::set('email_sender_name', $request->input('email_sender_name'));
7058

7159
Alert::success('Settings have been successfully updated.')->flash();
7260

app/Observers/ServerObserver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function deleting(Server $server)
7979
{
8080
event(new Events\Server\Deleting($server));
8181

82-
$this->dispatch((new SuspendServer($server->id))->onQueue(env('QUEUE_HIGH', 'high')));
82+
$this->dispatch((new SuspendServer($server->id))->onQueue(config('pterodactyl.queues.high')));
8383
}
8484

8585
/**
@@ -94,8 +94,8 @@ public function deleted(Server $server)
9494

9595
$this->dispatch(
9696
(new DeleteServer($server->id))
97-
->delay(Carbon::now()->addMinutes(env('APP_DELETE_MINUTES', 10)))
98-
->onQueue(env('QUEUE_STANDARD', 'standard'))
97+
->delay(Carbon::now()->addMinutes(config('pterodactyl.tasks.delete_server')))
98+
->onQueue(config('pterodactyl.queues.standard'))
9999
);
100100
}
101101

app/Services/VersionService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class VersionService
3636
*/
3737
public function __construct()
3838
{
39-
self::$versions = Cache::remember('versions', env('VERSION_CACHE_TIME', 60), function () {
39+
self::$versions = Cache::remember('versions', config('pterodactyl.cdn.cache'), function () {
4040
$client = new Client();
4141

4242
try {
43-
$response = $client->request('GET', env('VERSION_CHECK_URL', 'https://cdn.pterodactyl.io/releases/latest.json'));
43+
$response = $client->request('GET', config('pterodactyl.cdn.url'));
4444

4545
if ($response->getStatusCode() === 200) {
4646
return json_decode($response->getBody());
@@ -52,7 +52,7 @@ public function __construct()
5252
return (object) [
5353
'panel' => 'error',
5454
'daemon' => 'error',
55-
'discord' => 'https://pterodactyl.io',
55+
'discord' => 'https://pterodactyl.io/discord',
5656
];
5757
}
5858
});

config/database.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@
4646

4747
'connections' => [
4848

49-
'sqlite' => [
50-
'driver' => 'sqlite',
51-
'database' => storage_path('database.sqlite'),
52-
'prefix' => '',
53-
],
54-
5549
'mysql' => [
5650
'driver' => 'mysql',
5751
'host' => env('DB_HOST', 'localhost'),
@@ -65,27 +59,6 @@
6559
'strict' => false,
6660
],
6761

68-
'pgsql' => [
69-
'driver' => 'pgsql',
70-
'host' => env('DB_HOST', 'localhost'),
71-
'database' => env('DB_DATABASE', 'forge'),
72-
'username' => env('DB_USERNAME', 'forge'),
73-
'password' => env('DB_PASSWORD', ''),
74-
'charset' => 'utf8',
75-
'prefix' => '',
76-
'schema' => 'public',
77-
],
78-
79-
'sqlsrv' => [
80-
'driver' => 'sqlsrv',
81-
'host' => env('DB_HOST', 'localhost'),
82-
'database' => env('DB_DATABASE', 'forge'),
83-
'username' => env('DB_USERNAME', 'forge'),
84-
'password' => env('DB_PASSWORD', ''),
85-
'charset' => 'utf8',
86-
'prefix' => '',
87-
],
88-
8962
],
9063

9164
/*

config/pterodactyl.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,41 @@
4242
'connect_timeout' => env('GUZZLE_CONNECT_TIMEOUT', 3),
4343
],
4444

45+
/*
46+
|--------------------------------------------------------------------------
47+
| Queue Names
48+
|--------------------------------------------------------------------------
49+
|
50+
| Configure the names of queues to be used in the database.
51+
*/
52+
'queues' => [
53+
'low' => env('QUEUE_LOW', 'low'),
54+
'standard' => env('QUEUE_STANDARD', 'standard'),
55+
'high' => env('QUEUE_HIGH', 'high'),
56+
],
57+
58+
/*
59+
|--------------------------------------------------------------------------
60+
| Task Timers
61+
|--------------------------------------------------------------------------
62+
|
63+
| The amount of time in minutes before performing certain actions on the system.
64+
*/
65+
'tasks' => [
66+
'clear_log' => env('PTERODACTYL_CLEAR_TASKLOG', 720),
67+
'delete_server' => env('PTERODACTYL_DELETE_MINUTES', 10),
68+
],
69+
70+
/*
71+
|--------------------------------------------------------------------------
72+
| CDN
73+
|--------------------------------------------------------------------------
74+
|
75+
| Information for the panel to use when contacting the CDN to confirm
76+
| if panel is up to date.
77+
*/
78+
'cdn' => [
79+
'cache' => 60,
80+
'url' => 'https://cdn.pterodactyl.io/releases/latest.json',
81+
],
4582
];

0 commit comments

Comments
 (0)