Skip to content

Commit 99aceac

Browse files
committed
Merge branch 'develop' of https://github.com/Pterodactyl/Panel into develop
2 parents 5331885 + ea71deb commit 99aceac

File tree

76 files changed

+2351
-1132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2351
-1132
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
2828
* Server creation page now only asks for a node to deploy to, rather than requiring a location and then a node.
2929
* Database passwords are now hidden by default and will only show if clicked on. In addition, database view in ACP now indicates that passwords must be viewed on the front-end.
3030
* Localhost cannot be used as a connection address in the environment configuration script. `127.0.0.1` is allowed.
31+
* Application locale can now be quickly set using an environment variable `APP_LOCALE` rather than having to edit core files.
3132

3233
### Fixed
3334
* Unable to change the daemon secret for a server via the Admin CP.

app/Contracts/Repository/ScheduleRepositoryInterface.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@
99

1010
namespace Pterodactyl\Contracts\Repository;
1111

12+
use Pterodactyl\Models\Schedule;
13+
use Illuminate\Support\Collection;
14+
1215
interface ScheduleRepositoryInterface extends RepositoryInterface
1316
{
1417
/**
1518
* Return all of the schedules for a given server.
1619
*
1720
* @param int $server
18-
* @return \Illuminate\Database\Eloquent\Collection
21+
* @return \Illuminate\Support\Collection
1922
*/
20-
public function getServerSchedules($server);
23+
public function findServerSchedules(int $server): Collection;
2124

2225
/**
2326
* Return a schedule model with all of the associated tasks as a relationship.
2427
*
2528
* @param int $schedule
26-
* @return \Illuminate\Support\Collection
29+
* @return \Pterodactyl\Models\Schedule
30+
*
31+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
2732
*/
28-
public function getScheduleWithTasks($schedule);
33+
public function getScheduleWithTasks(int $schedule): Schedule;
2934

3035
/**
3136
* Return all of the schedules that should be processed.

app/Contracts/Repository/SubuserRepositoryInterface.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository;
114

5+
use Pterodactyl\Models\Subuser;
6+
127
interface SubuserRepositoryInterface extends RepositoryInterface
138
{
149
/**
1510
* Return a subuser with the associated server relationship.
1611
*
17-
* @param int $id
12+
* @param \Pterodactyl\Models\Subuser $subuser
13+
* @param bool $refresh
1814
* @return \Pterodactyl\Models\Subuser
19-
*
20-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
2115
*/
22-
public function getWithServer($id);
16+
public function getWithServer(Subuser $subuser, bool $refresh = false): Subuser;
2317

2418
/**
2519
* Return a subuser with the associated permissions relationship.
2620
*
27-
* @param int $id
28-
* @return \Illuminate\Database\Eloquent\Collection
29-
*
30-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
21+
* @param \Pterodactyl\Models\Subuser $subuser
22+
* @param bool $refresh
23+
* @return \Pterodactyl\Models\Subuser
3124
*/
32-
public function getWithPermissions($id);
25+
public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser;
3326

3427
/**
3528
* Return a subuser and associated permissions given a user_id and server_id.

app/Http/Controllers/Server/ConsoleController.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Http\Controllers\Server;
114

12-
use Illuminate\Contracts\Session\Session;
5+
use Illuminate\View\View;
6+
use Illuminate\Http\Request;
137
use Pterodactyl\Http\Controllers\Controller;
148
use Pterodactyl\Traits\Controllers\JavascriptInjection;
159
use Illuminate\Contracts\Config\Repository as ConfigRepository;
@@ -23,35 +17,27 @@ class ConsoleController extends Controller
2317
*/
2418
protected $config;
2519

26-
/**
27-
* @var \Illuminate\Contracts\Session\Session
28-
*/
29-
protected $session;
30-
3120
/**
3221
* ConsoleController constructor.
3322
*
3423
* @param \Illuminate\Contracts\Config\Repository $config
35-
* @param \Illuminate\Contracts\Session\Session $session
3624
*/
37-
public function __construct(
38-
ConfigRepository $config,
39-
Session $session
40-
) {
25+
public function __construct(ConfigRepository $config)
26+
{
4127
$this->config = $config;
42-
$this->session = $session;
4328
}
4429

4530
/**
4631
* Render server index page with the console and power options.
4732
*
48-
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
33+
* @param \Illuminate\Http\Request $request
34+
* @return \Illuminate\View\View
4935
*/
50-
public function index()
36+
public function index(Request $request): View
5137
{
52-
$server = $this->session->get('server_data.model');
38+
$server = $request->attributes->get('server');
5339

54-
$this->injectJavascript([
40+
$this->setRequest($request)->injectJavascript([
5541
'meta' => [
5642
'saveFile' => route('server.files.save', $server->uuidShort),
5743
'csrfToken' => csrf_token(),
@@ -68,11 +54,12 @@ public function index()
6854
/**
6955
* Render a stand-alone console in the browser.
7056
*
71-
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
57+
* @param \Illuminate\Http\Request $request
58+
* @return \Illuminate\View\View
7259
*/
73-
public function console()
60+
public function console(Request $request): View
7461
{
75-
$this->injectJavascript(['config' => [
62+
$this->setRequest($request)->injectJavascript(['config' => [
7663
'console_count' => $this->config->get('pterodactyl.console.count'),
7764
'console_freq' => $this->config->get('pterodactyl.console.frequency'),
7865
]]);

app/Http/Controllers/Server/Files/DownloadController.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
namespace Pterodactyl\Http\Controllers\Server\Files;
1111

12+
use Illuminate\Http\Request;
1213
use Illuminate\Cache\Repository;
13-
use Illuminate\Contracts\Session\Session;
14+
use Illuminate\Http\RedirectResponse;
1415
use Pterodactyl\Http\Controllers\Controller;
1516

1617
class DownloadController extends Controller
@@ -20,42 +21,35 @@ class DownloadController extends Controller
2021
*/
2122
protected $cache;
2223

23-
/**
24-
* @var \Illuminate\Contracts\Session\Session
25-
*/
26-
protected $session;
27-
2824
/**
2925
* DownloadController constructor.
3026
*
31-
* @param \Illuminate\Cache\Repository $cache
32-
* @param \Illuminate\Contracts\Session\Session $session
27+
* @param \Illuminate\Cache\Repository $cache
3328
*/
34-
public function __construct(Repository $cache, Session $session)
29+
public function __construct(Repository $cache)
3530
{
3631
$this->cache = $cache;
37-
$this->session = $session;
3832
}
3933

4034
/**
4135
* Setup a unique download link for a user to download a file from.
4236
*
43-
* @param string $uuid
44-
* @param string $file
45-
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
37+
* @param \Illuminate\Http\Request $request
38+
* @param string $uuid
39+
* @param string $file
40+
* @return \Illuminate\Http\RedirectResponse
4641
*
4742
* @throws \Illuminate\Auth\Access\AuthorizationException
4843
*/
49-
public function index($uuid, $file)
44+
public function index(Request $request, string $uuid, string $file): RedirectResponse
5045
{
51-
$server = $this->session->get('server_data.model');
46+
$server = $request->attributes->get('server');
5247
$this->authorize('download-files', $server);
5348

5449
$token = str_random(40);
50+
$node = $server->getRelation('node');
5551
$this->cache->tags(['Server:Downloads'])->put($token, ['server' => $server->uuid, 'path' => $file], 5);
5652

57-
return redirect(sprintf(
58-
'%s://%s:%s/v1/server/file/download/%s', $server->node->scheme, $server->node->fqdn, $server->node->daemonListen, $token
59-
));
53+
return redirect(sprintf('%s://%s:%s/v1/server/file/download/%s', $node->scheme, $node->fqdn, $node->daemonListen, $token));
6054
}
6155
}

app/Http/Controllers/Server/Files/FileActionsController.php

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99

1010
namespace Pterodactyl\Http\Controllers\Server\Files;
1111

12-
use Illuminate\Log\Writer;
12+
use Illuminate\View\View;
1313
use Illuminate\Http\Request;
14-
use Illuminate\Contracts\Session\Session;
1514
use GuzzleHttp\Exception\RequestException;
16-
use Pterodactyl\Exceptions\DisplayException;
1715
use Pterodactyl\Http\Controllers\Controller;
1816
use Pterodactyl\Traits\Controllers\JavascriptInjection;
1917
use Pterodactyl\Http\Requests\Server\UpdateFileContentsFormRequest;
2018
use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface;
19+
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
2120

2221
class FileActionsController extends Controller
2322
{
@@ -26,30 +25,16 @@ class FileActionsController extends Controller
2625
/**
2726
* @var \Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface
2827
*/
29-
protected $fileRepository;
30-
31-
/**
32-
* @var \Illuminate\Contracts\Session\Session
33-
*/
34-
protected $session;
35-
36-
/**
37-
* @var \Illuminate\Log\Writer
38-
*/
39-
protected $writer;
28+
protected $repository;
4029

4130
/**
4231
* FileActionsController constructor.
4332
*
44-
* @param \Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface $fileRepository
45-
* @param \Illuminate\Contracts\Session\Session $session
46-
* @param \Illuminate\Log\Writer $writer
33+
* @param \Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface $repository
4734
*/
48-
public function __construct(FileRepositoryInterface $fileRepository, Session $session, Writer $writer)
35+
public function __construct(FileRepositoryInterface $repository)
4936
{
50-
$this->fileRepository = $fileRepository;
51-
$this->session = $session;
52-
$this->writer = $writer;
37+
$this->repository = $repository;
5338
}
5439

5540
/**
@@ -60,12 +45,12 @@ public function __construct(FileRepositoryInterface $fileRepository, Session $se
6045
*
6146
* @throws \Illuminate\Auth\Access\AuthorizationException
6247
*/
63-
public function index(Request $request)
48+
public function index(Request $request): View
6449
{
65-
$server = $this->session->get('server_data.model');
50+
$server = $request->attributes->get('server');
6651
$this->authorize('list-files', $server);
6752

68-
$this->injectJavascript([
53+
$this->setRequest($request)->injectJavascript([
6954
'meta' => [
7055
'directoryList' => route('server.files.directory-list', $server->uuidShort),
7156
'csrftoken' => csrf_token(),
@@ -92,10 +77,10 @@ public function index(Request $request)
9277
*
9378
* @throws \Illuminate\Auth\Access\AuthorizationException
9479
*/
95-
public function create(Request $request)
80+
public function create(Request $request): View
9681
{
97-
$this->authorize('create-files', $this->session->get('server_data.model'));
98-
$this->injectJavascript();
82+
$this->authorize('create-files', $request->attributes->get('server'));
83+
$this->setRequest($request)->injectJavascript();
9984

10085
return view('server.files.add', [
10186
'directory' => (in_array($request->get('dir'), [null, '/', ''])) ? '' : trim($request->get('dir'), '/') . '/',
@@ -114,31 +99,24 @@ public function create(Request $request)
11499
* @throws \Pterodactyl\Exceptions\DisplayException
115100
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
116101
*/
117-
public function update(UpdateFileContentsFormRequest $request, $uuid, $file)
102+
public function update(UpdateFileContentsFormRequest $request, string $uuid, string $file): View
118103
{
119-
$server = $this->session->get('server_data.model');
120-
$this->authorize('edit-files', $server);
104+
$server = $request->attributes->get('server');
121105

122106
$dirname = pathinfo($file, PATHINFO_DIRNAME);
123107
try {
124-
$content = $this->fileRepository->setNode($server->node_id)
125-
->setAccessServer($server->uuid)
126-
->setAccessToken($this->session->get('server_data.token'))
108+
$content = $this->repository->setNode($server->node_id)->setAccessServer($server->uuid)
109+
->setAccessToken($request->attributes->get('server_token'))
127110
->getContent($file);
128111
} catch (RequestException $exception) {
129-
$response = $exception->getResponse();
130-
$this->writer->warning($exception);
131-
132-
throw new DisplayException(trans('exceptions.daemon_connection_failed', [
133-
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
134-
]));
112+
throw new DaemonConnectionException($exception);
135113
}
136114

137-
$this->injectJavascript(['stat' => $request->getStats()]);
115+
$this->setRequest($request)->injectJavascript(['stat' => $request->attributes->get('file_stats')]);
138116

139117
return view('server.files.edit', [
140118
'file' => $file,
141-
'stat' => $request->getStats(),
119+
'stat' => $request->attributes->get('file_stats'),
142120
'contents' => $content,
143121
'directory' => (in_array($dirname, ['.', './', '/'])) ? '/' : trim($dirname, '/') . '/',
144122
]);

0 commit comments

Comments
 (0)