From aa6e733ba50fcfdabb7051d55f33f729852b53c1 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 3 Jan 2017 16:47:33 -0500 Subject: [PATCH] Switch filemanager and EULA check to use pure Javascript methods Removes the need for the javascript to be parsed by Blade template engine by using a defined javascript variable with the values that are necessary for checking everything and passing the correct values. This does make it so that if a user does not have permission to do something they could theoretically make the option show up in the context menu, however when they click it, it will simply return an error by the daemon. --- .../Controllers/Server/ServerController.php | 56 ++- app/Http/Routes/ServerRoutes.php | 9 - composer.json | 3 +- config/app.php | 2 + config/javascript.php | 32 ++ public/js/files/actions.js | 394 +++++++++++++++++ .../js/files/contextmenu.js | 127 +++--- .../js/files/index.js | 4 +- .../js/plugins/minecraft/eula.js | 42 +- resources/views/server/files/index.blade.php | 6 +- resources/views/server/files/list.blade.php | 4 +- resources/views/server/index.blade.php | 8 +- .../server/js/filemanager/actions.blade.php | 408 ------------------ 13 files changed, 567 insertions(+), 528 deletions(-) create mode 100644 config/javascript.php create mode 100644 public/js/files/actions.js rename resources/views/server/js/filemanager/contextmenu.blade.php => public/js/files/contextmenu.js (64%) rename resources/views/server/js/filemanager/index.blade.php => public/js/files/index.js (95%) rename resources/views/server/js/minecraft/eula.blade.php => public/js/plugins/minecraft/eula.js (55%) delete mode 100644 resources/views/server/js/filemanager/actions.blade.php diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index ed051b8e9..dfedd0057 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -28,6 +28,7 @@ use DB; use Log; use Uuid; use Alert; +use Javascript; use Pterodactyl\Models; use Illuminate\Http\Request; use InvalidArgumentException; @@ -49,24 +50,6 @@ class ServerController extends Controller // } - public function getJavascript(Request $request, $uuid, $folder, $file) - { - $server = Models\Server::getByUUID($uuid); - - $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; - } - } - /** * Renders server index page for specified server. * @@ -77,6 +60,13 @@ class ServerController extends Controller { $server = Models\Server::getByUUID($request->route()->server); + Javascript::put([ + 'meta' => [ + 'saveFile' => route('server.files.save', $server->uuidShort), + 'csrfToken' => csrf_token(), + ], + ]); + return view('server.index', [ 'server' => $server, 'allocations' => Models\Allocation::where('assigned_to', $server->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(), @@ -90,14 +80,34 @@ class ServerController extends Controller * @param Request $request * @return \Illuminate\Contracts\View\View */ - public function getFiles(Request $request) + public function getFiles(Request $request, $uuid) { - $server = Models\Server::getByUUID($request->route()->server); + $server = Models\Server::getByUUID($uuid); $this->authorize('list-files', $server); + $node = Models\Node::find($server->node); + + Javascript::put([ + 'server' => collect($server->makeVisible('daemonSecret'))->only('uuid', 'uuidShort', 'daemonSecret'), + 'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'), + 'meta' => [ + 'directoryList' => route('server.files.directory-list', $server->uuidShort), + 'csrftoken' => csrf_token(), + ], + 'permissions' => [ + 'moveFiles' => $request->user()->can('move-files', $server), + 'copyFiles' => $request->user()->can('copy-files', $server), + 'compressFiles' => $request->user()->can('compress-files', $server), + 'decompressFiles' => $request->user()->can('decompress-files', $server), + 'createFiles' => $request->user()->can('create-files', $server), + 'downloadFiles' => $request->user()->can('download-files', $server), + 'deleteFiles' => $request->user()->can('delete-files', $server), + ], + ]); + return view('server.files.index', [ 'server' => $server, - 'node' => Models\Node::find($server->node), + 'node' => $node, ]); } @@ -107,9 +117,9 @@ class ServerController extends Controller * @param Request $request * @return \Illuminate\Contracts\View\View */ - public function getAddFile(Request $request) + public function getAddFile(Request $request, $uuid) { - $server = Models\Server::getByUUID($request->route()->server); + $server = Models\Server::getByUUID($uuid); $this->authorize('add-files', $server); return view('server.files.add', [ diff --git a/app/Http/Routes/ServerRoutes.php b/app/Http/Routes/ServerRoutes.php index 49c58754a..061652761 100644 --- a/app/Http/Routes/ServerRoutes.php +++ b/app/Http/Routes/ServerRoutes.php @@ -166,15 +166,6 @@ class ServerRoutes 'uses' => 'Server\AjaxController@postResetDatabasePassword', ]); }); - - // Assorted AJAX Routes - $router->group(['prefix' => 'js'], function ($server) use ($router) { - // Returns Server Status - $router->get('{folder}/{file}', [ - 'as' => 'server.js', - 'uses' => 'Server\ServerController@getJavascript', - ])->where('file', '.*'); - }); }); } } diff --git a/composer.json b/composer.json index 3569e3d1b..b8cc9fd2d 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "mtdowling/cron-expression": "1.1.0", "dingo/api": "1.0.0-beta6", "aws/aws-sdk-php": "3.19.20", - "predis/predis": "1.1.1" + "predis/predis": "1.1.1", + "laracasts/utilities": "^2.1" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/config/app.php b/config/app.php index a3c3ff532..8fbce1528 100644 --- a/config/app.php +++ b/config/app.php @@ -158,6 +158,7 @@ return [ igaster\laravelTheme\themeServiceProvider::class, Prologue\Alerts\AlertsServiceProvider::class, Krucas\Settings\Providers\SettingsServiceProvider::class, + Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class, ], @@ -198,6 +199,7 @@ return [ 'Hash' => Illuminate\Support\Facades\Hash::class, 'Input' => Illuminate\Support\Facades\Input::class, 'Inspiring' => Illuminate\Foundation\Inspiring::class, + 'Javascript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, diff --git a/config/javascript.php b/config/javascript.php new file mode 100644 index 000000000..72c47f27f --- /dev/null +++ b/config/javascript.php @@ -0,0 +1,32 @@ + [ + 'layouts.master' + ], + + /* + |-------------------------------------------------------------------------- + | JavaScript Namespace + |-------------------------------------------------------------------------- + | + | By default, we'll add variables to the global window object. However, + | it's recommended that you change this to some namespace - anything. + | That way, you can access vars, like "SomeNamespace.someVariable." + | + */ + 'js_namespace' => 'Pterodactyl' + +]; diff --git a/public/js/files/actions.js b/public/js/files/actions.js new file mode 100644 index 000000000..9ff978539 --- /dev/null +++ b/public/js/files/actions.js @@ -0,0 +1,394 @@ +"use strict"; + +// Copyright (c) 2015 - 2016 Dane Everitt +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +class ActionsClass { + constructor(element, menu) { + this.element = element; + this.menu = menu; + } + + destroy() { + this.element = undefined; + } + + folder() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const currentName = decodeURIComponent(nameBlock.attr('data-name')); + const currentPath = decodeURIComponent(nameBlock.data('path')); + + let inputValue = `${currentPath}${currentName}/`; + if ($(this.element).data('type') === 'file') { + inputValue = currentPath; + } + swal({ + type: 'input', + title: 'Create Folder', + text: 'Please enter the path and folder name below.', + showCancelButton: true, + showConfirmButton: true, + closeOnConfirm: false, + showLoaderOnConfirm: true, + inputValue: inputValue + }, (val) => { + $.ajax({ + type: 'POST', + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + }, + contentType: 'application/json; charset=utf-8', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/folder`, + timeout: 10000, + data: JSON.stringify({ + path: val, + }), + }).done(data => { + swal.close(); + Files.list(); + }).fail(jqXHR => { + console.error(jqXHR); + var error = 'An error occured while trying to process this request.'; + if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') { + error = jqXHR.responseJSON.error; + } + swal({ + type: 'error', + title: '', + text: error, + }); + }); + }); + } + + move() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const currentName = decodeURIComponent(nameBlock.attr('data-name')); + const currentPath = decodeURIComponent(nameBlock.data('path')); + + swal({ + type: 'input', + title: 'Move File', + text: 'Please enter the new path for the file below.', + showCancelButton: true, + showConfirmButton: true, + closeOnConfirm: false, + showLoaderOnConfirm: true, + inputValue: `${currentPath}${currentName}`, + }, (val) => { + $.ajax({ + type: 'POST', + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + }, + contentType: 'application/json; charset=utf-8', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/move`, + timeout: 10000, + data: JSON.stringify({ + from: `${currentPath}${currentName}`, + to: `${val}`, + }), + }).done(data => { + nameBlock.parent().addClass('warning').delay(200).fadeOut(); + swal.close(); + }).fail(jqXHR => { + console.error(jqXHR); + var error = 'An error occured while trying to process this request.'; + if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') { + error = jqXHR.responseJSON.error; + } + swal({ + type: 'error', + title: '', + text: error, + }); + }); + }); + + } + + rename() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const currentLink = nameBlock.find('a'); + const currentName = decodeURIComponent(nameBlock.attr('data-name')); + const attachEditor = ` + + + `; + + nameBlock.html(attachEditor); + const inputField = nameBlock.find('input'); + const inputLoader = nameBlock.find('.input-loader'); + + inputField.focus(); + inputField.on('blur keydown', e => { + // Save Field + if ( + (e.type === 'keydown' && e.which === 27) + || e.type === 'blur' + || (e.type === 'keydown' && e.which === 13 && currentName === inputField.val()) + ) { + if (!_.isEmpty(currentLink)) { + nameBlock.html(currentLink); + } else { + nameBlock.html(currentName); + } + inputField.remove(); + ContextMenu.unbind().run(); + return; + } + + if (e.type === 'keydown' && e.which !== 13) return; + + inputLoader.show(); + const currentPath = decodeURIComponent(nameBlock.data('path')); + + $.ajax({ + type: 'POST', + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + }, + contentType: 'application/json; charset=utf-8', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/rename`, + timeout: 10000, + data: JSON.stringify({ + from: `${currentPath}${currentName}`, + to: `${currentPath}${inputField.val()}`, + }), + }).done(data => { + nameBlock.attr('data-name', inputField.val()); + if (!_.isEmpty(currentLink)) { + let newLink = currentLink.attr('href'); + if (nameBlock.parent().data('type') !== 'folder') { + newLink = newLink.substr(0, newLink.lastIndexOf('/')) + '/' + inputField.val(); + } + currentLink.attr('href', newLink); + nameBlock.html( + currentLink.html(inputField.val()) + ); + } else { + nameBlock.html(inputField.val()); + } + inputField.remove(); + }).fail(jqXHR => { + console.error(jqXHR); + var error = 'An error occured while trying to process this request.'; + if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') { + error = jqXHR.responseJSON.error; + } + nameBlock.addClass('has-error').delay(2000).queue(() => { + nameBlock.removeClass('has-error').dequeue(); + }); + inputField.popover({ + animation: true, + placement: 'top', + content: error, + title: 'Save Error' + }).popover('show'); + }).always(() => { + inputLoader.remove(); + ContextMenu.unbind().run(); + }); + }); + } + + copy() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const currentName = decodeURIComponent(nameBlock.attr('data-name')); + const currentPath = decodeURIComponent(nameBlock.data('path')); + + swal({ + type: 'input', + title: 'Copy File', + text: 'Please enter the new path for the copied file below.', + showCancelButton: true, + showConfirmButton: true, + closeOnConfirm: false, + showLoaderOnConfirm: true, + inputValue: `${currentPath}${currentName}`, + }, (val) => { + $.ajax({ + type: 'POST', + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + }, + contentType: 'application/json; charset=utf-8', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/copy`, + timeout: 10000, + data: JSON.stringify({ + from: `${currentPath}${currentName}`, + to: `${val}`, + }), + }).done(data => { + swal({ + type: 'success', + title: '', + text: 'File successfully copied.' + }); + Files.list(); + }).fail(jqXHR => { + console.error(jqXHR); + var error = 'An error occured while trying to process this request.'; + if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') { + error = jqXHR.responseJSON.error; + } + swal({ + type: 'error', + title: '', + text: error, + }); + }); + }); + } + + download() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const fileName = decodeURIComponent(nameBlock.attr('data-name')); + const filePath = decodeURIComponent(nameBlock.data('path')); + + window.location = `/server/${Pterodactyl.server.uuidShort}/files/download/${filePath}${fileName}`; + } + + delete() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const delPath = decodeURIComponent(nameBlock.data('path')); + const delName = decodeURIComponent(nameBlock.data('name')); + + swal({ + type: 'warning', + title: '', + text: 'Are you sure you want to delete ' + delName + '? There is no reversing this action.', + html: true, + showCancelButton: true, + showConfirmButton: true, + closeOnConfirm: false, + showLoaderOnConfirm: true + }, () => { + $.ajax({ + type: 'DELETE', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/f/${delPath}${delName}`, + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + } + }).done(data => { + nameBlock.parent().addClass('warning').delay(200).fadeOut(); + swal({ + type: 'success', + title: 'File Deleted' + }); + }).fail(jqXHR => { + console.error(jqXHR); + swal({ + type: 'error', + title: 'Whoops!', + html: true, + text: 'An error occured while attempting to delete this file. Please try again.', + }); + }); + }); + } + + decompress() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const compPath = decodeURIComponent(nameBlock.data('path')); + const compName = decodeURIComponent(nameBlock.data('name')); + + swal({ + title: ' Decompressing...', + text: 'This might take a few seconds to complete.', + html: true, + allowOutsideClick: false, + allowEscapeKey: false, + showConfirmButton: false, + }); + + $.ajax({ + type: 'POST', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/decompress`, + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + }, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ + files: `${compPath}${compName}` + }) + }).done(data => { + swal.close(); + Files.list(compPath); + }).fail(jqXHR => { + console.error(jqXHR); + var error = 'An error occured while trying to process this request.'; + if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') { + error = jqXHR.responseJSON.error; + } + swal({ + type: 'error', + title: 'Whoops!', + html: true, + text: error + }); + }); + } + + compress() { + const nameBlock = $(this.element).find('td[data-identifier="name"]'); + const compPath = decodeURIComponent(nameBlock.data('path')); + const compName = decodeURIComponent(nameBlock.data('name')); + + $.ajax({ + type: 'POST', + url: `${Pterodactyl.node.scheme}://${Pterodactyl.node.fqdn}:${Pterodactyl.node.daemonListen}/server/file/compress`, + headers: { + 'X-Access-Token': Pterodactyl.server.daemonSecret, + 'X-Access-Server': Pterodactyl.server.uuid, + }, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ + files: `${compPath}${compName}`, + to: compPath.toString() + }) + }).done(data => { + Files.list(compPath, err => { + if (err) return; + const fileListing = $('#file_listing').find(`[data-name="${data.saved_as}"]`).parent(); + fileListing.addClass('success pulsate').delay(3000).queue(() => { + fileListing.removeClass('success pulsate').dequeue(); + }); + }); + }).fail(jqXHR => { + console.error(jqXHR); + var error = 'An error occured while trying to process this request.'; + if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') { + error = jqXHR.responseJSON.error; + } + swal({ + type: 'error', + title: 'Whoops!', + html: true, + text: error + }); + }); + } +} diff --git a/resources/views/server/js/filemanager/contextmenu.blade.php b/public/js/files/contextmenu.js similarity index 64% rename from resources/views/server/js/filemanager/contextmenu.blade.php rename to public/js/files/contextmenu.js index e396b50aa..aeff39212 100644 --- a/resources/views/server/js/filemanager/contextmenu.blade.php +++ b/public/js/files/contextmenu.js @@ -40,19 +40,46 @@ class ContextMenuClass { const currentPath = decodeURIComponent(nameBlock.data('path')); newFilePath = `${currentPath}${currentName}`; } - return ''; + + let buildMenu = ''; + return buildMenu; } rightClick() { @@ -82,79 +109,69 @@ class ContextMenuClass { this.activeLine = parent; this.activeLine.addClass('active'); - @can('download-files', $server) - if (parent.data('type') === 'file') { - $(menu).find('li[data-action="download"]').removeClass('hidden'); - } - @endcan - - @can('compress-files', $server) - if (parent.data('type') === 'folder') { - $(menu).find('li[data-action="compress"]').removeClass('hidden'); - } - @endcan - - @can('decompress-files', $server) - if (_.without(['application/zip', 'application/gzip', 'application/x-gzip'], parent.data('mime')).length < 3) { - $(menu).find('li[data-action="decompress"]').removeClass('hidden'); - } - @endcan - // Handle Events const Actions = new ActionsClass(parent, menu); - @can('move-files', $server) + if (Pterodactyl.permissions.moveFiles) { $(menu).find('li[data-action="move"]').unbind().on('click', e => { e.preventDefault(); Actions.move(); }); - @endcan - - @can('copy-files', $server) - $(menu).find('li[data-action="copy"]').unbind().on('click', e => { - e.preventDefault(); - Actions.copy(); - }); - @endcan - - @can('move-files', $server) $(menu).find('li[data-action="rename"]').unbind().on('click', e => { e.preventDefault(); Actions.rename(); }); - @endcan + } - @can('compress-files', $server) + if (Pterodactyl.permissions.copyFiles) { + $(menu).find('li[data-action="copy"]').unbind().on('click', e => { + e.preventDefault(); + Actions.copy(); + }); + } + + if (Pterodactyl.permissions.compressFiles) { + if (parent.data('type') === 'folder') { + $(menu).find('li[data-action="compress"]').removeClass('hidden'); + } $(menu).find('li[data-action="compress"]').unbind().on('click', e => { e.preventDefault(); Actions.compress(); }); - @endcan + } - @can('decompress-files', $server) + if (Pterodactyl.permissions.decompressFiles) { + if (_.without(['application/zip', 'application/gzip', 'application/x-gzip'], parent.data('mime')).length < 3) { + $(menu).find('li[data-action="decompress"]').removeClass('hidden'); + } $(menu).find('li[data-action="decompress"]').unbind().on('click', e => { e.preventDefault(); Actions.decompress(); }); - @endcan + } - @can('create-files', $server) + if (Pterodactyl.permissions.createFiles) { $(menu).find('li[data-action="folder"]').unbind().on('click', e => { e.preventDefault(); Actions.folder(); }); - @endcan + } - @can('download-files', $server) + if (Pterodactyl.permissions.downloadFiles) { + if (parent.data('type') === 'file') { + $(menu).find('li[data-action="download"]').removeClass('hidden'); + } $(menu).find('li[data-action="download"]').unbind().on('click', e => { e.preventDefault(); Actions.download(); }); - @endcan + } - $(menu).find('li[data-action="delete"]').unbind().on('click', e => { - e.preventDefault(); - Actions.delete(); - }); + if (Pterodactyl.permissions.deleteFiles) { + $(menu).find('li[data-action="delete"]').unbind().on('click', e => { + e.preventDefault(); + Actions.delete(); + }); + } $(window).on('click', () => { $(menu).remove(); diff --git a/resources/views/server/js/filemanager/index.blade.php b/public/js/files/index.js similarity index 95% rename from resources/views/server/js/filemanager/index.blade.php rename to public/js/files/index.js index a89b4114f..a8142123f 100644 --- a/resources/views/server/js/filemanager/index.blade.php +++ b/public/js/files/index.js @@ -32,9 +32,9 @@ class FileManager { this.loader(true); $.ajax({ type: 'POST', - url: '{{ route('server.files.directory-list', $server->uuidShort) }}', + url: Pterodactyl.meta.directoryList, headers: { - 'X-CSRF-Token': '{{ csrf_token() }}', + 'X-CSRF-Token': Pterodactyl.meta.csrftoken, }, data: { directory: path, diff --git a/resources/views/server/js/minecraft/eula.blade.php b/public/js/plugins/minecraft/eula.js similarity index 55% rename from resources/views/server/js/minecraft/eula.blade.php rename to public/js/plugins/minecraft/eula.js index 5eefb11f7..28fe082e0 100644 --- a/resources/views/server/js/minecraft/eula.blade.php +++ b/public/js/plugins/minecraft/eula.js @@ -1,22 +1,22 @@ -{{-- Copyright (c) 2015 - 2016 Dane Everitt --}} - -{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}} -{{-- of this software and associated documentation files (the "Software"), to deal --}} -{{-- in the Software without restriction, including without limitation the rights --}} -{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}} -{{-- copies of the Software, and to permit persons to whom the Software is --}} -{{-- furnished to do so, subject to the following conditions: --}} - -{{-- The above copyright notice and this permission notice shall be included in all --}} -{{-- copies or substantial portions of the Software. --}} - -{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}} -{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}} -{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}} -{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}} -{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}} -{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}} -{{-- SOFTWARE. --}} +// Copyright (c) 2015 - 2016 Dane Everitt +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. $(window).load(function () { socket.on('console', function (data) { if (data.line.indexOf('You need to agree to the EULA in order to run the server') > -1) { @@ -34,8 +34,8 @@ $(window).load(function () { }, function () { $.ajax({ type: 'POST', - url: '{{ route('server.files.save', $server->uuidShort) }}', - headers: { 'X-CSRF-Token': '{{ csrf_token() }}' }, + url: Pterodactyl.meta.saveFile, + headers: { 'X-CSRF-Token': Pterodactyl.meta.csrfToken, }, data: { file: 'eula.txt', contents: 'eula=true' diff --git a/resources/views/server/files/index.blade.php b/resources/views/server/files/index.blade.php index c664414ba..4e8b7291c 100644 --- a/resources/views/server/files/index.blade.php +++ b/resources/views/server/files/index.blade.php @@ -58,9 +58,9 @@ - - - +{!! Theme::js('js/files/index.js') !!} +{!! Theme::js('js/files/contextmenu.js') !!} +{!! Theme::js('js/files/actions.js') !!} + {!! Theme::js('js/plugins/minecraft/eula.js') !!} @endif