From 77198b48df26d0bc3ec73ab149b6bb9340c9b40a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 6 Oct 2016 17:27:30 -0400 Subject: [PATCH] Support folders within folders for JS path --- .gitignore | 3 +++ .../Controllers/Server/ServerController.php | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8a1adc7e2..9dfd2bc12 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ composer.lock Homestead.yaml Vagrantfile Vagrantfile + +node_modules +.babelrc \ No newline at end of file diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index 1fdedbf7d..810223303 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -38,6 +38,8 @@ use Pterodactyl\Repositories\ServerRepository; use Pterodactyl\Http\Controllers\Controller; use Illuminate\Http\Request; +use InvalidArgumentException; + class ServerController extends Controller { @@ -54,10 +56,19 @@ class ServerController extends Controller public function getJavascript(Request $request, $uuid, $folder, $file) { $server = Models\Server::getByUUID($uuid); - return response()->view('server.js.' . $folder . '.' . basename($file, '.js'), [ - 'server' => $server, - 'node' => Models\Node::find($server->node) - ])->header('Content-Type', 'application/javascript'); + + $info = pathinfo($file); + $routeFile = str_replace('/', '.', $info['dirname']) . '.' . $info['filename']; + try { + return response()->view('server.js.' . $folder . '.' . $routeFile, [ + 'server' => $server, + 'node' => Models\Node::find($server->node) + ])->header('Content-Type', 'application/javascript'); + } catch (InvalidArgumentException $ex) { + return abort(404); + } catch (\Exception $ex) { + throw $ex; + } } /**