Apply fixes from StyleCI
This commit is contained in:
parent
a1d3bbf73d
commit
c1fb0a665f
150 changed files with 1558 additions and 1760 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,10 +21,10 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use DB;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ClearServices extends Command
|
||||
|
@ -60,7 +60,6 @@ class ClearServices extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
if (! $this->confirm('This is a destructive operation, are you sure you wish to continue?')) {
|
||||
$this->error('Canceling.');
|
||||
exit();
|
||||
|
|
|
@ -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,19 +21,16 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Carbon;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
use Pterodactyl\Jobs\SendScheduledTask;
|
||||
|
||||
class ClearTasks extends Command
|
||||
{
|
||||
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,11 +21,10 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use Hash;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Pterodactyl\Repositories\UserRepository;
|
||||
|
||||
class MakeUser extends Command
|
||||
|
@ -77,6 +76,7 @@ class MakeUser extends Command
|
|||
try {
|
||||
$user = new UserRepository;
|
||||
$user->create($email, $password, $admin);
|
||||
|
||||
return $this->info('User successfully created.');
|
||||
} catch (\Exception $ex) {
|
||||
return $this->error($ex->getMessage());
|
||||
|
|
|
@ -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,19 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Carbon;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
use Pterodactyl\Jobs\SendScheduledTask;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
class RunTasks extends Command
|
||||
{
|
||||
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,10 +21,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Version;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ShowVersion extends Command
|
||||
{
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -75,35 +76,35 @@ class UpdateEmailSettings extends Command
|
|||
|
||||
$this->table([
|
||||
'Option',
|
||||
'Description'
|
||||
'Description',
|
||||
], [
|
||||
[
|
||||
'smtp',
|
||||
'SMTP Server Email'
|
||||
'SMTP Server Email',
|
||||
],
|
||||
[
|
||||
'mail',
|
||||
'PHP\'s Internal Mail Server'
|
||||
'PHP\'s Internal Mail Server',
|
||||
],
|
||||
[
|
||||
'mailgun',
|
||||
'Mailgun Email Service'
|
||||
'Mailgun Email Service',
|
||||
],
|
||||
[
|
||||
'mandrill',
|
||||
'Mandrill Transactional Email Service'
|
||||
'Mandrill Transactional Email Service',
|
||||
],
|
||||
[
|
||||
'postmark',
|
||||
'Postmark Transactional Email Service'
|
||||
]
|
||||
'Postmark Transactional Email Service',
|
||||
],
|
||||
]);
|
||||
$variables['MAIL_DRIVER'] = is_null($this->option('driver')) ? $this->choice('Which email driver would you like to use?', [
|
||||
'smtp',
|
||||
'mail',
|
||||
'mailgun',
|
||||
'mandrill',
|
||||
'postmark'
|
||||
'postmark',
|
||||
]) : $this->option('driver');
|
||||
|
||||
switch ($variables['MAIL_DRIVER']) {
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands;
|
||||
|
||||
use Uuid;
|
||||
|
@ -66,7 +67,6 @@ class UpdateEnvironment extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$variables = [];
|
||||
$file = base_path() . '/.env';
|
||||
if (! file_exists($file)) {
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
@ -40,5 +41,4 @@ class ServerDeleted
|
|||
{
|
||||
$this->server = $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,9 +21,9 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
class AccountNotFoundException extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
use Log;
|
||||
|
||||
class DisplayException extends \Exception
|
||||
{
|
||||
|
||||
private $_logging = null;
|
||||
|
||||
public function __construct($message, $log = null)
|
||||
|
@ -44,5 +44,4 @@ class DisplayException extends \Exception
|
|||
{
|
||||
return $this->_logging;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
class DisplayValidationException extends \Exception
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
use Log;
|
||||
|
||||
use Exception;
|
||||
use DisplayException;
|
||||
use DisplayValidationException;
|
||||
use AccountNotFoundException;
|
||||
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
|
@ -52,7 +48,7 @@ class Handler extends ExceptionHandler
|
|||
{
|
||||
if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('remote/*')) {
|
||||
$response = response()->json([
|
||||
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.'
|
||||
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.',
|
||||
], 500);
|
||||
|
||||
// parent::render() will log it, we are bypassing it in this case.
|
||||
|
@ -74,7 +70,7 @@ class Handler extends ExceptionHandler
|
|||
if ($request->expectsJson()) {
|
||||
return response()->json(['error' => 'Unauthenticated.'], 401);
|
||||
}
|
||||
|
||||
return redirect()->guest('/auth/login');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Version extends Facade
|
||||
{
|
||||
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return '\Pterodactyl\Services\VersionService';
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use DB;
|
||||
|
@ -32,14 +33,13 @@ use Pterodactyl\Models\Location;
|
|||
*/
|
||||
class LocationController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* List All Locations
|
||||
* List All Locations.
|
||||
*
|
||||
* Lists all locations currently on the system.
|
||||
*
|
||||
|
@ -60,5 +60,4 @@ class LocationController extends BaseController
|
|||
|
||||
return $locations->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,18 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Transformers\NodeTransformer;
|
||||
use Pterodactyl\Transformers\AllocationTransformer;
|
||||
use Pterodactyl\Repositories\NodeRepository;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Illuminate\Http\Request;
|
||||
use Dingo\Api\Exception\ResourceException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Repositories\NodeRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
|
@ -42,14 +39,13 @@ use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
|||
*/
|
||||
class NodeController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* List All Nodes
|
||||
* List All Nodes.
|
||||
*
|
||||
* Lists all nodes currently on the system.
|
||||
*
|
||||
|
@ -66,7 +62,7 @@ class NodeController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a New Node
|
||||
* Create a New Node.
|
||||
*
|
||||
* @Post("/nodes")
|
||||
* @Versions({"v1"})
|
||||
|
@ -102,6 +98,7 @@ class NodeController extends BaseController
|
|||
try {
|
||||
$node = new NodeRepository;
|
||||
$new = $node->create($request->all());
|
||||
|
||||
return ['id' => $new];
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
|
@ -113,7 +110,7 @@ class NodeController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* List Specific Node
|
||||
* List Specific Node.
|
||||
*
|
||||
* Lists specific fields about a server or all fields pertaining to that node.
|
||||
*
|
||||
|
@ -146,8 +143,8 @@ class NodeController extends BaseController
|
|||
'node' => $node->first(),
|
||||
'allocations' => [
|
||||
'assigned' => Models\Allocation::where('node', $id)->whereNotNull('assigned_to')->get(),
|
||||
'unassigned' => Models\Allocation::where('node', $id)->whereNull('assigned_to')->get()
|
||||
]
|
||||
'unassigned' => Models\Allocation::where('node', $id)->whereNull('assigned_to')->get(),
|
||||
],
|
||||
];
|
||||
} catch (NotFoundHttpException $ex) {
|
||||
throw $ex;
|
||||
|
@ -174,45 +171,45 @@ class NodeController extends BaseController
|
|||
'ssl' => [
|
||||
'enabled' => ($node->scheme === 'https'),
|
||||
'certificate' => '/etc/certs/' . $node->fqdn . '/fullchain.pem',
|
||||
'key' => '/etc/certs/' . $node->fqdn . '/privkey.pem'
|
||||
]
|
||||
'key' => '/etc/certs/' . $node->fqdn . '/privkey.pem',
|
||||
],
|
||||
],
|
||||
'docker' => [
|
||||
'socket' => '/var/run/docker.sock',
|
||||
'autoupdate_images' => true
|
||||
'autoupdate_images' => true,
|
||||
],
|
||||
'sftp' => [
|
||||
'path' => $node->daemonBase,
|
||||
'port' => (int) $node->daemonSFTP,
|
||||
'container' => 'ptdl-sftp'
|
||||
'container' => 'ptdl-sftp',
|
||||
],
|
||||
'query' => [
|
||||
'kill_on_fail' => true,
|
||||
'fail_limit' => 5
|
||||
'fail_limit' => 5,
|
||||
],
|
||||
'logger' => [
|
||||
'path' => 'logs/',
|
||||
'src' => false,
|
||||
'level' => 'info',
|
||||
'period' => '1d',
|
||||
'count' => 3
|
||||
'count' => 3,
|
||||
],
|
||||
'remote' => [
|
||||
'base' => config('app.url'),
|
||||
'download' => route('remote.download'),
|
||||
'installed' => route('remote.install')
|
||||
'installed' => route('remote.install'),
|
||||
],
|
||||
'uploads' => [
|
||||
'size_limit' => $node->upload_size
|
||||
'size_limit' => $node->upload_size,
|
||||
],
|
||||
'keys' => [
|
||||
$node->daemonSecret
|
||||
$node->daemonSecret,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all Node Allocations
|
||||
* List all Node Allocations.
|
||||
*
|
||||
* Returns a listing of all allocations for every node.
|
||||
*
|
||||
|
@ -226,11 +223,12 @@ class NodeController extends BaseController
|
|||
if ($allocations->count() < 1) {
|
||||
throw new NotFoundHttpException('No allocations have been created.');
|
||||
}
|
||||
|
||||
return $allocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* List Node Allocation based on assigned to ID
|
||||
* List Node Allocation based on assigned to ID.
|
||||
*
|
||||
* Returns a listing of the allocation for the specified server id.
|
||||
*
|
||||
|
@ -242,7 +240,6 @@ class NodeController extends BaseController
|
|||
{
|
||||
$query = Models\Allocation::where('assigned_to', $id)->get();
|
||||
try {
|
||||
|
||||
if (empty($query)) {
|
||||
throw new NotFoundHttpException('No allocations for that server were found.');
|
||||
}
|
||||
|
@ -256,7 +253,7 @@ class NodeController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete Node
|
||||
* Delete Node.
|
||||
*
|
||||
* @Delete("/nodes/{id}")
|
||||
* @Versions({"v1"})
|
||||
|
@ -270,6 +267,7 @@ class NodeController extends BaseController
|
|||
try {
|
||||
$node = new NodeRepository;
|
||||
$node->delete($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
} catch (DisplayException $ex) {
|
||||
throw new ResourceException($ex->getMessage());
|
||||
|
@ -277,5 +275,4 @@ class NodeController extends BaseController
|
|||
throw new ServiceUnavailableHttpException('An error occured while attempting to delete this node.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,18 +21,16 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Log;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Transformers\ServerTransformer;
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Illuminate\Http\Request;
|
||||
use Dingo\Api\Exception\ResourceException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
|
@ -42,14 +40,13 @@ use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
|||
*/
|
||||
class ServerController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* List All Servers
|
||||
* List All Servers.
|
||||
*
|
||||
* Lists all servers currently on the system.
|
||||
*
|
||||
|
@ -66,7 +63,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Create Server
|
||||
* Create Server.
|
||||
*
|
||||
* @Post("/servers")
|
||||
* @Versions({"v1"})
|
||||
|
@ -77,6 +74,7 @@ class ServerController extends BaseController
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$new = $server->create($request->all());
|
||||
|
||||
return ['id' => $new];
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
|
@ -89,7 +87,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* List Specific Server
|
||||
* List Specific Server.
|
||||
*
|
||||
* Lists specific fields about a server or all fields pertaining to that server.
|
||||
*
|
||||
|
@ -126,8 +124,8 @@ class ServerController extends BaseController
|
|||
|
||||
$response = $client->request('GET', '/servers', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
]
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
]);
|
||||
|
||||
// Only return the daemon token if the request is using HTTPS
|
||||
|
@ -140,14 +138,14 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
return $server->toArray();
|
||||
|
||||
} catch (NotFoundHttpException $ex) {
|
||||
throw $ex;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
// Couldn't hit the daemon, return what we have though.
|
||||
$server->daemon = [
|
||||
'error' => 'There was an error encountered while attempting to connect to the remote daemon.'
|
||||
'error' => 'There was an error encountered while attempting to connect to the remote daemon.',
|
||||
];
|
||||
|
||||
return $server->toArray();
|
||||
} catch (\Exception $ex) {
|
||||
throw new BadRequestHttpException('There was an issue with the fields passed in the request.');
|
||||
|
@ -155,7 +153,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Update Server configuration
|
||||
* Update Server configuration.
|
||||
*
|
||||
* Updates display information on panel.
|
||||
*
|
||||
|
@ -179,6 +177,7 @@ class ServerController extends BaseController
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->updateDetails($id, $request->all());
|
||||
|
||||
return Models\Server::findOrFail($id);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
|
@ -190,7 +189,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Update Server Build Configuration
|
||||
* Update Server Build Configuration.
|
||||
*
|
||||
* Updates server build information on panel and on node.
|
||||
*
|
||||
|
@ -223,6 +222,7 @@ class ServerController extends BaseController
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->changeBuild($id, $request->all());
|
||||
|
||||
return Models\Server::findOrFail($id);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
|
@ -234,7 +234,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Suspend Server
|
||||
* Suspend Server.
|
||||
*
|
||||
* @Post("/servers/{id}/suspend")
|
||||
* @Versions({"v1"})
|
||||
|
@ -248,6 +248,7 @@ class ServerController extends BaseController
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->suspend($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
} catch (DisplayException $ex) {
|
||||
throw new ResourceException($ex->getMessage());
|
||||
|
@ -257,7 +258,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Unsuspend Server
|
||||
* Unsuspend Server.
|
||||
*
|
||||
* @Post("/servers/{id}/unsuspend")
|
||||
* @Versions({"v1"})
|
||||
|
@ -271,6 +272,7 @@ class ServerController extends BaseController
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->unsuspend($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
} catch (DisplayException $ex) {
|
||||
throw new ResourceException($ex->getMessage());
|
||||
|
@ -280,7 +282,7 @@ class ServerController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete Server
|
||||
* Delete Server.
|
||||
*
|
||||
* @Delete("/servers/{id}/{force}")
|
||||
* @Versions({"v1"})
|
||||
|
@ -295,6 +297,7 @@ class ServerController extends BaseController
|
|||
try {
|
||||
$server = new ServerRepository;
|
||||
$server->deleteServer($id, $force);
|
||||
|
||||
return $this->response->noContent();
|
||||
} catch (DisplayException $ex) {
|
||||
throw new ResourceException($ex->getMessage());
|
||||
|
@ -302,5 +305,4 @@ class ServerController extends BaseController
|
|||
throw new ServiceUnavailableHttpException('An error occured while attempting to delete this server.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Transformers\ServiceTransformer;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +33,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||
*/
|
||||
class ServiceController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -60,9 +57,7 @@ class ServiceController extends BaseController
|
|||
|
||||
return [
|
||||
'service' => $service,
|
||||
'options' => $options
|
||||
'options' => $options,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API\User;
|
||||
|
||||
use Auth;
|
||||
use Dingo;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Pterodactyl\Http\Controllers\API\BaseController;
|
||||
|
||||
class InfoController extends BaseController
|
||||
|
@ -45,11 +43,11 @@ class InfoController extends BaseController
|
|||
'node' => $server->nodeName,
|
||||
'ip' => [
|
||||
'set' => $server->ip,
|
||||
'alias' => $server->ip_alias
|
||||
'alias' => $server->ip_alias,
|
||||
],
|
||||
'port' => $server->port,
|
||||
'service' => $server->a_serviceName,
|
||||
'option' => $server->a_serviceOptionName
|
||||
'option' => $server->a_serviceOptionName,
|
||||
]]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,18 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API\User;
|
||||
|
||||
use Auth;
|
||||
use Log;
|
||||
use Auth;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Pterodactyl\Http\Controllers\API\BaseController;
|
||||
|
||||
class ServerController extends BaseController
|
||||
{
|
||||
|
||||
public function info(Request $request, $uuid)
|
||||
{
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
|
@ -43,19 +42,19 @@ class ServerController extends BaseController
|
|||
$response = $client->request('GET', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $server->daemonSecret,
|
||||
'X-Access-Server' => $server->uuid
|
||||
]
|
||||
'X-Access-Server' => $server->uuid,
|
||||
],
|
||||
]);
|
||||
|
||||
$json = json_decode($response->getBody());
|
||||
$daemon = [
|
||||
'status' => $json->status,
|
||||
'stats' => $json->proc,
|
||||
'query' => $json->query
|
||||
'query' => $json->query,
|
||||
];
|
||||
} catch (\Exception $ex) {
|
||||
$daemon = [
|
||||
'error' => 'An error was encountered while trying to connect to the daemon to collece information. It might be offline.'
|
||||
'error' => 'An error was encountered while trying to connect to the daemon to collece information. It might be offline.',
|
||||
];
|
||||
Log::error($ex);
|
||||
}
|
||||
|
@ -65,6 +64,7 @@ class ServerController extends BaseController
|
|||
$allocation->default = ($allocation->id === $server->allocation);
|
||||
unset($allocation->id);
|
||||
}
|
||||
|
||||
return [
|
||||
'uuidShort' => $server->uuidShort,
|
||||
'uuid' => $server->uuid,
|
||||
|
@ -76,16 +76,16 @@ class ServerController extends BaseController
|
|||
'disk' => $server->disk,
|
||||
'io' => $server->io,
|
||||
'cpu' => $server->cpu,
|
||||
'oom_disabled' => (bool) $server->oom_disabled
|
||||
'oom_disabled' => (bool) $server->oom_disabled,
|
||||
],
|
||||
'allocations' => $allocations,
|
||||
'sftp' => [
|
||||
'username' => (Auth::user()->can('view-sftp', $server)) ? $server->username : null
|
||||
'username' => (Auth::user()->can('view-sftp', $server)) ? $server->username : null,
|
||||
],
|
||||
'daemon' => [
|
||||
'token' => ($request->secure()) ? $server->daemonSecret : false,
|
||||
'response' => $daemon
|
||||
]
|
||||
'response' => $daemon,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -100,12 +100,12 @@ class ServerController extends BaseController
|
|||
$res = $client->request('PUT', '/server/power', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $server->daemonSecret
|
||||
'X-Access-Token' => $server->daemonSecret,
|
||||
],
|
||||
'exceptions' => false,
|
||||
'json' => [
|
||||
'action' => $request->input('action')
|
||||
]
|
||||
'action' => $request->input('action'),
|
||||
],
|
||||
]);
|
||||
|
||||
if ($res->getStatusCode() !== 204) {
|
||||
|
|
|
@ -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,18 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Dingo\Api\Exception\ResourceException;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Transformers\UserTransformer;
|
||||
use Pterodactyl\Repositories\UserRepository;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Illuminate\Http\Request;
|
||||
use Dingo\Api\Exception\ResourceException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Repositories\UserRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
|
@ -42,14 +39,12 @@ use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
|||
*/
|
||||
class UserController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* List All Users
|
||||
* List All Users.
|
||||
*
|
||||
* Lists all users currently on the system.
|
||||
*
|
||||
|
@ -66,7 +61,7 @@ class UserController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* List Specific User
|
||||
* List Specific User.
|
||||
*
|
||||
* Lists specific fields about a user or all fields pertaining to that user.
|
||||
*
|
||||
|
@ -105,11 +100,10 @@ class UserController extends BaseController
|
|||
} catch (\Exception $ex) {
|
||||
throw new BadRequestHttpException('There was an issue with the fields passed in the request.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a New User
|
||||
* Create a New User.
|
||||
*
|
||||
* @Post("/users")
|
||||
* @Versions({"v1"})
|
||||
|
@ -129,6 +123,7 @@ class UserController extends BaseController
|
|||
try {
|
||||
$user = new UserRepository;
|
||||
$create = $user->create($request->input('email'), $request->input('password'), $request->input('admin'), $request->input('custom_id'));
|
||||
|
||||
return ['id' => $create];
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
|
@ -140,7 +135,7 @@ class UserController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Update an Existing User
|
||||
* Update an Existing User.
|
||||
*
|
||||
* The data sent in the request will be used to update the existing user on the system.
|
||||
*
|
||||
|
@ -162,6 +157,7 @@ class UserController extends BaseController
|
|||
try {
|
||||
$user = new UserRepository;
|
||||
$user->update($id, $request->all());
|
||||
|
||||
return Models\User::findOrFail($id);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
|
@ -173,7 +169,7 @@ class UserController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a User
|
||||
* Delete a User.
|
||||
*
|
||||
* @Delete("/users/{id}")
|
||||
* @Versions({"v1"})
|
||||
|
@ -191,6 +187,7 @@ class UserController extends BaseController
|
|||
try {
|
||||
$user = new UserRepository;
|
||||
$user->delete($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
} catch (DisplayException $ex) {
|
||||
throw new ResourceException($ex->getMessage());
|
||||
|
@ -198,5 +195,4 @@ class UserController extends BaseController
|
|||
throw new ServiceUnavailableHttpException('Unable to delete this user due to an error.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -64,17 +61,18 @@ class LocationsController extends Controller
|
|||
|
||||
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()
|
||||
{
|
||||
|
@ -68,11 +65,12 @@ class NodesController extends Controller
|
|||
{
|
||||
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,15 +169,17 @@ 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',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -198,21 +203,21 @@ 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();
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -162,28 +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->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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,15 +191,13 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerGetNodes(Request $request)
|
||||
{
|
||||
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,10 +208,9 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerGetIps(Request $request)
|
||||
{
|
||||
|
||||
if (! $request->input('node')) {
|
||||
return response()->json([
|
||||
'error' => 'Missing node in request.'
|
||||
'error' => 'Missing node in request.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
|
@ -230,8 +224,8 @@ class ServersController extends Controller
|
|||
$listing[$ip->ip] = [$ip->port];
|
||||
}
|
||||
}
|
||||
return response()->json($listing);
|
||||
|
||||
return response()->json($listing);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,16 +236,15 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerServiceOptions(Request $request)
|
||||
{
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,10 +255,9 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function postNewServerServiceVariables(Request $request)
|
||||
{
|
||||
|
||||
if (! $request->input('option')) {
|
||||
return response()->json([
|
||||
'error' => 'Missing option in request.'
|
||||
'error' => 'Missing option in request.',
|
||||
], 500);
|
||||
}
|
||||
|
||||
|
@ -279,28 +271,25 @@ class ServersController extends Controller
|
|||
return response()->json([
|
||||
'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 +300,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 +326,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 +340,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 +351,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 +372,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 +388,7 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_build'
|
||||
'tab' => 'tab_build',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -407,6 +398,7 @@ 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();
|
||||
|
@ -414,9 +406,10 @@ class ServersController extends Controller
|
|||
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',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -434,7 +427,7 @@ class ServersController extends Controller
|
|||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -444,7 +437,7 @@ 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) {
|
||||
|
@ -455,7 +448,7 @@ class ServersController extends Controller
|
|||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_startup'
|
||||
'tab' => 'tab_startup',
|
||||
])->withInput();
|
||||
}
|
||||
}
|
||||
|
@ -465,13 +458,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 +473,7 @@ class ServersController extends Controller
|
|||
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_database'
|
||||
'tab' => 'tab_database',
|
||||
])->withInput();
|
||||
}
|
||||
|
||||
|
@ -498,7 +491,7 @@ class ServersController extends Controller
|
|||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +510,7 @@ class ServersController extends Controller
|
|||
} finally {
|
||||
return redirect()->route('admin.servers.view', [
|
||||
'id' => $id,
|
||||
'tab' => 'tab_manage'
|
||||
'tab' => 'tab_manage',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -529,24 +522,28 @@ class ServersController extends Controller
|
|||
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);
|
||||
} elseif (! is_null($request->input('delete'))) {
|
||||
$repo->deleteNow($id);
|
||||
Alert::success('Server was successfully deleted from the system.')->flash();
|
||||
|
||||
return redirect()->route('admin.servers');
|
||||
} 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,24 +21,21 @@
|
|||
* 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 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()
|
||||
{
|
||||
//
|
||||
|
@ -50,7 +47,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(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -64,9 +61,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();
|
||||
|
@ -76,6 +74,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();
|
||||
}
|
||||
|
||||
|
@ -86,7 +85,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(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -95,7 +94,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) {
|
||||
|
@ -106,6 +105,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();
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,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();
|
||||
|
@ -122,12 +123,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,
|
||||
|
@ -135,7 +138,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),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -144,7 +147,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) {
|
||||
|
@ -153,6 +156,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();
|
||||
}
|
||||
|
||||
|
@ -164,6 +168,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();
|
||||
|
@ -171,6 +176,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]);
|
||||
}
|
||||
|
||||
|
@ -184,7 +190,7 @@ 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;
|
||||
|
@ -196,6 +202,7 @@ class ServiceController extends Controller
|
|||
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();
|
||||
|
@ -203,6 +210,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();
|
||||
}
|
||||
|
||||
|
@ -210,7 +218,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(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -219,9 +227,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();
|
||||
|
@ -231,6 +240,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();
|
||||
}
|
||||
|
||||
|
@ -246,9 +256,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();
|
||||
|
@ -256,6 +267,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();
|
||||
}
|
||||
|
||||
|
@ -271,7 +283,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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
@ -63,7 +59,7 @@ class UserController extends Controller
|
|||
$query->where('email', 'LIKE', '%' . $match . '%');
|
||||
$query->orWhere([
|
||||
['uuid', 'LIKE', '%' . $match . '%'],
|
||||
['root_admin', 'LIKE', '%' . $match . '%']
|
||||
['root_admin', 'LIKE', '%' . $match . '%'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +73,7 @@ class UserController extends Controller
|
|||
}
|
||||
|
||||
return view('admin.users.index', [
|
||||
'users' => $users
|
||||
'users' => $users,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -104,6 +100,7 @@ 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) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -111,6 +108,7 @@ class UserController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An exception was encountered while attempting to delete this user.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.users.view', $id);
|
||||
}
|
||||
|
||||
|
@ -120,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');
|
||||
}
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -160,7 +161,7 @@ class UserController extends Controller
|
|||
foreach (User::select('email')->get() as $user) {
|
||||
$resp[] = $user->email;
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,20 +22,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
namespace Pterodactyl\Http\Controllers\Auth;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
namespace Pterodactyl\Http\Controllers\Auth;
|
||||
|
||||
use Auth;
|
||||
use Alert;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
|
@ -62,14 +57,14 @@ class LoginController extends Controller
|
|||
/**
|
||||
* Lockout time for failed login requests.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $lockoutTime = 120;
|
||||
|
||||
/**
|
||||
* After how many attempts should logins be throttled and locked.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $maxLoginAttempts = 3;
|
||||
|
||||
|
@ -91,7 +86,6 @@ class LoginController extends Controller
|
|||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
|
@ -99,42 +93,40 @@ class LoginController extends Controller
|
|||
|
||||
if ($lockedOut = $this->hasTooManyLoginAttempts($request)) {
|
||||
$this->fireLockoutEvent($request);
|
||||
|
||||
return $this->sendLockoutResponse($request);
|
||||
}
|
||||
|
||||
// Is the email & password valid?
|
||||
if (! Auth::once([
|
||||
'email' => $request->input('email'),
|
||||
'password' => $request->input('password')
|
||||
'password' => $request->input('password'),
|
||||
], $request->has('remember'))) {
|
||||
|
||||
if (! $lockedOut) {
|
||||
$this->incrementLoginAttempts($request);
|
||||
}
|
||||
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
|
||||
}
|
||||
|
||||
// Verify TOTP Token was Valid
|
||||
if (Auth::user()->use_totp === 1) {
|
||||
$G2FA = new Google2FA();
|
||||
if (is_null($request->input('totp_token')) || ! $G2FA->verifyKey(Auth::user()->totp_secret, $request->input('totp_token'))) {
|
||||
|
||||
if (! $lockedOut) {
|
||||
$this->incrementLoginAttempts($request);
|
||||
}
|
||||
|
||||
Alert::danger(trans('auth.totp_failed'))->flash();
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
}
|
||||
}
|
||||
|
||||
// Successfully Authenticated.
|
||||
Auth::login(Auth::user(), $request->has('remember'));
|
||||
return $this->sendLoginResponse($request);
|
||||
|
||||
return $this->sendLoginResponse($request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,5 +139,4 @@ class LoginController extends Controller
|
|||
{
|
||||
return response()->json(User::select('id')->where('email', $request->input('email'))->where('use_totp', 1)->first());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Auth;
|
||||
|
||||
use Pterodactyl\User;
|
||||
use Validator;
|
||||
use Pterodactyl\User;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ class ResetPasswordController extends Controller
|
|||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
|
||||
protected function rules() {
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'token' => 'required', 'email' => 'required|email',
|
||||
'password' => 'required|confirmed|' . User::PASSWORD_RULES,
|
||||
|
|
|
@ -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,19 +22,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Alert;
|
||||
use Log;
|
||||
|
||||
use Alert;
|
||||
use Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Repositories\APIRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class APIController extends Controller
|
||||
{
|
||||
|
@ -46,7 +44,7 @@ class APIController extends Controller
|
|||
}
|
||||
|
||||
return view('base.api.index', [
|
||||
'keys' => $keys
|
||||
'keys' => $keys,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -61,6 +59,7 @@ class APIController extends Controller
|
|||
$repo = new APIRepository($request->user());
|
||||
$secret = $repo->new($request->except(['_token']));
|
||||
Alert::success('An API Keypair has successfully been generated. The API secret for this public key is shown below and will not be shown again.<br /><br /><code>' . $secret . '</code>')->flash();
|
||||
|
||||
return redirect()->route('account.api');
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('account.api.new')->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -70,6 +69,7 @@ class APIController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attempting to add this API key.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('account.api.new')->withInput();
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,11 @@ class APIController extends Controller
|
|||
try {
|
||||
$repo = new APIRepository($request->user());
|
||||
$repo->revoke($key);
|
||||
|
||||
return response('', 204);
|
||||
} catch (\Exception $ex) {
|
||||
return response()->json([
|
||||
'error' => 'An error occured while attempting to remove this key.'
|
||||
'error' => 'An error occured while attempting to remove this key.',
|
||||
], 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,16 +22,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Alert;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
/**
|
||||
|
@ -53,16 +52,16 @@ class AccountController extends Controller
|
|||
*/
|
||||
public function email(Request $request)
|
||||
{
|
||||
|
||||
$this->validate($request, [
|
||||
'new_email' => 'required|email',
|
||||
'password' => 'required'
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
if (! password_verify($request->input('password'), $user->password)) {
|
||||
Alert::danger('The password provided was not valid for this account.')->flash();
|
||||
|
||||
return redirect()->route('account');
|
||||
}
|
||||
|
||||
|
@ -70,8 +69,8 @@ class AccountController extends Controller
|
|||
$user->save();
|
||||
|
||||
Alert::success('Your email address has successfully been updated.')->flash();
|
||||
return redirect()->route('account');
|
||||
|
||||
return redirect()->route('account');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,17 +81,17 @@ class AccountController extends Controller
|
|||
*/
|
||||
public function password(Request $request)
|
||||
{
|
||||
|
||||
$this->validate($request, [
|
||||
'current_password' => 'required',
|
||||
'new_password' => 'required|confirmed|different:current_password|' . User::PASSWORD_RULES,
|
||||
'new_password_confirmation' => 'required'
|
||||
'new_password_confirmation' => 'required',
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
if (! password_verify($request->input('current_password'), $user->password)) {
|
||||
Alert::danger('The password provided was not valid for this account.')->flash();
|
||||
|
||||
return redirect()->route('account');
|
||||
}
|
||||
|
||||
|
@ -104,6 +103,5 @@ class AccountController extends Controller
|
|||
}
|
||||
|
||||
return redirect()->route('account');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,18 +22,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -73,5 +72,4 @@ class IndexController extends Controller
|
|||
|
||||
return $generated;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,18 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Auth;
|
||||
use Session;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
class LanguageController extends Controller
|
||||
{
|
||||
|
||||
protected $languages = [
|
||||
'de' => 'Danish',
|
||||
'en' => 'English',
|
||||
|
@ -47,7 +46,7 @@ class LanguageController extends Controller
|
|||
];
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -64,7 +63,7 @@ class LanguageController extends Controller
|
|||
}
|
||||
Session::set('applocale', $language);
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,19 +22,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Google2FA;
|
||||
use Alert;
|
||||
|
||||
use Google2FA;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Session;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SecurityController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns Security Management Page.
|
||||
*
|
||||
|
@ -44,7 +42,7 @@ class SecurityController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
return view('base.security', [
|
||||
'sessions' => Session::where('user_id', $request->user()->id)->get()
|
||||
'sessions' => Session::where('user_id', $request->user()->id)->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -57,7 +55,6 @@ class SecurityController extends Controller
|
|||
*/
|
||||
public function generateTotp(Request $request)
|
||||
{
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$user->totp_secret = Google2FA::generateSecretKey();
|
||||
|
@ -69,9 +66,8 @@ class SecurityController extends Controller
|
|||
$user->email,
|
||||
$user->totp_secret
|
||||
),
|
||||
'secret' => $user->totp_secret
|
||||
'secret' => $user->totp_secret,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +78,6 @@ class SecurityController extends Controller
|
|||
*/
|
||||
public function setTotp(Request $request)
|
||||
{
|
||||
|
||||
if (! $request->has('token')) {
|
||||
return response(null, 500);
|
||||
}
|
||||
|
@ -93,7 +88,6 @@ class SecurityController extends Controller
|
|||
}
|
||||
|
||||
return response('false');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,9 +98,9 @@ class SecurityController extends Controller
|
|||
*/
|
||||
public function disableTotp(Request $request)
|
||||
{
|
||||
|
||||
if (! $request->has('token')) {
|
||||
Alert::danger('Missing required `token` field in request.')->flash();
|
||||
|
||||
return redirect()->route('account.totp');
|
||||
}
|
||||
|
||||
|
@ -116,15 +110,15 @@ class SecurityController extends Controller
|
|||
}
|
||||
|
||||
Alert::danger('The TOTP token provided was invalid.')->flash();
|
||||
return redirect()->route('account.security');
|
||||
|
||||
return redirect()->route('account.security');
|
||||
}
|
||||
|
||||
public function revoke(Request $request, $id)
|
||||
{
|
||||
$session = Session::where('id', $id)->where('user_id', $request->user()->id)->firstOrFail();
|
||||
$session->delete();
|
||||
|
||||
return redirect()->route('account.security');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,38 +21,38 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Remote;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Services\NotificationService;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\NotificationService;
|
||||
|
||||
class RemoteController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// No middleware for this route.
|
||||
}
|
||||
|
||||
public function postDownload(Request $request) {
|
||||
public function postDownload(Request $request)
|
||||
{
|
||||
$download = Models\Download::where('token', $request->input('token', '00'))->first();
|
||||
if (! $download) {
|
||||
return response()->json([
|
||||
'error' => 'An invalid request token was recieved with this request.'
|
||||
'error' => 'An invalid request token was recieved with this request.',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$download->delete();
|
||||
|
||||
return response()->json([
|
||||
'path' => $download->path,
|
||||
'server' => $download->server
|
||||
'server' => $download->server,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class RemoteController extends Controller
|
|||
$server = Models\Server::where('uuid', $request->input('server'))->first();
|
||||
if (! $server) {
|
||||
return response()->json([
|
||||
'error' => 'No server by that ID was found on the system.'
|
||||
'error' => 'No server by that ID was found on the system.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class RemoteController extends Controller
|
|||
|
||||
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) {
|
||||
return response()->json([
|
||||
'error' => 'Signed HMAC was invalid.'
|
||||
'error' => 'Signed HMAC was invalid.',
|
||||
], 403);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ class RemoteController extends Controller
|
|||
$server->save();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Recieved!'
|
||||
'message' => 'Recieved!',
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class RemoteController extends Controller
|
|||
$server = Models\Server::where('uuid', $request->input('server'))->first();
|
||||
if (! $server) {
|
||||
return response()->json([
|
||||
'error' => 'No server by that ID was found on the system.'
|
||||
'error' => 'No server by that ID was found on the system.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class RemoteController extends Controller
|
|||
$hmac = $request->input('signed');
|
||||
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) {
|
||||
return response()->json([
|
||||
'error' => 'Signed HMAC was invalid.'
|
||||
'error' => 'Signed HMAC was invalid.',
|
||||
], 403);
|
||||
}
|
||||
|
||||
|
@ -107,5 +107,4 @@ class RemoteController extends Controller
|
|||
|
||||
return response('', 201);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,24 +21,20 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Server;
|
||||
|
||||
use Log;
|
||||
use Pterodactyl\Models;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Repositories;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Pterodactyl\Repositories;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class AjaxController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -55,7 +51,7 @@ class AjaxController extends Controller
|
|||
protected $directory;
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -81,7 +77,7 @@ class AjaxController extends Controller
|
|||
|
||||
try {
|
||||
$res = $client->request('GET', '/server', [
|
||||
'headers' => Models\Server::getGuzzleHeaders($uuid)
|
||||
'headers' => Models\Server::getGuzzleHeaders($uuid),
|
||||
]);
|
||||
if ($res->getStatusCode() === 200) {
|
||||
return response()->json(json_decode($res->getBody()));
|
||||
|
@ -89,6 +85,7 @@ class AjaxController extends Controller
|
|||
} catch (RequestException $e) {
|
||||
//
|
||||
}
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
|
@ -101,13 +98,12 @@ class AjaxController extends Controller
|
|||
*/
|
||||
public function postDirectoryList(Request $request, $uuid)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->directory = '/' . trim(urldecode($request->input('directory', '/')), '/');
|
||||
$this->authorize('list-files', $server);
|
||||
|
||||
$prevDir = [
|
||||
'header' => ($this->directory !== '/') ? $this->directory : ''
|
||||
'header' => ($this->directory !== '/') ? $this->directory : '',
|
||||
];
|
||||
if ($this->directory !== '/') {
|
||||
$prevDir['first'] = true;
|
||||
|
@ -131,6 +127,7 @@ class AjaxController extends Controller
|
|||
return response($ex->getMessage(), 500);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response('An error occured while attempting to load the requested directory, please try again.', 500);
|
||||
}
|
||||
|
||||
|
@ -139,9 +136,8 @@ class AjaxController extends Controller
|
|||
'files' => $directoryContents->files,
|
||||
'folders' => $directoryContents->folders,
|
||||
'editableMime' => Repositories\HelperRepository::editableFiles(),
|
||||
'directory' => $prevDir
|
||||
'directory' => $prevDir,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,7 +149,6 @@ class AjaxController extends Controller
|
|||
*/
|
||||
public function postSaveFile(Request $request, $uuid)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->authorize('save-files', $server);
|
||||
|
||||
|
@ -161,31 +156,31 @@ class AjaxController extends Controller
|
|||
|
||||
try {
|
||||
$controller->saveFileContents($request->input('file'), $request->input('contents'));
|
||||
|
||||
return response(null, 204);
|
||||
} catch (DisplayException $ex) {
|
||||
return response($ex->getMessage(), 500);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response('An error occured while attempting to save this file, please try again.', 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* [postSetPrimary description]
|
||||
* [postSetPrimary description].
|
||||
* @param Request $request
|
||||
* @param string $uuid
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postSetPrimary(Request $request, $uuid)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->authorize('set-connection', $server);
|
||||
|
||||
if ((int) $request->input('allocation') === $server->allocation) {
|
||||
return response()->json([
|
||||
'error' => 'You are already using this as your default connection.'
|
||||
'error' => 'You are already using this as your default connection.',
|
||||
], 409);
|
||||
}
|
||||
|
||||
|
@ -193,7 +188,7 @@ class AjaxController extends Controller
|
|||
$allocation = Models\Allocation::where('id', $request->input('allocation'))->where('assigned_to', $server->id)->first();
|
||||
if (! $allocation) {
|
||||
return response()->json([
|
||||
'error' => 'No allocation matching your request was found in the system.'
|
||||
'error' => 'No allocation matching your request was found in the system.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
|
@ -201,6 +196,7 @@ class AjaxController extends Controller
|
|||
$repo->changeBuild($server->id, [
|
||||
'default' => $allocation->ip . ':' . $allocation->port,
|
||||
]);
|
||||
|
||||
return response('The default connection for this server has been updated. Please be aware that you will need to restart your server for this change to go into effect.');
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return response()->json([
|
||||
|
@ -212,8 +208,9 @@ class AjaxController extends Controller
|
|||
], 503);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response()->json([
|
||||
'error' => 'An unhandled exception occured while attemping to modify the default connection for this server.'
|
||||
'error' => 'An unhandled exception occured while attemping to modify the default connection for this server.',
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
@ -225,10 +222,10 @@ class AjaxController extends Controller
|
|||
|
||||
$this->authorize('reset-db-password', $server);
|
||||
try {
|
||||
|
||||
$repo = new Repositories\DatabaseRepository;
|
||||
$password = str_random(16);
|
||||
$repo->modifyPassword($request->input('database'), $password);
|
||||
|
||||
return response($password);
|
||||
} catch (\Pterodactyl\Exceptions\DisplayException $ex) {
|
||||
return response()->json([
|
||||
|
@ -236,10 +233,10 @@ class AjaxController extends Controller
|
|||
], 503);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response()->json([
|
||||
'error' => 'An unhandled error occured while attempting to modify this database\'s password.'
|
||||
'error' => 'An unhandled error occured while attempting to modify this database\'s password.',
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,30 +21,26 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Server;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use Log;
|
||||
use Uuid;
|
||||
use Alert;
|
||||
use Log;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Repositories\Daemon\FileRepository;
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
use Pterodactyl\Repositories\Daemon\FileRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -62,7 +58,7 @@ class ServerController extends Controller
|
|||
try {
|
||||
return response()->view('server.js.' . $folder . '.' . $routeFile, [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::find($server->node)
|
||||
'node' => Models\Node::find($server->node),
|
||||
])->header('Content-Type', 'application/javascript');
|
||||
} catch (InvalidArgumentException $ex) {
|
||||
return abort(404);
|
||||
|
@ -80,10 +76,11 @@ class ServerController extends Controller
|
|||
public function getIndex(Request $request)
|
||||
{
|
||||
$server = Models\Server::getByUUID($request->route()->server);
|
||||
|
||||
return view('server.index', [
|
||||
'server' => $server,
|
||||
'allocations' => Models\Allocation::where('assigned_to', $server->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(),
|
||||
'node' => Models\Node::find($server->node)
|
||||
'node' => Models\Node::find($server->node),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -95,13 +92,12 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function getFiles(Request $request)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($request->route()->server);
|
||||
$this->authorize('list-files', $server);
|
||||
|
||||
return view('server.files.index', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::find($server->node)
|
||||
'node' => Models\Node::find($server->node),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -113,14 +109,13 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function getAddFile(Request $request)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($request->route()->server);
|
||||
$this->authorize('add-files', $server);
|
||||
|
||||
return view('server.files.add', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::find($server->node),
|
||||
'directory' => (in_array($request->get('dir'), [null, '/', ''])) ? '' : trim($request->get('dir'), '/') . '/'
|
||||
'directory' => (in_array($request->get('dir'), [null, '/', ''])) ? '' : trim($request->get('dir'), '/') . '/',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -134,7 +129,6 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function getEditFile(Request $request, $uuid, $file)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->authorize('edit-files', $server);
|
||||
|
||||
|
@ -145,10 +139,12 @@ class ServerController extends Controller
|
|||
$fileContent = $controller->returnFileContents($file);
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
||||
return redirect()->route('server.files.index', $uuid);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An error occured while attempting to load the requested file for editing, please try again.')->flash();
|
||||
|
||||
return redirect()->route('server.files.index', $uuid);
|
||||
}
|
||||
|
||||
|
@ -158,9 +154,8 @@ class ServerController extends Controller
|
|||
'file' => $file,
|
||||
'stat' => $fileContent['stat'],
|
||||
'contents' => $fileContent['file']->content,
|
||||
'directory' => (in_array($fileInfo->dirname, ['.', './', '/'])) ? '/' : trim($fileInfo->dirname, '/') . '/'
|
||||
'directory' => (in_array($fileInfo->dirname, ['.', './', '/'])) ? '/' : trim($fileInfo->dirname, '/') . '/',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +168,6 @@ class ServerController extends Controller
|
|||
*/
|
||||
public function getDownloadFile(Request $request, $uuid, $file)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$node = Models\Node::find($server->node);
|
||||
|
||||
|
@ -188,7 +182,6 @@ class ServerController extends Controller
|
|||
$download->save();
|
||||
|
||||
return redirect($node->scheme . '://' . $node->fqdn . ':' . $node->daemonListen . '/server/file/download/' . $download->token);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,6 +252,7 @@ class ServerController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to update this server\'s SFTP settings.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('server.settings', $uuid);
|
||||
}
|
||||
|
||||
|
@ -270,7 +264,7 @@ class ServerController extends Controller
|
|||
try {
|
||||
$repo = new ServerRepository;
|
||||
$repo->updateStartup($server->id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Server startup variables were successfully updated.')->flash();
|
||||
} catch (DisplayException $ex) {
|
||||
|
@ -279,10 +273,10 @@ class ServerController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attemping to update startup variables for this server. Please try again.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('server.settings', [
|
||||
'uuid' => $uuid,
|
||||
'tab' => 'tab_startup'
|
||||
'tab' => 'tab_startup',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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\Server;
|
||||
|
||||
use DB;
|
||||
use Log;
|
||||
use Auth;
|
||||
use Alert;
|
||||
use Log;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\SubuserRepository;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\SubuserRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class SubuserController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -61,9 +58,8 @@ class SubuserController extends Controller
|
|||
'subusers' => Models\Subuser::select('subusers.*', 'users.email as a_userEmail')
|
||||
->join('users', 'users.id', '=', 'subusers.user_id')
|
||||
->where('server_id', $server->id)
|
||||
->get()
|
||||
->get(),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function getView(Request $request, $uuid, $id)
|
||||
|
@ -99,14 +95,12 @@ class SubuserController extends Controller
|
|||
|
||||
public function postView(Request $request, $uuid, $id)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->authorize('edit-subuser', $server);
|
||||
|
||||
$subuser = Models\Subuser::where(DB::raw('md5(id)'), $id)->where('server_id', $server->id)->first();
|
||||
|
||||
try {
|
||||
|
||||
if (! $subuser) {
|
||||
throw new DisplayException('Unable to locate a subuser by that ID.');
|
||||
} elseif ($subuser->user_id === Auth::user()->id) {
|
||||
|
@ -117,14 +111,14 @@ class SubuserController extends Controller
|
|||
$repo->update($subuser->id, [
|
||||
'permissions' => $request->input('permissions'),
|
||||
'server' => $server->id,
|
||||
'user' => $subuser->user_id
|
||||
'user' => $subuser->user_id,
|
||||
]);
|
||||
|
||||
Alert::success('Subuser permissions have successfully been updated.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('server.subusers.view', [
|
||||
'uuid' => $uuid,
|
||||
'id' => $id
|
||||
'id' => $id,
|
||||
])->withErrors(json_decode($ex->getMessage()));
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -132,9 +126,10 @@ class SubuserController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to update this subuser.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('server.subusers.view', [
|
||||
'uuid' => $uuid,
|
||||
'id' => $id
|
||||
'id' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -145,7 +140,7 @@ class SubuserController extends Controller
|
|||
|
||||
return view('server.users.new', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::find($server->node)
|
||||
'node' => Models\Node::find($server->node),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -157,12 +152,13 @@ class SubuserController extends Controller
|
|||
try {
|
||||
$repo = new SubuserRepository;
|
||||
$id = $repo->create($server->id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully created new subuser.')->flash();
|
||||
|
||||
return redirect()->route('server.subusers.view', [
|
||||
'uuid' => $uuid,
|
||||
'id' => md5($id)
|
||||
'id' => md5($id),
|
||||
]);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('server.subusers.new', $uuid)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -172,6 +168,7 @@ class SubuserController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to add a new subuser.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('server.subusers.new', $uuid)->withInput();
|
||||
}
|
||||
|
||||
|
@ -188,17 +185,17 @@ class SubuserController extends Controller
|
|||
|
||||
$repo = new SubuserRepository;
|
||||
$repo->delete($subuser->id);
|
||||
|
||||
return response('', 204);
|
||||
} catch (DisplayException $ex) {
|
||||
response()->json([
|
||||
'error' => $ex->getMessage()
|
||||
'error' => $ex->getMessage(),
|
||||
], 422);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
response()->json([
|
||||
'error' => 'An unknown error occured while attempting to delete this subuser.'
|
||||
'error' => 'An unknown error occured while attempting to delete this subuser.',
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,19 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Server;
|
||||
|
||||
use Alert;
|
||||
use Log;
|
||||
use Cron;
|
||||
|
||||
use Pterodactyl\Repositories;
|
||||
use Alert;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Repositories;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class TaskController extends Controller
|
||||
{
|
||||
|
@ -53,8 +51,8 @@ class TaskController extends Controller
|
|||
'tasks' => Models\Task::where('server', $server->id)->get(),
|
||||
'actions' => [
|
||||
'command' => 'Send Command',
|
||||
'power' => 'Set Power Status'
|
||||
]
|
||||
'power' => 'Set Power Status',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -65,7 +63,7 @@ class TaskController extends Controller
|
|||
|
||||
return view('server.tasks.new', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::findOrFail($server->node)
|
||||
'node' => Models\Node::findOrFail($server->node),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -77,7 +75,7 @@ class TaskController extends Controller
|
|||
try {
|
||||
$repo = new Repositories\TaskRepository;
|
||||
$repo->create($server->id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('server.tasks', $uuid)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -87,8 +85,8 @@ class TaskController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to create this task.')->flash();
|
||||
}
|
||||
return redirect()->route('server.tasks', $uuid);
|
||||
|
||||
return redirect()->route('server.tasks', $uuid);
|
||||
}
|
||||
|
||||
public function getView(Request $request, $uuid, $id)
|
||||
|
@ -99,7 +97,7 @@ class TaskController extends Controller
|
|||
return view('server.tasks.view', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::findOrFail($server->node),
|
||||
'task' => Models\Task::where('id', $id)->where('server', $server->id)->firstOrFail()
|
||||
'task' => Models\Task::where('id', $id)->where('server', $server->id)->firstOrFail(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -112,18 +110,20 @@ class TaskController extends Controller
|
|||
|
||||
if (! $task || $server->id !== $task->server) {
|
||||
return response()->json([
|
||||
'error' => 'No task by that ID was found associated with this server.'
|
||||
'error' => 'No task by that ID was found associated with this server.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
try {
|
||||
$repo = new Repositories\TaskRepository;
|
||||
$repo->delete($id);
|
||||
|
||||
return response()->json([], 204);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response()->json([
|
||||
'error' => 'A server error occured while attempting to delete this task.'
|
||||
'error' => 'A server error occured while attempting to delete this task.',
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
@ -137,20 +137,22 @@ class TaskController extends Controller
|
|||
|
||||
if (! $task || $server->id !== $task->server) {
|
||||
return response()->json([
|
||||
'error' => 'No task by that ID was found associated with this server.'
|
||||
'error' => 'No task by that ID was found associated with this server.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
try {
|
||||
$repo = new Repositories\TaskRepository;
|
||||
$resp = $repo->toggle($id);
|
||||
|
||||
return response()->json([
|
||||
'status' => $resp
|
||||
'status' => $resp,
|
||||
]);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
|
||||
return response()->json([
|
||||
'error' => 'A server error occured while attempting to toggle this task.'
|
||||
'error' => 'A server error occured while attempting to toggle this task.',
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Auth;
|
||||
|
@ -28,24 +29,20 @@ use Crypt;
|
|||
use Config;
|
||||
use IPTools\IP;
|
||||
use IPTools\Range;
|
||||
|
||||
use Dingo\Api\Routing\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\APIKey;
|
||||
use Pterodactyl\Models\APIPermission;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Services\APILogService;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Dingo\Api\Routing\Route;
|
||||
use Dingo\Api\Auth\Provider\Authorization;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; // 400
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; // 401
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException; // 400
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; // 401
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; // 403
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException; //500
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; //500
|
||||
|
||||
class APISecretToken extends Authorization
|
||||
{
|
||||
|
||||
protected $algo = 'sha256';
|
||||
|
||||
protected $permissionAllowed = false;
|
||||
|
@ -123,14 +120,14 @@ class APISecretToken extends Authorization
|
|||
|
||||
// Log the Route Access
|
||||
APILogService::log($request, null, true);
|
||||
return Auth::loginUsingId($key->user);
|
||||
|
||||
return Auth::loginUsingId($key->user);
|
||||
}
|
||||
|
||||
protected function _generateHMAC($body, $key)
|
||||
{
|
||||
$data = $this->url . $body;
|
||||
|
||||
return hash_hmac($this->algo, $data, $key, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
|
|
@ -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,12 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
use Closure;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Debugbar;
|
||||
|
||||
class CheckServer
|
||||
{
|
||||
|
@ -39,7 +39,6 @@ class CheckServer
|
|||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
if (! Auth::user()) {
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
|
@ -58,6 +57,5 @@ class CheckServer
|
|||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,18 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Auth;
|
||||
use Closure;
|
||||
use Session;
|
||||
use Settings;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class LanguageMiddleware
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -55,6 +54,7 @@ class LanguageMiddleware
|
|||
} else {
|
||||
App::setLocale(Settings::get('default_language', 'en'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ class VerifyCsrfToken extends BaseVerifier
|
|||
*/
|
||||
protected $except = [
|
||||
'remote/*',
|
||||
'api/*'
|
||||
'api/*',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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,167 +21,164 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class APIRoutes
|
||||
{
|
||||
|
||||
public function map(Router $router) {
|
||||
|
||||
public function map(Router $router)
|
||||
{
|
||||
$api = app('Dingo\Api\Routing\Router');
|
||||
$api->version('v1', ['prefix' => 'api/me', 'middleware' => 'api.auth'], function ($api) {
|
||||
$api->get('/', [
|
||||
'as' => 'api.user.me',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\User\InfoController@me'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\User\InfoController@me',
|
||||
]);
|
||||
|
||||
$api->get('/server/{uuid}', [
|
||||
'as' => 'api.user.server',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\User\ServerController@info'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\User\ServerController@info',
|
||||
]);
|
||||
|
||||
$api->put('/server/{uuid}', [
|
||||
'as' => 'api.user.server.power',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\User\ServerController@power'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\User\ServerController@power',
|
||||
]);
|
||||
});
|
||||
|
||||
$api->version('v1', ['prefix' => 'api', 'middleware' => 'api.auth'], function ($api) {
|
||||
|
||||
/**
|
||||
/*
|
||||
* User Routes
|
||||
*/
|
||||
$api->get('users', [
|
||||
'as' => 'api.admin.users.list',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@list'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@list',
|
||||
]);
|
||||
|
||||
$api->post('users', [
|
||||
'as' => 'api.admin.users.create',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@create'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@create',
|
||||
]);
|
||||
|
||||
$api->get('users/{id}', [
|
||||
'as' => 'api.admin.users.view',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@view'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@view',
|
||||
]);
|
||||
|
||||
$api->patch('users/{id}', [
|
||||
'as' => 'api.admin.users.update',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@update'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@update',
|
||||
]);
|
||||
|
||||
$api->delete('users/{id}', [
|
||||
'as' => 'api.admin.users.delete',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@delete'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\UserController@delete',
|
||||
]);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Server Routes
|
||||
*/
|
||||
$api->get('servers', [
|
||||
'as' => 'api.admin.servers.list',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@list'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@list',
|
||||
]);
|
||||
|
||||
$api->post('servers', [
|
||||
'as' => 'api.admin.servers.create',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@create'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@create',
|
||||
]);
|
||||
|
||||
$api->get('servers/{id}', [
|
||||
'as' => 'api.admin.servers.view',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@view'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@view',
|
||||
]);
|
||||
|
||||
$api->patch('servers/{id}/config', [
|
||||
'as' => 'api.admin.servers.config',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@config'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@config',
|
||||
]);
|
||||
|
||||
$api->patch('servers/{id}/build', [
|
||||
'as' => 'api.admin.servers.build',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@build'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@build',
|
||||
]);
|
||||
|
||||
$api->post('servers/{id}/suspend', [
|
||||
'as' => 'api.admin.servers.suspend',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@suspend'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@suspend',
|
||||
]);
|
||||
|
||||
$api->post('servers/{id}/unsuspend', [
|
||||
'as' => 'api.admin.servers.unsuspend',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@unsuspend'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@unsuspend',
|
||||
]);
|
||||
|
||||
$api->delete('servers/{id}/{force?}', [
|
||||
'as' => 'api.admin.servers.delete',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@delete'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServerController@delete',
|
||||
]);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Node Routes
|
||||
*/
|
||||
$api->get('nodes', [
|
||||
'as' => 'api.admin.nodes.list',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@list'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@list',
|
||||
]);
|
||||
|
||||
$api->post('nodes', [
|
||||
'as' => 'api.admin.nodes.create',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@create'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@create',
|
||||
]);
|
||||
|
||||
$api->get('nodes/allocations', [
|
||||
'as' => 'api.admin.nodes.allocations',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@allocations'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@allocations',
|
||||
]);
|
||||
|
||||
$api->get('nodes/allocations/{id}', [
|
||||
'as' => 'api.admin.nodes.allocations',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@allocationsView'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@allocationsView',
|
||||
]);
|
||||
|
||||
$api->get('nodes/{id}', [
|
||||
'as' => 'api.admin.nodes.view',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@view'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@view',
|
||||
]);
|
||||
|
||||
$api->get('nodes/{id}/config', [
|
||||
'as' => 'api.admin.nodes.view',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@config'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@config',
|
||||
]);
|
||||
|
||||
$api->delete('nodes/{id}', [
|
||||
'as' => 'api.admin.nodes.delete',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@delete'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@delete',
|
||||
]);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Location Routes
|
||||
*/
|
||||
$api->get('locations', [
|
||||
'as' => 'api.admin.locations.list',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\LocationController@list'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\LocationController@list',
|
||||
]);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Service Routes
|
||||
*/
|
||||
$api->get('services', [
|
||||
'as' => 'api.admin.services.list',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServiceController@list'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServiceController@list',
|
||||
]);
|
||||
|
||||
$api->get('services/{id}', [
|
||||
'as' => 'api.admin.services.view',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServiceController@view'
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\ServiceController@view',
|
||||
]);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +22,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class AdminRoutes {
|
||||
|
||||
public function map(Router $router) {
|
||||
class AdminRoutes
|
||||
{
|
||||
public function map(Router $router)
|
||||
{
|
||||
|
||||
// Admin Index
|
||||
$router->get('admin', [
|
||||
|
@ -36,9 +38,9 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
'csrf',
|
||||
],
|
||||
'uses' => 'Admin\BaseController@getIndex'
|
||||
'uses' => 'Admin\BaseController@getIndex',
|
||||
]);
|
||||
|
||||
$router->group([
|
||||
|
@ -46,15 +48,15 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'admin.settings',
|
||||
'uses' => 'Admin\BaseController@getSettings'
|
||||
'uses' => 'Admin\BaseController@getSettings',
|
||||
]);
|
||||
$router->post('/', [
|
||||
'uses' => 'Admin\BaseController@postSettings'
|
||||
'uses' => 'Admin\BaseController@postSettings',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -63,48 +65,47 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
|
||||
// View All Accounts on System
|
||||
$router->get('/', [
|
||||
'as' => 'admin.users',
|
||||
'uses' => 'Admin\UserController@getIndex'
|
||||
'uses' => 'Admin\UserController@getIndex',
|
||||
]);
|
||||
|
||||
$router->get('/accounts.json', [
|
||||
'as' => 'admin.users.json',
|
||||
'uses' => 'Admin\UserController@getJson'
|
||||
'uses' => 'Admin\UserController@getJson',
|
||||
]);
|
||||
|
||||
// View Specific Account
|
||||
$router->get('/view/{id}', [
|
||||
'as' => 'admin.users.view',
|
||||
'uses' => 'Admin\UserController@getView'
|
||||
'uses' => 'Admin\UserController@getView',
|
||||
]);
|
||||
|
||||
// View Specific Account
|
||||
$router->post('/view/{id}', [
|
||||
'uses' => 'Admin\UserController@updateUser'
|
||||
'uses' => 'Admin\UserController@updateUser',
|
||||
]);
|
||||
|
||||
// Delete an Account Matching an ID
|
||||
$router->delete('/view/{id}', [
|
||||
'uses' => 'Admin\UserController@deleteUser'
|
||||
'uses' => 'Admin\UserController@deleteUser',
|
||||
]);
|
||||
|
||||
// Show Create Account Page
|
||||
$router->get('/new', [
|
||||
'as' => 'admin.users.new',
|
||||
'uses' => 'Admin\UserController@getNew'
|
||||
'uses' => 'Admin\UserController@getNew',
|
||||
]);
|
||||
|
||||
// Handle Creating New Account
|
||||
$router->post('/new', [
|
||||
'uses' => 'Admin\UserController@postNew'
|
||||
'uses' => 'Admin\UserController@postNew',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
// Server Routes
|
||||
|
@ -113,108 +114,107 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
|
||||
// View All Servers
|
||||
$router->get('/', [
|
||||
'as' => 'admin.servers',
|
||||
'uses' => 'Admin\ServersController@getIndex' ]);
|
||||
'uses' => 'Admin\ServersController@getIndex', ]);
|
||||
|
||||
// View Create Server Page
|
||||
$router->get('/new', [
|
||||
'as' => 'admin.servers.new',
|
||||
'uses' => 'Admin\ServersController@getNew'
|
||||
'uses' => 'Admin\ServersController@getNew',
|
||||
]);
|
||||
|
||||
// Handle POST Request for Creating Server
|
||||
$router->post('/new', [
|
||||
'uses' => 'Admin\ServersController@postNewServer'
|
||||
'uses' => 'Admin\ServersController@postNewServer',
|
||||
]);
|
||||
|
||||
// Assorted Page Helpers
|
||||
$router->post('/new/get-nodes', [
|
||||
'uses' => 'Admin\ServersController@postNewServerGetNodes'
|
||||
'uses' => 'Admin\ServersController@postNewServerGetNodes',
|
||||
]);
|
||||
|
||||
$router->post('/new/get-ips', [
|
||||
'uses' => 'Admin\ServersController@postNewServerGetIps'
|
||||
'uses' => 'Admin\ServersController@postNewServerGetIps',
|
||||
]);
|
||||
|
||||
$router->post('/new/service-options', [
|
||||
'uses' => 'Admin\ServersController@postNewServerServiceOptions'
|
||||
'uses' => 'Admin\ServersController@postNewServerServiceOptions',
|
||||
]);
|
||||
|
||||
$router->post('/new/service-variables', [
|
||||
'uses' => 'Admin\ServersController@postNewServerServiceVariables'
|
||||
'uses' => 'Admin\ServersController@postNewServerServiceVariables',
|
||||
]);
|
||||
// End Assorted Page Helpers
|
||||
|
||||
// View Specific Server
|
||||
$router->get('/view/{id}', [
|
||||
'as' => 'admin.servers.view',
|
||||
'uses' => 'Admin\ServersController@getView'
|
||||
'uses' => 'Admin\ServersController@getView',
|
||||
]);
|
||||
|
||||
// Database Stuffs
|
||||
$router->post('/view/{id}/database', [
|
||||
'as' => 'admin.servers.database',
|
||||
'uses' => 'Admin\ServersController@postDatabase'
|
||||
'uses' => 'Admin\ServersController@postDatabase',
|
||||
]);
|
||||
|
||||
// Change Server Details
|
||||
$router->post('/view/{id}/details', [
|
||||
'uses' => 'Admin\ServersController@postUpdateServerDetails'
|
||||
'uses' => 'Admin\ServersController@postUpdateServerDetails',
|
||||
]);
|
||||
|
||||
// Change Server Details
|
||||
$router->post('/view/{id}/container', [
|
||||
'as' => 'admin.servers.post.container',
|
||||
'uses' => 'Admin\ServersController@postUpdateContainerDetails'
|
||||
'uses' => 'Admin\ServersController@postUpdateContainerDetails',
|
||||
]);
|
||||
|
||||
// Change Server Details
|
||||
$router->post('/view/{id}/startup', [
|
||||
'as' => 'admin.servers.post.startup',
|
||||
'uses' => 'Admin\ServersController@postUpdateServerStartup'
|
||||
'uses' => 'Admin\ServersController@postUpdateServerStartup',
|
||||
]);
|
||||
|
||||
// Rebuild Server
|
||||
$router->post('/view/{id}/rebuild', [
|
||||
'uses' => 'Admin\ServersController@postUpdateServerToggleBuild'
|
||||
'uses' => 'Admin\ServersController@postUpdateServerToggleBuild',
|
||||
]);
|
||||
|
||||
// Change Build Details
|
||||
$router->post('/view/{id}/build', [
|
||||
'uses' => 'Admin\ServersController@postUpdateServerUpdateBuild'
|
||||
'uses' => 'Admin\ServersController@postUpdateServerUpdateBuild',
|
||||
]);
|
||||
|
||||
// Suspend Server
|
||||
$router->post('/view/{id}/suspend', [
|
||||
'uses' => 'Admin\ServersController@postSuspendServer'
|
||||
'uses' => 'Admin\ServersController@postSuspendServer',
|
||||
]);
|
||||
|
||||
// Unsuspend Server
|
||||
$router->post('/view/{id}/unsuspend', [
|
||||
'uses' => 'Admin\ServersController@postUnsuspendServer'
|
||||
'uses' => 'Admin\ServersController@postUnsuspendServer',
|
||||
]);
|
||||
|
||||
// Change Install Status
|
||||
$router->post('/view/{id}/installed', [
|
||||
'uses' => 'Admin\ServersController@postToggleInstall'
|
||||
'uses' => 'Admin\ServersController@postToggleInstall',
|
||||
]);
|
||||
|
||||
// Delete [force delete]
|
||||
$router->delete('/view/{id}/{force?}', [
|
||||
'uses' => 'Admin\ServersController@deleteServer'
|
||||
'uses' => 'Admin\ServersController@deleteServer',
|
||||
]);
|
||||
|
||||
$router->post('/view/{id}/queuedDeletion', [
|
||||
'uses' => 'Admin\ServersController@postQueuedDeletionHandler',
|
||||
'as' => 'admin.servers.post.queuedDeletion'
|
||||
'as' => 'admin.servers.post.queuedDeletion',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
// Node Routes
|
||||
|
@ -223,70 +223,69 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
|
||||
// View All Nodes
|
||||
$router->get('/', [
|
||||
'as' => 'admin.nodes',
|
||||
'uses' => 'Admin\NodesController@getIndex'
|
||||
'uses' => 'Admin\NodesController@getIndex',
|
||||
]);
|
||||
|
||||
// Add New Node
|
||||
$router->get('/new', [
|
||||
'as' => 'admin.nodes.new',
|
||||
'uses' => 'Admin\NodesController@getNew'
|
||||
'uses' => 'Admin\NodesController@getNew',
|
||||
]);
|
||||
|
||||
$router->post('/new', [
|
||||
'uses' => 'Admin\NodesController@postNew'
|
||||
'uses' => 'Admin\NodesController@postNew',
|
||||
]);
|
||||
|
||||
// View Node
|
||||
$router->get('/view/{id}', [
|
||||
'as' => 'admin.nodes.view',
|
||||
'uses' => 'Admin\NodesController@getView'
|
||||
'uses' => 'Admin\NodesController@getView',
|
||||
]);
|
||||
|
||||
$router->post('/view/{id}', [
|
||||
'uses' => 'Admin\NodesController@postView'
|
||||
'uses' => 'Admin\NodesController@postView',
|
||||
]);
|
||||
|
||||
$router->delete('/view/{id}/deallocate/single/{allocation}', [
|
||||
'uses' => 'Admin\NodesController@deallocateSingle'
|
||||
'uses' => 'Admin\NodesController@deallocateSingle',
|
||||
]);
|
||||
|
||||
$router->post('/view/{id}/deallocate/block', [
|
||||
'uses' => 'Admin\NodesController@deallocateBlock'
|
||||
'uses' => 'Admin\NodesController@deallocateBlock',
|
||||
]);
|
||||
|
||||
$router->post('/view/{id}/alias', [
|
||||
'as' => 'admin.nodes.alias',
|
||||
'uses' => 'Admin\NodesController@setAlias'
|
||||
'uses' => 'Admin\NodesController@setAlias',
|
||||
]);
|
||||
|
||||
$router->get('/view/{id}/allocations.json', [
|
||||
'as' => 'admin.nodes.view.allocations',
|
||||
'uses' => 'Admin\NodesController@getAllocationsJson'
|
||||
'uses' => 'Admin\NodesController@getAllocationsJson',
|
||||
]);
|
||||
|
||||
$router->post('/view/{id}/allocations', [
|
||||
'as' => 'admin.nodes.post.allocations',
|
||||
'uses' => 'Admin\NodesController@postAllocations'
|
||||
'uses' => 'Admin\NodesController@postAllocations',
|
||||
]);
|
||||
|
||||
// View Deploy
|
||||
$router->get('/view/{id}/deploy', [
|
||||
'as' => 'admin.nodes.deply',
|
||||
'uses' => 'Admin\NodesController@getScript'
|
||||
'uses' => 'Admin\NodesController@getScript',
|
||||
]);
|
||||
|
||||
$router->delete('/view/{id}', [
|
||||
'as' => 'admin.nodes.delete',
|
||||
'uses' => 'Admin\NodesController@deleteNode'
|
||||
'uses' => 'Admin\NodesController@deleteNode',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
// Location Routes
|
||||
|
@ -295,21 +294,21 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'admin.locations',
|
||||
'uses' => 'Admin\LocationsController@getIndex'
|
||||
'uses' => 'Admin\LocationsController@getIndex',
|
||||
]);
|
||||
$router->delete('/{id}', [
|
||||
'uses' => 'Admin\LocationsController@deleteLocation'
|
||||
'uses' => 'Admin\LocationsController@deleteLocation',
|
||||
]);
|
||||
$router->patch('/{id}', [
|
||||
'uses' => 'Admin\LocationsController@patchLocation'
|
||||
'uses' => 'Admin\LocationsController@patchLocation',
|
||||
]);
|
||||
$router->post('/', [
|
||||
'uses' => 'Admin\LocationsController@postLocation'
|
||||
'uses' => 'Admin\LocationsController@postLocation',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -319,27 +318,27 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'admin.databases',
|
||||
'uses' => 'Admin\DatabaseController@getIndex'
|
||||
'uses' => 'Admin\DatabaseController@getIndex',
|
||||
]);
|
||||
$router->get('/new', [
|
||||
'as' => 'admin.databases.new',
|
||||
'uses' => 'Admin\DatabaseController@getNew'
|
||||
'uses' => 'Admin\DatabaseController@getNew',
|
||||
]);
|
||||
$router->post('/new', [
|
||||
'uses' => 'Admin\DatabaseController@postNew'
|
||||
'uses' => 'Admin\DatabaseController@postNew',
|
||||
]);
|
||||
$router->delete('/delete/{id}', [
|
||||
'as' => 'admin.databases.delete',
|
||||
'uses' => 'Admin\DatabaseController@deleteDatabase'
|
||||
'uses' => 'Admin\DatabaseController@deleteDatabase',
|
||||
]);
|
||||
$router->delete('/delete-server/{id}', [
|
||||
'as' => 'admin.databases.delete-server',
|
||||
'uses' => 'Admin\DatabaseController@deleteServer'
|
||||
'uses' => 'Admin\DatabaseController@deleteServer',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -349,78 +348,76 @@ class AdminRoutes {
|
|||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'admin.services',
|
||||
'uses' => 'Admin\ServiceController@getIndex'
|
||||
'uses' => 'Admin\ServiceController@getIndex',
|
||||
]);
|
||||
|
||||
$router->get('/new', [
|
||||
'as' => 'admin.services.new',
|
||||
'uses' => 'Admin\ServiceController@getNew'
|
||||
'uses' => 'Admin\ServiceController@getNew',
|
||||
]);
|
||||
|
||||
$router->post('/new', [
|
||||
'uses' => 'Admin\ServiceController@postNew'
|
||||
'uses' => 'Admin\ServiceController@postNew',
|
||||
]);
|
||||
|
||||
$router->get('/service/{id}', [
|
||||
'as' => 'admin.services.service',
|
||||
'uses' => 'Admin\ServiceController@getService'
|
||||
'uses' => 'Admin\ServiceController@getService',
|
||||
]);
|
||||
|
||||
$router->post('/service/{id}', [
|
||||
'uses' => 'Admin\ServiceController@postService'
|
||||
'uses' => 'Admin\ServiceController@postService',
|
||||
]);
|
||||
|
||||
$router->delete('/service/{id}', [
|
||||
'uses' => 'Admin\ServiceController@deleteService'
|
||||
'uses' => 'Admin\ServiceController@deleteService',
|
||||
]);
|
||||
|
||||
$router->get('/service/{service}/option/new', [
|
||||
'as' => 'admin.services.option.new',
|
||||
'uses' => 'Admin\ServiceController@newOption'
|
||||
'uses' => 'Admin\ServiceController@newOption',
|
||||
]);
|
||||
|
||||
$router->post('/service/{service}/option/new', [
|
||||
'uses' => 'Admin\ServiceController@postNewOption'
|
||||
'uses' => 'Admin\ServiceController@postNewOption',
|
||||
]);
|
||||
|
||||
$router->get('/service/{service}/option/{option}', [
|
||||
'as' => 'admin.services.option',
|
||||
'uses' => 'Admin\ServiceController@getOption'
|
||||
'uses' => 'Admin\ServiceController@getOption',
|
||||
]);
|
||||
|
||||
$router->post('/service/{service}/option/{option}', [
|
||||
'uses' => 'Admin\ServiceController@postOption'
|
||||
'uses' => 'Admin\ServiceController@postOption',
|
||||
]);
|
||||
|
||||
$router->delete('/service/{service}/option/{id}', [
|
||||
'uses' => 'Admin\ServiceController@deleteOption'
|
||||
'uses' => 'Admin\ServiceController@deleteOption',
|
||||
]);
|
||||
|
||||
$router->get('/service/{service}/option/{option}/variable/new', [
|
||||
'as' => 'admin.services.option.variable.new',
|
||||
'uses' => 'Admin\ServiceController@getNewVariable'
|
||||
'uses' => 'Admin\ServiceController@getNewVariable',
|
||||
]);
|
||||
|
||||
$router->post('/service/{service}/option/{option}/variable/new', [
|
||||
'uses' => 'Admin\ServiceController@postNewVariable'
|
||||
'uses' => 'Admin\ServiceController@postNewVariable',
|
||||
]);
|
||||
|
||||
$router->post('/service/{service}/option/{option}/variable/{variable}', [
|
||||
'as' => 'admin.services.option.variable',
|
||||
'uses' => 'Admin\ServiceController@postOptionVariable'
|
||||
'uses' => 'Admin\ServiceController@postOptionVariable',
|
||||
]);
|
||||
|
||||
$router->get('/service/{service}/option/{option}/variable/{variable}/delete', [
|
||||
'as' => 'admin.services.option.variable.delete',
|
||||
'uses' => 'Admin\ServiceController@deleteVariable'
|
||||
'uses' => 'Admin\ServiceController@deleteVariable',
|
||||
]);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,71 +22,68 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Request;
|
||||
use Pterodactyl\Models\User as User;
|
||||
|
||||
use Auth;
|
||||
class AuthRoutes {
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
public function map(Router $router) {
|
||||
class AuthRoutes
|
||||
{
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group([
|
||||
'prefix' => 'auth',
|
||||
'middleware' => [
|
||||
'guest',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
|
||||
// Display Login Page
|
||||
$router->get('login', [
|
||||
'as' => 'auth.login',
|
||||
'uses' => 'Auth\LoginController@showLoginForm'
|
||||
'uses' => 'Auth\LoginController@showLoginForm',
|
||||
]);
|
||||
|
||||
// Handle Login
|
||||
$router->post('login', [
|
||||
'uses' => 'Auth\LoginController@login'
|
||||
'uses' => 'Auth\LoginController@login',
|
||||
]);
|
||||
|
||||
// Determine if we need to ask for a TOTP Token
|
||||
$router->post('login/totp', [
|
||||
'uses' => 'Auth\LoginController@checkTotp'
|
||||
'uses' => 'Auth\LoginController@checkTotp',
|
||||
]);
|
||||
|
||||
// Show Password Reset Form
|
||||
$router->get('password', [
|
||||
'as' => 'auth.password',
|
||||
'uses' => 'Auth\ForgotPasswordController@showLinkRequestForm'
|
||||
'uses' => 'Auth\ForgotPasswordController@showLinkRequestForm',
|
||||
]);
|
||||
|
||||
// Handle Password Reset
|
||||
$router->post('password', [
|
||||
'uses' => 'Auth\ForgotPasswordController@sendResetLinkEmail'
|
||||
'uses' => 'Auth\ForgotPasswordController@sendResetLinkEmail',
|
||||
]);
|
||||
|
||||
// Show Verification Checkpoint
|
||||
$router->get('password/reset/{token}', [
|
||||
'as' => 'auth.reset',
|
||||
'uses' => 'Auth\ResetPasswordController@showResetForm'
|
||||
'uses' => 'Auth\ResetPasswordController@showResetForm',
|
||||
]);
|
||||
|
||||
// Handle Verification
|
||||
$router->post('password/reset', [
|
||||
'uses' => 'Auth\ResetPasswordController@reset'
|
||||
'uses' => 'Auth\ResetPasswordController@reset',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
// Not included above because we don't want the guest middleware
|
||||
$router->get('auth/logout', [
|
||||
'as' => 'auth.logout',
|
||||
'middleware' => 'auth',
|
||||
'uses' => 'Auth\LoginController@logout'
|
||||
'uses' => 'Auth\LoginController@logout',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,19 +22,21 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class BaseRoutes {
|
||||
|
||||
public function map(Router $router) {
|
||||
class BaseRoutes
|
||||
{
|
||||
public function map(Router $router)
|
||||
{
|
||||
|
||||
// Index of Panel
|
||||
$router->get('/', [
|
||||
'as' => 'index',
|
||||
'middleware' => 'auth',
|
||||
'uses' => 'Base\IndexController@getIndex'
|
||||
'uses' => 'Base\IndexController@getIndex',
|
||||
]);
|
||||
|
||||
// Handle Index. Redirect /index to /
|
||||
|
@ -46,7 +48,7 @@ class BaseRoutes {
|
|||
$router->get('/password-gen/{length}', [
|
||||
'as' => 'password-gen',
|
||||
'middleware' => 'auth',
|
||||
'uses' => 'Base\IndexController@getPassword'
|
||||
'uses' => 'Base\IndexController@getPassword',
|
||||
]);
|
||||
|
||||
// Account Routes
|
||||
|
@ -54,18 +56,18 @@ class BaseRoutes {
|
|||
'prefix' => 'account',
|
||||
'middleware' => [
|
||||
'auth',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'account',
|
||||
'uses' => 'Base\AccountController@index'
|
||||
'uses' => 'Base\AccountController@index',
|
||||
]);
|
||||
$router->post('/password', [
|
||||
'uses' => 'Base\AccountController@password'
|
||||
'uses' => 'Base\AccountController@password',
|
||||
]);
|
||||
$router->post('/email', [
|
||||
'uses' => 'Base\AccountController@email'
|
||||
'uses' => 'Base\AccountController@email',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -74,23 +76,23 @@ class BaseRoutes {
|
|||
'prefix' => 'account/api',
|
||||
'middleware' => [
|
||||
'auth',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'account.api',
|
||||
'uses' => 'Base\APIController@index'
|
||||
'uses' => 'Base\APIController@index',
|
||||
]);
|
||||
$router->get('/new', [
|
||||
'as' => 'account.api.new',
|
||||
'uses' => 'Base\APIController@new'
|
||||
'uses' => 'Base\APIController@new',
|
||||
]);
|
||||
$router->post('/new', [
|
||||
'uses' => 'Base\APIController@save'
|
||||
'uses' => 'Base\APIController@save',
|
||||
]);
|
||||
|
||||
$router->delete('/revoke/{key}', [
|
||||
'uses' => 'Base\APIController@revoke'
|
||||
'uses' => 'Base\APIController@revoke',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -99,28 +101,26 @@ class BaseRoutes {
|
|||
'prefix' => 'account/security',
|
||||
'middleware' => [
|
||||
'auth',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'account.security',
|
||||
'uses' => 'Base\SecurityController@index'
|
||||
'uses' => 'Base\SecurityController@index',
|
||||
]);
|
||||
$router->get('/revoke/{id}', [
|
||||
'as' => 'account.security.revoke',
|
||||
'uses' => 'Base\SecurityController@revoke'
|
||||
'uses' => 'Base\SecurityController@revoke',
|
||||
]);
|
||||
$router->put('/totp', [
|
||||
'uses' => 'Base\SecurityController@generateTotp'
|
||||
'uses' => 'Base\SecurityController@generateTotp',
|
||||
]);
|
||||
$router->post('/totp', [
|
||||
'uses' => 'Base\SecurityController@setTotp'
|
||||
'uses' => 'Base\SecurityController@setTotp',
|
||||
]);
|
||||
$router->delete('/totp', [
|
||||
'uses' => 'Base\SecurityController@disableTotp'
|
||||
'uses' => 'Base\SecurityController@disableTotp',
|
||||
]);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,18 +21,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class LanguageRoutes {
|
||||
|
||||
class LanguageRoutes
|
||||
{
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->get('language/{lang}', [
|
||||
'as' => 'langauge.set',
|
||||
'uses' => 'Base\LanguageController@setLanguage'
|
||||
'uses' => 'Base\LanguageController@setLanguage',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,31 +21,31 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Request;
|
||||
|
||||
class RemoteRoutes {
|
||||
|
||||
public function map(Router $router) {
|
||||
class RemoteRoutes
|
||||
{
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group(['prefix' => 'remote'], function () use ($router) {
|
||||
// Handles Remote Download Authentication Requests
|
||||
$router->post('download', [
|
||||
'as' => 'remote.download',
|
||||
'uses' => 'Remote\RemoteController@postDownload'
|
||||
'uses' => 'Remote\RemoteController@postDownload',
|
||||
]);
|
||||
|
||||
$router->post('install', [
|
||||
'as' => 'remote.install',
|
||||
'uses' => 'Remote\RemoteController@postInstall'
|
||||
'uses' => 'Remote\RemoteController@postInstall',
|
||||
]);
|
||||
|
||||
$router->post('event', [
|
||||
'as' => 'remote.event',
|
||||
'uses' => 'Remote\RemoteController@event'
|
||||
'uses' => 'Remote\RemoteController@event',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,148 +21,149 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Routes;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class ServerRoutes {
|
||||
|
||||
public function map(Router $router) {
|
||||
|
||||
class ServerRoutes
|
||||
{
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group([
|
||||
'prefix' => 'server/{server}',
|
||||
'middleware' => [
|
||||
'auth',
|
||||
'server',
|
||||
'csrf'
|
||||
]
|
||||
'csrf',
|
||||
],
|
||||
], function ($server) use ($router) {
|
||||
|
||||
// Index View for Server
|
||||
$router->get('/', [
|
||||
'as' => 'server.index',
|
||||
'uses' => 'Server\ServerController@getIndex'
|
||||
'uses' => 'Server\ServerController@getIndex',
|
||||
]);
|
||||
|
||||
// Settings
|
||||
$router->get('/settings', [
|
||||
'as' => 'server.settings',
|
||||
'uses' => 'Server\ServerController@getSettings'
|
||||
'uses' => 'Server\ServerController@getSettings',
|
||||
]);
|
||||
|
||||
$router->post('/settings/sftp', [
|
||||
'as' => 'server.settings.sftp',
|
||||
'uses' => 'Server\ServerController@postSettingsSFTP'
|
||||
'uses' => 'Server\ServerController@postSettingsSFTP',
|
||||
]);
|
||||
|
||||
$router->post('/settings/startup', [
|
||||
'as' => 'server.settings.startup',
|
||||
'uses' => 'Server\ServerController@postSettingsStartup'
|
||||
'uses' => 'Server\ServerController@postSettingsStartup',
|
||||
]);
|
||||
|
||||
// File Manager Routes
|
||||
$router->get('/files', [
|
||||
'as' => 'server.files.index',
|
||||
'uses' => 'Server\ServerController@getFiles'
|
||||
'uses' => 'Server\ServerController@getFiles',
|
||||
]);
|
||||
|
||||
$router->get('/files/edit/{file}', [
|
||||
'as' => 'server.files.edit',
|
||||
'uses' => 'Server\ServerController@getEditFile'
|
||||
'uses' => 'Server\ServerController@getEditFile',
|
||||
])->where('file', '.*');
|
||||
|
||||
$router->get('/files/download/{file}', [
|
||||
'as' => 'server.files.download',
|
||||
'uses' => 'Server\ServerController@getDownloadFile'
|
||||
'uses' => 'Server\ServerController@getDownloadFile',
|
||||
])->where('file', '.*');
|
||||
|
||||
$router->get('/files/add', [
|
||||
'as' => 'server.files.add',
|
||||
'uses' => 'Server\ServerController@getAddFile'
|
||||
'uses' => 'Server\ServerController@getAddFile',
|
||||
]);
|
||||
|
||||
$router->post('files/directory-list', [
|
||||
'as' => 'server.files.directory-list',
|
||||
'uses' => 'Server\AjaxController@postDirectoryList'
|
||||
'uses' => 'Server\AjaxController@postDirectoryList',
|
||||
]);
|
||||
|
||||
$router->post('files/save', [
|
||||
'as' => 'server.files.save',
|
||||
'uses' => 'Server\AjaxController@postSaveFile'
|
||||
'uses' => 'Server\AjaxController@postSaveFile',
|
||||
]);
|
||||
|
||||
// Sub-User Routes
|
||||
$router->get('users', [
|
||||
'as' => 'server.subusers',
|
||||
'uses' => 'Server\SubuserController@getIndex'
|
||||
'uses' => 'Server\SubuserController@getIndex',
|
||||
]);
|
||||
|
||||
$router->get('users/new', [
|
||||
'as' => 'server.subusers.new',
|
||||
'uses' => 'Server\SubuserController@getNew'
|
||||
'uses' => 'Server\SubuserController@getNew',
|
||||
]);
|
||||
|
||||
$router->post('users/new', [
|
||||
'uses' => 'Server\SubuserController@postNew'
|
||||
'uses' => 'Server\SubuserController@postNew',
|
||||
]);
|
||||
|
||||
$router->get('users/view/{id}', [
|
||||
'as' => 'server.subusers.view',
|
||||
'uses' => 'Server\SubuserController@getView'
|
||||
'uses' => 'Server\SubuserController@getView',
|
||||
]);
|
||||
|
||||
$router->post('users/view/{id}', [
|
||||
'uses' => 'Server\SubuserController@postView'
|
||||
'uses' => 'Server\SubuserController@postView',
|
||||
]);
|
||||
|
||||
$router->delete('users/delete/{id}', [
|
||||
'uses' => 'Server\SubuserController@deleteSubuser'
|
||||
'uses' => 'Server\SubuserController@deleteSubuser',
|
||||
]);
|
||||
|
||||
$router->get('tasks/', [
|
||||
'as' => 'server.tasks',
|
||||
'uses' => 'Server\TaskController@getIndex'
|
||||
'uses' => 'Server\TaskController@getIndex',
|
||||
]);
|
||||
|
||||
$router->get('tasks/view/{id}', [
|
||||
'as' => 'server.tasks.view',
|
||||
'uses' => 'Server\TaskController@getView'
|
||||
'uses' => 'Server\TaskController@getView',
|
||||
]);
|
||||
|
||||
$router->get('tasks/new', [
|
||||
'as' => 'server.tasks.new',
|
||||
'uses' => 'Server\TaskController@getNew'
|
||||
'uses' => 'Server\TaskController@getNew',
|
||||
]);
|
||||
|
||||
$router->post('tasks/new', [
|
||||
'uses' => 'Server\TaskController@postNew'
|
||||
'uses' => 'Server\TaskController@postNew',
|
||||
]);
|
||||
|
||||
$router->delete('tasks/delete/{id}', [
|
||||
'as' => 'server.tasks.delete',
|
||||
'uses' => 'Server\TaskController@deleteTask'
|
||||
'uses' => 'Server\TaskController@deleteTask',
|
||||
]);
|
||||
|
||||
$router->post('tasks/toggle/{id}', [
|
||||
'as' => 'server.tasks.toggle',
|
||||
'uses' => 'Server\TaskController@toggleTask'
|
||||
'uses' => 'Server\TaskController@toggleTask',
|
||||
]);
|
||||
|
||||
// Assorted AJAX Routes
|
||||
$router->group(['prefix' => 'ajax'], function ($server) use ($router) {
|
||||
// Returns Server Status
|
||||
$router->get('status', [
|
||||
'uses' => 'Server\AjaxController@getStatus'
|
||||
'uses' => 'Server\AjaxController@getStatus',
|
||||
]);
|
||||
|
||||
// Sets the Default Connection for the Server
|
||||
$router->post('set-primary', [
|
||||
'uses' => 'Server\AjaxController@postSetPrimary'
|
||||
'uses' => 'Server\AjaxController@postSetPrimary',
|
||||
]);
|
||||
|
||||
$router->post('settings/reset-database-password', [
|
||||
'as' => 'server.ajax.reset-database-password',
|
||||
'uses' => 'Server\AjaxController@postResetDatabasePassword'
|
||||
'uses' => 'Server\AjaxController@postResetDatabasePassword',
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -171,11 +172,9 @@ class ServerRoutes {
|
|||
// Returns Server Status
|
||||
$router->get('{folder}/{file}', [
|
||||
'as' => 'server.js',
|
||||
'uses' => 'Server\ServerController@getJavascript'
|
||||
'uses' => 'Server\ServerController@getJavascript',
|
||||
])->where('file', '.*');
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,16 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Jobs;
|
||||
|
||||
use DB;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
|
||||
class DeleteServer extends Job implements ShouldQueue
|
||||
|
@ -46,7 +42,7 @@ class DeleteServer extends Job implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param integer $server
|
||||
* @param int $server
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($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,19 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Jobs;
|
||||
|
||||
use Pterodactyl\Jobs\Job;
|
||||
use Cron;
|
||||
use Carbon;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
use DB;
|
||||
use Carbon;
|
||||
use Cron;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\Daemon\CommandRepository;
|
||||
use Pterodactyl\Repositories\Daemon\PowerRepository;
|
||||
use Pterodactyl\Repositories\Daemon\CommandRepository;
|
||||
|
||||
class SendScheduledTask extends Job implements ShouldQueue
|
||||
{
|
||||
|
@ -84,14 +82,14 @@ class SendScheduledTask extends Job implements ShouldQueue
|
|||
'task_id' => $this->task->id,
|
||||
'run_time' => $time,
|
||||
'run_status' => 0,
|
||||
'response' => $response
|
||||
'response' => $response,
|
||||
]);
|
||||
} catch (\Exception $ex) {
|
||||
$log->fill([
|
||||
'task_id' => $this->task->id,
|
||||
'run_time' => $time,
|
||||
'run_status' => 1,
|
||||
'response' => $ex->getMessage()
|
||||
'response' => $ex->getMessage(),
|
||||
]);
|
||||
} finally {
|
||||
$cron = Cron::factory(sprintf('%s %s %s %s %s %s',
|
||||
|
@ -105,7 +103,7 @@ class SendScheduledTask extends Job implements ShouldQueue
|
|||
$this->task->fill([
|
||||
'last_run' => $time,
|
||||
'next_run' => $cron->getNextRunDate(),
|
||||
'queued' => 0
|
||||
'queued' => 0,
|
||||
]);
|
||||
$this->task->save();
|
||||
$log->save();
|
||||
|
|
|
@ -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,14 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Jobs;
|
||||
|
||||
use Debugbar;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
use Pterodactyl\Repositories\ServerRepository;
|
||||
|
||||
class SuspendServer extends Job implements ShouldQueue
|
||||
|
@ -44,7 +42,7 @@ class SuspendServer extends Job implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($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,19 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Listeners;
|
||||
|
||||
use Carbon;
|
||||
|
||||
use Pterodactyl\Jobs\DeleteServer;
|
||||
use Pterodactyl\Jobs\SuspendServer;
|
||||
use Pterodactyl\Events\ServerDeleted;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
use Pterodactyl\Jobs\SuspendServer;
|
||||
use Pterodactyl\Jobs\DeleteServer;
|
||||
|
||||
class DeleteServerListener
|
||||
{
|
||||
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class APIKey extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -48,5 +48,4 @@ class APIKey extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class APILog extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -55,7 +55,6 @@ class APILog extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'authorized' => 'boolean'
|
||||
'authorized' => 'boolean',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class APIPermission extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -54,8 +54,7 @@ class APIPermission extends Model
|
|||
/**
|
||||
* Disable timestamps for this table.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Allocation extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -52,5 +52,4 @@ class Allocation extends Model
|
|||
'port' => 'integer',
|
||||
'assigned_to' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Database extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -58,5 +58,4 @@ class Database extends Model
|
|||
'server' => 'integer',
|
||||
'db_server' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DatabaseServer extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -57,7 +57,6 @@ class DatabaseServer extends Model
|
|||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'server_id' => 'integer',
|
||||
'db_server' => 'integer'
|
||||
'db_server' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,19 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Debugbar;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Download extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'downloads';
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Location extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -41,5 +41,4 @@ class Location extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -28,7 +29,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Node extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -88,9 +88,9 @@ class Node extends Model
|
|||
return self::$nodes[$id];
|
||||
}
|
||||
|
||||
self::$nodes[$id] = Node::where('id', $id)->first();
|
||||
return self::$nodes[$id];
|
||||
self::$nodes[$id] = self::where('id', $id)->first();
|
||||
|
||||
return self::$nodes[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,5 @@ class Node extends Model
|
|||
]);
|
||||
|
||||
return self::$guzzle[$node];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -61,5 +61,4 @@ class Permission extends Model
|
|||
{
|
||||
return $query->where('server_id', $server->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,18 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Auth;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
class Server extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +92,7 @@ class Server extends Model
|
|||
protected static $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -112,7 +109,6 @@ class Server extends Model
|
|||
*/
|
||||
public static function getUserDaemonSecret(Server $server)
|
||||
{
|
||||
|
||||
if (self::$user->id === $server->owner || self::$user->root_admin === 1) {
|
||||
return $server->daemonSecret;
|
||||
}
|
||||
|
@ -124,7 +120,6 @@ class Server extends Model
|
|||
}
|
||||
|
||||
return $subuser->daemonSecret;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +130,6 @@ class Server extends Model
|
|||
*/
|
||||
public static function getUserServers($paginate = null)
|
||||
{
|
||||
|
||||
$query = self::select(
|
||||
'servers.*',
|
||||
'nodes.name as nodeName',
|
||||
|
@ -160,7 +154,6 @@ class Server extends Model
|
|||
}
|
||||
|
||||
return $query->get();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +166,6 @@ class Server extends Model
|
|||
*/
|
||||
public static function getByUUID($uuid)
|
||||
{
|
||||
|
||||
if (array_key_exists($uuid, self::$serverUUIDInstance)) {
|
||||
return self::$serverUUIDInstance[$uuid];
|
||||
}
|
||||
|
@ -194,28 +186,25 @@ class Server extends Model
|
|||
}
|
||||
|
||||
self::$serverUUIDInstance[$uuid] = $result;
|
||||
return self::$serverUUIDInstance[$uuid];
|
||||
|
||||
return self::$serverUUIDInstance[$uuid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-administrative headers for accessing a server on the daemon
|
||||
* Returns non-administrative headers for accessing a server on the daemon.
|
||||
*
|
||||
* @param string $uuid
|
||||
* @return array
|
||||
*/
|
||||
public static function getGuzzleHeaders($uuid)
|
||||
{
|
||||
|
||||
if (array_key_exists($uuid, self::$serverUUIDInstance)) {
|
||||
return [
|
||||
'X-Access-Server' => self::$serverUUIDInstance[$uuid]->uuid,
|
||||
'X-Access-Token' => self::$serverUUIDInstance[$uuid]->daemonSecret
|
||||
'X-Access-Token' => self::$serverUUIDInstance[$uuid]->daemonSecret,
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServerVariables extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -51,5 +51,4 @@ class ServerVariables extends Model
|
|||
'server_id' => 'integer',
|
||||
'variable_id' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -41,5 +41,4 @@ class Service extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceOptions extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -50,5 +50,4 @@ class ServiceOptions extends Model
|
|||
protected $casts = [
|
||||
'parent_service' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceVariables extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -53,5 +53,4 @@ class ServiceVariables extends Model
|
|||
'user_editable' => 'integer',
|
||||
'required' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Session extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -44,5 +44,4 @@ class Session extends Model
|
|||
'id' => 'string',
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Auth;
|
||||
|
@ -28,7 +29,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Subuser extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -66,7 +66,7 @@ class Subuser extends Model
|
|||
protected static $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -80,7 +80,6 @@ class Subuser extends Model
|
|||
*/
|
||||
public static function accessServers()
|
||||
{
|
||||
|
||||
$access = [];
|
||||
|
||||
$union = self::select('server_id')->where('user_id', self::$user->id);
|
||||
|
@ -91,7 +90,5 @@ class Subuser extends Model
|
|||
}
|
||||
|
||||
return $access;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -59,5 +59,4 @@ class Task extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $dates = ['last_run', 'next_run', 'created_at', 'updated_at'];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,13 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TaskLog extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
@ -50,7 +50,7 @@ class TaskLog extends Model
|
|||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'task_id' => 'integer',
|
||||
'run_status' => 'integer'
|
||||
'run_status' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -59,5 +59,4 @@ class TaskLog extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $dates = ['run_time', 'created_at', 'updated_at'];
|
||||
|
||||
}
|
||||
|
|
|
@ -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,24 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Models;
|
||||
|
||||
use Hash;
|
||||
use Google2FA;
|
||||
use Pterodactyl\Exceptions\AccountNotFoundException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification;
|
||||
|
||||
class User extends Model implements AuthenticatableContract,
|
||||
class User extends Model implements
|
||||
AuthenticatableContract,
|
||||
AuthorizableContract,
|
||||
CanResetPasswordContract
|
||||
{
|
||||
|
@ -77,7 +76,7 @@ class User extends Model implements AuthenticatableContract,
|
|||
protected $hidden = ['password', 'remember_token', 'totp_secret'];
|
||||
|
||||
/**
|
||||
* The rules for user passwords
|
||||
* The rules for user passwords.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -92,11 +91,10 @@ class User extends Model implements AuthenticatableContract,
|
|||
* Enables or disables TOTP on an account if the token is valid.
|
||||
*
|
||||
* @param int $token The token that we want to verify.
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function toggleTotp($token)
|
||||
{
|
||||
|
||||
if (! Google2FA::verifyKey($this->totp_secret, $token)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -105,7 +103,6 @@ class User extends Model implements AuthenticatableContract,
|
|||
$this->save();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +110,7 @@ class User extends Model implements AuthenticatableContract,
|
|||
* - 8 or more characters in length
|
||||
* - at least one uppercase character
|
||||
* - at least one lowercase character
|
||||
* - at least one number
|
||||
* - at least one number.
|
||||
*
|
||||
* @param string $password The raw password to set the account password to.
|
||||
* @param string $regex The regex to use when validating the password. Defaults to '((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})'.
|
||||
|
@ -121,16 +118,12 @@ class User extends Model implements AuthenticatableContract,
|
|||
*/
|
||||
public function setPassword($password, $regex = '((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})')
|
||||
{
|
||||
|
||||
if (! preg_match($regex, $password)) {
|
||||
throw new DisplayException('The password passed did not meet the minimum password requirements.');
|
||||
}
|
||||
|
||||
$this->password = Hash::make($password);
|
||||
$this->save();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,5 +136,4 @@ class User extends Model implements AuthenticatableContract,
|
|||
{
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
@ -73,5 +74,4 @@ class AccountCreated extends Notification implements ShouldQueue
|
|||
->line('Email: ' . $notifiable->email)
|
||||
->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . $notifiable->email));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
|
|
@ -52,5 +52,4 @@ class ServerCreated extends Notification implements ShouldQueue
|
|||
->action('Peel Off the Protective Wrap', route('server.index', $this->server->uuidShort))
|
||||
->line('Please let us know if you have any additional questions or concerns!');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Policies;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
|
@ -28,7 +29,6 @@ use Pterodactyl\Models\Server;
|
|||
|
||||
class ServerPolicy
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new policy instance.
|
||||
*
|
||||
|
@ -44,7 +44,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function isOwner(User $user, Server $server)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param string $ability
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function before(User $user, $ability)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function power(User $user, Server $server)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function powerStart(User $user, Server $server)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function powerStop(User $user, Server $server)
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function powerRestart(User $user, Server $server)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function powerKill(User $user, Server $server)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function sendCommand(User $user, Server $server)
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function listFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function editFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function saveFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function moveFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function copyFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function compressFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -262,7 +262,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function decompressFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -278,7 +278,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function addFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -295,7 +295,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function uploadFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -311,7 +311,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function downloadFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -327,7 +327,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteFiles(User $user, Server $server)
|
||||
{
|
||||
|
@ -343,7 +343,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function listSubusers(User $user, Server $server)
|
||||
{
|
||||
|
@ -359,7 +359,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function viewSubuser(User $user, Server $server)
|
||||
{
|
||||
|
@ -375,7 +375,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function editSubuser(User $user, Server $server)
|
||||
{
|
||||
|
@ -391,7 +391,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteSubuser(User $user, Server $server)
|
||||
{
|
||||
|
@ -407,7 +407,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function createSubuser(User $user, Server $server)
|
||||
{
|
||||
|
@ -423,7 +423,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function setConnection(User $user, Server $server)
|
||||
{
|
||||
|
@ -439,7 +439,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function viewStartup(User $user, Server $server)
|
||||
{
|
||||
|
@ -455,7 +455,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function editStartup(User $user, Server $server)
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function viewSftp(User $user, Server $server)
|
||||
{
|
||||
|
@ -487,7 +487,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function resetSftp(User $user, Server $server)
|
||||
{
|
||||
|
@ -503,7 +503,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function viewSftpPassword(User $user, Server $server)
|
||||
{
|
||||
|
@ -519,7 +519,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function viewDatabases(User $user, Server $server)
|
||||
{
|
||||
|
@ -535,7 +535,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function resetDbPassword(User $user, Server $server)
|
||||
{
|
||||
|
@ -551,7 +551,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function listTasks(User $user, Server $server)
|
||||
{
|
||||
|
@ -567,7 +567,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function viewTask(User $user, Server $server)
|
||||
{
|
||||
|
@ -583,7 +583,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function toggleTask(User $user, Server $server)
|
||||
{
|
||||
|
@ -599,7 +599,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function queueTask(User $user, Server $server)
|
||||
{
|
||||
|
@ -615,7 +615,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteTask(User $user, Server $server)
|
||||
{
|
||||
|
@ -631,7 +631,7 @@ class ServerPolicy
|
|||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function createTask(User $user, Server $server)
|
||||
{
|
||||
|
@ -641,5 +641,4 @@ class ServerPolicy
|
|||
|
||||
return $user->permissions()->server($server)->permission('create-task')->exists();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'Pterodactyl\Models\Server' => 'Pterodactyl\Policies\ServerPolicy'
|
||||
'Pterodactyl\Models\Server' => 'Pterodactyl\Policies\ServerPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,21 +21,20 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use Auth;
|
||||
use Crypt;
|
||||
use Validator;
|
||||
use IPTools\Network;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class APIRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Valid API permissions.
|
||||
* @var array
|
||||
|
@ -97,7 +96,7 @@ class APIRepository
|
|||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(Models\User $user = null)
|
||||
{
|
||||
|
@ -122,7 +121,7 @@ class APIRepository
|
|||
$validator = Validator::make($data, [
|
||||
'memo' => 'string|max:500',
|
||||
'permissions' => 'sometimes|required|array',
|
||||
'adminPermissions' => 'sometimes|required|array'
|
||||
'adminPermissions' => 'sometimes|required|array',
|
||||
]);
|
||||
|
||||
$validator->after(function ($validator) use ($data) {
|
||||
|
@ -155,14 +154,16 @@ class APIRepository
|
|||
'secret' => Crypt::encrypt($secretKey),
|
||||
'allowed_ips' => empty($this->allowed) ? null : json_encode($this->allowed),
|
||||
'memo' => $data['memo'],
|
||||
'expires_at' => null
|
||||
'expires_at' => null,
|
||||
]);
|
||||
$key->save();
|
||||
|
||||
$totalPermissions = 0;
|
||||
if (isset($data['permissions'])) {
|
||||
foreach ($data['permissions'] as $permNode) {
|
||||
if (!strpos($permNode, ':')) continue;
|
||||
if (! strpos($permNode, ':')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($toss, $permission) = explode(':', $permNode);
|
||||
if (in_array($permission, $this->permissions['user'])) {
|
||||
|
@ -170,7 +171,7 @@ class APIRepository
|
|||
$model = new Models\APIPermission;
|
||||
$model->fill([
|
||||
'key_id' => $key->id,
|
||||
'permission' => 'api.user.' . $permission
|
||||
'permission' => 'api.user.' . $permission,
|
||||
]);
|
||||
$model->save();
|
||||
}
|
||||
|
@ -179,7 +180,9 @@ class APIRepository
|
|||
|
||||
if ($this->user->root_admin === 1 && isset($data['adminPermissions'])) {
|
||||
foreach ($data['adminPermissions'] as $permNode) {
|
||||
if (!strpos($permNode, ':')) continue;
|
||||
if (! strpos($permNode, ':')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($toss, $permission) = explode(':', $permNode);
|
||||
if (in_array($permission, $this->permissions['admin'])) {
|
||||
|
@ -187,7 +190,7 @@ class APIRepository
|
|||
$model = new Models\APIPermission;
|
||||
$model->fill([
|
||||
'key_id' => $key->id,
|
||||
'permission' => 'api.admin.' . $permission
|
||||
'permission' => 'api.admin.' . $permission,
|
||||
]);
|
||||
$model->save();
|
||||
}
|
||||
|
@ -199,12 +202,12 @@ class APIRepository
|
|||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $secretKey;
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,5 +234,4 @@ class APIRepository
|
|||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,16 +21,16 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\Daemon;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Pterodactyl\Models;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
class CommandRepository {
|
||||
|
||||
class CommandRepository
|
||||
{
|
||||
protected $server;
|
||||
protected $node;
|
||||
protected $client;
|
||||
|
@ -43,9 +43,9 @@ class CommandRepository {
|
|||
}
|
||||
|
||||
/**
|
||||
* [send description]
|
||||
* [send description].
|
||||
* @param string $command
|
||||
* @return boolean
|
||||
* @return bool
|
||||
* @throws DisplayException
|
||||
* @throws RequestException
|
||||
*/
|
||||
|
@ -59,11 +59,11 @@ class CommandRepository {
|
|||
$response = $this->client->request('POST', '/server/command', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $this->server->daemonSecret,
|
||||
'X-Access-Server' => $this->server->uuid
|
||||
'X-Access-Server' => $this->server->uuid,
|
||||
],
|
||||
'json' => [
|
||||
'command' => $command
|
||||
]
|
||||
'command' => $command,
|
||||
],
|
||||
]);
|
||||
|
||||
if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
|
||||
|
@ -75,5 +75,4 @@ class CommandRepository {
|
|||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,22 +21,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\Daemon;
|
||||
|
||||
use \Exception;
|
||||
use Log;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Repositories\HelperRepository;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Repositories\HelperRepository;
|
||||
|
||||
class FileRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* The Eloquent Model associated with the requested server.
|
||||
*
|
||||
|
@ -60,25 +56,23 @@ class FileRepository
|
|||
|
||||
/**
|
||||
* The Guzzle Client headers associated with the requested server and node.
|
||||
* (non-administrative headers)
|
||||
* (non-administrative headers).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $server The server Short UUID
|
||||
*/
|
||||
public function __construct($uuid)
|
||||
{
|
||||
|
||||
$this->server = Server::getByUUID($uuid);
|
||||
$this->node = Node::getByID($this->server->node);
|
||||
$this->client = Node::guzzleRequest($this->server->node);
|
||||
$this->headers = Server::getGuzzleHeaders($uuid);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +83,6 @@ class FileRepository
|
|||
*/
|
||||
public function returnFileContents($file)
|
||||
{
|
||||
|
||||
if (empty($file)) {
|
||||
throw new Exception('Not all parameters were properly passed to the function.');
|
||||
}
|
||||
|
@ -99,7 +92,7 @@ class FileRepository
|
|||
$file->dirname = (in_array($file->dirname, ['.', './', '/'])) ? null : trim($file->dirname, '/') . '/';
|
||||
|
||||
$res = $this->client->request('GET', '/server/file/stat/' . rawurlencode($file->dirname . $file->basename), [
|
||||
'headers' => $this->headers
|
||||
'headers' => $this->headers,
|
||||
]);
|
||||
|
||||
$stat = json_decode($res->getBody());
|
||||
|
@ -116,7 +109,7 @@ class FileRepository
|
|||
}
|
||||
|
||||
$res = $this->client->request('GET', '/server/file/f/' . rawurlencode($file->dirname . $file->basename), [
|
||||
'headers' => $this->headers
|
||||
'headers' => $this->headers,
|
||||
]);
|
||||
|
||||
$json = json_decode($res->getBody());
|
||||
|
@ -126,9 +119,8 @@ class FileRepository
|
|||
|
||||
return [
|
||||
'file' => $json,
|
||||
'stat' => $stat
|
||||
'stat' => $stat,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +132,6 @@ class FileRepository
|
|||
*/
|
||||
public function saveFileContents($file, $content)
|
||||
{
|
||||
|
||||
if (empty($file)) {
|
||||
throw new Exception('A valid file and path must be specified to save a file.');
|
||||
}
|
||||
|
@ -153,8 +144,8 @@ class FileRepository
|
|||
'headers' => $this->headers,
|
||||
'json' => [
|
||||
'path' => rawurlencode($file->dirname . $file->basename),
|
||||
'content' => $content
|
||||
]
|
||||
'content' => $content,
|
||||
],
|
||||
]);
|
||||
|
||||
if ($res->getStatusCode() !== 204) {
|
||||
|
@ -162,7 +153,6 @@ class FileRepository
|
|||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,13 +163,12 @@ class FileRepository
|
|||
*/
|
||||
public function returnDirectoryListing($directory)
|
||||
{
|
||||
|
||||
if (empty($directory)) {
|
||||
throw new Exception('A valid directory must be specified in order to list its contents.');
|
||||
}
|
||||
|
||||
$res = $this->client->request('GET', '/server/directory/' . rawurlencode($directory), [
|
||||
'headers' => $this->headers
|
||||
'headers' => $this->headers,
|
||||
]);
|
||||
|
||||
$json = json_decode($res->getBody());
|
||||
|
@ -191,7 +180,6 @@ class FileRepository
|
|||
$files = [];
|
||||
$folders = [];
|
||||
foreach ($json as &$value) {
|
||||
|
||||
if ($value->directory === true) {
|
||||
|
||||
// @TODO Handle Symlinks
|
||||
|
@ -200,29 +188,23 @@ class FileRepository
|
|||
'directory' => trim($directory, '/'),
|
||||
'size' => null,
|
||||
'date' => strtotime($value->modified),
|
||||
'mime' => $value->mime
|
||||
'mime' => $value->mime,
|
||||
]]);
|
||||
|
||||
} elseif ($value->file === true) {
|
||||
|
||||
$files = array_merge($files, [[
|
||||
'entry' => $value->name,
|
||||
'directory' => trim($directory, '/'),
|
||||
'extension' => pathinfo($value->name, PATHINFO_EXTENSION),
|
||||
'size' => HelperRepository::bytesToHuman($value->size),
|
||||
'date' => strtotime($value->modified),
|
||||
'mime' => $value->mime
|
||||
'mime' => $value->mime,
|
||||
]]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (object) [
|
||||
'files' => $files,
|
||||
'folders' => $folders,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,16 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\Daemon;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
class PowerRepository {
|
||||
|
||||
class PowerRepository
|
||||
{
|
||||
protected $server;
|
||||
protected $node;
|
||||
protected $client;
|
||||
|
@ -52,11 +51,11 @@ class PowerRepository {
|
|||
$response = $this->client->request('PUT', '/server/power', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $this->server->daemonSecret,
|
||||
'X-Access-Server' => $this->server->uuid
|
||||
'X-Access-Server' => $this->server->uuid,
|
||||
],
|
||||
'json' => [
|
||||
'action' => $action
|
||||
]
|
||||
'action' => $action,
|
||||
],
|
||||
]);
|
||||
|
||||
if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) {
|
||||
|
@ -88,5 +87,4 @@ class PowerRepository {
|
|||
{
|
||||
$this->do('kill');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,21 +21,19 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Crypt;
|
||||
use Log;
|
||||
use DB;
|
||||
use Crypt;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
class DatabaseRepository {
|
||||
|
||||
class DatabaseRepository
|
||||
{
|
||||
/**
|
||||
* Adds a new database to a given database server.
|
||||
* @param int $server Id of the server to add a database for.
|
||||
|
@ -64,7 +62,7 @@ class DatabaseRepository {
|
|||
'database' => "s{$server->id}_{$options['database']}",
|
||||
'username' => $server->uuidShort . '_' . str_random(7),
|
||||
'remote' => $options['remote'],
|
||||
'password' => Crypt::encrypt(str_random(20))
|
||||
'password' => Crypt::encrypt(str_random(20)),
|
||||
]);
|
||||
$db->save();
|
||||
|
||||
|
@ -84,11 +82,10 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
throw new DisplayException('There was an error while connecting to the Database Host Server. Please check the error logs.', $ex);
|
||||
|
@ -128,7 +125,6 @@ class DatabaseRepository {
|
|||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
|
||||
$db->password = Crypt::encrypt($password);
|
||||
$db->save();
|
||||
|
||||
|
@ -145,7 +141,7 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
@ -164,9 +160,9 @@ class DatabaseRepository {
|
|||
}
|
||||
|
||||
/**
|
||||
* Drops a database from the associated MySQL Server
|
||||
* Drops a database from the associated MySQL Server.
|
||||
* @param int $database The ID of the database to drop.
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function drop($database)
|
||||
{
|
||||
|
@ -189,7 +185,7 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
@ -200,12 +196,12 @@ class DatabaseRepository {
|
|||
$db->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollback();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,7 +227,6 @@ class DatabaseRepository {
|
|||
*/
|
||||
public function add(array $data)
|
||||
{
|
||||
|
||||
if (isset($data['host'])) {
|
||||
$data['host'] = gethostbyname($data['host']);
|
||||
}
|
||||
|
@ -265,7 +260,7 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
@ -280,8 +275,8 @@ class DatabaseRepository {
|
|||
'port' => $data['port'],
|
||||
'username' => $data['username'],
|
||||
'password' => Crypt::encrypt($data['password']),
|
||||
'max_databases' => NULL,
|
||||
'linked_node' => (!empty($data['linked_node']) && $data['linked_node'] > 0) ? $data['linked_node'] : NULL
|
||||
'max_databases' => null,
|
||||
'linked_node' => (! empty($data['linked_node']) && $data['linked_node'] > 0) ? $data['linked_node'] : null,
|
||||
]);
|
||||
$dbh->save();
|
||||
|
||||
|
@ -291,5 +286,4 @@ class DatabaseRepository {
|
|||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,10 +21,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
class HelperRepository {
|
||||
|
||||
class HelperRepository
|
||||
{
|
||||
/**
|
||||
* Listing of editable files in the control panel.
|
||||
* @var array
|
||||
|
@ -40,10 +41,9 @@ class HelperRepository {
|
|||
'text/plain',
|
||||
'text/x-perl',
|
||||
'text/x-shellscript',
|
||||
'inode/x-empty'
|
||||
'inode/x-empty',
|
||||
];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -58,17 +58,14 @@ class HelperRepository {
|
|||
*/
|
||||
public static function bytesToHuman($bytes, $decimals = 2)
|
||||
{
|
||||
|
||||
$sz = explode(',', 'B,KB,MB,GB');
|
||||
$factor = floor((strlen($bytes) - 1) / 3);
|
||||
|
||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . $sz[$factor];
|
||||
|
||||
}
|
||||
|
||||
public static function editableFiles()
|
||||
{
|
||||
return self::$editable;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,16 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class LocationRepository
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -40,13 +39,13 @@ class LocationRepository
|
|||
* Creates a new location on the system.
|
||||
* @param array $data
|
||||
* @throws Pterodactyl\Exceptions\DisplayValidationException
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
$validator = Validator::make($data, [
|
||||
'short' => 'required|regex:/^[a-z0-9_.-]{1,10}$/i|unique:locations,short',
|
||||
'long' => 'required|string|min:1|max:255'
|
||||
'long' => 'required|string|min:1|max:255',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
@ -58,7 +57,7 @@ class LocationRepository
|
|||
$location = new Models\Location;
|
||||
$location->fill([
|
||||
'long' => $data['long'],
|
||||
'short' => $data['short']
|
||||
'short' => $data['short'],
|
||||
]);
|
||||
$location->save();
|
||||
|
||||
|
@ -67,16 +66,16 @@ class LocationRepository
|
|||
|
||||
/**
|
||||
* Modifies a location based on the fields passed in $data.
|
||||
* @param integer $id
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @throws Pterodactyl\Exceptions\DisplayValidationException
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function edit($id, array $data)
|
||||
{
|
||||
$validator = Validator::make($data, [
|
||||
'short' => 'regex:/^[a-z0-9_.-]{1,10}$/i',
|
||||
'long' => 'string|min:1|max:255'
|
||||
'long' => 'string|min:1|max:255',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
|
|
@ -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\Repositories;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
use IPTools\Network;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use IPTools\Network;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class NodeRepository {
|
||||
|
||||
class NodeRepository
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -88,7 +87,6 @@ class NodeRepository {
|
|||
$node->save();
|
||||
|
||||
return $node->id;
|
||||
|
||||
}
|
||||
|
||||
public function update($id, array $data)
|
||||
|
@ -133,7 +131,6 @@ class NodeRepository {
|
|||
if (! filter_var(gethostbyname($data['fqdn']), FILTER_VALIDATE_IP)) {
|
||||
throw new DisplayException('The FQDN (or IP Address) provided does not resolve to a valid IP address.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Should we be nulling the overallocations?
|
||||
|
@ -183,13 +180,12 @@ class NodeRepository {
|
|||
],
|
||||
'keys' => [
|
||||
$node->daemonSecret,
|
||||
]
|
||||
],
|
||||
],
|
||||
]);
|
||||
} catch (\Exception $ex) {
|
||||
throw new DisplayException('Failed to update the node configuration, however your changes have been saved to the database. You will need to manually update the configuration file for the node to apply these changes.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function addAllocations($id, array $allocations)
|
||||
|
@ -221,7 +217,7 @@ class NodeRepository {
|
|||
$alloc = Models\Allocation::firstOrNew([
|
||||
'node' => $node->id,
|
||||
'ip' => $ip,
|
||||
'port' => $assignPort
|
||||
'port' => $assignPort,
|
||||
]);
|
||||
if (! $alloc->exists) {
|
||||
$alloc->fill([
|
||||
|
@ -229,7 +225,7 @@ class NodeRepository {
|
|||
'ip' => $ip,
|
||||
'port' => $assignPort,
|
||||
'ip_alias' => $setAlias,
|
||||
'assigned_to' => null
|
||||
'assigned_to' => null,
|
||||
]);
|
||||
$alloc->save();
|
||||
}
|
||||
|
@ -238,7 +234,7 @@ class NodeRepository {
|
|||
$alloc = Models\Allocation::firstOrNew([
|
||||
'node' => $node->id,
|
||||
'ip' => $ip,
|
||||
'port' => $port
|
||||
'port' => $port,
|
||||
]);
|
||||
if (! $alloc->exists) {
|
||||
$alloc->fill([
|
||||
|
@ -246,7 +242,7 @@ class NodeRepository {
|
|||
'ip' => $ip,
|
||||
'port' => $port,
|
||||
'ip_alias' => $setAlias,
|
||||
'assigned_to' => null
|
||||
'assigned_to' => null,
|
||||
]);
|
||||
$alloc->save();
|
||||
}
|
||||
|
@ -290,5 +286,4 @@ class NodeRepository {
|
|||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,29 +21,25 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Crypt;
|
||||
use DB;
|
||||
use Debugbar;
|
||||
use Validator;
|
||||
use Log;
|
||||
|
||||
use Crypt;
|
||||
use Validator;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Events\ServerDeleted;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
use Pterodactyl\Services\DeploymentService;
|
||||
use Pterodactyl\Notifications\ServerCreated;
|
||||
use Pterodactyl\Events\ServerDeleted;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\AccountNotFoundException;
|
||||
use Pterodactyl\Notifications\ServerCreated;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class ServerRepository
|
||||
{
|
||||
|
||||
protected $daemonPermissions = [
|
||||
's:*'
|
||||
's:*',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
|
@ -53,7 +49,7 @@ class ServerRepository
|
|||
|
||||
/**
|
||||
* Generates a SFTP username for a server given a server name.
|
||||
* format: mumble_67c7a4b0
|
||||
* format: mumble_67c7a4b0.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $uuid
|
||||
|
@ -61,16 +57,15 @@ class ServerRepository
|
|||
*/
|
||||
protected function generateSFTPUsername($name, $uuid = null)
|
||||
{
|
||||
|
||||
$uuid = is_null($uuid) ? str_random(8) : $uuid;
|
||||
return strtolower(substr(preg_replace('/\s+/', '', $name), 0, 6) . '_' . $uuid);
|
||||
|
||||
return strtolower(substr(preg_replace('/\s+/', '', $name), 0, 6) . '_' . $uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new server to the system.
|
||||
* @param array $data An array of data descriptors for creating the server. These should align to the columns in the database.
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
|
@ -97,18 +92,17 @@ class ServerRepository
|
|||
});
|
||||
|
||||
$validator->sometimes('ip', 'required|ip', function ($input) {
|
||||
return (!$input->auto_deploy && !$input->allocation);
|
||||
return ! $input->auto_deploy && ! $input->allocation;
|
||||
});
|
||||
|
||||
$validator->sometimes('port', 'required|numeric|min:1|max:65535', function ($input) {
|
||||
return (!$input->auto_deploy && !$input->allocation);
|
||||
return ! $input->auto_deploy && ! $input->allocation;
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation', 'numeric|exists:allocations,id', function ($input) {
|
||||
return ! ($input->auto_deploy || ($input->port && $input->ip));
|
||||
});
|
||||
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
// Exception includes a JSON result of failed validation rules.
|
||||
if ($validator->fails()) {
|
||||
|
@ -126,7 +120,7 @@ class ServerRepository
|
|||
}
|
||||
|
||||
$autoDeployed = false;
|
||||
if (isset($data['auto_deploy']) && in_array($data['auto_deploy'], [true, 1, "1"])) {
|
||||
if (isset($data['auto_deploy']) && in_array($data['auto_deploy'], [true, 1, '1'])) {
|
||||
// This is an auto-deployment situation
|
||||
// Ignore any other passed node data
|
||||
unset($data['node'], $data['ip'], $data['port'], $data['allocation']);
|
||||
|
@ -179,7 +173,7 @@ class ServerRepository
|
|||
$variableList = array_merge($variableList, [[
|
||||
'id' => $variable->id,
|
||||
'env' => $variable->env_variable,
|
||||
'val' => $variable->default_value
|
||||
'val' => $variable->default_value,
|
||||
]]);
|
||||
continue;
|
||||
}
|
||||
|
@ -192,7 +186,7 @@ class ServerRepository
|
|||
$variableList = array_merge($variableList, [[
|
||||
'id' => $variable->id,
|
||||
'env' => $variable->env_variable,
|
||||
'val' => $data['env_' . $variable->env_variable]
|
||||
'val' => $data['env_' . $variable->env_variable],
|
||||
]]);
|
||||
continue;
|
||||
}
|
||||
|
@ -201,7 +195,6 @@ class ServerRepository
|
|||
// Check Overallocation
|
||||
if (! $autoDeployed) {
|
||||
if (is_numeric($node->memory_overallocate) || is_numeric($node->disk_overallocate)) {
|
||||
|
||||
$totals = Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node', $node->id)->first();
|
||||
|
||||
// Check memory limits
|
||||
|
@ -258,7 +251,7 @@ class ServerRepository
|
|||
'daemonSecret' => $uuid->generate('servers', 'daemonSecret'),
|
||||
'image' => (isset($data['custom_image_name'])) ? $data['custom_image_name'] : $option->docker_image,
|
||||
'username' => $this->generateSFTPUsername($data['name'], $genShortUuid),
|
||||
'sftp_password' => Crypt::encrypt('not set')
|
||||
'sftp_password' => Crypt::encrypt('not set'),
|
||||
]);
|
||||
$server->save();
|
||||
|
||||
|
@ -269,16 +262,16 @@ class ServerRepository
|
|||
// Add Variables
|
||||
$environmentVariables = [];
|
||||
$environmentVariables = array_merge($environmentVariables, [
|
||||
'STARTUP' => $data['startup']
|
||||
'STARTUP' => $data['startup'],
|
||||
]);
|
||||
foreach ($variableList as $item) {
|
||||
$environmentVariables = array_merge($environmentVariables, [
|
||||
$item['env'] => $item['val']
|
||||
$item['env'] => $item['val'],
|
||||
]);
|
||||
Models\ServerVariables::create([
|
||||
'server_id' => $server->id,
|
||||
'variable_id' => $item['id'],
|
||||
'variable_value' => $item['val']
|
||||
'variable_value' => $item['val'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -289,13 +282,13 @@ class ServerRepository
|
|||
'node' => $node->name,
|
||||
'service' => $service->name,
|
||||
'option' => $option->name,
|
||||
'uuidShort' => $server->uuidShort
|
||||
'uuidShort' => $server->uuidShort,
|
||||
])));
|
||||
|
||||
$client = Models\Node::guzzleRequest($node->id);
|
||||
$client->request('POST', '/servers', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'uuid' => (string) $server->uuid,
|
||||
|
@ -303,10 +296,10 @@ class ServerRepository
|
|||
'build' => [
|
||||
'default' => [
|
||||
'ip' => $allocation->ip,
|
||||
'port' => (int) $allocation->port
|
||||
'port' => (int) $allocation->port,
|
||||
],
|
||||
'ports' => [
|
||||
(string) $allocation->ip => [ (int) $allocation->port ]
|
||||
(string) $allocation->ip => [(int) $allocation->port],
|
||||
],
|
||||
'env' => $environmentVariables,
|
||||
'memory' => (int) $server->memory,
|
||||
|
@ -314,20 +307,21 @@ class ServerRepository
|
|||
'io' => (int) $server->io,
|
||||
'cpu' => (int) $server->cpu,
|
||||
'disk' => (int) $server->disk,
|
||||
'image' => (isset($data['custom_image_name'])) ? $data['custom_image_name'] : $option->docker_image
|
||||
'image' => (isset($data['custom_image_name'])) ? $data['custom_image_name'] : $option->docker_image,
|
||||
],
|
||||
'service' => [
|
||||
'type' => $service->file,
|
||||
'option' => $option->tag
|
||||
'option' => $option->tag,
|
||||
],
|
||||
'keys' => [
|
||||
(string) $server->daemonSecret => $this->daemonPermissions
|
||||
(string) $server->daemonSecret => $this->daemonPermissions,
|
||||
],
|
||||
'rebuild' => false,
|
||||
],
|
||||
'rebuild' => false
|
||||
]
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $server->id;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -336,25 +330,23 @@ class ServerRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* [updateDetails description]
|
||||
* @param integer $id
|
||||
* [updateDetails description].
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function updateDetails($id, array $data)
|
||||
{
|
||||
|
||||
$uuid = new UuidService;
|
||||
$resetDaemonKey = false;
|
||||
|
||||
// Validate Fields
|
||||
$validator = Validator::make($data, [
|
||||
'owner' => 'email|exists:users,email',
|
||||
'name' => 'regex:([\w -]{4,35})'
|
||||
'name' => 'regex:([\w -]{4,35})',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
@ -393,6 +385,7 @@ class ServerRepository
|
|||
// Do we need to update? If not, return successful.
|
||||
if (! $resetDaemonKey) {
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -403,19 +396,20 @@ class ServerRepository
|
|||
$res = $client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'exceptions' => false,
|
||||
'json' => [
|
||||
'keys' => [
|
||||
(string) $oldDaemonKey => [],
|
||||
(string) $server->daemonSecret => $this->daemonPermissions
|
||||
]
|
||||
]
|
||||
(string) $server->daemonSecret => $this->daemonPermissions,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
if ($res->getStatusCode() === 204) {
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
throw new DisplayException('Daemon returned a a non HTTP/204 error code. HTTP/' + $res->getStatusCode());
|
||||
|
@ -425,11 +419,10 @@ class ServerRepository
|
|||
Log::error($ex);
|
||||
throw new DisplayException('An error occured while attempting to update this server\'s information.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* [updateContainer description]
|
||||
* [updateContainer description].
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return bool
|
||||
|
@ -437,7 +430,7 @@ class ServerRepository
|
|||
public function updateContainer($id, array $data)
|
||||
{
|
||||
$validator = Validator::make($data, [
|
||||
'image' => 'required|string'
|
||||
'image' => 'required|string',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
@ -459,16 +452,17 @@ class ServerRepository
|
|||
$client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'build' => [
|
||||
'image' => $server->image
|
||||
]
|
||||
]
|
||||
'image' => $server->image,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -477,22 +471,20 @@ class ServerRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* [changeBuild description]
|
||||
* @param integer $id
|
||||
* [changeBuild description].
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function changeBuild($id, array $data)
|
||||
{
|
||||
|
||||
$validator = Validator::make($data, [
|
||||
'default' => [
|
||||
'string',
|
||||
'regex:/^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])):(\d{1,5})$/'
|
||||
'regex:/^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5])):(\d{1,5})$/',
|
||||
],
|
||||
'add_additional' => 'nullable|array',
|
||||
'remove_additional' => 'nullable|array',
|
||||
|
@ -500,7 +492,7 @@ class ServerRepository
|
|||
'swap' => 'integer|min:-1',
|
||||
'io' => 'integer|min:10|max:1000',
|
||||
'cpu' => 'integer|min:0',
|
||||
'disk' => 'integer|min:0'
|
||||
'disk' => 'integer|min:0',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
@ -528,7 +520,7 @@ class ServerRepository
|
|||
$server->allocation = $selection->id;
|
||||
$newBuild['default'] = [
|
||||
'ip' => $ip,
|
||||
'port' => (int) $port
|
||||
'port' => (int) $port,
|
||||
];
|
||||
|
||||
// Re-Run to keep updated for rest of function
|
||||
|
@ -553,7 +545,7 @@ class ServerRepository
|
|||
|
||||
$newPorts = true;
|
||||
Models\Allocation::where('ip', $ip)->where('port', $port)->where('assigned_to', $server->id)->update([
|
||||
'assigned_to' => null
|
||||
'assigned_to' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -574,7 +566,7 @@ class ServerRepository
|
|||
|
||||
$newPorts = true;
|
||||
Models\Allocation::where('ip', $ip)->where('port', $port)->whereNull('assigned_to')->update([
|
||||
'assigned_to' => $server->id
|
||||
'assigned_to' => $server->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -634,15 +626,16 @@ class ServerRepository
|
|||
$client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'build' => $newBuild
|
||||
]
|
||||
'build' => $newBuild,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -651,12 +644,10 @@ class ServerRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function updateStartup($id, array $data, $admin = false)
|
||||
{
|
||||
|
||||
$server = Models\Server::findOrFail($id);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
@ -684,7 +675,7 @@ class ServerRepository
|
|||
$variableList = array_merge($variableList, [[
|
||||
'id' => $variable->id,
|
||||
'env' => $variable->env_variable,
|
||||
'val' => $variable->a_currentValue
|
||||
'val' => $variable->a_currentValue,
|
||||
]]);
|
||||
continue;
|
||||
}
|
||||
|
@ -694,7 +685,7 @@ class ServerRepository
|
|||
$variableList = array_merge($variableList, [[
|
||||
'id' => $variable->id,
|
||||
'env' => $variable->env_variable,
|
||||
'val' => null
|
||||
'val' => null,
|
||||
]]);
|
||||
continue;
|
||||
}
|
||||
|
@ -720,7 +711,7 @@ class ServerRepository
|
|||
$variableList = array_merge($variableList, [[
|
||||
'id' => $variable->id,
|
||||
'env' => $variable->env_variable,
|
||||
'val' => $data[$variable->env_variable]
|
||||
'val' => $data[$variable->env_variable],
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
@ -728,17 +719,17 @@ class ServerRepository
|
|||
// Add Variables
|
||||
$environmentVariables = [];
|
||||
$environmentVariables = array_merge($environmentVariables, [
|
||||
'STARTUP' => $server->startup
|
||||
'STARTUP' => $server->startup,
|
||||
]);
|
||||
foreach ($variableList as $item) {
|
||||
$environmentVariables = array_merge($environmentVariables, [
|
||||
$item['env'] => $item['val']
|
||||
$item['env'] => $item['val'],
|
||||
]);
|
||||
|
||||
// Update model or make a new record if it doesn't exist.
|
||||
$model = Models\ServerVariables::firstOrNew([
|
||||
'variable_id' => $item['id'],
|
||||
'server_id' => $server->id
|
||||
'server_id' => $server->id,
|
||||
]);
|
||||
$model->variable_value = $item['val'];
|
||||
$model->save();
|
||||
|
@ -750,16 +741,17 @@ class ServerRepository
|
|||
$client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'build' => [
|
||||
'env|overwrite' => $environmentVariables
|
||||
]
|
||||
]
|
||||
'env|overwrite' => $environmentVariables,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -768,7 +760,6 @@ class ServerRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function deleteServer($id, $force)
|
||||
|
@ -792,7 +783,8 @@ class ServerRepository
|
|||
}
|
||||
}
|
||||
|
||||
public function deleteNow($id, $force = false) {
|
||||
public function deleteNow($id, $force = false)
|
||||
{
|
||||
$server = Models\Server::withTrashed()->findOrFail($id);
|
||||
$node = Models\Node::findOrFail($server->node);
|
||||
|
||||
|
@ -806,7 +798,7 @@ class ServerRepository
|
|||
try {
|
||||
// Unassign Allocations
|
||||
Models\Allocation::where('assigned_to', $server->id)->update([
|
||||
'assigned_to' => null
|
||||
'assigned_to' => null,
|
||||
]);
|
||||
|
||||
// Remove Variables
|
||||
|
@ -836,8 +828,8 @@ class ServerRepository
|
|||
$client->request('DELETE', '/servers', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
'X-Access-Server' => $server->uuid
|
||||
]
|
||||
'X-Access-Server' => $server->uuid,
|
||||
],
|
||||
]);
|
||||
|
||||
$server->forceDelete();
|
||||
|
@ -873,13 +865,14 @@ class ServerRepository
|
|||
throw new DisplayException('This server was marked as having a failed install, you cannot override this.');
|
||||
}
|
||||
$server->installed = ($server->installed === 1) ? 0 : 1;
|
||||
|
||||
return $server->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspends a server instance making it unable to be booted or used by a user.
|
||||
* @param integer $id
|
||||
* @return boolean
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function suspend($id, $deleted = false)
|
||||
{
|
||||
|
@ -902,8 +895,8 @@ class ServerRepository
|
|||
$client->request('POST', '/server/suspend', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
'X-Access-Server' => $server->uuid
|
||||
]
|
||||
'X-Access-Server' => $server->uuid,
|
||||
],
|
||||
]);
|
||||
|
||||
return DB::commit();
|
||||
|
@ -918,8 +911,8 @@ class ServerRepository
|
|||
|
||||
/**
|
||||
* Unsuspends a server instance.
|
||||
* @param integer $id
|
||||
* @return boolean
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function unsuspend($id)
|
||||
{
|
||||
|
@ -942,8 +935,8 @@ class ServerRepository
|
|||
$client->request('POST', '/server/unsuspend', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
'X-Access-Server' => $server->uuid
|
||||
]
|
||||
'X-Access-Server' => $server->uuid,
|
||||
],
|
||||
]);
|
||||
|
||||
return DB::commit();
|
||||
|
@ -964,7 +957,7 @@ class ServerRepository
|
|||
$validator = Validator::make([
|
||||
'password' => $password,
|
||||
], [
|
||||
'password' => 'required|regex:/^((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})$/'
|
||||
'password' => 'required|regex:/^((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})$/',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -981,7 +974,7 @@ class ServerRepository
|
|||
$client->request('POST', '/server/password', [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
'X-Access-Server' => $server->uuid
|
||||
'X-Access-Server' => $server->uuid,
|
||||
],
|
||||
'json' => [
|
||||
'password' => $password,
|
||||
|
@ -989,6 +982,7 @@ class ServerRepository
|
|||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -997,7 +991,5 @@ class ServerRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\ServiceRepository;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class Option
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -50,7 +47,7 @@ class Option
|
|||
'tag' => 'required|string|max:255',
|
||||
'executable' => 'sometimes|string|max:255',
|
||||
'docker_image' => 'required|string|max:255',
|
||||
'startup' => 'sometimes|string'
|
||||
'startup' => 'sometimes|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -105,7 +102,7 @@ class Option
|
|||
'tag' => 'sometimes|required|string|max:255',
|
||||
'executable' => 'sometimes|string|max:255',
|
||||
'docker_image' => 'sometimes|required|string|max:255',
|
||||
'startup' => 'sometimes|string'
|
||||
'startup' => 'sometimes|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -123,5 +120,4 @@ class Option
|
|||
$option->fill($data);
|
||||
$option->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,21 +21,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\ServiceRepository;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
use Uuid;
|
||||
|
||||
use Validator;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class Service
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -48,7 +45,7 @@ class Service
|
|||
'description' => 'required|string',
|
||||
'file' => 'required|regex:/^[\w.-]{1,50}$/',
|
||||
'executable' => 'max:255|regex:/^(.*)$/',
|
||||
'startup' => 'string'
|
||||
'startup' => 'string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -77,7 +74,7 @@ class Service
|
|||
'description' => 'sometimes|required|string',
|
||||
'file' => 'sometimes|required|regex:/^[\w.-]{1,50}$/',
|
||||
'executable' => 'sometimes|max:255|regex:/^(.*)$/',
|
||||
'startup' => 'sometimes|string'
|
||||
'startup' => 'sometimes|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -109,5 +106,4 @@ class Service
|
|||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories\ServiceRepository;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class Variable
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -52,7 +49,7 @@ class Variable
|
|||
'user_viewable' => 'sometimes|required|numeric|size:1',
|
||||
'user_editable' => 'sometimes|required|numeric|size:1',
|
||||
'required' => 'sometimes|required|numeric|size:1',
|
||||
'regex' => 'required|string|min:1'
|
||||
'regex' => 'required|string|min:1',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -77,7 +74,8 @@ class Variable
|
|||
$variable->save();
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
public function delete($id)
|
||||
{
|
||||
$variable = Models\ServiceVariables::findOrFail($id);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
@ -104,7 +102,7 @@ class Variable
|
|||
'user_viewable' => 'sometimes|required|numeric|boolean',
|
||||
'user_editable' => 'sometimes|required|numeric|boolean',
|
||||
'required' => 'sometimes|required|numeric|boolean',
|
||||
'regex' => 'sometimes|required|string|min:1'
|
||||
'regex' => 'sometimes|required|string|min:1',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -129,5 +127,4 @@ class Variable
|
|||
$variable->fill($data);
|
||||
$variable->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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\Repositories;
|
||||
|
||||
use DB;
|
||||
use Mail;
|
||||
use Settings;
|
||||
use Validator;
|
||||
use Mail;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\UserRepository;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class SubuserRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Core permissions required for every subuser on the daemon.
|
||||
* Without this we cannot connect the websocket or get basic
|
||||
|
@ -46,7 +43,7 @@ class SubuserRepository
|
|||
*/
|
||||
protected $coreDaemonPermissions = [
|
||||
's:get',
|
||||
's:console'
|
||||
's:console',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -101,7 +98,7 @@ class SubuserRepository
|
|||
|
||||
// Databases
|
||||
'view-databases' => null,
|
||||
'reset-db-password' => null
|
||||
'reset-db-password' => null,
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
|
@ -111,18 +108,18 @@ class SubuserRepository
|
|||
|
||||
/**
|
||||
* Creates a new subuser on the server.
|
||||
* @param integer $id The ID of the server to add this subuser to.
|
||||
* @param int $id The ID of the server to add this subuser to.
|
||||
* @param array $data
|
||||
* @throws DisplayValidationException
|
||||
* @throws DisplayException
|
||||
* @return integer Returns the ID of the newly created subuser.
|
||||
* @return int Returns the ID of the newly created subuser.
|
||||
*/
|
||||
public function create($sid, array $data)
|
||||
{
|
||||
$server = Models\Server::findOrFail($sid);
|
||||
$validator = Validator::make($data, [
|
||||
'permissions' => 'required|array',
|
||||
'email' => 'required|email'
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -151,7 +148,7 @@ class SubuserRepository
|
|||
$subuser->fill([
|
||||
'user_id' => $user->id,
|
||||
'server_id' => $server->id,
|
||||
'daemonSecret' => (string) $uuid->generate('servers', 'uuid')
|
||||
'daemonSecret' => (string) $uuid->generate('servers', 'uuid'),
|
||||
]);
|
||||
$subuser->save();
|
||||
|
||||
|
@ -166,7 +163,7 @@ class SubuserRepository
|
|||
$model->fill([
|
||||
'user_id' => $user->id,
|
||||
'server_id' => $server->id,
|
||||
'permission' => $permission
|
||||
'permission' => $permission,
|
||||
]);
|
||||
$model->save();
|
||||
}
|
||||
|
@ -182,13 +179,13 @@ class SubuserRepository
|
|||
$res = $client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'keys' => [
|
||||
$subuser->daemonSecret => $daemonPermissions
|
||||
]
|
||||
]
|
||||
$subuser->daemonSecret => $daemonPermissions,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$email = $data['email'];
|
||||
|
@ -201,6 +198,7 @@ class SubuserRepository
|
|||
$message->subject(Settings::get('company') . ' - Added to Server');
|
||||
});
|
||||
DB::commit();
|
||||
|
||||
return $subuser->id;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -209,12 +207,13 @@ class SubuserRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revokes a users permissions on a server.
|
||||
* @param integer $id The ID of the subuser row in MySQL.
|
||||
* @param int $id The ID of the subuser row in MySQL.
|
||||
* @param array $data
|
||||
* @throws DisplayValidationException
|
||||
* @throws DisplayException
|
||||
|
@ -236,17 +235,18 @@ class SubuserRepository
|
|||
$res = $client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'keys' => [
|
||||
$subuser->daemonSecret => []
|
||||
]
|
||||
]
|
||||
$subuser->daemonSecret => [],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$subuser->delete();
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -255,12 +255,13 @@ class SubuserRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates permissions for a given subuser.
|
||||
* @param integer $id The ID of the subuser row in MySQL. (Not the user ID)
|
||||
* @param int $id The ID of the subuser row in MySQL. (Not the user ID)
|
||||
* @param array $data
|
||||
* @throws DisplayValidationException
|
||||
* @throws DisplayException
|
||||
|
@ -297,7 +298,7 @@ class SubuserRepository
|
|||
$model->fill([
|
||||
'user_id' => $data['user'],
|
||||
'server_id' => $data['server'],
|
||||
'permission' => $permission
|
||||
'permission' => $permission,
|
||||
]);
|
||||
$model->save();
|
||||
}
|
||||
|
@ -312,16 +313,17 @@ class SubuserRepository
|
|||
$res = $client->request('PATCH', '/server', [
|
||||
'headers' => [
|
||||
'X-Access-Server' => $server->uuid,
|
||||
'X-Access-Token' => $node->daemonSecret
|
||||
'X-Access-Token' => $node->daemonSecret,
|
||||
],
|
||||
'json' => [
|
||||
'keys' => [
|
||||
$subuser->daemonSecret => $daemonPermissions
|
||||
]
|
||||
]
|
||||
$subuser->daemonSecret => $daemonPermissions,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -330,7 +332,7 @@ class SubuserRepository
|
|||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,19 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Cron;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class TaskRepository
|
||||
{
|
||||
|
||||
protected $defaults = [
|
||||
'year' => '*',
|
||||
'day_of_week' => '*',
|
||||
|
@ -64,6 +62,7 @@ class TaskRepository
|
|||
$task = Models\Task::findOrFail($id);
|
||||
try {
|
||||
$task->delete();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $ex) {
|
||||
throw $ex;
|
||||
|
@ -111,7 +110,7 @@ class TaskRepository
|
|||
'month' => 'string|sometimes',
|
||||
'day_of_month' => 'string|sometimes',
|
||||
'hour' => 'string|sometimes',
|
||||
'minute' => 'string|sometimes'
|
||||
'minute' => 'string|sometimes',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -157,11 +156,9 @@ class TaskRepository
|
|||
'hour' => $cron['hour'],
|
||||
'minute' => $cron['minute'],
|
||||
'last_run' => null,
|
||||
'next_run' => $buildCron->getNextRunDate()
|
||||
'next_run' => $buildCron->getNextRunDate(),
|
||||
]);
|
||||
|
||||
return $task->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,26 +22,22 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use DB;
|
||||
use Settings;
|
||||
use Hash;
|
||||
use Validator;
|
||||
use Mail;
|
||||
use Carbon;
|
||||
use Auth;
|
||||
|
||||
use Hash;
|
||||
use Carbon;
|
||||
use Validator;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
use Pterodactyl\Notifications\AccountCreated;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Notifications\AccountCreated;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class UserRepository
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
|
@ -54,7 +50,7 @@ class UserRepository
|
|||
* @param string|null $password An unhashed version of the user's password.
|
||||
* @param bool $admin Boolean value if user should be an admin or not.
|
||||
* @param int $token A custom user ID.
|
||||
* @return bool|integer
|
||||
* @return bool|int
|
||||
*/
|
||||
public function create($email, $password = null, $admin = false, $token = null)
|
||||
{
|
||||
|
@ -99,12 +95,13 @@ class UserRepository
|
|||
DB::table('password_resets')->insert([
|
||||
'email' => $user->email,
|
||||
'token' => $token,
|
||||
'created_at' => Carbon::now()->toDateTimeString()
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
|
||||
$user->notify((new AccountCreated($token)));
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $user->id;
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
|
@ -115,9 +112,9 @@ class UserRepository
|
|||
/**
|
||||
* Updates a user on the panel.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param int $id
|
||||
* @param array $data An array of columns and their associated values to update for the user.
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function update($id, array $data)
|
||||
{
|
||||
|
@ -129,7 +126,7 @@ class UserRepository
|
|||
'root_admin' => 'sometimes|required|boolean',
|
||||
'language' => 'sometimes|required|string|min:1|max:5',
|
||||
'use_totp' => 'sometimes|required|boolean',
|
||||
'totp_secret' => 'sometimes|required|size:16'
|
||||
'totp_secret' => 'sometimes|required|size:16',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
@ -153,8 +150,8 @@ class UserRepository
|
|||
/**
|
||||
* Deletes a user on the panel, returns the number of records deleted.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return integer
|
||||
* @param int $id
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
|
@ -175,11 +172,11 @@ class UserRepository
|
|||
Models\User::destroy($id);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,16 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services;
|
||||
|
||||
use Log;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\APILog;
|
||||
|
||||
class APILogService
|
||||
{
|
||||
|
||||
public function __constructor()
|
||||
{
|
||||
//
|
||||
|
@ -53,7 +52,7 @@ class APILogService
|
|||
'route' => $request->fullUrl(),
|
||||
'content' => (empty($request->getContent())) ? null : $request->getContent(),
|
||||
'user_agent' => $request->header('User-Agent'),
|
||||
'request_ip' => $request->ip()
|
||||
'request_ip' => $request->ip(),
|
||||
]);
|
||||
$log->save();
|
||||
} catch (\Exception $ex) {
|
||||
|
|
|
@ -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,16 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services;
|
||||
|
||||
use DB;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
||||
class DeploymentService
|
||||
{
|
||||
|
||||
public function __constructor()
|
||||
{
|
||||
//
|
||||
|
@ -63,7 +62,7 @@ class DeploymentService
|
|||
{
|
||||
$useLocation = Models\Location::where('id', $location)->first();
|
||||
if (! $useLocation) {
|
||||
throw new DisplayException("The location passed was not valid and could not be found.");
|
||||
throw new DisplayException('The location passed was not valid and could not be found.');
|
||||
}
|
||||
|
||||
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
|
||||
|
@ -84,14 +83,15 @@ class DeploymentService
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public static function smartRandomNode($memory, $disk, $location = null) {
|
||||
public static function smartRandomNode($memory, $disk, $location = null)
|
||||
{
|
||||
$node = self::randomNode($location);
|
||||
$notIn = [];
|
||||
do {
|
||||
$return = self::checkNodeAllocation($node, $memory, $disk);
|
||||
if (! $return) {
|
||||
$notIn = array_merge($notIn, [
|
||||
$node->id
|
||||
$node->id,
|
||||
]);
|
||||
$node = self::randomNode($location, $notIn);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class DeploymentService
|
|||
$diskLimitReached = (($totals->disk + $disk) > $limit);
|
||||
}
|
||||
|
||||
return (!$diskLimitReached && !$memoryLimitReached);
|
||||
return ! $diskLimitReached && ! $memoryLimitReached;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,15 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\User;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Notifications\Daemon;
|
||||
|
||||
class NotificationService {
|
||||
|
||||
class NotificationService
|
||||
{
|
||||
protected $server;
|
||||
|
||||
protected $user;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue