Merge branch 'develop' into feature/service-changes
This commit is contained in:
commit
fc38b09e1f
169 changed files with 2268 additions and 2289 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,20 +21,19 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use Settings;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -57,7 +56,7 @@ class BaseController extends Controller
|
|||
'company' => 'required|between:1,256',
|
||||
'default_language' => 'required|alpha_dash|min:2|max:5',
|
||||
'email_from' => 'required|email',
|
||||
'email_sender_name' => 'required|between:1,256'
|
||||
'email_sender_name' => 'required|between:1,256',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -70,8 +69,7 @@ class BaseController extends Controller
|
|||
Settings::set('email_sender_name', $request->input('email_sender_name'));
|
||||
|
||||
Alert::success('Settings have been successfully updated.')->flash();
|
||||
|
||||
return redirect()->route('admin.settings');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,25 +21,23 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
use Alert;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\DatabaseRepository;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\DatabaseRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class DatabaseController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -63,7 +61,7 @@ class DatabaseController extends Controller
|
|||
'nodes.name as a_linkedNode',
|
||||
DB::raw('(SELECT COUNT(*) FROM `databases` WHERE `databases`.`db_server` = database_servers.id) as c_databases')
|
||||
)->leftJoin('nodes', 'nodes.id', '=', 'database_servers.linked_node')
|
||||
->paginate(20)
|
||||
->paginate(20),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -72,7 +70,7 @@ class DatabaseController extends Controller
|
|||
return view('admin.databases.new', [
|
||||
'nodes' => Models\Node::select('nodes.id', 'nodes.name', 'locations.long as a_location')
|
||||
->join('locations', 'locations.id', '=', 'nodes.location')
|
||||
->get()
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -81,12 +79,13 @@ class DatabaseController extends Controller
|
|||
try {
|
||||
$repo = new DatabaseRepository;
|
||||
$repo->add($request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
|
||||
Alert::success('Successfully added a new database server to the system.')->flash();
|
||||
|
||||
return redirect()->route('admin.databases', [
|
||||
'tab' => 'tab_dbservers'
|
||||
'tab' => 'tab_dbservers',
|
||||
]);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.databases.new')->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -97,6 +96,7 @@ class DatabaseController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occurred while attempting to delete this database server from the system.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.databases.new')->withInput();
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +108,9 @@ class DatabaseController extends Controller
|
|||
$repo->drop($id);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response()->json([
|
||||
'error' => ($ex instanceof DisplayException) ? $ex->getMessage() : 'An error occurred while attempting to delete this database from the system.'
|
||||
'error' => ($ex instanceof DisplayException) ? $ex->getMessage() : 'An error occurred while attempting to delete this database from the system.',
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
@ -121,10 +122,10 @@ class DatabaseController extends Controller
|
|||
$repo->delete($id);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response()->json([
|
||||
'error' => ($ex instanceof DisplayException) ? $ex->getMessage() : 'An error occurred while attempting to delete this database server from the system.'
|
||||
'error' => ($ex instanceof DisplayException) ? $ex->getMessage() : 'An error occurred while attempting to delete this database server from the system.',
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,23 +21,20 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use DB;
|
||||
use Alert;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\LocationRepository;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\LocationRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class LocationsController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -50,7 +47,7 @@ class LocationsController extends Controller
|
|||
'locations.*',
|
||||
DB::raw('(SELECT COUNT(*) FROM nodes WHERE nodes.location = locations.id) as a_nodeCount'),
|
||||
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount')
|
||||
)->paginate(20)
|
||||
)->paginate(20),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -62,19 +59,20 @@ class LocationsController extends Controller
|
|||
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount')
|
||||
)->where('id', $id)->first();
|
||||
|
||||
if (!$model) {
|
||||
if (! $model) {
|
||||
return response()->json([
|
||||
'error' => 'No location with that ID exists on the system.'
|
||||
'error' => 'No location with that ID exists on the system.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($model->a_nodeCount > 0 || $model->a_serverCount > 0) {
|
||||
return response()->json([
|
||||
'error' => 'You cannot remove a location that is currently assigned to a node or server.'
|
||||
'error' => 'You cannot remove a location that is currently assigned to a node or server.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
|
||||
|
@ -83,10 +81,11 @@ class LocationsController extends Controller
|
|||
try {
|
||||
$location = new LocationRepository;
|
||||
$location->edit($id, $request->all());
|
||||
|
||||
return response('', 204);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return response()->json([
|
||||
'error' => 'There was a validation error while processing this request. Location descriptions must be between 1 and 255 characters, and the location code must be between 1 and 10 characters with no spaces or special characters.'
|
||||
'error' => 'There was a validation error while processing this request. Location descriptions must be between 1 and 255 characters, and the location code must be between 1 and 10 characters with no spaces or special characters.',
|
||||
], 422);
|
||||
} catch (\Exception $ex) {
|
||||
// This gets caught and processed into JSON anyways.
|
||||
|
@ -99,9 +98,10 @@ class LocationsController extends Controller
|
|||
try {
|
||||
$location = new LocationRepository;
|
||||
$id = $location->create($request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('New location successfully added.')->flash();
|
||||
|
||||
return redirect()->route('admin.locations');
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.locations')->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -111,7 +111,7 @@ class LocationsController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attempting to add this location. Please try again.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.locations')->withInput();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,27 +21,24 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use Debugbar;
|
||||
use Log;
|
||||
use DB;
|
||||
use Log;
|
||||
use Alert;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\NodeRepository;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\NodeRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class NodesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -50,7 +47,7 @@ class NodesController extends Controller
|
|||
|
||||
public function getScript(Request $request, $id)
|
||||
{
|
||||
return response()->view('admin.nodes.remote.deploy', [ 'node' => Models\Node::findOrFail($id) ])->header('Content-Type', 'text/plain');
|
||||
return response()->view('admin.nodes.remote.deploy', ['node' => Models\Node::findOrFail($id)])->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
public function getIndex(Request $request)
|
||||
|
@ -66,13 +63,14 @@ class NodesController extends Controller
|
|||
|
||||
public function getNew(Request $request)
|
||||
{
|
||||
if (!Models\Location::all()->count()) {
|
||||
if (! Models\Location::all()->count()) {
|
||||
Alert::warning('You must add a location before you can add a new node.')->flash();
|
||||
|
||||
return redirect()->route('admin.locations');
|
||||
}
|
||||
|
||||
return view('admin.nodes.new', [
|
||||
'locations' => Models\Location::all()
|
||||
'locations' => Models\Location::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -81,12 +79,13 @@ class NodesController extends Controller
|
|||
try {
|
||||
$node = new NodeRepository;
|
||||
$new = $node->create($request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully created new node. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash();
|
||||
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $new,
|
||||
'tab' => 'tab_allocation'
|
||||
'tab' => 'tab_allocation',
|
||||
]);
|
||||
} catch (DisplayValidationException $e) {
|
||||
return redirect()->route('admin.nodes.new')->withErrors(json_decode($e->getMessage()))->withInput();
|
||||
|
@ -96,6 +95,7 @@ class NodesController extends Controller
|
|||
Log::error($e);
|
||||
Alert::danger('An unhandled exception occured while attempting to add this node. Please try again.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.nodes.new')->withInput();
|
||||
}
|
||||
|
||||
|
@ -129,12 +129,13 @@ class NodesController extends Controller
|
|||
try {
|
||||
$node = new NodeRepository;
|
||||
$node->update($id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully update this node\'s information. If you changed any daemon settings you will need to restart it now.')->flash();
|
||||
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_settings'
|
||||
'tab' => 'tab_settings',
|
||||
]);
|
||||
} catch (DisplayValidationException $e) {
|
||||
return redirect()->route('admin.nodes.view', $id)->withErrors(json_decode($e->getMessage()))->withInput();
|
||||
|
@ -144,9 +145,10 @@ class NodesController extends Controller
|
|||
Log::error($e);
|
||||
Alert::danger('An unhandled exception occured while attempting to edit this node. Please try again.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_settings'
|
||||
'tab' => 'tab_settings',
|
||||
])->withInput();
|
||||
}
|
||||
|
||||
|
@ -155,9 +157,10 @@ class NodesController extends Controller
|
|||
$query = Models\Allocation::where('node', $node)->whereNull('assigned_to')->where('id', $allocation)->delete();
|
||||
if ((int) $query === 0) {
|
||||
return response()->json([
|
||||
'error' => 'Unable to find an allocation matching those details to delete.'
|
||||
'error' => 'Unable to find an allocation matching those details to delete.',
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
|
||||
|
@ -166,21 +169,23 @@ class NodesController extends Controller
|
|||
$query = Models\Allocation::where('node', $node)->whereNull('assigned_to')->where('ip', $request->input('ip'))->delete();
|
||||
if ((int) $query === 0) {
|
||||
Alert::danger('There was an error while attempting to delete allocations on that IP.')->flash();
|
||||
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $node,
|
||||
'tab' => 'tab_allocations'
|
||||
'tab' => 'tab_allocations',
|
||||
]);
|
||||
}
|
||||
Alert::success('Deleted all unallocated ports for <code>' . $request->input('ip') . '</code>.')->flash();
|
||||
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $node,
|
||||
'tab' => 'tab_allocation'
|
||||
'tab' => 'tab_allocation',
|
||||
]);
|
||||
}
|
||||
|
||||
public function setAlias(Request $request, $node)
|
||||
{
|
||||
if (!$request->input('allocation')) {
|
||||
if (! $request->input('allocation')) {
|
||||
return response('Missing required parameters.', 422);
|
||||
}
|
||||
|
||||
|
@ -198,36 +203,36 @@ class NodesController extends Controller
|
|||
public function getAllocationsJson(Request $request, $id)
|
||||
{
|
||||
$allocations = Models\Allocation::select('ip')->where('node', $id)->groupBy('ip')->get();
|
||||
|
||||
return response()->json($allocations);
|
||||
}
|
||||
|
||||
public function postAllocations(Request $request, $id)
|
||||
{
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'allocate_ip.*' => 'required|string',
|
||||
'allocate_port.*' => 'required'
|
||||
'allocate_port.*' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_allocation'
|
||||
'tab' => 'tab_allocation',
|
||||
])->withErrors($validator->errors())->withInput();
|
||||
}
|
||||
|
||||
$processedData = [];
|
||||
foreach($request->input('allocate_ip') as $ip) {
|
||||
if (!array_key_exists($ip, $processedData)) {
|
||||
foreach ($request->input('allocate_ip') as $ip) {
|
||||
if (! array_key_exists($ip, $processedData)) {
|
||||
$processedData[$ip] = [];
|
||||
}
|
||||
}
|
||||
|
||||
foreach($request->input('allocate_port') as $portid => $ports) {
|
||||
foreach ($request->input('allocate_port') as $portid => $ports) {
|
||||
if (array_key_exists($portid, $request->input('allocate_ip'))) {
|
||||
$json = json_decode($ports);
|
||||
if (json_last_error() === 0 && !empty($json)) {
|
||||
foreach($json as &$parsed) {
|
||||
if (json_last_error() === 0 && ! empty($json)) {
|
||||
foreach ($json as &$parsed) {
|
||||
array_push($processedData[$request->input('allocate_ip')[$portid]], $parsed->value);
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +251,7 @@ class NodesController extends Controller
|
|||
} finally {
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_allocation'
|
||||
'tab' => 'tab_allocation',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -257,6 +262,7 @@ class NodesController extends Controller
|
|||
$repo = new NodeRepository;
|
||||
$repo->delete($id);
|
||||
Alert::success('Successfully deleted the requested node from the panel.')->flash();
|
||||
|
||||
return redirect()->route('admin.nodes');
|
||||
} catch (DisplayException $e) {
|
||||
Alert::danger($e->getMessage())->flash();
|
||||
|
@ -267,8 +273,7 @@ class NodesController extends Controller
|
|||
|
||||
return redirect()->route('admin.nodes.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_delete'
|
||||
'tab' => 'tab_delete',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,28 +21,24 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use Debugbar;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
use Alert;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
use Pterodactyl\Repositories\DatabaseRepository;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ServersController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -62,17 +58,17 @@ class ServersController extends Controller
|
|||
->join('users', 'servers.owner', '=', 'users.id')
|
||||
->join('allocations', 'servers.allocation', '=', 'allocations.id');
|
||||
|
||||
if ($request->input('filter') && !is_null($request->input('filter'))) {
|
||||
if ($request->input('filter') && ! is_null($request->input('filter'))) {
|
||||
preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches);
|
||||
foreach($matches[0] as $match) {
|
||||
foreach ($matches[0] as $match) {
|
||||
$match = str_replace('"', '', $match);
|
||||
if (strpos($match, ':')) {
|
||||
list($field, $term) = explode(':', $match);
|
||||
if ($field === 'node') {
|
||||
$field = 'nodes.name';
|
||||
} else if ($field === 'owner') {
|
||||
} elseif ($field === 'owner') {
|
||||
$field = 'users.email';
|
||||
} else if (!strpos($field, '.')) {
|
||||
} elseif (! strpos($field, '.')) {
|
||||
$field = 'servers.' . $field;
|
||||
}
|
||||
|
||||
|
@ -107,7 +103,7 @@ class ServersController extends Controller
|
|||
}
|
||||
|
||||
return view('admin.servers.index', [
|
||||
'servers' => $servers
|
||||
'servers' => $servers,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -115,7 +111,7 @@ class ServersController extends Controller
|
|||
{
|
||||
return view('admin.servers.new', [
|
||||
'locations' => Models\Location::all(),
|
||||
'services' => Models\Service::all()
|
||||
'services' => Models\Service::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -123,9 +119,7 @@ class ServersController extends Controller
|
|||
{
|
||||
$server = Models\Server::withTrashed()->select(
|
||||
'servers.*',
|
||||
'nodes.name as a_nodeName',
|
||||
'users.email as a_ownerEmail',
|
||||
'locations.long as a_locationName',
|
||||
'services.name as a_serviceName',
|
||||
DB::raw('IFNULL(service_options.executable, services.executable) as a_serviceExecutable'),
|
||||
'service_options.docker_image',
|
||||
|
@ -135,19 +129,24 @@ class ServersController extends Controller
|
|||
'allocations.ip_alias'
|
||||
)->join('nodes', 'servers.node', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner', '=', 'users.id')
|
||||
->join('locations', 'nodes.location', '=', 'locations.id')
|
||||
->join('services', 'servers.service', '=', 'services.id')
|
||||
->join('service_options', 'servers.option', '=', 'service_options.id')
|
||||
->join('allocations', 'servers.allocation', '=', 'allocations.id')
|
||||
->where('servers.id', $id)
|
||||
->first();
|
||||
|
||||
if (!$server) {
|
||||
if (! $server) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
return view('admin.servers.view', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::select(
|
||||
'nodes.*',
|
||||
'locations.long as a_locationName'
|
||||
)->join('locations', 'nodes.location', '=', 'locations.id')
|
||||
->where('nodes.id', $server->node)
|
||||
->first(),
|
||||
'assigned' => Models\Allocation::where('assigned_to', $id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(),
|
||||
'unassigned' => Models\Allocation::where('node', $server->node)->whereNull('assigned_to')->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(),
|
||||
'startup' => Models\ServiceVariables::select('service_variables.*', 'server_variables.variable_value as a_serverValue')
|
||||
|
@ -159,30 +158,29 @@ class ServersController extends Controller
|
|||
->where('server_id', $server->id)
|
||||
->join('database_servers', 'database_servers.id', '=', 'databases.db_server')
|
||||
->get(),
|
||||
'db_servers' => Models\DatabaseServer::all()
|
||||
'db_servers' => Models\DatabaseServer::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function postNewServer(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$server = new ServerRepository;
|
||||
$response = $server->create($request->except([
|
||||
'_token'
|
||||
]));
|
||||
return redirect()->route('admin.servers.view', [ 'id' => $response ]);
|
||||
$response = $server->create($request->all());
|
||||
|
||||
return redirect()->route('admin.servers.view', ['id' => $response]);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.servers.new')->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
||||
return redirect()->route('admin.servers.new')->withInput();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attemping to add this server. Please try again.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers.new')->withInput();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,15 +191,13 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerGetNodes(Request $request)
|
||||
{
|
||||
|
||||
if(!$request->input('location')) {
|
||||
if (! $request->input('location')) {
|
||||
return response()->json([
|
||||
'error' => 'Missing location in request.'
|
||||
'error' => 'Missing location in request.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
return response()->json(Models\Node::select('id', 'name', 'public')->where('location', $request->input('location'))->get());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,25 +208,24 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerGetIps(Request $request)
|
||||
{
|
||||
|
||||
if(!$request->input('node')) {
|
||||
if (! $request->input('node')) {
|
||||
return response()->json([
|
||||
'error' => 'Missing node in request.'
|
||||
'error' => 'Missing node in request.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
$ips = Models\Allocation::where('node', $request->input('node'))->whereNull('assigned_to')->get();
|
||||
$listing = [];
|
||||
|
||||
foreach($ips as &$ip) {
|
||||
foreach ($ips as &$ip) {
|
||||
if (array_key_exists($ip->ip, $listing)) {
|
||||
$listing[$ip->ip] = array_merge($listing[$ip->ip], [$ip->port]);
|
||||
} else {
|
||||
$listing[$ip->ip] = [$ip->port];
|
||||
}
|
||||
}
|
||||
return response()->json($listing);
|
||||
|
||||
return response()->json($listing);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,16 +236,15 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerServiceOptions(Request $request)
|
||||
{
|
||||
|
||||
if(!$request->input('service')) {
|
||||
if (! $request->input('service')) {
|
||||
return response()->json([
|
||||
'error' => 'Missing service in request.'
|
||||
'error' => 'Missing service in request.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
$service = Models\Service::select('executable', 'startup')->where('id', $request->input('service'))->first();
|
||||
return response()->json(Models\ServiceOptions::select('id', 'name', 'docker_image')->where('parent_service', $request->input('service'))->orderBy('name', 'asc')->get());
|
||||
|
||||
return response()->json(Models\ServiceOptions::select('id', 'name', 'docker_image')->where('parent_service', $request->input('service'))->orderBy('name', 'asc')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,10 +255,9 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerOptionDetails(Request $request)
|
||||
{
|
||||
|
||||
if(!$request->input('option')) {
|
||||
if (! $request->input('option')) {
|
||||
return response()->json([
|
||||
'error' => 'Missing option in request.'
|
||||
'error' => 'Missing option in request.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
|
@ -279,28 +272,25 @@ class ServersController extends Controller
|
|||
'packs' => Models\ServicePack::select('id', 'name', 'version')->where('option', $request->input('option'))->where('selectable', true)->get(),
|
||||
'variables' => Models\ServiceVariables::where('option_id', $request->input('option'))->get(),
|
||||
'exec' => $option->executable,
|
||||
'startup' => $option->startup
|
||||
'startup' => $option->startup,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function postUpdateServerDetails(Request $request, $id)
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$server = new ServerRepository;
|
||||
$server->updateDetails($id, [
|
||||
'owner' => $request->input('owner'),
|
||||
'name' => $request->input('name'),
|
||||
'reset_token' => ($request->input('reset_token', false) === 'on') ? true : false
|
||||
'reset_token' => ($request->input('reset_token', false) === 'on') ? true : false,
|
||||
]);
|
||||
|
||||
Alert::success('Server details were successfully updated.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_details'
|
||||
'tab' => 'tab_details',
|
||||
])->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -311,21 +301,22 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_details'
|
||||
'tab' => 'tab_details',
|
||||
])->withInput();
|
||||
}
|
||||
|
||||
public function postUpdateContainerDetails(Request $request, $id) {
|
||||
public function postUpdateContainerDetails(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->updateContainer($id, [
|
||||
'image' => $request->input('docker_image')
|
||||
'image' => $request->input('docker_image'),
|
||||
]);
|
||||
Alert::success('Successfully updated this server\'s docker image.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_details'
|
||||
'tab' => 'tab_details',
|
||||
])->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -336,11 +327,12 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_details'
|
||||
'tab' => 'tab_details',
|
||||
]);
|
||||
}
|
||||
|
||||
public function postUpdateServerToggleBuild(Request $request, $id) {
|
||||
public function postUpdateServerToggleBuild(Request $request, $id)
|
||||
{
|
||||
$server = Models\Server::findOrFail($id);
|
||||
$node = Models\Node::findOrFail($server->node);
|
||||
$client = Models\Node::guzzleRequest($server->node);
|
||||
|
@ -349,8 +341,8 @@ class ServersController extends Controller
|
|||
$res = $client->request('POST', '/server/rebuild', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
]
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
]);
|
||||
Alert::success('A rebuild has been queued successfully. It will run the next time this server is booted.')->flash();
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
|
@ -360,14 +352,13 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
|
||||
public function postUpdateServerUpdateBuild(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
|
||||
$server = new ServerRepository;
|
||||
$server->changeBuild($id, [
|
||||
'default' => $request->input('default'),
|
||||
|
@ -382,13 +373,14 @@ class ServersController extends Controller
|
|||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_build'
|
||||
'tab' => 'tab_build',
|
||||
])->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_build'
|
||||
'tab' => 'tab_build',
|
||||
]);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
@ -397,7 +389,7 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_build'
|
||||
'tab' => 'tab_build',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -407,16 +399,18 @@ class ServersController extends Controller
|
|||
$server = new ServerRepository;
|
||||
$server->deleteServer($id, $force);
|
||||
Alert::success('Server has been marked for deletion on the system.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers');
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch(\Exception $ex) {
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attemping to delete this server. Please try again.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_delete'
|
||||
'tab' => 'tab_delete',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -428,13 +422,13 @@ class ServersController extends Controller
|
|||
Alert::success('Server status was successfully toggled.')->flash();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch(\Exception $ex) {
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attemping to toggle this servers status.')->flash();
|
||||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -444,18 +438,18 @@ class ServersController extends Controller
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->updateStartup($id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]), true);
|
||||
Alert::success('Server startup variables were successfully updated.')->flash();
|
||||
} catch (\Pterodactyl\Exceptions\DisplayException $e) {
|
||||
Alert::danger($e->getMessage())->flash();
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e);
|
||||
Alert::danger('An unhandled exception occured while attemping to update startup variables for this server. Please try again.')->flash();
|
||||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_startup'
|
||||
'tab' => 'tab_startup',
|
||||
])->withInput();
|
||||
}
|
||||
}
|
||||
|
@ -465,13 +459,13 @@ class ServersController extends Controller
|
|||
try {
|
||||
$repo = new DatabaseRepository;
|
||||
$repo->create($id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Added new database to this server.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_database'
|
||||
'tab' => 'tab_database',
|
||||
])->withInput()->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
@ -480,7 +474,7 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_database'
|
||||
'tab' => 'tab_database',
|
||||
])->withInput();
|
||||
}
|
||||
|
||||
|
@ -492,13 +486,13 @@ class ServersController extends Controller
|
|||
Alert::success('Server has been suspended on the system. All running processes have been stopped and will not be startable until it is un-suspended.');
|
||||
} catch (DisplayException $e) {
|
||||
Alert::danger($e->getMessage())->flash();
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e);
|
||||
Alert::danger('An unhandled exception occured while attemping to suspend this server. Please try again.')->flash();
|
||||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -511,13 +505,13 @@ class ServersController extends Controller
|
|||
Alert::success('Server has been unsuspended on the system. Access has been re-enabled.');
|
||||
} catch (DisplayException $e) {
|
||||
Alert::danger($e->getMessage())->flash();
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e);
|
||||
Alert::danger('An unhandled exception occured while attemping to unsuspend this server. Please try again.')->flash();
|
||||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -526,27 +520,31 @@ class ServersController extends Controller
|
|||
{
|
||||
try {
|
||||
$repo = new ServerRepository;
|
||||
if (!is_null($request->input('cancel'))) {
|
||||
if (! is_null($request->input('cancel'))) {
|
||||
$repo->cancelDeletion($id);
|
||||
Alert::success('Server deletion has been cancelled. This server will remain suspended until you unsuspend it.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers.view', $id);
|
||||
} else if(!is_null($request->input('delete'))) {
|
||||
} elseif (! is_null($request->input('delete'))) {
|
||||
$repo->deleteNow($id);
|
||||
Alert::success('Server was successfully deleted from the system.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers');
|
||||
} else if(!is_null($request->input('force_delete'))) {
|
||||
} elseif (! is_null($request->input('force_delete'))) {
|
||||
$repo->deleteNow($id, true);
|
||||
Alert::success('Server was successfully force deleted from the system.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers');
|
||||
}
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
||||
return redirect()->route('admin.servers.view', $id);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An unhandled error occured while attempting to perform this action.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers.view', $id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,25 +21,23 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use DB;
|
||||
use Log;
|
||||
use Validator;
|
||||
use Alert;
|
||||
use Storage;
|
||||
|
||||
use Validator;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\ServiceRepository;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\ServiceRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -51,7 +49,7 @@ class ServiceController extends Controller
|
|||
'services' => Models\Service::select(
|
||||
'services.*',
|
||||
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.service = services.id) as c_servers')
|
||||
)->get()
|
||||
)->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -65,9 +63,10 @@ class ServiceController extends Controller
|
|||
try {
|
||||
$repo = new ServiceRepository\Service;
|
||||
$id = $repo->create($request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully created new service!')->flash();
|
||||
|
||||
return redirect()->route('admin.services.service', $id);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.services.new')->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -77,6 +76,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occured while attempting to add a new service.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.new')->withInput();
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class ServiceController extends Controller
|
|||
'options' => Models\ServiceOptions::select(
|
||||
'service_options.*',
|
||||
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.option = service_options.id) as c_servers')
|
||||
)->where('parent_service', $service)->get()
|
||||
)->where('parent_service', $service)->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ class ServiceController extends Controller
|
|||
try {
|
||||
$repo = new ServiceRepository\Service;
|
||||
$repo->update($service, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully updated this service.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
|
@ -107,6 +107,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occurred while attempting to update this service.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.service', $service)->withInput();
|
||||
}
|
||||
|
||||
|
@ -116,6 +117,7 @@ class ServiceController extends Controller
|
|||
$repo = new ServiceRepository\Service;
|
||||
$repo->delete($service);
|
||||
Alert::success('Successfully deleted that service.')->flash();
|
||||
|
||||
return redirect()->route('admin.services');
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -123,12 +125,14 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error was encountered while attempting to delete that service.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.service', $service);
|
||||
}
|
||||
|
||||
public function getOption(Request $request, $service, $option)
|
||||
{
|
||||
$opt = Models\ServiceOptions::findOrFail($option);
|
||||
|
||||
return view('admin.services.options.view', [
|
||||
'service' => Models\Service::findOrFail($opt->parent_service),
|
||||
'option' => $opt,
|
||||
|
@ -136,7 +140,7 @@ class ServiceController extends Controller
|
|||
'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail')
|
||||
->join('users', 'users.id', '=', 'servers.owner')
|
||||
->where('option', $option)
|
||||
->paginate(10)
|
||||
->paginate(10),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -145,7 +149,7 @@ class ServiceController extends Controller
|
|||
try {
|
||||
$repo = new ServiceRepository\Option;
|
||||
$repo->update($option, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Option settings successfully updated.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
|
@ -154,6 +158,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occured while attempting to modify this option.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $option])->withInput();
|
||||
}
|
||||
|
||||
|
@ -165,6 +170,7 @@ class ServiceController extends Controller
|
|||
$repo->delete($option);
|
||||
|
||||
Alert::success('Successfully deleted that option.')->flash();
|
||||
|
||||
return redirect()->route('admin.services.service', $service->parent_service);
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -172,6 +178,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error was encountered while attempting to delete this option.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $option]);
|
||||
}
|
||||
|
||||
|
@ -185,18 +192,19 @@ class ServiceController extends Controller
|
|||
$data = [
|
||||
'user_viewable' => '0',
|
||||
'user_editable' => '0',
|
||||
'required' => '0'
|
||||
'required' => '0',
|
||||
];
|
||||
foreach($request->except(['_token']) as $id => $val) {
|
||||
$data[str_replace($variable.'_', '', $id)] = $val;
|
||||
foreach ($request->except(['_token']) as $id => $val) {
|
||||
$data[str_replace($variable . '_', '', $id)] = $val;
|
||||
}
|
||||
$repo->update($variable, $data);
|
||||
Alert::success('Successfully updated variable.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
$data = [];
|
||||
foreach(json_decode($ex->getMessage(), true) as $id => $val) {
|
||||
$data[$variable.'_'.$id] = $val;
|
||||
foreach (json_decode($ex->getMessage(), true) as $id => $val) {
|
||||
$data[$variable . '_' . $id] = $val;
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $option])->withErrors((object) $data)->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -204,6 +212,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occurred while attempting to update this service.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $option])->withInput();
|
||||
}
|
||||
|
||||
|
@ -211,7 +220,7 @@ class ServiceController extends Controller
|
|||
{
|
||||
return view('admin.services.options.variable', [
|
||||
'service' => Models\Service::findOrFail($service),
|
||||
'option' => Models\ServiceOptions::where('parent_service', $service)->where('id', $option)->firstOrFail()
|
||||
'option' => Models\ServiceOptions::where('parent_service', $service)->where('id', $option)->firstOrFail(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -220,9 +229,10 @@ class ServiceController extends Controller
|
|||
try {
|
||||
$repo = new ServiceRepository\Variable;
|
||||
$repo->create($option, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully added new variable to this option.')->flash();
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $option])->withInput();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.services.option.variable.new', [$service, $option])->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -232,6 +242,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occurred while attempting to add this variable.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option.variable.new', [$service, $option])->withInput();
|
||||
}
|
||||
|
||||
|
@ -247,9 +258,10 @@ class ServiceController extends Controller
|
|||
try {
|
||||
$repo = new ServiceRepository\Option;
|
||||
$id = $repo->create($service, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully created new service option.')->flash();
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $id]);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.services.option.new', $service)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -257,6 +269,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occured while attempting to add this service option.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option.new', $service)->withInput();
|
||||
}
|
||||
|
||||
|
@ -272,6 +285,7 @@ class ServiceController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An error occured while attempting to delete that variable.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.option', [$service, $option]);
|
||||
}
|
||||
|
||||
|
@ -306,5 +320,4 @@ class ServiceController extends Controller
|
|||
], 503);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Some Modifications (c) 2015 Dylan Seidt <dylan.seidt@gmail.com>
|
||||
* Some Modifications (c) 2015 Dylan Seidt <dylan.seidt@gmail.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,27 +22,23 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use Settings;
|
||||
use Mail;
|
||||
use Log;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Repositories\UserRepository;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Alert;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\UserRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -51,8 +47,33 @@ class UserController extends Controller
|
|||
|
||||
public function getIndex(Request $request)
|
||||
{
|
||||
$query = User::select('users.*');
|
||||
if ($request->input('filter') && ! is_null($request->input('filter'))) {
|
||||
preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches);
|
||||
foreach ($matches[0] as $match) {
|
||||
$match = str_replace('"', '', $match);
|
||||
if (strpos($match, ':')) {
|
||||
list($field, $term) = explode(':', $match);
|
||||
$query->orWhere($field, 'LIKE', '%' . $term . '%');
|
||||
} else {
|
||||
$query->where('email', 'LIKE', '%' . $match . '%');
|
||||
$query->orWhere([
|
||||
['uuid', 'LIKE', '%' . $match . '%'],
|
||||
['root_admin', 'LIKE', '%' . $match . '%'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$users = $query->paginate(20);
|
||||
} catch (\Exception $ex) {
|
||||
Alert::warning('There was an error with the search parameters provided.');
|
||||
$users = User::all()->paginate(20);
|
||||
}
|
||||
|
||||
return view('admin.users.index', [
|
||||
'users' => User::paginate(20)
|
||||
'users' => $users,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -79,13 +100,15 @@ class UserController extends Controller
|
|||
$repo = new UserRepository;
|
||||
$repo->delete($id);
|
||||
Alert::success('Successfully deleted user from system.')->flash();
|
||||
|
||||
return redirect()->route('admin.users');
|
||||
} catch(DisplayException $ex) {
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An exception was encountered while attempting to delete this user.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.users.view', $id);
|
||||
}
|
||||
|
||||
|
@ -95,12 +118,14 @@ class UserController extends Controller
|
|||
$user = new UserRepository;
|
||||
$userid = $user->create($request->input('email'), $request->input('password'));
|
||||
Alert::success('Account has been successfully created.')->flash();
|
||||
|
||||
return redirect()->route('admin.users.view', $userid);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.users.new')->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An error occured while attempting to add a new user.')->flash();
|
||||
|
||||
return redirect()->route('admin.users.new');
|
||||
}
|
||||
}
|
||||
|
@ -127,15 +152,16 @@ class UserController extends Controller
|
|||
Log::error($e);
|
||||
Alert::danger('An error occured while attempting to update this user.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.users.view', $user);
|
||||
}
|
||||
|
||||
public function getJson(Request $request)
|
||||
{
|
||||
foreach(User::select('email')->get() as $user) {
|
||||
foreach (User::select('email')->get() as $user) {
|
||||
$resp[] = $user->email;
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue