Merge pull request #608 from Pterodactyl/feature/PTDL-472

Merge code refactor into develop.
This commit is contained in:
Dane Everitt 2017-08-27 14:57:13 -05:00 committed by GitHub
commit a91d84ecfe
504 changed files with 22962 additions and 7141 deletions

View file

@ -13,5 +13,5 @@ Default panel users:
MySQL is accessible using root/pterodactyl or pterodactyl/pterodactyl
Services for pteroq and mailhog are running
Service for pteroq and mailhog are running
#####################################################

View file

@ -24,10 +24,6 @@ MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM=you@example.com
API_PREFIX=api
API_VERSION=v1
API_DEBUG=false
QUEUE_DRIVER=database
QUEUE_HIGH=high
QUEUE_STANDARD=standard

16
.env.travis Normal file
View file

@ -0,0 +1,16 @@
APP_ENV=testing
APP_DEBUG=true
APP_KEY=SomeRandomString3232RandomString
APP_THEME=pterodactyl
APP_TIMEZONE=UTC
APP_URL=http://localhost/
DB_HOST=127.0.0.1
DB_DATABASE=travis
DB_USERNAME=root
DB_PASSWORD=""
CACHE_DRIVER=array
SESSION_DRIVER=array
MAIL_DRIVER=array
QUEUE_DRIVER=sync

1
.gitignore vendored
View file

@ -23,3 +23,4 @@ docker-compose.yml
# for image related files
misc
.phpstorm.meta.php
.php_cs.cache

42
.php_cs
View file

@ -1,7 +1,41 @@
<?php
require_once __DIR__ . '/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';
$finder = PhpCsFixer\Finder::create()
->in([
'app',
'bootstrap',
'config',
'database',
'resources/lang',
'routes',
'tests',
]);
use SLLH\StyleCIBridge\ConfigBridge;
return ConfigBridge::create();
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@PSR1' => true,
'@PSR2' => true,
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_return' => true,
'blank_line_before_statement' => false,
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'single'],
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'new_with_braces' => false,
'no_alias_functions' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'not_operator_with_successor_space' => true,
'phpdoc_align' => ['tags' => ['param']],
'phpdoc_separation' => false,
'protected_to_private' => false,
'psr0' => ['dir' => 'app'],
'psr4' => true,
'random_api_migration' => true,
'standardize_not_equals' => true,
])->setRiskyAllowed(true)->setFinder($finder);

View file

@ -4,3 +4,4 @@ disabled:
- concat_without_spaces
enabled:
- concat_with_spaces
- no_unused_imports

24
.travis.yml Normal file
View file

@ -0,0 +1,24 @@
language: php
dist: trusty
php:
- '7.0'
- '7.1'
- '7.2'
sudo: false
cache:
directories:
- $HOME/.composer/cache
services:
- mysql
before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
before_script:
- cp .env.travis .env
- composer install --no-interaction --prefer-dist --no-suggest --verbose
- php artisan migrate --seed -v
script:
- vendor/bin/phpunit --coverage-clover coverage.xml
notifications:
email: false
after_success:
- bash <(curl -s https://codecov.io/bash)

View file

@ -246,7 +246,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* New theme applied to Admin CP. Many graphical changes were made, some data was moved around and some display data changed. Too much was changed to feasibly log it all in here. Major breaking changes or notable new features will be logged.
* New server creation page now makes significantly less AJAX calls and is much quicker to respond.
* Server and Node view pages wee modified to split tabs into individual pages to make re-themeing and modifications significantly easier, and reduce MySQL query loads on page.
* `[pre.4]` — Services and Pack magement overhauled to be faster, cleaner, and more extensible in the future.
* `[pre.4]` — Service and Pack magement overhauled to be faster, cleaner, and more extensible in the future.
* Most of the backend `UnhandledException` display errors now include a clearer error that directs admins to the program's logs.
* Table seeders for services now can be run during upgrades and will attempt to locate and update, or create new if not found in the database.
* Many structural changes to the database and `Pterodactyl\Models` classes that would flood this changelog if they were all included. All required migrations included to handle database changes.

View file

@ -49,8 +49,6 @@ class AddLocation extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -57,8 +57,6 @@ class AddNode extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -46,8 +46,6 @@ class CleanServiceBackup extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -45,8 +45,6 @@ class ClearServices extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -49,8 +49,6 @@ class ClearTasks extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -25,7 +25,7 @@
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
use Pterodactyl\Repositories\UserRepository;
use Pterodactyl\Repositories\oldUserRepository;
class MakeUser extends Command
{
@ -51,8 +51,6 @@ class MakeUser extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
@ -80,7 +78,7 @@ class MakeUser extends Command
$data['root_admin'] = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
try {
$user = new UserRepository;
$user = new oldUserRepository;
$user->create($data);
return $this->info('User successfully created.');

View file

@ -49,8 +49,6 @@ class RebuildServer extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -50,8 +50,6 @@ class RunTasks extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -45,8 +45,6 @@ class ShowVersion extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -51,8 +51,6 @@ class UpdateEmailSettings extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -55,8 +55,6 @@ class UpdateEnvironment extends Command
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{

View file

@ -31,7 +31,6 @@ class Kernel extends ConsoleKernel
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{

View file

@ -0,0 +1,39 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Criteria;
use Pterodactyl\Repositories\Repository;
interface CriteriaInterface
{
/**
* Apply selected criteria to a repository call.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Pterodactyl\Repositories\Repository $repository
* @return mixed
*/
public function apply($model, Repository $repository);
}

View file

@ -0,0 +1,45 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface AllocationRepositoryInterface extends RepositoryInterface
{
/**
* Set an array of allocation IDs to be assigned to a specific server.
*
* @param int|null $server
* @param array $ids
* @return int
*/
public function assignAllocationsToServer($server, array $ids);
/**
* Return all of the allocations for a specific node.
*
* @param int $node
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getAllocationsForNode($node);
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface ApiKeyRepositoryInterface extends RepositoryInterface
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface ApiPermissionRepositoryInterface extends RepositoryInterface
{
}

View file

@ -1,5 +1,5 @@
<?php
/**
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
@ -22,19 +22,15 @@
* SOFTWARE.
*/
namespace Pterodactyl\Facades;
namespace Pterodactyl\Contracts\Repository\Attributes;
use Illuminate\Support\Facades\Facade;
class Version extends Facade
interface SearchableInterface
{
/**
* Returns the facade accessor class.
* Filter results by search term.
*
* @return strig
* @param string $term
* @return $this
*/
protected static function getFacadeAccessor()
{
return '\Pterodactyl\Services\VersionService';
}
public function search($term);
}

View file

@ -0,0 +1,83 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository\Daemon;
interface BaseRepositoryInterface
{
/**
* Set the node model to be used for this daemon connection.
*
* @param int $id
* @return $this
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function setNode($id);
/**
* Return the node model being used.
*
* @return \Pterodactyl\Models\Node
*/
public function getNode();
/**
* Set the UUID for the server to be used in the X-Access-Server header for daemon requests.
*
* @param null|string $server
* @return $this
*/
public function setAccessServer($server = null);
/**
* Return the UUID of the server being used in requests.
*
* @return string
*/
public function getAccessServer();
/**
* Set the token to be used in the X-Access-Token header for requests to the daemon.
*
* @param null|string $token
* @return $this
*/
public function setAccessToken($token = null);
/**
* Return the access token being used for requests.
*
* @return string
*/
public function getAccessToken();
/**
* Return an instance of the Guzzle HTTP Client to be used for requests.
*
* @param array $headers
* @return \GuzzleHttp\Client
*/
public function getHttpClient(array $headers = []);
}

View file

@ -0,0 +1,36 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository\Daemon;
interface CommandRepositoryInterface extends BaseRepositoryInterface
{
/**
* Send a command to a server.
*
* @param string $command
* @return \Psr\Http\Message\ResponseInterface
*/
public function send($command);
}

View file

@ -0,0 +1,36 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository\Daemon;
interface ConfigurationRepositoryInterface extends BaseRepositoryInterface
{
/**
* Update the configuration details for the specified node using data from the database.
*
* @param array $overrides
* @return \Psr\Http\Message\ResponseInterface
*/
public function update(array $overrides = []);
}

View file

@ -0,0 +1,61 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository\Daemon;
interface FileRepositoryInterface extends BaseRepositoryInterface
{
/**
* Return stat information for a given file.
*
* @param string $path
* @return object
*/
public function getFileStat($path);
/**
* Return the contents of a given file if it can be edited in the Panel.
*
* @param string $path
* @return object
*/
public function getContent($path);
/**
* Save new contents to a given file.
*
* @param string $path
* @param string $content
* @return \Psr\Http\Message\ResponseInterface
*/
public function putContent($path, $content);
/**
* Return a directory listing for a given path.
*
* @param string $path
* @return array
*/
public function getDirectory($path);
}

View file

@ -0,0 +1,43 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository\Daemon;
interface PowerRepositoryInterface extends BaseRepositoryInterface
{
const SIGNAL_START = 'start';
const SIGNAL_STOP = 'stop';
const SIGNAL_RESTART = 'restart';
const SIGNAL_KILL = 'kill';
/**
* Send a power signal to a server.
*
* @param string $signal
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
*/
public function sendSignal($signal);
}

View file

@ -0,0 +1,91 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository\Daemon;
interface ServerRepositoryInterface extends BaseRepositoryInterface
{
/**
* Create a new server on the daemon for the panel.
*
* @param int $id
* @param array $overrides
* @param bool $start
* @return \Psr\Http\Message\ResponseInterface
*/
public function create($id, array $overrides = [], $start = false);
/**
* Set an access token and associated permissions for a server.
*
* @param string $key
* @param array $permissions
* @return \Psr\Http\Message\ResponseInterface
*/
public function setSubuserKey($key, array $permissions);
/**
* Update server details on the daemon.
*
* @param array $data
* @return \Psr\Http\Message\ResponseInterface
*/
public function update(array $data);
/**
* Mark a server to be reinstalled on the system.
*
* @param array|null $data
* @return \Psr\Http\Message\ResponseInterface
*/
public function reinstall($data = null);
/**
* Mark a server as needing a container rebuild the next time the server is booted.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function rebuild();
/**
* Suspend a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function suspend();
/**
* Un-suspend a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function unsuspend();
/**
* Delete a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function delete();
}

View file

@ -0,0 +1,45 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface DatabaseHostRepositoryInterface extends RepositoryInterface
{
/**
* Return database hosts with a count of databases and the node information for which it is attached.
*
* @return \Illuminate\Support\Collection
*/
public function getWithViewDetails();
/**
* Return a database host with the databases and associated servers that are attached to said databases.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithServers($id);
}

View file

@ -0,0 +1,98 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface DatabaseRepositoryInterface extends RepositoryInterface
{
/**
* Create a new database if it does not already exist on the host with
* the provided details.
*
* @param array $data
* @return mixed
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function createIfNotExists(array $data);
/**
* Create a new database on a given connection.
*
* @param string $database
* @param null|string $connection
* @return bool
*/
public function createDatabase($database, $connection = null);
/**
* Create a new database user on a given connection.
*
* @param string $username
* @param string $remote
* @param string $password
* @param null|string $connection
* @return bool
*/
public function createUser($username, $remote, $password, $connection = null);
/**
* Give a specific user access to a given database.
*
* @param string $database
* @param string $username
* @param string $remote
* @param null|string $connection
* @return bool
*/
public function assignUserToDatabase($database, $username, $remote, $connection = null);
/**
* Flush the privileges for a given connection.
*
* @param null|string $connection
* @return mixed
*/
public function flush($connection = null);
/**
* Drop a given database on a specific connection.
*
* @param string $database
* @param null|string $connection
* @return bool
*/
public function dropDatabase($database, $connection = null);
/**
* Drop a given user on a specific connection.
*
* @param string $username
* @param string $remote
* @param null|string $connection
* @return mixed
*/
public function dropUser($username, $remote, $connection = null);
}

View file

@ -0,0 +1,65 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface LocationRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Delete a location only if there are no nodes attached to it.
*
* @param $id
* @return bool|mixed|null
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function deleteIfNoNodes($id);
/**
* Return locations with a count of nodes and servers attached to it.
*
* @return mixed
*/
public function getAllWithDetails();
/**
* Return all of the available locations with the nodes as a relationship.
*
* @return \Illuminate\Support\Collection
*/
public function getAllWithNodes();
/**
* Return all of the nodes and their respective count of servers for a location.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithNodes($id);
}

View file

@ -0,0 +1,84 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Return the usage stats for a single node.
*
* @param int $id
* @return array
*/
public function getUsageStats($id);
/**
* Return all available nodes with a searchable interface.
*
* @param int $count
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getNodeListingData($count = 25);
/**
* Return a single node with location and server information.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getSingleNode($id);
/**
* Return a node with all of the associated allocations and servers that are attached to said allocations.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getNodeAllocations($id);
/**
* Return a node with all of the servers attached to that node.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getNodeServers($id);
/**
* Return a collection of nodes beloning to a specific location for use on frontend display.
*
* @param int $location
* @return mixed
*/
public function getNodesForLocation($location);
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface OptionVariableRepositoryInterface extends RepositoryInterface
{
}

View file

@ -0,0 +1,59 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface PackRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Return a paginated listing of packs with their associated option and server count.
*
* @param int $paginate
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginateWithOptionAndServerCount($paginate = 50);
/**
* Return a pack with the associated server models attached to it.
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function getWithServers($id);
/**
* Return all of the file archives for a given pack.
*
* @param int $id
* @param bool $collection
* @return object|\Illuminate\Support\Collection
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function getFileArchives($id, $collection = false);
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface PermissionRepositoryInterface extends RepositoryInterface
{
}

View file

@ -0,0 +1,205 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface RepositoryInterface
{
/**
* Return an identifier or Model object to be used by the repository.
*
* @return string|\Closure|object
*/
public function model();
/**
* Return the model being used for this repository instance.
*
* @return mixed
*/
public function getModel();
/**
* Returns an instance of a query builder.
*
* @return mixed
*/
public function getBuilder();
/**
* Returns the colummns to be selected or returned by the query.
*
* @return mixed
*/
public function getColumns();
/**
* An array of columns to filter the response by.
*
* @param array $columns
* @return $this
*/
public function withColumns($columns = ['*']);
/**
* Disable returning a fresh model when data is inserted or updated.
*
* @return $this
*/
public function withoutFresh();
/**
* Create a new model instance and persist it to the database.
*
* @param array $fields
* @param bool $validate
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function create(array $fields, $validate = true);
/**
* Delete a given record from the database.
*
* @param int $id
* @return int
*/
public function delete($id);
/**
* Delete records matching the given attributes.
*
* @param array $attributes
* @return int
*/
public function deleteWhere(array $attributes);
/**
* Find a model that has the specific ID passed.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function find($id);
/**
* Find a model matching an array of where clauses.
*
* @param array $fields
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function findWhere(array $fields);
/**
* Find and return the first matching instance for the given fields.
*
* @param array $fields
* @return mixed
*/
public function findFirstWhere(array $fields);
/**
* Return a count of records matching the passed arguments.
*
* @param array $fields
* @return int
*/
public function findCountWhere(array $fields);
/**
* Update a given ID with the passed array of fields.
*
* @param int $id
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update($id, array $fields, $validate = true, $force = false);
/**
* Perform a mass update where matching records are updated using whereIn.
* This does not perform any model data validation.
*
* @param string $column
* @param array $values
* @param array $fields
* @return int
*/
public function updateWhereIn($column, array $values, array $fields);
/**
* Update a record if it exists in the database, otherwise create it.
*
* @param array $where
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function updateOrCreate(array $where, array $fields, $validate = true, $force = false);
/**
* Update multiple records matching the passed clauses.
*
* @param array $where
* @param array $fields
* @return mixed
*/
public function massUpdate(array $where, array $fields);
/**
* Return all records from the model.
*
* @return mixed
*/
public function all();
/**
* Insert a single or multiple records into the database at once skipping
* validation and mass assignment checking.
*
* @param array $data
* @return bool
*/
public function insert(array $data);
/**
* Insert multiple records into the database and ignore duplicates.
*
* @param array $values
* @return bool
*/
public function insertIgnore(array $values);
}

View file

@ -0,0 +1,90 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface ServerRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Returns a listing of all servers that exist including relationships.
*
* @param int $paginate
* @return mixed
*/
public function getAllServers($paginate);
/**
* Return a server model and all variables associated with the server.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function findWithVariables($id);
/**
* Return all of the server variables possible and default to the variable
* default if there is no value defined for the specific server requested.
*
* @param int $id
* @param bool $returnAsObject
* @return array|object
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getVariablesWithValues($id, $returnAsObject = false);
/**
* Return enough data to be used for the creation of a server via the daemon.
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getDataForCreation($id);
/**
* Return a server as well as associated databases and their hosts.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithDatabases($id);
/**
* Return data about the daemon service in a consumable format.
*
* @param int $id
* @return array
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getDaemonServiceData($id);
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface ServerVariableRepositoryInterface extends RepositoryInterface
{
}

View file

@ -0,0 +1,53 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface ServiceOptionRepositoryInterface extends RepositoryInterface
{
/**
* Return a service option with the variables relation attached.
*
* @param int $id
* @return mixed
*/
public function getWithVariables($id);
/**
* Return a service option with the copyFrom relation loaded onto the model.
*
* @param int $id
* @return mixed
*/
public function getWithCopyFrom($id);
/**
* Confirm a copy script belongs to the same service as the item trying to use it.
*
* @param int $copyFromId
* @param int $service
* @return bool
*/
public function isCopiableScript($copyFromId, $service);
}

View file

@ -0,0 +1,44 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface ServiceRepositoryInterface extends RepositoryInterface
{
/**
* Return a service or all services with their associated options, variables, and packs.
*
* @param int $id
* @return \Illuminate\Support\Collection
*/
public function getWithOptions($id = null);
/**
* Return a service along with its associated options and the servers relation on those options.
*
* @param int $id
* @return mixed
*/
public function getWithOptionServers($id);
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface ServiceVariableRepositoryInterface extends RepositoryInterface
{
}

View file

@ -0,0 +1,48 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
interface SubuserRepositoryInterface extends RepositoryInterface
{
/**
* Return a subuser with the associated server relationship.
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithServer($id);
/**
* Find a subuser and return with server and permissions relationships.
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithServerAndPermissions($id);
}

View file

@ -0,0 +1,45 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface UserRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Return all users with counts of servers and subusers of servers.
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getAllUsersWithCounts();
/**
* Return all matching models for a user in a format that can be used for dropdowns.
*
* @param string $query
* @return \Illuminate\Database\Eloquent\Collection
*/
public function filterUsersByQuery($query);
}

View file

@ -49,7 +49,6 @@ class FailedCaptcha
*
* @param string $ip
* @param string $domain
* @return void
*/
public function __construct($ip, $domain)
{

View file

@ -49,7 +49,6 @@ class FailedPasswordReset
*
* @param string $ip
* @param string $email
* @return void
*/
public function __construct($ip, $email)
{

View file

@ -4,5 +4,4 @@ namespace Pterodactyl\Events;
abstract class Event
{
//
}

View file

@ -42,7 +42,6 @@ class Created
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Creating
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Deleted
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Deleting
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Saved
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Saving
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Updated
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Updating
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
* @return void
*/
public function __construct(Server $server)
{

View file

@ -42,7 +42,6 @@ class Created
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/
public function __construct(Subuser $subuser)
{

View file

@ -42,7 +42,6 @@ class Creating
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/
public function __construct(Subuser $subuser)
{

View file

@ -42,7 +42,6 @@ class Deleted
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/
public function __construct(Subuser $subuser)
{

View file

@ -42,7 +42,6 @@ class Deleting
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/
public function __construct(Subuser $subuser)
{

View file

@ -42,7 +42,6 @@ class Created
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
* @return void
*/
public function __construct(User $user)
{

View file

@ -42,7 +42,6 @@ class Creating
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
* @return void
*/
public function __construct(User $user)
{

View file

@ -42,7 +42,6 @@ class Deleted
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
* @return void
*/
public function __construct(User $user)
{

View file

@ -42,7 +42,6 @@ class Deleting
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
* @return void
*/
public function __construct(User $user)
{

View file

@ -26,5 +26,4 @@ namespace Pterodactyl\Exceptions;
class AccountNotFoundException extends \Exception
{
//
}

View file

@ -26,5 +26,4 @@ namespace Pterodactyl\Exceptions;
class AutoDeploymentException extends \Exception
{
//
}

View file

@ -26,14 +26,13 @@ namespace Pterodactyl\Exceptions;
use Log;
class DisplayException extends \Exception
class DisplayException extends PterodactylException
{
/**
* Exception constructor.
*
* @param string $message
* @param mixed $log
* @return void
*/
public function __construct($message, $log = null)
{

View file

@ -24,7 +24,6 @@
namespace Pterodactyl\Exceptions;
class DisplayValidationException extends \Exception
class DisplayValidationException extends PterodactylException
{
//
}

View file

@ -2,9 +2,15 @@
namespace Pterodactyl\Exceptions;
use Log;
use Exception;
use Prologue\Alerts\Facades\Alert;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Pterodactyl\Exceptions\Model\DataValidationException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
@ -15,12 +21,15 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
AuthenticationException::class,
AuthorizationException::class,
DisplayException::class,
DataValidationException::class,
DisplayValidationException::class,
HttpException::class,
ModelNotFoundException::class,
TokenMismatchException::class,
ValidationException::class,
];
/**
@ -29,11 +38,12 @@ class Handler extends ExceptionHandler
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*
* @throws \Exception
*/
public function report(Exception $exception)
{
return parent::report($exception);
parent::report($exception);
}
/**
@ -41,14 +51,16 @@ class Handler extends ExceptionHandler
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
public function render($request, Exception $exception)
{
if ($request->expectsJson() || $request->isJson() || $request->is(...config('pterodactyl.json_routes'))) {
$exception = $this->prepareException($exception);
if (config('app.debug') || $this->isHttpException($exception)) {
if (config('app.debug') || $this->isHttpException($exception) || $exception instanceof DisplayException) {
$displayError = $exception->getMessage();
} else {
$displayError = 'An unhandled exception was encountered with this request.';
@ -61,6 +73,10 @@ class Handler extends ExceptionHandler
], ($this->isHttpException($exception)) ? $exception->getStatusCode() : 500, [], JSON_UNESCAPED_SLASHES);
parent::report($exception);
} elseif ($exception instanceof DisplayException) {
Alert::danger($exception->getMessage())->flash();
return redirect()->back()->withInput();
}
return (isset($response)) ? $response : parent::render($request, $exception);

View file

@ -0,0 +1,50 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Model;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\ValidationException;
use Illuminate\Contracts\Support\MessageProvider;
class DataValidationException extends ValidationException implements MessageProvider
{
/**
* DataValidationException constructor.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
*/
public function __construct(Validator $validator)
{
parent::__construct($validator);
}
/**
* @return \Illuminate\Support\MessageBag
*/
public function getMessageBag()
{
return $this->validator->errors();
}
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions;
class PterodactylException extends \Exception
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Repository\Daemon;
class InvalidPowerSignalException extends \Exception
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Repository;
use Pterodactyl\Exceptions\DisplayException;
class DuplicateDatabaseNameException extends DisplayException
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Repository;
class RecordNotFoundException extends \Exception
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Repository;
class RepositoryException extends \Exception
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service;
use Pterodactyl\Exceptions\DisplayException;
class HasActiveServersException extends DisplayException
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Helper;
class CdnVersionFetchingException extends \Exception
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Pack;
use Pterodactyl\Exceptions\DisplayException;
class InvalidFileMimeTypeException extends DisplayException
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Pack;
use Pterodactyl\Exceptions\DisplayException;
class InvalidFileUploadException extends DisplayException
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Pack;
use Pterodactyl\Exceptions\DisplayException;
class InvalidPackArchiveFormatException extends DisplayException
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Pack;
use Pterodactyl\Exceptions\DisplayException;
class UnreadableZipArchiveException extends DisplayException
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Pack;
class ZipArchiveCreationException extends \Exception
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Pack;
use Pterodactyl\Exceptions\DisplayException;
class ZipExtractionException extends DisplayException
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Server;
use Exception;
class RequiredVariableMissingException extends Exception
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\ServiceOption;
class InvalidCopyFromException extends \Exception
{
}

View file

@ -0,0 +1,29 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\ServiceOption;
class NoParentConfigurationFoundException extends \Exception
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\ServiceVariable;
use Exception;
class ReservedVariableNameException extends Exception
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Subuser;
use Pterodactyl\Exceptions\DisplayException;
class ServerSubuserExistsException extends DisplayException
{
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions\Service\Subuser;
use Pterodactyl\Exceptions\DisplayException;
class UserIsServerOwnerException extends DisplayException
{
}

View file

@ -0,0 +1,94 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Extensions;
use Pterodactyl\Models\DatabaseHost;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
class DynamicDatabaseConnection
{
const DB_CHARSET = 'utf8';
const DB_COLLATION = 'utf8_unicode_ci';
const DB_DRIVER = 'mysql';
/**
* @var \Illuminate\Config\Repository
*/
protected $config;
/**
* @var \Illuminate\Contracts\Encryption\Encrypter
*/
protected $encrypter;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
*/
protected $repository;
/**
* DynamicDatabaseConnection constructor.
*
* @param \Illuminate\Config\Repository $config
* @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
*/
public function __construct(
ConfigRepository $config,
DatabaseHostRepositoryInterface $repository,
Encrypter $encrypter
) {
$this->config = $config;
$this->encrypter = $encrypter;
$this->repository = $repository;
}
/**
* Adds a dynamic database connection entry to the runtime config.
*
* @param string $connection
* @param \Pterodactyl\Models\DatabaseHost|int $host
* @param string $database
*/
public function set($connection, $host, $database = 'mysql')
{
if (! $host instanceof DatabaseHost) {
$host = $this->repository->find($host);
}
$this->config->set('database.connections.' . $connection, [
'driver' => self::DB_DRIVER,
'host' => $host->host,
'port' => $host->port,
'database' => $database,
'username' => $host->username,
'password' => $this->encrypter->decrypt($host->password),
'charset' => self::DB_CHARSET,
'collation' => self::DB_COLLATION,
]);
}
}

View file

@ -30,7 +30,7 @@ use Illuminate\Http\Request;
use Pterodactyl\Models\User;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\UserRepository;
use Pterodactyl\Repositories\oldUserRepository;
use Pterodactyl\Transformers\Admin\UserTransformer;
use Pterodactyl\Exceptions\DisplayValidationException;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
@ -91,7 +91,7 @@ class UserController extends Controller
{
$this->authorize('user-create', $request->apiKey());
$repo = new UserRepository;
$repo = new oldUserRepository;
try {
$user = $repo->create($request->only([
'custom_id', 'email', 'password', 'name_first',
@ -128,7 +128,7 @@ class UserController extends Controller
{
$this->authorize('user-edit', $request->apiKey());
$repo = new UserRepository;
$repo = new oldUserRepository;
try {
$user = $repo->update($user, $request->intersect([
'email', 'password', 'name_first',
@ -165,7 +165,7 @@ class UserController extends Controller
{
$this->authorize('user-delete', $request->apiKey());
$repo = new UserRepository;
$repo = new oldUserRepository;
try {
$repo->delete($id);

View file

@ -28,9 +28,9 @@ use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\Daemon\PowerRepository;
use Pterodactyl\Transformers\User\ServerTransformer;
use Pterodactyl\Repositories\Daemon\CommandRepository;
use Pterodactyl\Repositories\old_Daemon\PowerRepository;
use Pterodactyl\Repositories\old_Daemon\CommandRepository;
class ServerController extends Controller
{

View file

@ -24,32 +24,62 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Alert;
use Settings;
use Validator;
use Illuminate\Http\Request;
use Krucas\Settings\Settings;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Http\Requests\Admin\BaseFormRequest;
use Pterodactyl\Services\Helpers\SoftwareVersionService;
class BaseController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Krucas\Settings\Settings
*/
protected $settings;
/**
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
*/
protected $version;
/**
* BaseController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Krucas\Settings\Settings $settings
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $version
*/
public function __construct(
AlertsMessageBag $alert,
Settings $settings,
SoftwareVersionService $version
) {
$this->alert = $alert;
$this->settings = $settings;
$this->version = $version;
}
/**
* Return the admin index view.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function getIndex(Request $request)
public function getIndex()
{
return view('admin.index');
return view('admin.index', ['version' => $this->version]);
}
/**
* Return the admin settings view.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function getSettings(Request $request)
public function getSettings()
{
return view('admin.settings');
}
@ -57,24 +87,14 @@ class BaseController extends Controller
/**
* Handle settings post request.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Http\Requests\Admin\BaseFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function postSettings(Request $request)
public function postSettings(BaseFormRequest $request)
{
$validator = Validator::make($request->all(), [
'company' => 'required|between:1,256',
// 'default_language' => 'required|alpha_dash|min:2|max:5',
]);
$this->settings->set('company', $request->input('company'));
if ($validator->fails()) {
return redirect()->route('admin.settings')->withErrors($validator->errors())->withInput();
}
Settings::set('company', $request->input('company'));
// Settings::set('default_language', $request->input('default_language'));
Alert::success('Settings have been successfully updated.')->flash();
$this->alert->success('Settings have been successfully updated.')->flash();
return redirect()->route('admin.settings');
}

View file

@ -24,112 +24,146 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Illuminate\Http\Request;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\Location;
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Exceptions\DisplayException;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\DatabaseRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
use Pterodactyl\Services\Database\DatabaseHostService;
use Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
class DatabaseController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $locationRepository;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Database\DatabaseHostService
*/
protected $service;
/**
* DatabaseController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository
* @param \Pterodactyl\Services\Database\DatabaseHostService $service
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
*/
public function __construct(
AlertsMessageBag $alert,
DatabaseHostRepositoryInterface $repository,
DatabaseHostService $service,
LocationRepositoryInterface $locationRepository
) {
$this->alert = $alert;
$this->repository = $repository;
$this->service = $service;
$this->locationRepository = $locationRepository;
}
/**
* Display database host index.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function index(Request $request)
public function index()
{
return view('admin.databases.index', [
'locations' => Location::with('nodes')->get(),
'hosts' => DatabaseHost::withCount('databases')->with('node')->get(),
'locations' => $this->locationRepository->getAllWithNodes(),
'hosts' => $this->repository->getWithViewDetails(),
]);
}
/**
* Display database host to user.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $host
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(Request $request, $id)
public function view($host)
{
return view('admin.databases.view', [
'locations' => Location::with('nodes')->get(),
'host' => DatabaseHost::with('databases.server')->findOrFail($id),
'locations' => $this->locationRepository->getAllWithNodes(),
'host' => $this->repository->getWithServers($host),
]);
}
/**
* Handle post request to create database host.
* Handle request to create a new database host.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
*/
public function create(Request $request)
public function create(DatabaseHostFormRequest $request)
{
$repo = new DatabaseRepository;
try {
$host = $repo->add($request->intersect([
'name', 'username', 'password',
'host', 'port', 'node_id',
]));
Alert::success('Successfully created new database host on the system.')->flash();
$host = $this->service->create($request->normalize());
$this->alert->success('Successfully created a new database host on the system.')->flash();
return redirect()->route('admin.databases.view', $host->id);
} catch (\PDOException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.databases')->withErrors(json_decode($ex->getMessage()));
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error was encountered while trying to process this request. This error has been logged.')->flash();
$this->alert->danger($ex->getMessage())->flash();
}
return redirect()->route('admin.databases');
}
/**
* Handle post request to update a database host.
* Handle updating database host.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
* @param \Pterodactyl\Models\DatabaseHost $host
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function update(Request $request, $id)
public function update(DatabaseHostFormRequest $request, DatabaseHost $host)
{
$repo = new DatabaseRepository;
if ($request->input('action') === 'delete') {
return $this->delete($host);
}
try {
if ($request->input('action') !== 'delete') {
$host = $repo->update($id, $request->intersect([
'name', 'username', 'password',
'host', 'port', 'node_id',
]));
Alert::success('Database host was updated successfully.')->flash();
} else {
$repo->delete($id);
$host = $this->service->update($host->id, $request->normalize());
$this->alert->success('Database host was updated successfully.')->flash();
} catch (\PDOException $ex) {
$this->alert->danger($ex->getMessage())->flash();
}
return redirect()->route('admin.databases.view', $host->id);
}
/**
* Handle request to delete a database host.
*
* @param \Pterodactyl\Models\DatabaseHost $host
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete(DatabaseHost $host)
{
$this->service->delete($host->id);
$this->alert->success('The requested database host has been deleted from the system.')->flash();
return redirect()->route('admin.databases');
}
} catch (\PDOException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.databases.view', $id)->withErrors(json_decode($ex->getMessage()));
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error was encountered while trying to process this request. This error has been logged.')->flash();
}
return redirect()->route('admin.databases.view', $id);
}
}

View file

@ -24,96 +24,133 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Illuminate\Http\Request;
use Pterodactyl\Models\Location;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Services\LocationService;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\LocationRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
use Pterodactyl\Http\Requests\Admin\LocationFormRequest;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
class LocationController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\\LocationService
*/
protected $service;
/**
* LocationController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
* @param \Pterodactyl\Services\LocationService $service
*/
public function __construct(
AlertsMessageBag $alert,
LocationRepositoryInterface $repository,
LocationService $service
) {
$this->alert = $alert;
$this->repository = $repository;
$this->service = $service;
}
/**
* Return the location overview page.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function index(Request $request)
public function index()
{
return view('admin.locations.index', [
'locations' => Location::withCount('nodes', 'servers')->get(),
'locations' => $this->repository->getAllWithDetails(),
]);
}
/**
* Return the location view page.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(Request $request, $id)
public function view($id)
{
return view('admin.locations.view', ['location' => Location::with('nodes.servers')->findOrFail($id)]);
return view('admin.locations.view', [
'location' => $this->repository->getWithNodes($id),
]);
}
/**
* Handle request to create new location.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Http\Requests\Admin\LocationFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
* @throws \Watson\Validating\ValidationException
*/
public function create(Request $request)
public function create(LocationFormRequest $request)
{
$repo = new LocationRepository;
try {
$location = $repo->create($request->intersect(['short', 'long']));
Alert::success('Location was created successfully.')->flash();
$location = $this->service->create($request->normalize());
$this->alert->success('Location was created successfully.')->flash();
return redirect()->route('admin.locations.view', $location->id);
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.locations')->withErrors(json_decode($ex->getMessage()));
} catch (\Exception $ex) {
Log::error($ex);
Alert::error('An unhandled exception occurred while processing this request. This error has been logged.')->flash();
}
return redirect()->route('admin.locations');
}
/**
* Handle request to update or delete location.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Http\Requests\Admin\LocationFormRequest $request
* @param \Pterodactyl\Models\Location $location
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
* @throws \Watson\Validating\ValidationException
*/
public function update(Request $request, $id)
public function update(LocationFormRequest $request, Location $location)
{
$repo = new LocationRepository;
if ($request->input('action') === 'delete') {
return $this->delete($location);
}
$this->service->update($location->id, $request->normalize());
$this->alert->success('Location was updated successfully.')->flash();
return redirect()->route('admin.locations.view', $location->id);
}
/**
* Delete a location from the system.
*
* @param \Pterodactyl\Models\Location $location
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete(Location $location)
{
try {
if ($request->input('action') !== 'delete') {
$location = $repo->update($id, $request->intersect(['short', 'long']));
Alert::success('Location was updated successfully.')->flash();
} else {
$repo->delete($id);
$this->service->delete($location->id);
return redirect()->route('admin.locations');
}
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.locations.view', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::error('An unhandled exception occurred while processing this request. This error has been logged.')->flash();
$this->alert->danger($ex->getMessage())->flash();
}
return redirect()->route('admin.locations.view', $id);
return redirect()->route('admin.locations.view', $location->id);
}
}

View file

@ -24,20 +24,105 @@
namespace Pterodactyl\Http\Controllers\Admin;
use DB;
use Log;
use Alert;
use Cache;
use Javascript;
use Pterodactyl\Models;
use Illuminate\Http\Request;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Models\Node;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\NodeRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
use Pterodactyl\Services\Nodes\UpdateService;
use Pterodactyl\Services\Nodes\CreationService;
use Pterodactyl\Services\Nodes\DeletionService;
use Illuminate\Cache\Repository as CacheRepository;
use Pterodactyl\Services\Allocations\AssignmentService;
use Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest;
class NodesController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
*/
protected $allocationRepository;
/**
* @var \Pterodactyl\Services\Allocations\AssignmentService
*/
protected $assignmentService;
/**
* @var \Illuminate\Cache\Repository
*/
protected $cache;
/**
* @var \Pterodactyl\Services\Nodes\CreationService
*/
protected $creationService;
/**
* @var \Pterodactyl\Services\Nodes\DeletionService
*/
protected $deletionService;
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $locationRepository;
/**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Nodes\UpdateService
*/
protected $updateService;
/**
* NodesController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Allocations\AssignmentService $assignmentService
* @param \Illuminate\Cache\Repository $cache
* @param \Pterodactyl\Services\Nodes\CreationService $creationService
* @param \Pterodactyl\Services\Nodes\DeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
* @param \Pterodactyl\Services\Nodes\UpdateService $updateService
*/
public function __construct(
AlertsMessageBag $alert,
AllocationRepositoryInterface $allocationRepository,
AssignmentService $assignmentService,
CacheRepository $cache,
CreationService $creationService,
DeletionService $deletionService,
LocationRepositoryInterface $locationRepository,
NodeRepositoryInterface $repository,
UpdateService $updateService
) {
$this->alert = $alert;
$this->allocationRepository = $allocationRepository;
$this->assignmentService = $assignmentService;
$this->cache = $cache;
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->locationRepository = $locationRepository;
$this->repository = $repository;
$this->updateService = $updateService;
}
/**
* Displays the index page listing all nodes on the panel.
*
@ -46,26 +131,21 @@ class NodesController extends Controller
*/
public function index(Request $request)
{
$nodes = Models\Node::with('location')->withCount('servers');
if (! is_null($request->input('query'))) {
$nodes->search($request->input('query'));
}
return view('admin.nodes.index', ['nodes' => $nodes->paginate(25)]);
return view('admin.nodes.index', [
'nodes' => $this->repository->search($request->input('query'))->getNodeListingData(),
]);
}
/**
* Displays create new node page.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function create(Request $request)
public function create()
{
$locations = Models\Location::all();
if (! $locations->count()) {
Alert::warning('You must add a location before you can add a new node.')->flash();
$locations = $this->locationRepository->all();
if (count($locations) < 1) {
$this->alert->warning(trans('admin/node.notices.location_required'))->flash();
return redirect()->route('admin.locations');
}
@ -76,117 +156,72 @@ class NodesController extends Controller
/**
* Post controller to create a new node on the system.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(Request $request)
public function store(NodeFormRequest $request)
{
try {
$repo = new NodeRepository;
$node = $repo->create(array_merge(
$request->only([
'public', 'disk_overallocate',
'memory_overallocate', 'behind_proxy',
]),
$request->intersect([
'name', 'location_id', 'fqdn',
'scheme', 'memory', 'disk',
'daemonBase', 'daemonSFTP', 'daemonListen',
])
));
Alert::success('Successfully created new node that can be configured automatically on your remote machine by visiting the configuration tab. <strong>Before you can add any servers you need to first assign some IP addresses and ports by adding an allocation.</strong>')->flash();
$node = $this->creationService->handle($request->normalize());
$this->alert->info(trans('admin/node.notices.node_created'))->flash();
return redirect()->route('admin.nodes.view.allocation', $node->id);
} catch (DisplayValidationException $e) {
return redirect()->route('admin.nodes.new')->withErrors(json_decode($e->getMessage()))->withInput();
} catch (DisplayException $e) {
Alert::danger($e->getMessage())->flash();
} catch (\Exception $e) {
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();
}
/**
* Shows the index overview page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $node
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function viewIndex(Request $request, $id)
public function viewIndex($node)
{
$node = Models\Node::with('location')->withCount('servers')->findOrFail($id);
$stats = collect(
Models\Server::select(
DB::raw('SUM(memory) as memory, SUM(disk) as disk')
)->where('node_id', $node->id)->first()
)->mapWithKeys(function ($item, $key) use ($node) {
if ($node->{$key . '_overallocate'} > 0) {
$withover = $node->{$key} * (1 + ($node->{$key . '_overallocate'} / 100));
} else {
$withover = $node->{$key};
}
$percent = ($item / $withover) * 100;
return [$key => [
'value' => number_format($item),
'max' => number_format($withover),
'percent' => $percent,
'css' => ($percent <= 75) ? 'green' : (($percent > 90) ? 'red' : 'yellow'),
]];
})->toArray();
return view('admin.nodes.view.index', ['node' => $node, 'stats' => $stats]);
return view('admin.nodes.view.index', [
'node' => $this->repository->getSingleNode($node),
'stats' => $this->repository->getUsageStats($node),
]);
}
/**
* Shows the settings page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\View\View
*/
public function viewSettings(Request $request, $id)
public function viewSettings(Node $node)
{
return view('admin.nodes.view.settings', [
'node' => Models\Node::findOrFail($id),
'locations' => Models\Location::all(),
'node' => $node,
'locations' => $this->locationRepository->all(),
]);
}
/**
* Shows the configuration page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\View\View
*/
public function viewConfiguration(Request $request, $id)
public function viewConfiguration(Node $node)
{
return view('admin.nodes.view.configuration', [
'node' => Models\Node::findOrFail($id),
]);
return view('admin.nodes.view.configuration', ['node' => $node]);
}
/**
* Shows the allocation page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $node
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function viewAllocation(Request $request, $id)
public function viewAllocation($node)
{
$node = Models\Node::findOrFail($id);
$node->setRelation('allocations', $node->allocations()->orderBy('ip', 'asc')->orderBy('port', 'asc')->with('server')->paginate(50));
Javascript::put([
'node' => collect($node)->only(['id']),
]);
$node = $this->repository->getNodeAllocations($node);
Javascript::put(['node' => collect($node)->only(['id'])]);
return view('admin.nodes.view.allocation', ['node' => $node]);
}
@ -194,74 +229,53 @@ class NodesController extends Controller
/**
* Shows the server listing page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $node
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function viewServers(Request $request, $id)
public function viewServers($node)
{
$node = Models\Node::with('servers.user', 'servers.service', 'servers.option')->findOrFail($id);
$node = $this->repository->getNodeServers($node);
Javascript::put([
'node' => collect($node->makeVisible('daemonSecret'))->only(['scheme', 'fqdn', 'daemonListen', 'daemonSecret']),
]);
return view('admin.nodes.view.servers', [
'node' => $node,
]);
return view('admin.nodes.view.servers', ['node' => $node]);
}
/**
* Updates settings for a node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function updateSettings(Request $request, $id)
public function updateSettings(NodeFormRequest $request, Node $node)
{
$repo = new NodeRepository;
$this->updateService->handle($node, $request->normalize());
$this->alert->success(trans('admin/node.notices.node_updated'))->flash();
try {
$node = $repo->update($id, array_merge(
$request->only([
'public', 'disk_overallocate',
'memory_overallocate', 'behind_proxy',
]),
$request->intersect([
'name', 'location_id', 'fqdn',
'scheme', 'memory', 'disk', 'upload_size',
'reset_secret', 'daemonSFTP', 'daemonListen',
])
));
Alert::success('Successfully updated this node\'s information. If you changed any daemon settings you will need to restart it now.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.nodes.view.settings', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attempting to edit this node. Please try again.')->flash();
}
return redirect()->route('admin.nodes.view.settings', $id)->withInput();
return redirect()->route('admin.nodes.view.settings', $node->id)->withInput();
}
/**
* Removes a single allocation from a node.
*
* @param \Illuminate\Http\Request $request
* @param int $node
* @param int $allocation
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function allocationRemoveSingle(Request $request, $node, $allocation)
public function allocationRemoveSingle($node, $allocation)
{
$query = Models\Allocation::where('node_id', $node)->whereNull('server_id')->where('id', $allocation)->delete();
if ($query < 1) {
return response()->json([
'error' => 'Unable to find an allocation matching those details to delete.',
], 400);
}
$this->allocationRepository->deleteWhere([
['id', '=', $allocation],
['node_id', '=', $node],
['server_id', '=', null],
]);
return response('', 204);
}
@ -275,12 +289,14 @@ class NodesController extends Controller
*/
public function allocationRemoveBlock(Request $request, $node)
{
$query = Models\Allocation::where('node_id', $node)->whereNull('server_id')->where('ip', $request->input('ip'))->delete();
if ($query < 1) {
Alert::danger('There was an error while attempting to delete allocations on that IP.')->flash();
} else {
Alert::success('Deleted all unallocated ports for <code>' . $request->input('ip') . '</code>.')->flash();
}
$this->allocationRepository->deleteWhere([
['node_id', '=', $node],
['server_id', '=', null],
['ip', '=', $request->input('ip')],
]);
$this->alert->success(trans('admin/node.notices.unallocated_deleted', ['ip' => $request->input('ip')]))
->flash();
return redirect()->route('admin.nodes.view.allocation', $node);
}
@ -288,92 +304,64 @@ class NodesController extends Controller
/**
* Sets an alias for a specific allocation on a node.
*
* @param \Illuminate\Http\Request $request
* @param int $node
* @return \Illuminate\Http\Response
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest $request
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function allocationSetAlias(Request $request, $node)
public function allocationSetAlias(AllocationAliasFormRequest $request)
{
if (! $request->input('allocation_id')) {
return response('Missing required parameters.', 422);
}
try {
$update = Models\Allocation::findOrFail($request->input('allocation_id'));
$update->ip_alias = (empty($request->input('alias'))) ? null : $request->input('alias');
$update->save();
$this->allocationRepository->update($request->input('allocation_id'), [
'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'),
]);
return response('', 204);
} catch (\Exception $ex) {
throw $ex;
}
}
/**
* Creates new allocations on a node.
*
* @param \Illuminate\Http\Request $request
* @param int $node
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest $request
* @param int|\Pterodactyl\Models\Node $node
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function createAllocation(Request $request, $node)
public function createAllocation(AllocationFormRequest $request, Node $node)
{
$repo = new NodeRepository;
$this->assignmentService->handle($node, $request->normalize());
$this->alert->success(trans('admin/node.notices.allocations_added'))->flash();
try {
$repo->addAllocations($node, $request->intersect(['allocation_ip', 'allocation_alias', 'allocation_ports']));
Alert::success('Successfully added new allocations!')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.nodes.view.allocation', $node)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attempting to add allocations this node. This error has been logged.')->flash();
}
return redirect()->route('admin.nodes.view.allocation', $node);
return redirect()->route('admin.nodes.view.allocation', $node->id);
}
/**
* Deletes a node from the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param $node
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete(Request $request, $id)
public function delete($node)
{
$repo = new NodeRepository;
try {
$repo->delete($id);
Alert::success('Successfully deleted the requested node from the panel.')->flash();
$this->deletionService->handle($node);
$this->alert->success(trans('admin/node.notices.node_deleted'))->flash();
return redirect()->route('admin.nodes');
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attempting to delete this node. Please try again.')->flash();
}
return redirect()->route('admin.nodes.view', $id);
}
/**
* Returns the configuration token to auto-deploy a node.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Http\JsonResponse
*/
public function setToken(Request $request, $id)
public function setToken(Node $node)
{
$node = Models\Node::findOrFail($id);
$token = str_random(32);
Cache::tags(['Node:Configuration'])->put($token, $node->id, 5);
$token = bin2hex(random_bytes(16));
$this->cache->tags(['Node:Configuration'])->put($token, $node->id, 5);
return response()->json(['token' => $token]);
}

View file

@ -24,136 +24,171 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Javascript;
use Illuminate\Http\Request;
use Pterodactyl\Models\Service;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Models\ServiceOption;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\OptionRepository;
use Pterodactyl\Repositories\VariableRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
use Pterodactyl\Http\Requests\Admin\Service\EditOptionScript;
use Pterodactyl\Services\Services\Options\OptionUpdateService;
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
use Pterodactyl\Services\Services\Options\OptionCreationService;
use Pterodactyl\Services\Services\Options\OptionDeletionService;
use Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest;
use Pterodactyl\Services\Services\Options\InstallScriptUpdateService;
use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
class OptionController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Services\Services\Options\InstallScriptUpdateService
*/
protected $installScriptUpdateService;
/**
* @var \Pterodactyl\Services\Services\Options\OptionCreationService
*/
protected $optionCreationService;
/**
* @var \Pterodactyl\Services\Services\Options\OptionDeletionService
*/
protected $optionDeletionService;
/**
* @var \Pterodactyl\Services\Services\Options\OptionUpdateService
*/
protected $optionUpdateService;
/**
* @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface
*/
protected $serviceRepository;
/**
* @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface
*/
protected $serviceOptionRepository;
/**
* OptionController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService
* @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService
* @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService
* @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
* @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $serviceOptionRepository
*/
public function __construct(
AlertsMessageBag $alert,
InstallScriptUpdateService $installScriptUpdateService,
OptionCreationService $optionCreationService,
OptionDeletionService $optionDeletionService,
OptionUpdateService $optionUpdateService,
ServiceRepositoryInterface $serviceRepository,
ServiceOptionRepositoryInterface $serviceOptionRepository
) {
$this->alert = $alert;
$this->installScriptUpdateService = $installScriptUpdateService;
$this->optionCreationService = $optionCreationService;
$this->optionDeletionService = $optionDeletionService;
$this->optionUpdateService = $optionUpdateService;
$this->serviceRepository = $serviceRepository;
$this->serviceOptionRepository = $serviceOptionRepository;
}
/**
* Handles request to view page for adding new option.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function create(Request $request)
public function create()
{
$services = Service::with('options')->get();
$services = $this->serviceRepository->getWithOptions();
Javascript::put(['services' => $services->keyBy('id')]);
return view('admin.services.options.new', ['services' => $services]);
}
/**
* Handles POST request to create a new option.
* Handle adding a new service option.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Response\RedirectResponse
* @param \Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(Request $request)
public function store(ServiceOptionFormRequest $request)
{
$repo = new OptionRepository;
try {
$option = $repo->create($request->intersect([
'service_id', 'name', 'description', 'tag',
'docker_image', 'startup', 'config_from', 'config_startup',
'config_logs', 'config_files', 'config_stop',
]));
Alert::success('Successfully created new service option.')->flash();
$option = $this->optionCreationService->handle($request->normalize());
$this->alert->success(trans('admin/services.options.notices.option_created'))->flash();
} catch (NoParentConfigurationFoundException $exception) {
$this->alert->danger($exception->getMessage())->flash();
return redirect()->route('admin.services.option.view', $option->id);
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.option.new')->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occurred while attempting to create this service. This error has been logged.')->flash();
return redirect()->back()->withInput();
}
return redirect()->route('admin.services.option.new')->withInput();
return redirect()->route('admin.services.option.view', $option->id);
}
/**
* Handles POST request to create a new option variable.
* Delete a given option from the database.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\ServiceOption $option
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function createVariable(Request $request, $id)
public function destroy(ServiceOption $option)
{
$repo = new VariableRepository;
$this->optionDeletionService->handle($option->id);
$this->alert->success(trans('admin/services.options.notices.option_deleted'))->flash();
try {
$variable = $repo->create($id, $request->intersect([
'name', 'description', 'env_variable',
'default_value', 'options', 'rules',
]));
Alert::success('New variable successfully assigned to this service option.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.option.variables', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash();
}
return redirect()->route('admin.services.option.variables', $id);
return redirect()->route('admin.services.view', $option->service_id);
}
/**
* Display option overview page.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\ServiceOption $option
* @return \Illuminate\View\View
*/
public function viewConfiguration(Request $request, $id)
public function viewConfiguration(ServiceOption $option)
{
return view('admin.services.options.view', ['option' => ServiceOption::findOrFail($id)]);
}
/**
* Display variable overview page for a service option.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\View\View
*/
public function viewVariables(Request $request, $id)
{
return view('admin.services.options.variables', ['option' => ServiceOption::with('variables')->findOrFail($id)]);
return view('admin.services.options.view', ['option' => $option]);
}
/**
* Display script management page for an option.
*
* @param Request $request
* @param int $id
* @param int $option
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function viewScripts(Request $request, $id)
public function viewScripts($option)
{
$option = ServiceOption::with('copyFrom')->findOrFail($id);
$option = $this->serviceOptionRepository->getWithCopyFrom($option);
$copyOptions = $this->serviceOptionRepository->findWhere([
['copy_script_from', '=', null],
['service_id', '=', $option->service_id],
['id', '!=', $option],
]);
$relyScript = $this->serviceOptionRepository->findWhere([['copy_script_from', '=', $option]]);
return view('admin.services.options.scripts', [
'copyFromOptions' => ServiceOption::whereNull('copy_script_from')->where([
['service_id', $option->service_id],
['id', '!=', $option->id],
])->get(),
'relyOnScript' => ServiceOption::where('copy_script_from', $option->id)->get(),
'copyFromOptions' => $copyOptions,
'relyOnScript' => $relyScript,
'option' => $option,
]);
}
@ -162,100 +197,44 @@ class OptionController extends Controller
* Handles POST when editing a configration for a service option.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\ServiceOption $option
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function editConfiguration(Request $request, $id)
public function editConfiguration(Request $request, ServiceOption $option)
{
$repo = new OptionRepository;
try {
if ($request->input('action') !== 'delete') {
$repo->update($id, $request->intersect([
'name', 'description', 'tag', 'docker_image', 'startup',
'config_from', 'config_stop', 'config_logs', 'config_files', 'config_startup',
]));
Alert::success('Service option configuration has been successfully updated.')->flash();
} else {
$option = ServiceOption::with('service')->where('id', $id)->first();
$repo->delete($id);
Alert::success('Successfully deleted service option from the system.')->flash();
return redirect()->route('admin.services.view', $option->service_id);
}
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.option.view', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occurred while attempting to perform that action. This error has been logged.')->flash();
$this->optionUpdateService->handle($option, $request->all());
$this->alert->success(trans('admin/services.options.notices.option_updated'))->flash();
} catch (NoParentConfigurationFoundException $exception) {
dd('hodor');
$this->alert->danger($exception->getMessage())->flash();
}
return redirect()->route('admin.services.option.view', $id);
return redirect()->route('admin.services.option.view', $option->id);
}
/**
* Handles POST when editing a configration for a service option.
* Handles POST when updating script for a service option.
*
* @param \Illuminate\Http\Request $request
* @param int $option
* @param int $variable
* @param \Pterodactyl\Http\Requests\Admin\Service\EditOptionScript $request
* @param \Pterodactyl\Models\ServiceOption $option
* @return \Illuminate\Http\RedirectResponse
*/
public function editVariable(Request $request, $option, $variable)
{
$repo = new VariableRepository;
try {
if ($request->input('action') !== 'delete') {
$variable = $repo->update($variable, $request->only([
'name', 'description', 'env_variable',
'default_value', 'options', 'rules',
]));
Alert::success("The service variable '{$variable->name}' has been updated.")->flash();
} else {
$repo->delete($variable);
Alert::success('That service variable has been deleted.')->flash();
}
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.option.variables', $option)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash();
}
return redirect()->route('admin.services.option.variables', $option);
}
/**
* Handles POST when updating scripts for a service option.
*
* @param Request $request
* @param int $id
* @return \Illuminate\Response\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function updateScripts(Request $request, $id)
public function updateScripts(EditOptionScript $request, ServiceOption $option)
{
$repo = new OptionRepository;
try {
$repo->scripts($id, $request->only([
'script_install', 'script_entry',
'script_container', 'copy_script_from',
]));
Alert::success('Successfully updated option scripts to be run when servers are installed.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.option.scripts', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash();
$this->installScriptUpdateService->handle($option, $request->normalize());
$this->alert->success(trans('admin/services.options.notices.script_updated'))->flash();
} catch (InvalidCopyFromException $exception) {
$this->alert->danger($exception->getMessage())->flash();
}
return redirect()->route('admin.services.option.scripts', $id);
return redirect()->route('admin.services.option.scripts', $option->id);
}
}

View file

@ -24,19 +24,102 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Storage;
use Illuminate\Http\Request;
use Pterodactyl\Models\Pack;
use Pterodactyl\Models\Service;
use Pterodactyl\Exceptions\DisplayException;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\PackRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
use Pterodactyl\Services\Packs\ExportPackService;
use Pterodactyl\Services\Packs\PackUpdateService;
use Pterodactyl\Services\Packs\PackCreationService;
use Pterodactyl\Services\Packs\PackDeletionService;
use Pterodactyl\Http\Requests\Admin\PackFormRequest;
use Pterodactyl\Services\Packs\TemplateUploadService;
use Pterodactyl\Contracts\Repository\PackRepositoryInterface;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
class PackController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Pterodactyl\Services\Packs\PackCreationService
*/
protected $creationService;
/**
* @var \Pterodactyl\Services\Packs\PackDeletionService
*/
protected $deletionService;
/**
* @var \Pterodactyl\Services\Packs\ExportPackService
*/
protected $exportService;
/**
* @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Packs\PackUpdateService
*/
protected $updateService;
/**
* @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface
*/
protected $serviceRepository;
/**
* @var \Pterodactyl\Services\Packs\TemplateUploadService
*/
protected $templateUploadService;
/**
* PackController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Packs\ExportPackService $exportService
* @param \Pterodactyl\Services\Packs\PackCreationService $creationService
* @param \Pterodactyl\Services\Packs\PackDeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\PackRepositoryInterface $repository
* @param \Pterodactyl\Services\Packs\PackUpdateService $updateService
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
* @param \Pterodactyl\Services\Packs\TemplateUploadService $templateUploadService
*/
public function __construct(
AlertsMessageBag $alert,
ConfigRepository $config,
ExportPackService $exportService,
PackCreationService $creationService,
PackDeletionService $deletionService,
PackRepositoryInterface $repository,
PackUpdateService $updateService,
ServiceRepositoryInterface $serviceRepository,
TemplateUploadService $templateUploadService
) {
$this->alert = $alert;
$this->config = $config;
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->exportService = $exportService;
$this->repository = $repository;
$this->updateService = $updateService;
$this->serviceRepository = $serviceRepository;
$this->templateUploadService = $templateUploadService;
}
/**
* Display listing of all packs on the system.
*
@ -45,170 +128,135 @@ class PackController extends Controller
*/
public function index(Request $request)
{
$packs = Pack::with('option')->withCount('servers');
if (! is_null($request->input('query'))) {
$packs->search($request->input('query'));
}
return view('admin.packs.index', ['packs' => $packs->paginate(50)]);
return view('admin.packs.index', [
'packs' => $this->repository->search($request->input('query'))->paginateWithOptionAndServerCount(
$this->config->get('pterodactyl.paginate.admin.packs')
),
]);
}
/**
* Display new pack creation form.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function create(Request $request)
public function create()
{
return view('admin.packs.new', [
'services' => Service::with('options')->get(),
'services' => $this->serviceRepository->getWithOptions(),
]);
}
/**
* Display new pack creation modal for use with template upload.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function newTemplate(Request $request)
public function newTemplate()
{
return view('admin.packs.modal', [
'services' => Service::with('options')->get(),
'services' => $this->serviceRepository->getWithOptions(),
]);
}
/**
* Handle create pack request and route user to location.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Http\Requests\Admin\PackFormRequest $request
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
* @throws \Pterodactyl\Exceptions\Service\Pack\ZipExtractionException
*/
public function store(Request $request)
public function store(PackFormRequest $request)
{
$repo = new PackRepository;
try {
if ($request->input('action') === 'from_template') {
$pack = $repo->createWithTemplate($request->intersect(['option_id', 'file_upload']));
if ($request->has('from_template')) {
$pack = $this->templateUploadService->handle($request->input('option_id'), $request->file('file_upload'));
} else {
$pack = $repo->create($request->intersect([
'name', 'description', 'version', 'option_id',
'selectable', 'visible', 'locked', 'file_upload',
]));
$pack = $this->creationService->handle($request->normalize(), $request->file('file_upload'));
}
Alert::success('Pack successfully created on the system.')->flash();
$this->alert->success(trans('admin/pack.notices.pack_created'))->flash();
return redirect()->route('admin.packs.view', $pack->id);
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.packs.new')->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to add a new service pack. This error has been logged.')->flash();
}
return redirect()->route('admin.packs.new')->withInput();
}
/**
* Display pack view template to user.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $pack
* @return \Illuminate\View\View
*/
public function view(Request $request, $id)
public function view($pack)
{
return view('admin.packs.view', [
'pack' => Pack::with('servers.node', 'servers.user')->findOrFail($id),
'services' => Service::with('options')->get(),
'pack' => $this->repository->getWithServers($pack),
'services' => $this->serviceRepository->getWithOptions(),
]);
}
/**
* Handle updating or deleting pack information.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Http\Requests\Admin\PackFormRequest $request
* @param \Pterodactyl\Models\Pack $pack
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function update(Request $request, $id)
public function update(PackFormRequest $request, Pack $pack)
{
$repo = new PackRepository;
$this->updateService->handle($pack, $request->normalize());
$this->alert->success(trans('admin/pack.notices.pack_updated'))->flash();
try {
if ($request->input('action') !== 'delete') {
$pack = $repo->update($id, $request->intersect([
'name', 'description', 'version',
'option_id', 'selectable', 'visible', 'locked',
]));
Alert::success('Pack successfully updated.')->flash();
} else {
$repo->delete($id);
Alert::success('Pack was successfully deleted from the system.')->flash();
return redirect()->route('admin.packs.view', $pack->id);
}
/**
* Delete a pack if no servers are attached to it currently.
*
* @param \Pterodactyl\Models\Pack $pack
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function destroy(Pack $pack)
{
$this->deletionService->handle($pack->id);
$this->alert->success(trans('admin/pack.notices.pack_deleted', [
'name' => $pack->name,
]))->flash();
return redirect()->route('admin.packs');
}
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.packs.view', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to edit this service pack. This error has been logged.')->flash();
}
return redirect()->route('admin.packs.view', $id);
}
/**
* Creates an archive of the pack and downloads it to the browser.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param bool $files
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
* @param \Pterodactyl\Models\Pack $pack
* @param bool|string $files
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Pack\ZipArchiveCreationException
*/
public function export(Request $request, $id, $files = false)
public function export(Pack $pack, $files = false)
{
$pack = Pack::findOrFail($id);
$json = [
'name' => $pack->name,
'version' => $pack->version,
'description' => $pack->description,
'selectable' => $pack->selectable,
'visible' => $pack->visible,
'locked' => $pack->locked,
];
$filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
if ($files === 'with-files') {
$zip = new \ZipArchive;
if (! $zip->open($filename, \ZipArchive::CREATE)) {
abort(503, 'Unable to open file for writing.');
}
$files = Storage::files('packs/' . $pack->uuid);
foreach ($files as $file) {
$zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file)));
}
$zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT));
$zip->close();
$filename = $this->exportService->handle($pack, is_string($files));
if (is_string($files)) {
return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true);
} else {
$fp = fopen($filename, 'a+');
fwrite($fp, json_encode($json, JSON_PRETTY_PRINT));
fclose($fp);
}
return response()->download($filename, 'pack-' . $pack->name . '.json', [
'Content-Type' => 'application/json',
])->deleteFileAfterSend(true);
}
}
}

View file

@ -24,49 +24,210 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Javascript;
use Pterodactyl\Models;
use Illuminate\Http\Request;
use GuzzleHttp\Exception\TransferException;
use Pterodactyl\Models\Server;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\ServerRepository;
use Pterodactyl\Repositories\DatabaseRepository;
use Pterodactyl\Exceptions\AutoDeploymentException;
use Pterodactyl\Exceptions\DisplayValidationException;
use Pterodactyl\Services\Servers\CreationService;
use Pterodactyl\Services\Servers\DeletionService;
use Pterodactyl\Services\Servers\ReinstallService;
use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Http\Requests\Admin\ServerFormRequest;
use Pterodactyl\Services\Servers\ContainerRebuildService;
use Pterodactyl\Services\Servers\BuildModificationService;
use Pterodactyl\Services\Database\DatabaseManagementService;
use Pterodactyl\Services\Servers\DetailsModificationService;
use Pterodactyl\Services\Servers\StartupModificationService;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
class ServersController extends Controller
{
/**
* Display the index page with all servers currently on the system.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
* @var \Prologue\Alerts\AlertsMessageBag
*/
public function index(Request $request)
{
$servers = Models\Server::with('node', 'user', 'allocation');
protected $alert;
if (! is_null($request->input('query'))) {
$servers->search($request->input('query'));
/**
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
*/
protected $allocationRepository;
/**
* @var \Pterodactyl\Services\Servers\BuildModificationService
*/
protected $buildModificationService;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Pterodactyl\Services\Servers\ContainerRebuildService
*/
protected $containerRebuildService;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
*/
protected $databaseRepository;
/**
* @var \Pterodactyl\Services\Database\DatabaseManagementService
*/
protected $databaseManagementService;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
*/
protected $databaseHostRepository;
/**
* @var \Pterodactyl\Services\Servers\DeletionService
*/
protected $deletionService;
/**
* @var \Pterodactyl\Services\Servers\DetailsModificationService
*/
protected $detailsModificationService;
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $locationRepository;
/**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
*/
protected $nodeRepository;
/**
* @var \Pterodactyl\Services\Servers\ReinstallService
*/
protected $reinstallService;
/**
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Servers\CreationService
*/
protected $service;
/**
* @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface
*/
protected $serviceRepository;
/**
* @var \Pterodactyl\Services\Servers\StartupModificationService
*/
private $startupModificationService;
/**
* @var \Pterodactyl\Services\Servers\SuspensionService
*/
protected $suspensionService;
/**
* ServersController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Servers\ContainerRebuildService $containerRebuildService
* @param \Pterodactyl\Services\Servers\CreationService $service
* @param \Pterodactyl\Services\Database\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
* @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository
* @param \Pterodactyl\Services\Servers\DeletionService $deletionService
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository
* @param \Pterodactyl\Services\Servers\ReinstallService $reinstallService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
* @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
*/
public function __construct(
AlertsMessageBag $alert,
AllocationRepositoryInterface $allocationRepository,
BuildModificationService $buildModificationService,
ConfigRepository $config,
ContainerRebuildService $containerRebuildService,
CreationService $service,
DatabaseManagementService $databaseManagementService,
DatabaseRepositoryInterface $databaseRepository,
DatabaseHostRepository $databaseHostRepository,
DeletionService $deletionService,
DetailsModificationService $detailsModificationService,
LocationRepositoryInterface $locationRepository,
NodeRepositoryInterface $nodeRepository,
ReinstallService $reinstallService,
ServerRepositoryInterface $repository,
ServiceRepositoryInterface $serviceRepository,
StartupModificationService $startupModificationService,
SuspensionService $suspensionService
) {
$this->alert = $alert;
$this->allocationRepository = $allocationRepository;
$this->buildModificationService = $buildModificationService;
$this->config = $config;
$this->containerRebuildService = $containerRebuildService;
$this->databaseManagementService = $databaseManagementService;
$this->databaseRepository = $databaseRepository;
$this->databaseHostRepository = $databaseHostRepository;
$this->detailsModificationService = $detailsModificationService;
$this->deletionService = $deletionService;
$this->locationRepository = $locationRepository;
$this->nodeRepository = $nodeRepository;
$this->reinstallService = $reinstallService;
$this->repository = $repository;
$this->service = $service;
$this->serviceRepository = $serviceRepository;
$this->startupModificationService = $startupModificationService;
$this->suspensionService = $suspensionService;
}
/**
* Display the index page with all servers currently on the system.
*
* @return \Illuminate\View\View
*/
public function index()
{
return view('admin.servers.index', [
'servers' => $servers->paginate(25),
'servers' => $this->repository->getAllServers(
$this->config->get('pterodactyl.paginate.admin.servers')
),
]);
}
/**
* Display create new server page.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*
* @throws \Exception
*/
public function create(Request $request)
public function create()
{
$services = Models\Service::with('options.packs', 'options.variables')->get();
$services = $this->serviceRepository->getWithOptions();
Javascript::put([
'services' => $services->map(function ($item) {
return array_merge($item->toArray(), [
@ -76,147 +237,114 @@ class ServersController extends Controller
]);
return view('admin.servers.new', [
'locations' => Models\Location::all(),
'locations' => $this->locationRepository->all(),
'services' => $services,
]);
}
/**
* Create server controller method.
* Handle POST of server creation form.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Response\RedirectResponse
* @param \Pterodactyl\Http\Requests\Admin\ServerFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(Request $request)
public function store(ServerFormRequest $request)
{
try {
$repo = new ServerRepository;
$server = $repo->create($request->except('_token'));
$server = $this->service->create($request->except('_token'));
$this->alert->success(trans('admin/server.alerts.server_created'))->flash();
return redirect()->route('admin.servers.view', $server->id);
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.new')->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (AutoDeploymentException $ex) {
Alert::danger('Auto-Deployment Exception: ' . $ex->getMessage())->flash();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.')->flash();
} 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();
}
/**
* Returns a tree of all avaliable nodes in a given location.
*
* @param \Illuminate\Http\Request $request
* @return array
* @return \Illuminate\Support\Collection
*/
public function nodes(Request $request)
{
$nodes = Models\Node::with('allocations')->where('location_id', $request->input('location'))->get();
return $nodes->map(function ($item) {
$filtered = $item->allocations->where('server_id', null)->map(function ($map) {
return collect($map)->only(['id', 'ip', 'port']);
});
$item->ports = $filtered->map(function ($map) use ($item) {
return [
'id' => $map['id'],
'text' => $map['ip'] . ':' . $map['port'],
];
})->values();
return [
'id' => $item->id,
'text' => $item->name,
'allocations' => $item->ports,
];
})->values();
return $this->nodeRepository->getNodesForLocation($request->input('location'));
}
/**
* Display the index when viewing a specific server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\View\View
*/
public function viewIndex(Request $request, $id)
public function viewIndex(Server $server)
{
return view('admin.servers.view.index', ['server' => Models\Server::findOrFail($id)]);
return view('admin.servers.view.index', ['server' => $server]);
}
/**
* Display the details page when viewing a specific server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @return \Illuminate\View\View
*/
public function viewDetails(Request $request, $id)
public function viewDetails($server)
{
$server = Models\Server::where('installed', 1)->findOrFail($id);
return view('admin.servers.view.details', ['server' => $server]);
return view('admin.servers.view.details', [
'server' => $this->repository->findFirstWhere([
['id', '=', $server],
['installed', '=', 1],
]),
]);
}
/**
* Display the build details page when viewing a specific server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @return \Illuminate\View\View
*/
public function viewBuild(Request $request, $id)
public function viewBuild($server)
{
$server = Models\Server::where('installed', 1)->with('node.allocations')->findOrFail($id);
$server = $this->repository->findFirstWhere([
['id', '=', $server],
['installed', '=', 1],
]);
$allocations = $this->allocationRepository->getAllocationsForNode($server->node_id);
return view('admin.servers.view.build', [
'server' => $server,
'assigned' => $server->node->allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
'unassigned' => $server->node->allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
]);
}
/**
* Display startup configuration page for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @return \Illuminate\View\View
*/
public function viewStartup(Request $request, $id)
public function viewStartup($server)
{
$server = Models\Server::where('installed', 1)->with('option.variables', 'variables')->findOrFail($id);
$server->option->variables->transform(function ($item, $key) use ($server) {
$item->server_value = $server->variables->where('variable_id', $item->id)->pluck('variable_value')->first();
$parameters = $this->repository->getVariablesWithValues($server, true);
if (! $parameters->server->installed) {
abort(404);
}
return $item;
});
$services = $this->serviceRepository->getWithOptions();
$services = Models\Service::with('options.packs', 'options.variables')->get();
Javascript::put([
'services' => $services->map(function ($item) {
return array_merge($item->toArray(), [
'options' => $item->options->keyBy('id')->toArray(),
]);
})->keyBy('id'),
'server_variables' => $server->variables->mapWithKeys(function ($item) {
return ['env_' . $item->variable_id => [
'value' => $item->variable_value,
]];
})->toArray(),
'server_variables' => $parameters->data,
]);
return view('admin.servers.view.startup', [
'server' => $server,
'server' => $parameters->server,
'services' => $services,
]);
}
@ -224,16 +352,15 @@ class ServersController extends Controller
/**
* Display the database management page for a specific server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @return \Illuminate\View\View
*/
public function viewDatabase(Request $request, $id)
public function viewDatabase($server)
{
$server = Models\Server::where('installed', 1)->with('databases.host')->findOrFail($id);
$server = $this->repository->getWithDatabases($server);
return view('admin.servers.view.database', [
'hosts' => Models\DatabaseHost::all(),
'hosts' => $this->databaseHostRepository->all(),
'server' => $server,
]);
}
@ -241,360 +368,268 @@ class ServersController extends Controller
/**
* Display the management page when viewing a specific server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\View\View
*/
public function viewManage(Request $request, $id)
public function viewManage(Server $server)
{
return view('admin.servers.view.manage', ['server' => Models\Server::findOrFail($id)]);
return view('admin.servers.view.manage', ['server' => $server]);
}
/**
* Display the deletion page for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\View\View
*/
public function viewDelete(Request $request, $id)
public function viewDelete(Server $server)
{
return view('admin.servers.view.delete', ['server' => Models\Server::findOrFail($id)]);
return view('admin.servers.view.delete', ['server' => $server]);
}
/**
* Update the details for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function setDetails(Request $request, $id)
public function setDetails(Request $request, Server $server)
{
$repo = new ServerRepository;
try {
$repo->updateDetails($id, array_merge(
$request->only('description'),
$request->intersect([
'owner_id', 'name', 'reset_token',
])
));
$this->detailsModificationService->edit($server, $request->only([
'owner_id', 'name', 'description', 'reset_token',
]));
Alert::success('Server details were successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.view.details', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to update this server. This error has been logged.')->flash();
}
$this->alert->success(trans('admin/server.alerts.details_updated'))->flash();
return redirect()->route('admin.servers.view.details', $id)->withInput();
return redirect()->route('admin.servers.view.details', $server->id);
}
/**
* Set the new docker container for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function setContainer(Request $request, $id)
public function setContainer(Request $request, Server $server)
{
$repo = new ServerRepository;
$this->detailsModificationService->setDockerImage($server, $request->input('docker_image'));
$this->alert->success(trans('admin/server.alerts.docker_image_updated'))->flash();
try {
$repo->updateContainer($id, $request->intersect('docker_image'));
Alert::success('Successfully updated this server\'s docker image.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.view.details', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException occured while attempting to update the container image. Is the daemon online? This error has been logged.');
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to update this server\'s docker image. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.details', $id);
return redirect()->route('admin.servers.view.details', $server->id);
}
/**
* Toggles the install status for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function toggleInstall(Request $request, $id)
public function toggleInstall(Server $server)
{
$repo = new ServerRepository;
try {
$repo->toggleInstall($id);
Alert::success('Server install status was successfully toggled.')->flash();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to toggle this servers status. This error has been logged.')->flash();
if ($server->installed > 1) {
throw new DisplayException(trans('admin/server.exceptions.marked_as_failed'));
}
return redirect()->route('admin.servers.view.manage', $id);
$this->repository->update($server->id, [
'installed' => ! $server->installed,
]);
$this->alert->success(trans('admin/server.alerts.install_toggled'))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Reinstalls the server with the currently assigned pack and service.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function reinstallServer(Request $request, $id)
public function reinstallServer(Server $server)
{
$repo = new ServerRepository;
try {
$repo->reinstall($id);
$this->reinstallService->reinstall($server);
$this->alert->success(trans('admin/server.alerts.server_reinstalled'))->flash();
Alert::success('Server successfully marked for reinstallation.')->flash();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to perform this reinstallation. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.manage', $id);
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Setup a server to have a container rebuild.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function rebuildContainer(Request $request, $id)
public function rebuildContainer(Server $server)
{
$server = Models\Server::with('node')->findOrFail($id);
$this->containerRebuildService->rebuild($server);
$this->alert->success(trans('admin/server.alerts.rebuild_on_boot'))->flash();
try {
$server->node->guzzleClient([
'X-Access-Server' => $server->uuid,
'X-Access-Token' => $server->node->daemonSecret,
])->request('POST', '/server/rebuild');
Alert::success('A rebuild has been queued successfully. It will run the next time this server is booted.')->flash();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.manage', $id);
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Manage the suspension status for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function manageSuspension(Request $request, $id)
public function manageSuspension(Request $request, Server $server)
{
$repo = new ServerRepository;
$action = $request->input('action');
$this->suspensionService->toggle($server, $request->input('action'));
$this->alert->success(trans('admin/server.alerts.suspension_toggled', [
'status' => $request->input('action') . 'ed',
]))->flash();
if (! in_array($action, ['suspend', 'unsuspend'])) {
Alert::danger('Invalid action was passed to function.')->flash();
return redirect()->route('admin.servers.view.manage', $id);
}
try {
$repo->toggleAccess($id, ($action === 'unsuspend'));
Alert::success('Server has been ' . $action . 'ed.');
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.')->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to ' . $action . ' this server. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.manage', $id);
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Update the build configuration for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @internal param int $id
*/
public function updateBuild(Request $request, $id)
public function updateBuild(Request $request, Server $server)
{
$repo = new ServerRepository;
try {
$repo->changeBuild($id, $request->intersect([
$this->buildModificationService->handle($server, $request->only([
'allocation_id', 'add_allocations', 'remove_allocations',
'memory', 'swap', 'io', 'cpu', 'disk',
]));
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
Alert::success('Server details were successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.view.build', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.')->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to add this server. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.build', $id);
return redirect()->route('admin.servers.view.build', $server->id);
}
/**
* Start the server deletion process.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function delete(Request $request, $id)
public function delete(Request $request, Server $server)
{
$repo = new ServerRepository;
try {
$repo->delete($id, $request->has('force_delete'));
Alert::success('Server was successfully deleted from the system.')->flash();
$this->deletionService->withForce($request->has('force_delete'))->handle($server);
$this->alert->success(trans('admin/server.alerts.server_deleted'))->flash();
return redirect()->route('admin.servers');
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException occurred while attempting to delete this server from the daemon, please ensure it is running. This error has been logged.')->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to delete this server. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.delete', $id);
}
/**
* Update the startup command as well as variables.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function saveStartup(Request $request, $id)
public function saveStartup(Request $request, Server $server)
{
$repo = new ServerRepository;
$this->startupModificationService->isAdmin()->handle(
$server,
$request->except('_token')
);
$this->alert->success(trans('admin/server.alerts.startup_changed'))->flash();
try {
if ($repo->updateStartup($id, $request->except('_token'), true)) {
Alert::success('Service configuration successfully modfied for this server, reinstalling now.')->flash();
return redirect()->route('admin.servers.view', $id);
} else {
Alert::success('Startup variables were successfully modified and assigned for this server.')->flash();
}
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.view.startup', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (TransferException $ex) {
Log::warning($ex);
Alert::danger('A TransferException occurred while attempting to update the startup for this server, please ensure the daemon is running. This error has been logged.')->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An unhandled exception occured while attemping to update startup variables for this server. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.startup', $id);
return redirect()->route('admin.servers.view.startup', $server->id);
}
/**
* Creates a new database assigned to a specific server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function newDatabase(Request $request, $id)
public function newDatabase(Request $request, $server)
{
$repo = new DatabaseRepository;
$this->databaseManagementService->create($server, [
'database' => $request->input('database'),
'remote' => $request->input('remote'),
'database_host_id' => $request->input('database_host_id'),
]);
try {
$repo->create($id, $request->only(['host', 'database', 'connection']));
Alert::success('A new database was assigned to this server successfully.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.view.database', $id)->withInput()->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An exception occured while attempting to add a new database for this server. This error has been logged.')->flash();
}
return redirect()->route('admin.servers.view.database', $id)->withInput();
return redirect()->route('admin.servers.view.database', $server)->withInput();
}
/**
* Resets the database password for a specific database on this server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function resetDatabasePassword(Request $request, $id)
public function resetDatabasePassword(Request $request, $server)
{
$database = Models\Database::where('server_id', $id)->findOrFail($request->input('database'));
$repo = new DatabaseRepository;
$database = $this->databaseRepository->findFirstWhere([
['server_id', '=', $server],
['id', '=', $request->input('database')],
]);
try {
$repo->password($database->id, str_random(20));
$this->databaseManagementService->changePassword($database->id, str_random(20));
return response('', 204);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json(['error' => 'A unhandled exception occurred while attempting to reset this password. This error has been logged.'], 503);
}
}
/**
* Deletes a database from a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param int $server
* @param int $database
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function deleteDatabase(Request $request, $id, $database)
public function deleteDatabase($server, $database)
{
$database = Models\Database::where('server_id', $id)->findOrFail($database);
$repo = new DatabaseRepository;
$database = $this->databaseRepository->findFirstWhere([
['server_id', '=', $server],
['id', '=', $database],
]);
try {
$repo->drop($database->id);
$this->databaseManagementService->delete($database->id);
return response('', 204);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json(['error' => 'A unhandled exception occurred while attempting to drop this database. This error has been logged.'], 503);
}
}
}

Some files were not shown because too many files have changed in this diff Show more