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; + } } /**