diff --git a/.gitignore b/.gitignore index 0826a5ebe..c3209c0d6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,14 +6,11 @@ storage/framework/* composer.lock - -Homestead.yaml -Vagrantfile -Vagrantfile - -node_modules -yarn.lock node_modules _ide_helper_models.php _ide_helper.php + +sami.phar +sami.config.php +/sami diff --git a/app/Events/Server/Created.php b/app/Events/Server/Created.php index d5a308876..2591cd5af 100644 --- a/app/Events/Server/Created.php +++ b/app/Events/Server/Created.php @@ -31,11 +31,17 @@ class Created { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Creating.php b/app/Events/Server/Creating.php index cbba63eb1..46e4898c1 100644 --- a/app/Events/Server/Creating.php +++ b/app/Events/Server/Creating.php @@ -31,11 +31,17 @@ class Creating { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Deleted.php b/app/Events/Server/Deleted.php index b36dca12d..6f8709b85 100644 --- a/app/Events/Server/Deleted.php +++ b/app/Events/Server/Deleted.php @@ -31,11 +31,17 @@ class Deleted { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Deleting.php b/app/Events/Server/Deleting.php index bb18e1ee9..3152ed96e 100644 --- a/app/Events/Server/Deleting.php +++ b/app/Events/Server/Deleting.php @@ -31,11 +31,17 @@ class Deleting { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Saved.php b/app/Events/Server/Saved.php index 08700e3cb..d19659045 100644 --- a/app/Events/Server/Saved.php +++ b/app/Events/Server/Saved.php @@ -31,11 +31,17 @@ class Saved { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Saving.php b/app/Events/Server/Saving.php index 2c6d3cb4e..1ae31da32 100644 --- a/app/Events/Server/Saving.php +++ b/app/Events/Server/Saving.php @@ -31,11 +31,17 @@ class Saving { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Updated.php b/app/Events/Server/Updated.php index 0310e20c6..1284ea504 100644 --- a/app/Events/Server/Updated.php +++ b/app/Events/Server/Updated.php @@ -31,11 +31,17 @@ class Updated { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Server/Updating.php b/app/Events/Server/Updating.php index f333ede6b..b2fc255c8 100644 --- a/app/Events/Server/Updating.php +++ b/app/Events/Server/Updating.php @@ -31,11 +31,17 @@ class Updating { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Server + */ public $server; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Server $server * @return void */ public function __construct(Server $server) diff --git a/app/Events/Subuser/Created.php b/app/Events/Subuser/Created.php index 7b3be9597..9a2d28536 100644 --- a/app/Events/Subuser/Created.php +++ b/app/Events/Subuser/Created.php @@ -31,11 +31,17 @@ class Created { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Subuser + */ public $subuser; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function __construct(Subuser $subuser) diff --git a/app/Events/Subuser/Creating.php b/app/Events/Subuser/Creating.php index 353497e24..5083c497c 100644 --- a/app/Events/Subuser/Creating.php +++ b/app/Events/Subuser/Creating.php @@ -31,11 +31,17 @@ class Creating { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Subuser + */ public $subuser; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function __construct(Subuser $subuser) diff --git a/app/Events/Subuser/Deleted.php b/app/Events/Subuser/Deleted.php index 3ffe3afe8..1e419ab81 100644 --- a/app/Events/Subuser/Deleted.php +++ b/app/Events/Subuser/Deleted.php @@ -31,11 +31,17 @@ class Deleted { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Subuser + */ public $subuser; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function __construct(Subuser $subuser) diff --git a/app/Events/Subuser/Deleting.php b/app/Events/Subuser/Deleting.php index da812019b..a06ebe2dc 100644 --- a/app/Events/Subuser/Deleting.php +++ b/app/Events/Subuser/Deleting.php @@ -31,11 +31,17 @@ class Deleting { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\Subuser + */ public $subuser; /** * Create a new event instance. * + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function __construct(Subuser $subuser) diff --git a/app/Events/User/Created.php b/app/Events/User/Created.php index a00bdd450..4e1fd9e75 100644 --- a/app/Events/User/Created.php +++ b/app/Events/User/Created.php @@ -31,11 +31,17 @@ class Created { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\User + */ public $user; /** * Create a new event instance. * + * @param \Pterodactyl\Models\User $user * @return void */ public function __construct(User $user) diff --git a/app/Events/User/Creating.php b/app/Events/User/Creating.php index 39a50f0c8..cc544af9e 100644 --- a/app/Events/User/Creating.php +++ b/app/Events/User/Creating.php @@ -31,11 +31,17 @@ class Creating { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\User + */ public $user; /** * Create a new event instance. * + * @param \Pterodactyl\Models\User $user * @return void */ public function __construct(User $user) diff --git a/app/Events/User/Deleted.php b/app/Events/User/Deleted.php index 348c859c9..a3cc3cffe 100644 --- a/app/Events/User/Deleted.php +++ b/app/Events/User/Deleted.php @@ -31,11 +31,17 @@ class Deleted { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\User + */ public $user; /** * Create a new event instance. * + * @param \Pterodactyl\Models\User $user * @return void */ public function __construct(User $user) diff --git a/app/Events/User/Deleting.php b/app/Events/User/Deleting.php index 5bbd91366..ad9397e45 100644 --- a/app/Events/User/Deleting.php +++ b/app/Events/User/Deleting.php @@ -31,11 +31,17 @@ class Deleting { use SerializesModels; + /** + * The Eloquent model of the server. + * + * @var \Pterodactyl\Models\User + */ public $user; /** * Create a new event instance. * + * @param \Pterodactyl\Models\User $user * @return void */ public function __construct(User $user) diff --git a/app/Exceptions/AccountNotFoundException.php b/app/Exceptions/AccountNotFoundException.php index f8e36ed49..b35bd2fc0 100644 --- a/app/Exceptions/AccountNotFoundException.php +++ b/app/Exceptions/AccountNotFoundException.php @@ -26,4 +26,5 @@ namespace Pterodactyl\Exceptions; class AccountNotFoundException extends \Exception { + // } diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index c1b701f36..f3f8fd719 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -28,20 +28,19 @@ use Log; class DisplayException extends \Exception { - private $_logging = null; - + /** + * Exception constructor. + * + * @param string $message + * @param mixed $log + * @return void + */ public function __construct($message, $log = null) { - $this->_logging = $log; - if ($this->_logging !== null) { + if (! is_null($log)) { Log::error($log); } parent::__construct($message); } - - public function getLogging() - { - return $this->_logging; - } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 6aac7cc02..0a2fd8f28 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -29,7 +29,7 @@ class Handler extends ExceptionHandler * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * - * @param \Exception $e + * @param \Exception $exception * @return void */ public function report(Exception $exception) @@ -41,7 +41,7 @@ class Handler extends ExceptionHandler * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Exception $e + * @param \Exception $exception * @return \Illuminate\Http\Response */ public function render($request, Exception $exception) @@ -60,7 +60,7 @@ class Handler extends ExceptionHandler /** * Convert an authentication exception into an unauthenticated response. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception * @return \Illuminate\Http\Response */ diff --git a/app/Extensions/PhraseAppTranslator.php b/app/Extensions/PhraseAppTranslator.php index 5a8d4a84e..f79cf2820 100644 --- a/app/Extensions/PhraseAppTranslator.php +++ b/app/Extensions/PhraseAppTranslator.php @@ -31,11 +31,11 @@ class PhraseAppTranslator extends LaravelTranslator /** * Get the translation for the given key. * - * @param string $key - * @param array $replace + * @param string $key + * @param array $replace * @param string|null $locale - * @param bool $fallback - * @return string|array|null + * @param bool $fallback + * @return string */ public function get($key, array $replace = [], $locale = null, $fallback = true) { diff --git a/app/Facades/Version.php b/app/Facades/Version.php index 2ce007360..e9475d2a6 100644 --- a/app/Facades/Version.php +++ b/app/Facades/Version.php @@ -28,6 +28,11 @@ use Illuminate\Support\Facades\Facade; class Version extends Facade { + /** + * Returns the facade accessor class. + * + * @return strig + */ protected static function getFacadeAccessor() { return '\Pterodactyl\Services\VersionService'; diff --git a/app/Http/Controllers/API/NodeController.php b/app/Http/Controllers/API/NodeController.php index 26ca56446..c0df9cba0 100755 --- a/app/Http/Controllers/API/NodeController.php +++ b/app/Http/Controllers/API/NodeController.php @@ -142,6 +142,7 @@ class NodeController extends BaseController * Returns a listing of the allocation for the specified server id. * * @param Request $request + * @param int $id * @return array */ public function allocationsView(Request $request, $id) diff --git a/app/Http/Controllers/Admin/BaseController.php b/app/Http/Controllers/Admin/BaseController.php index cd4b177c9..2d2fe469c 100644 --- a/app/Http/Controllers/Admin/BaseController.php +++ b/app/Http/Controllers/Admin/BaseController.php @@ -32,16 +32,34 @@ use Pterodactyl\Http\Controllers\Controller; class BaseController extends Controller { + /** + * Return the admin index view. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View + */ public function getIndex(Request $request) { return view('admin.index'); } + /** + * Return the admin settings view. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View + */ public function getSettings(Request $request) { return view('admin.settings'); } + /** + * Handle settings post request. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse + */ public function postSettings(Request $request) { $validator = Validator::make($request->all(), [ diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php index e41575458..6b4e12a1d 100644 --- a/app/Http/Controllers/Admin/DatabaseController.php +++ b/app/Http/Controllers/Admin/DatabaseController.php @@ -40,7 +40,7 @@ class DatabaseController extends Controller /** * Display database host index. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function index(Request $request) @@ -54,8 +54,8 @@ class DatabaseController extends Controller /** * Display database host to user. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function view(Request $request, $id) @@ -69,8 +69,8 @@ class DatabaseController extends Controller /** * Handle post request to create database host. * - * @param Request $request - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse */ public function create(Request $request) { @@ -99,9 +99,9 @@ class DatabaseController extends Controller /** * Handle post request to update a database host. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request, $id) { diff --git a/app/Http/Controllers/Admin/LocationController.php b/app/Http/Controllers/Admin/LocationController.php index 6ceae16e7..4e602f7ca 100644 --- a/app/Http/Controllers/Admin/LocationController.php +++ b/app/Http/Controllers/Admin/LocationController.php @@ -38,7 +38,7 @@ class LocationController extends Controller /** * Return the location overview page. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function index(Request $request) @@ -51,8 +51,8 @@ class LocationController extends Controller /** * Return the location view page. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function view(Request $request, $id) @@ -63,8 +63,8 @@ class LocationController extends Controller /** * Handle request to create new location. * - * @param Request $request - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse */ public function create(Request $request) { @@ -88,9 +88,9 @@ class LocationController extends Controller /** * Handle request to update or delete location. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request, $id) { diff --git a/app/Http/Controllers/Admin/NodesController.php b/app/Http/Controllers/Admin/NodesController.php index cbf3ff6ce..0c895fe15 100644 --- a/app/Http/Controllers/Admin/NodesController.php +++ b/app/Http/Controllers/Admin/NodesController.php @@ -40,7 +40,7 @@ class NodesController extends Controller /** * Displays the index page listing all nodes on the panel. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function index(Request $request) @@ -57,8 +57,8 @@ class NodesController extends Controller /** * Displays create new node page. * - * @param Request $request - * @return \Illuminate\View\View|\Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse */ public function new(Request $request) { @@ -75,8 +75,8 @@ class NodesController extends Controller /** * Post controller to create a new node on the system. * - * @param Request $request - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse */ public function create(Request $request) { @@ -110,9 +110,8 @@ class NodesController extends Controller /** * Shows the index overview page for a specific node. * - * @param Request $request - * @param int $id The ID of the node to display information for. - * + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewIndex(Request $request, $id) @@ -138,9 +137,8 @@ class NodesController extends Controller /** * Shows the settings page for a specific node. * - * @param Request $request - * @param int $id The ID of the node to display information for. - * + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewSettings(Request $request, $id) @@ -154,9 +152,8 @@ class NodesController extends Controller /** * Shows the configuration page for a specific node. * - * @param Request $request - * @param int $id The ID of the node to display information for. - * + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewConfiguration(Request $request, $id) @@ -169,9 +166,8 @@ class NodesController extends Controller /** * Shows the allocation page for a specific node. * - * @param Request $request - * @param int $id The ID of the node to display information for. - * + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewAllocation(Request $request, $id) @@ -189,9 +185,8 @@ class NodesController extends Controller /** * Shows the server listing page for a specific node. * - * @param Request $request - * @param int $id The ID of the node to display information for. - * + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewServers(Request $request, $id) @@ -209,8 +204,8 @@ class NodesController extends Controller /** * Updates settings for a node. * - * @param Request $request - * @param int $node + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\Http\RedirectResponse */ public function updateSettings(Request $request, $id) @@ -244,9 +239,9 @@ class NodesController extends Controller /** * Removes a single allocation from a node. * - * @param Request $request - * @param int $node - * @param int $allocation [description] + * @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) @@ -264,8 +259,8 @@ class NodesController extends Controller /** * Remove all allocations for a specific IP at once on a node. * - * @param Request $request - * @param int $node + * @param \Illuminate\Http\Request $request + * @param int $node * @return \Illuminate\Http\RedirectResponse */ public function allocationRemoveBlock(Request $request, $node) @@ -283,10 +278,9 @@ class NodesController extends Controller /** * Sets an alias for a specific allocation on a node. * - * @param Request $request - * @param int $node + * @param \Illuminate\Http\Request $request + * @param int $node * @return \Illuminate\Http\Response - * @throws \Exception */ public function allocationSetAlias(Request $request, $node) { @@ -308,8 +302,8 @@ class NodesController extends Controller /** * Creates new allocations on a node. * - * @param Request $request - * @param int $node + * @param \Illuminate\Http\Request $request + * @param int $node * @return \Illuminate\Http\RedirectResponse */ public function createAllocation(Request $request, $node) @@ -334,8 +328,8 @@ class NodesController extends Controller /** * Deletes a node from the system. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\Http\RedirectResponse */ public function delete(Request $request, $id) @@ -360,8 +354,8 @@ class NodesController extends Controller /** * Returns the configuration token to auto-deploy a node. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\Http\JsonResponse */ public function setToken(Request $request, $id) diff --git a/app/Http/Controllers/Admin/OptionController.php b/app/Http/Controllers/Admin/OptionController.php index 68ddfaf9e..4dfe34321 100644 --- a/app/Http/Controllers/Admin/OptionController.php +++ b/app/Http/Controllers/Admin/OptionController.php @@ -41,7 +41,7 @@ class OptionController extends Controller /** * Handles request to view page for adding new option. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function new(Request $request) @@ -55,7 +55,7 @@ class OptionController extends Controller /** * Handles POST request to create a new option. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\Response\RedirectResponse */ public function create(Request $request) @@ -86,9 +86,9 @@ class OptionController extends Controller /** * Handles POST request to create a new option variable. * - * @param Request $request - * @param int $id The ID of the service option to assign this variable to. - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function createVariable(Request $request, $id) { @@ -116,8 +116,8 @@ class OptionController extends Controller /** * Display option overview page. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewConfiguration(Request $request, $id) @@ -128,8 +128,8 @@ class OptionController extends Controller /** * Display variable overview page for a service option. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewVariables(Request $request, $id) @@ -140,8 +140,9 @@ class OptionController extends Controller /** * Handles POST when editing a configration for a service option. * - * @param Request $request - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function editConfiguration(Request $request, $id) { @@ -176,10 +177,10 @@ class OptionController extends Controller /** * Handles POST when editing a configration for a service option. * - * @param Request $request - * @param int $option - * @param int $variable - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $option + * @param int $variable + * @return \Illuminate\Http\RedirectResponse */ public function editVariable(Request $request, $option, $variable) { diff --git a/app/Http/Controllers/Admin/PackController.php b/app/Http/Controllers/Admin/PackController.php index 46674ae02..9d1e6e768 100644 --- a/app/Http/Controllers/Admin/PackController.php +++ b/app/Http/Controllers/Admin/PackController.php @@ -40,7 +40,7 @@ class PackController extends Controller /** * Display listing of all packs on the system. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function index(Request $request) @@ -57,7 +57,7 @@ class PackController extends Controller /** * Display new pack creation form. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function new(Request $request) @@ -70,7 +70,7 @@ class PackController extends Controller /** * Display new pack creation modal for use with template upload. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function newTemplate(Request $request) @@ -83,7 +83,7 @@ class PackController extends Controller /** * Handle create pack request and route user to location. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function create(Request $request) @@ -117,8 +117,8 @@ class PackController extends Controller /** * Display pack view template to user. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function view(Request $request, $id) @@ -132,9 +132,9 @@ class PackController extends Controller /** * Handle updating or deleting pack information. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request, $id) { @@ -168,10 +168,10 @@ class PackController extends Controller /** * Creates an archive of the pack and downloads it to the browser. * - * @param Request $request - * @param int $id - * @param bool $files - * @return \Illuminate\Response\BinaryFileResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @param bool $files + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function export(Request $request, $id, $files = false) { @@ -202,6 +202,7 @@ class PackController extends Controller 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); diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 3de8d0c9f..dd1ae466d 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -41,7 +41,7 @@ class ServersController extends Controller /** * Display the index page with all servers currently on the system. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function index(Request $request) @@ -62,7 +62,7 @@ class ServersController extends Controller /** * Display create new server page. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function new(Request $request) @@ -85,7 +85,7 @@ class ServersController extends Controller /** * Create server controller method. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\Response\RedirectResponse */ public function create(Request $request) @@ -110,7 +110,7 @@ class ServersController extends Controller /** * Returns a tree of all avaliable nodes in a given location. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return array */ public function newServerNodes(Request $request) @@ -140,8 +140,8 @@ class ServersController extends Controller /** * Display the index when viewing a specific server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewIndex(Request $request, $id) @@ -152,8 +152,8 @@ class ServersController extends Controller /** * Display the details page when viewing a specific server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewDetails(Request $request, $id) @@ -166,8 +166,8 @@ class ServersController extends Controller /** * Display the build details page when viewing a specific server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewBuild(Request $request, $id) @@ -184,8 +184,8 @@ class ServersController extends Controller /** * Display startup configuration page for a server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewStartup(Request $request, $id) @@ -203,8 +203,8 @@ class ServersController extends Controller /** * Display the database management page for a specific server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewDatabase(Request $request, $id) @@ -220,8 +220,8 @@ class ServersController extends Controller /** * Display the management page when viewing a specific server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewManage(Request $request, $id) @@ -232,8 +232,8 @@ class ServersController extends Controller /** * Display the deletion page for a server. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewDelete(Request $request, $id) @@ -244,9 +244,9 @@ class ServersController extends Controller /** * Update the details for a server. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function setDetails(Request $request, $id) { @@ -272,9 +272,9 @@ class ServersController extends Controller /** * Set the new docker container for a server. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function setContainer(Request $request, $id) { @@ -299,9 +299,9 @@ class ServersController extends Controller /** * Toggles the install status for a server. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function toggleInstall(Request $request, $id) { @@ -323,9 +323,9 @@ class ServersController extends Controller /** * Setup a server to have a container rebuild. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function rebuildContainer(Request $request, $id) { @@ -349,9 +349,9 @@ class ServersController extends Controller /** * Manage the suspension status for a server. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function manageSuspension(Request $request, $id) { @@ -381,9 +381,9 @@ class ServersController extends Controller /** * Update the build configuration for a server. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function updateBuild(Request $request, $id) { @@ -411,9 +411,9 @@ class ServersController extends Controller /** * Start the server deletion process. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function delete(Request $request, $id) { @@ -435,9 +435,9 @@ class ServersController extends Controller /** * Cancels a pending server deletion request. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function cancelDeletion(Request $request, $id) { @@ -452,10 +452,10 @@ class ServersController extends Controller /** * Skips the queue and continues the server deletion process. * - * @param Request $request - * @param int $id - * @param string $method - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @param string $method + * @return \Illuminate\Http\RedirectResponse */ public function continueDeletion(Request $request, $id, $method = 'safe') { @@ -482,9 +482,9 @@ class ServersController extends Controller /** * Update the startup command as well as variables. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function saveStartup(Request $request, $id) { @@ -511,9 +511,10 @@ class ServersController extends Controller /** * Creates a new database assigned to a specific server. - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function newDatabase(Request $request, $id) { @@ -537,9 +538,10 @@ class ServersController extends Controller /** * Resets the database password for a specific database on this server. - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function resetDatabasePassword(Request $request, $id) { @@ -559,9 +561,11 @@ class ServersController extends Controller /** * Deletes a database from a server. - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @param int $database + * @return \Illuminate\Http\RedirectResponse */ public function deleteDatabase(Request $request, $id, $database) { diff --git a/app/Http/Controllers/Admin/ServiceController.php b/app/Http/Controllers/Admin/ServiceController.php index bcf4d9008..2e63e5306 100644 --- a/app/Http/Controllers/Admin/ServiceController.php +++ b/app/Http/Controllers/Admin/ServiceController.php @@ -38,7 +38,7 @@ class ServiceController extends Controller /** * Display service overview page. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function index(Request $request) @@ -51,7 +51,7 @@ class ServiceController extends Controller /** * Display create service page. * - * @param Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function new(Request $request) @@ -62,8 +62,8 @@ class ServiceController extends Controller /** * Return base view for a service. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function view(Request $request, $id) @@ -76,8 +76,8 @@ class ServiceController extends Controller /** * Return function editing view for a service. * - * @param Request $request - * @param int $id + * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\View\View */ public function viewFunctions(Request $request, $id) @@ -88,8 +88,8 @@ class ServiceController extends Controller /** * Handle post action for new service. * - * @param Request $request - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse */ public function create(Request $request) { @@ -117,9 +117,9 @@ class ServiceController extends Controller /** * Edits configuration for a specific service. * - * @param Request $request - * @param int $id - * @return \Illuminate\Response\RedirectResponse + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse */ public function edit(Request $request, $id) { diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 0de02eca9..8439cc2ab 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -37,14 +37,11 @@ use Pterodactyl\Exceptions\DisplayValidationException; class UserController extends Controller { /** - * Controller Constructor. + * Display user index page. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View */ - public function __construct() - { - // - } - - // @TODO: implement nicolaslopezj/searchable to clean up this disaster. public function getIndex(Request $request) { $users = User::withCount('servers'); @@ -58,11 +55,24 @@ class UserController extends Controller ]); } + /** + * Display new user page. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View + */ public function getNew(Request $request) { return view('admin.users.new'); } + /** + * Display user view page. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\View\View + */ public function getView(Request $request, $id) { return view('admin.users.view', [ @@ -70,6 +80,13 @@ class UserController extends Controller ]); } + /** + * Delete a user. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse + */ public function deleteUser(Request $request, $id) { try { @@ -88,6 +105,12 @@ class UserController extends Controller return redirect()->route('admin.users.view', $id); } + /** + * Create a user. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse + */ public function postNew(Request $request) { try { @@ -109,6 +132,13 @@ class UserController extends Controller } } + /** + * Update a user. + * + * @param \Illuminate\Http\Request $request + * @param int $user + * @return \Illuminate\Http\RedirectResponse + */ public function updateUser(Request $request, $user) { try { @@ -128,6 +158,12 @@ class UserController extends Controller return redirect()->route('admin.users.view', $user); } + /** + * Get a JSON response of users on the system. + * + * @param \Illuminate\Http\Request $request + * @return \Pterodactyl\Models\User + */ public function getJson(Request $request) { return User::select('id', 'email', 'username', 'name_first', 'name_last') diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index d4d8c89c3..ada7aebb4 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -83,7 +83,7 @@ class LoginController extends Controller * Handle a login request to the application. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\Response|\Illuminate\Response\RedirectResponse */ public function login(Request $request) { @@ -126,6 +126,12 @@ class LoginController extends Controller } } + /** + * Handle a TOTP implementation page. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View + */ public function totp(Request $request) { $verifyKey = $request->session()->get('authentication_token'); @@ -140,6 +146,12 @@ class LoginController extends Controller ]); } + /** + * Handle a TOTP input. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse + */ public function totpCheckpoint(Request $request) { $G2FA = new Google2FA(); diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index fca008051..02138d04d 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -21,6 +21,11 @@ class ResetPasswordController extends Controller use ResetsPasswords; + /** + * The URL to redirect users to after password reset. + * + * @var string + */ public $redirectTo = '/'; /** @@ -33,6 +38,11 @@ class ResetPasswordController extends Controller $this->middleware('guest'); } + /** + * Return the rules used when validating password reset. + * + * @return array + */ protected function rules() { return [ diff --git a/app/Http/Controllers/Base/APIController.php b/app/Http/Controllers/Base/APIController.php index f4133bc7f..bc0ce7be4 100644 --- a/app/Http/Controllers/Base/APIController.php +++ b/app/Http/Controllers/Base/APIController.php @@ -36,6 +36,12 @@ use Pterodactyl\Exceptions\DisplayValidationException; class APIController extends Controller { + /** + * Display base API index page. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View + */ public function index(Request $request) { return view('base.api.index', [ @@ -43,11 +49,23 @@ class APIController extends Controller ]); } + /** + * Display API key creation page. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View + */ public function create(Request $request) { return view('base.api.new'); } + /** + * Handle saving new API key. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse + */ public function save(Request $request) { try { @@ -71,6 +89,13 @@ class APIController extends Controller return redirect()->route('account.api.new')->withInput(); } + /** + * Handle revoking API key. + * + * @param \Illuminate\Http\Request $request + * @param string $key + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response + */ public function revoke(Request $request, $key) { try { diff --git a/app/Http/Controllers/Base/AccountController.php b/app/Http/Controllers/Base/AccountController.php index 8db513bd5..99b950273 100644 --- a/app/Http/Controllers/Base/AccountController.php +++ b/app/Http/Controllers/Base/AccountController.php @@ -38,8 +38,8 @@ class AccountController extends Controller /** * Display base account information page. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View */ public function index(Request $request) { @@ -48,8 +48,10 @@ class AccountController extends Controller /** * Update details for a users account. - * @param \Illuminate\Http\Request $request - * @return void + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse + * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function update(Request $request) { diff --git a/app/Http/Controllers/Base/IndexController.php b/app/Http/Controllers/Base/IndexController.php index 5b6fab3a7..84b89e6aa 100644 --- a/app/Http/Controllers/Base/IndexController.php +++ b/app/Http/Controllers/Base/IndexController.php @@ -30,19 +30,11 @@ use Pterodactyl\Http\Controllers\Controller; class IndexController extends Controller { - /** - * Controller Constructor. - */ - public function __construct() - { - // - } - /** * Returns listing of user's servers. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View */ public function getIndex(Request $request) { @@ -54,8 +46,10 @@ class IndexController extends Controller /** * Generate a random string. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * @param int $length * @return string + * @deprecated */ public function getPassword(Request $request, $length = 16) { diff --git a/app/Http/Controllers/Base/LanguageController.php b/app/Http/Controllers/Base/LanguageController.php index e4967ee5e..24cb4d6e2 100644 --- a/app/Http/Controllers/Base/LanguageController.php +++ b/app/Http/Controllers/Base/LanguageController.php @@ -32,6 +32,11 @@ use Pterodactyl\Http\Controllers\Controller; class LanguageController extends Controller { + /** + * A list of supported languages on the panel. + * + * @var array + */ protected $languages = [ 'de' => 'German', 'en' => 'English', @@ -44,13 +49,12 @@ class LanguageController extends Controller ]; /** - * Controller Constructor. + * Sets the language for a user. + * + * @param \Illuminate\Http\Request $request + * @param string $language + * @return \Illuminate\Http\RedirectResponse */ - public function __construct() - { - // - } - public function setLanguage(Request $request, $language) { if (array_key_exists($language, $this->languages)) { diff --git a/app/Http/Controllers/Base/SecurityController.php b/app/Http/Controllers/Base/SecurityController.php index 23b6f0d68..052a7a527 100644 --- a/app/Http/Controllers/Base/SecurityController.php +++ b/app/Http/Controllers/Base/SecurityController.php @@ -36,8 +36,8 @@ class SecurityController extends Controller /** * Returns Security Management Page. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @return \Illuminate\View\View */ public function index(Request $request) { @@ -50,8 +50,8 @@ class SecurityController extends Controller * Generates TOTP Secret and returns popup data for user to verify * that they can generate a valid response. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse */ public function generateTotp(Request $request) { @@ -73,7 +73,7 @@ class SecurityController extends Controller /** * Verifies that 2FA token recieved is valid and will work on the account. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function setTotp(Request $request) @@ -95,8 +95,8 @@ class SecurityController extends Controller /** * Disables TOTP on an account. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse */ public function disableTotp(Request $request) { @@ -116,6 +116,13 @@ class SecurityController extends Controller return redirect()->route('account.security'); } + /** + * Revokes a user session. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse + */ public function revoke(Request $request, $id) { Session::where('user_id', $request->user()->id)->findOrFail($id)->delete(); diff --git a/app/Http/Controllers/Daemon/PackController.php b/app/Http/Controllers/Daemon/PackController.php index 4d35f6d77..419ae7c9c 100644 --- a/app/Http/Controllers/Daemon/PackController.php +++ b/app/Http/Controllers/Daemon/PackController.php @@ -31,19 +31,12 @@ use Pterodactyl\Http\Controllers\Controller; class PackController extends Controller { - /** - * Controller Constructor. - */ - public function __construct() - { - // - } - /** * Pulls an install pack archive from the system. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse */ public function pull(Request $request, $uuid) { @@ -63,8 +56,9 @@ class PackController extends Controller /** * Returns the hash information for a pack. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\JsonResponse */ public function hash(Request $request, $uuid) { @@ -87,9 +81,10 @@ class PackController extends Controller * Pulls an update pack archive from the system. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @return void */ public function pullUpdate(Request $request) { + // } } diff --git a/app/Http/Controllers/Daemon/ServiceController.php b/app/Http/Controllers/Daemon/ServiceController.php index 99d69cf02..5762ecef2 100644 --- a/app/Http/Controllers/Daemon/ServiceController.php +++ b/app/Http/Controllers/Daemon/ServiceController.php @@ -36,7 +36,7 @@ class ServiceController extends Controller * as well as the associated files and the file hashes for * caching purposes. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function list(Request $request) @@ -77,7 +77,7 @@ class ServiceController extends Controller * Returns a `main.json` file based on the configuration * of each service option. * - * @param int $id + * @param int $id * @return \Illuminate\Support\Collection */ protected function getConfiguration($id) diff --git a/app/Http/Controllers/Remote/RemoteController.php b/app/Http/Controllers/Remote/RemoteController.php index 93dd672e1..78cd4d444 100644 --- a/app/Http/Controllers/Remote/RemoteController.php +++ b/app/Http/Controllers/Remote/RemoteController.php @@ -32,13 +32,11 @@ use Pterodactyl\Http\Controllers\Controller; class RemoteController extends Controller { /** - * Controller Constructor. + * Handles download request from daemon. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse */ - public function __construct() - { - // No middleware for this route. - } - public function postDownload(Request $request) { $download = Models\Download::where('token', $request->input('token'))->first(); @@ -56,6 +54,12 @@ class RemoteController extends Controller ]); } + /** + * Handles install toggle request from daemon. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse + */ public function postInstall(Request $request) { $server = Models\Server::where('uuid', $request->input('server'))->with('node')->first(); @@ -82,6 +86,13 @@ class RemoteController extends Controller ], 200); } + /** + * Handles event from daemon. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response + * @deprecated + */ public function event(Request $request) { $server = Models\Server::where('uuid', $request->input('server'))->with('node')->first(); @@ -101,6 +112,13 @@ class RemoteController extends Controller return response('', 201); } + /** + * Handles configuration data request from daemon. + * + * @param \Illuminate\Http\Request $request + * @param string $token + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response + */ public function getConfiguration(Request $request, $token) { // Try to query the token and the node from the database diff --git a/app/Http/Controllers/Server/AjaxController.php b/app/Http/Controllers/Server/AjaxController.php index 4609ae270..9ffd13038 100644 --- a/app/Http/Controllers/Server/AjaxController.php +++ b/app/Http/Controllers/Server/AjaxController.php @@ -50,20 +50,12 @@ class AjaxController extends Controller */ protected $directory; - /** - * Controller Constructor. - */ - public function __construct() - { - // - } - /** * Returns true or false depending on the power status of the requested server. * - * @param \Illuminate\Http\Request $request - * @param string $uuid - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\JsonResponse */ public function getStatus(Request $request, $uuid) { @@ -96,9 +88,9 @@ class AjaxController extends Controller /** * Returns a listing of files in a given directory for a server. * - * @param \Illuminate\Http\Request $request - * @param string $uuid` - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View|\Illuminate\Http\Response */ public function postDirectoryList(Request $request, $uuid) { @@ -147,8 +139,8 @@ class AjaxController extends Controller /** * Handles a POST request to save a file. * - * @param Request $request - * @param string $uuid + * @param \Illuminate\Http\Request $request + * @param string $uuid * @return \Illuminate\Http\Response */ public function postSaveFile(Request $request, $uuid) @@ -172,10 +164,12 @@ class AjaxController extends Controller } /** - * [postSetPrimary description]. - * @param Request $request - * @param string $uuid - * @return \Illuminate\Http\Response + * Sets the primary allocation for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\JsonResponse + * @deprecated */ public function postSetPrimary(Request $request, $uuid) { @@ -219,6 +213,14 @@ class AjaxController extends Controller } } + /** + * Resets a database password for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\JsonResponse + * @deprecated + */ public function postResetDatabasePassword(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index 91b0f1133..5c3dc193d 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -37,21 +37,12 @@ use Pterodactyl\Exceptions\DisplayValidationException; class ServerController extends Controller { - /** - * Controller Constructor. - * - * @return void - */ - public function __construct() - { - // - } - /** * Renders server index page for specified server. * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View */ public function getIndex(Request $request, $uuid) { @@ -77,8 +68,9 @@ class ServerController extends Controller /** * Renders file overview page. * - * @param Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View */ public function getFiles(Request $request, $uuid) { @@ -110,8 +102,9 @@ class ServerController extends Controller /** * Renders add file page. * - * @param Request $request - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View */ public function getAddFile(Request $request, $uuid) { @@ -130,10 +123,10 @@ class ServerController extends Controller /** * Renders edit file page for a given file. * - * @param Request $request - * @param string $uuid - * @param string $file - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param string $file + * @return \Illuminate\View\View */ public function getEditFile(Request $request, $uuid, $file) { @@ -173,10 +166,10 @@ class ServerController extends Controller /** * Handles downloading a file for the user. * - * @param Request $request - * @param string $uuid - * @param string $file - * @return \Illuminate\Contracts\View\View + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param string $file + * @return \Illuminate\View\View */ public function getDownloadFile(Request $request, $uuid, $file) { @@ -194,6 +187,13 @@ class ServerController extends Controller return redirect($server->node->scheme . '://' . $server->node->fqdn . ':' . $server->node->daemonListen . '/server/file/download/' . $download->token); } + /** + * Returns the allocation overview for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getAllocation(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -209,6 +209,13 @@ class ServerController extends Controller ]); } + /** + * Returns the startup overview for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getStartup(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -239,6 +246,13 @@ class ServerController extends Controller ]); } + /** + * Returns the database overview for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getDatabases(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -254,6 +268,13 @@ class ServerController extends Controller ]); } + /** + * Returns the SFTP overview for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getSFTP(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -266,6 +287,13 @@ class ServerController extends Controller ]); } + /** + * Handles changing the SFTP password for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\RedirectResponse + */ public function postSettingsSFTP(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -287,6 +315,13 @@ class ServerController extends Controller return redirect()->route('server.settings.sftp', $uuid); } + /** + * Handles changing the startup settings for a server. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\RedirectResponse + */ public function postSettingsStartup(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); diff --git a/app/Http/Controllers/Server/SubuserController.php b/app/Http/Controllers/Server/SubuserController.php index a3ae8e3ba..390f7b328 100644 --- a/app/Http/Controllers/Server/SubuserController.php +++ b/app/Http/Controllers/Server/SubuserController.php @@ -37,15 +37,12 @@ use Pterodactyl\Exceptions\DisplayValidationException; class SubuserController extends Controller { /** - * Controller Constructor. + * Displays the subuser overview index. * - * @return void + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View */ - public function __construct() - { - // - } - public function getIndex(Request $request, $uuid) { $server = Models\Server::byUuid($uuid)->load('subusers.user'); @@ -60,6 +57,14 @@ class SubuserController extends Controller ]); } + /** + * Displays the a single subuser overview. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param int $id + * @return \Illuminate\View\View + */ public function getView(Request $request, $uuid, $id) { $server = Models\Server::byUuid($uuid)->load('node'); @@ -80,6 +85,14 @@ class SubuserController extends Controller ]); } + /** + * Handles editing a subuser. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param int $id + * @return \Illuminate\Http\RedirectResponse + */ public function postView(Request $request, $uuid, $id) { $server = Models\Server::byUuid($uuid); @@ -118,6 +131,13 @@ class SubuserController extends Controller ]); } + /** + * Display new subuser creation page. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getNew(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -130,6 +150,13 @@ class SubuserController extends Controller ]); } + /** + * Handles creating a new subuser. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\RedirectResponse + */ public function postNew(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -158,6 +185,14 @@ class SubuserController extends Controller return redirect()->route('server.subusers.new', $uuid)->withInput(); } + /** + * Handles deleting a subuser. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param int $id + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response + */ public function deleteSubuser(Request $request, $uuid, $id) { $server = Models\Server::byUuid($uuid); diff --git a/app/Http/Controllers/Server/TaskController.php b/app/Http/Controllers/Server/TaskController.php index 643e70a45..1ddc3eac2 100644 --- a/app/Http/Controllers/Server/TaskController.php +++ b/app/Http/Controllers/Server/TaskController.php @@ -35,11 +35,13 @@ use Pterodactyl\Exceptions\DisplayValidationException; class TaskController extends Controller { - public function __constructor() - { - // - } - + /** + * Display task index page. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getIndex(Request $request, $uuid) { $server = Models\Server::byUuid($uuid)->load('tasks'); @@ -57,6 +59,13 @@ class TaskController extends Controller ]); } + /** + * Display new task page. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\View\View + */ public function getNew(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -69,6 +78,13 @@ class TaskController extends Controller ]); } + /** + * Handle creation of new task. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @return \Illuminate\Http\RedirectResponse + */ public function postNew(Request $request, $uuid) { $server = Models\Server::byUuid($uuid); @@ -93,6 +109,14 @@ class TaskController extends Controller return redirect()->route('server.tasks.new', $uuid); } + /** + * Handle deletion of a task. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param int $id + * @return \Illuminate\Http\JsonResponse + */ public function deleteTask(Request $request, $uuid, $id) { $server = Models\Server::byUuid($uuid)->load('tasks'); @@ -119,6 +143,14 @@ class TaskController extends Controller } } + /** + * Toggle the status of a task. + * + * @param \Illuminate\Http\Request $request + * @param string $uuid + * @param int $id + * @return \Illuminate\Http\JsonResponse + */ public function toggleTask(Request $request, $uuid, $id) { $server = Models\Server::byUuid($uuid)->load('tasks'); diff --git a/app/Http/Middleware/AdminAuthenticate.php b/app/Http/Middleware/AdminAuthenticate.php index d533fc49d..175210929 100644 --- a/app/Http/Middleware/AdminAuthenticate.php +++ b/app/Http/Middleware/AdminAuthenticate.php @@ -32,14 +32,14 @@ class AdminAuthenticate /** * The Guard implementation. * - * @var Guard + * @var \Illuminate\Contracts\Auth\Guard */ protected $auth; /** * Create a new filter instance. * - * @param Guard $auth + * @param \Illuminate\Contracts\Auth\Guard $auth * @return void */ public function __construct(Guard $auth) @@ -51,7 +51,7 @@ class AdminAuthenticate * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 216465e23..b6db005ef 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -10,14 +10,14 @@ class Authenticate /** * The Guard implementation. * - * @var Guard + * @var \Illuminate\Contracts\Auth\Guard */ protected $auth; /** * Create a new filter instance. * - * @param Guard $auth + * @param \Illuminate\Contracts\Auth\Guard $auth * @return void */ public function __construct(Guard $auth) @@ -29,7 +29,7 @@ class Authenticate * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/CheckServer.php b/app/Http/Middleware/CheckServer.php index dba9395ac..33f817295 100644 --- a/app/Http/Middleware/CheckServer.php +++ b/app/Http/Middleware/CheckServer.php @@ -35,7 +35,7 @@ class CheckServer * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) diff --git a/app/Http/Middleware/DaemonAuthenticate.php b/app/Http/Middleware/DaemonAuthenticate.php index 73cb029d4..8b1813185 100644 --- a/app/Http/Middleware/DaemonAuthenticate.php +++ b/app/Http/Middleware/DaemonAuthenticate.php @@ -33,14 +33,14 @@ class DaemonAuthenticate /** * The Guard implementation. * - * @var Guard + * @var \Illuminate\Contracts\Auth\Guard */ protected $auth; /** * Create a new filter instance. * - * @param Guard $auth + * @param \Illuminate\Contracts\Auth\Guard $auth * @return void */ public function __construct(Guard $auth) @@ -52,7 +52,7 @@ class DaemonAuthenticate * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/LanguageMiddleware.php b/app/Http/Middleware/LanguageMiddleware.php index 58426063f..acd7be327 100644 --- a/app/Http/Middleware/LanguageMiddleware.php +++ b/app/Http/Middleware/LanguageMiddleware.php @@ -32,16 +32,11 @@ use Illuminate\Support\Facades\App; class LanguageMiddleware { - public function __construct() - { - // - } - /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 1735e49fe..06a0b50ff 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -11,8 +11,8 @@ class RedirectIfAuthenticated * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard + * @param \Closure $next + * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) diff --git a/app/Http/Routes/APIRoutes.php b/app/Http/Routes/APIRoutes.php index 6bd80e2bc..8351bcffd 100755 --- a/app/Http/Routes/APIRoutes.php +++ b/app/Http/Routes/APIRoutes.php @@ -28,6 +28,12 @@ use Illuminate\Routing\Router; class APIRoutes { + /** + * API routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { $api = app('Dingo\Api\Routing\Router'); diff --git a/app/Http/Routes/AdminRoutes.php b/app/Http/Routes/AdminRoutes.php index 41ab22482..889e03f90 100644 --- a/app/Http/Routes/AdminRoutes.php +++ b/app/Http/Routes/AdminRoutes.php @@ -29,6 +29,12 @@ use Illuminate\Routing\Router; class AdminRoutes { + /** + * Admin routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { diff --git a/app/Http/Routes/AuthRoutes.php b/app/Http/Routes/AuthRoutes.php index 77968321c..b138fe9d0 100644 --- a/app/Http/Routes/AuthRoutes.php +++ b/app/Http/Routes/AuthRoutes.php @@ -30,6 +30,12 @@ use Illuminate\Routing\Router; class AuthRoutes { + /** + * Authentication routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { $router->group([ diff --git a/app/Http/Routes/BaseRoutes.php b/app/Http/Routes/BaseRoutes.php index 40e86f8a7..bfcb5e8f3 100644 --- a/app/Http/Routes/BaseRoutes.php +++ b/app/Http/Routes/BaseRoutes.php @@ -29,6 +29,12 @@ use Illuminate\Routing\Router; class BaseRoutes { + /** + * Base routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { diff --git a/app/Http/Routes/DaemonRoutes.php b/app/Http/Routes/DaemonRoutes.php index 7367fae5f..7379341fe 100644 --- a/app/Http/Routes/DaemonRoutes.php +++ b/app/Http/Routes/DaemonRoutes.php @@ -28,6 +28,12 @@ use Illuminate\Routing\Router; class DaemonRoutes { + /** + * Daemon routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { $router->group(['prefix' => 'daemon', 'middleware' => 'daemon'], function () use ($router) { diff --git a/app/Http/Routes/LanguageRoutes.php b/app/Http/Routes/LanguageRoutes.php index 588711023..13be1be46 100644 --- a/app/Http/Routes/LanguageRoutes.php +++ b/app/Http/Routes/LanguageRoutes.php @@ -28,6 +28,12 @@ use Illuminate\Routing\Router; class LanguageRoutes { + /** + * Language controller routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { $router->get('language/{lang}', [ diff --git a/app/Http/Routes/RemoteRoutes.php b/app/Http/Routes/RemoteRoutes.php index 9ece1fb2e..cc9b4a627 100644 --- a/app/Http/Routes/RemoteRoutes.php +++ b/app/Http/Routes/RemoteRoutes.php @@ -28,6 +28,12 @@ use Illuminate\Routing\Router; class RemoteRoutes { + /** + * Remote daemon routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { $router->group(['prefix' => 'remote'], function () use ($router) { diff --git a/app/Http/Routes/ServerRoutes.php b/app/Http/Routes/ServerRoutes.php index 36c95827b..b03a530d6 100644 --- a/app/Http/Routes/ServerRoutes.php +++ b/app/Http/Routes/ServerRoutes.php @@ -28,6 +28,12 @@ use Illuminate\Routing\Router; class ServerRoutes { + /** + * Server routes. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ public function map(Router $router) { // Returns Server Status diff --git a/app/Jobs/DeleteServer.php b/app/Jobs/DeleteServer.php index 16d04b4ba..881d7dc9c 100644 --- a/app/Jobs/DeleteServer.php +++ b/app/Jobs/DeleteServer.php @@ -34,15 +34,16 @@ class DeleteServer extends Job implements ShouldQueue use InteractsWithQueue, SerializesModels; /** - * Id of server to be deleted. - * @var object + * ID of server to be deleted. + * + * @var int */ protected $id; /** * Create a new job instance. * - * @param int $server + * @param int $id * @return void */ public function __construct($id) diff --git a/app/Jobs/SendScheduledTask.php b/app/Jobs/SendScheduledTask.php index dd7a56e27..0f50f66f5 100644 --- a/app/Jobs/SendScheduledTask.php +++ b/app/Jobs/SendScheduledTask.php @@ -37,8 +37,14 @@ class SendScheduledTask extends Job implements ShouldQueue { use InteractsWithQueue, SerializesModels; + /** + * @var \Pterodactyl\Models\Server + */ protected $server; + /** + * @var \Pterodactyl\Models\Task + */ protected $task; /** diff --git a/app/Jobs/SuspendServer.php b/app/Jobs/SuspendServer.php index e4920f263..8129bfae5 100644 --- a/app/Jobs/SuspendServer.php +++ b/app/Jobs/SuspendServer.php @@ -35,7 +35,8 @@ class SuspendServer extends Job implements ShouldQueue /** * ID of associated server model. - * @var object + * + * @var int */ protected $id; diff --git a/app/Models/APILog.php b/app/Models/APILog.php index 5b481d8ff..6d5f26fda 100644 --- a/app/Models/APILog.php +++ b/app/Models/APILog.php @@ -49,12 +49,12 @@ class APILog extends Model */ protected $guarded = ['id', 'created_at', 'updated_at']; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'authorized' => 'boolean', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'authorized' => 'boolean', + ]; } diff --git a/app/Models/APIPermission.php b/app/Models/APIPermission.php index 5bed095ff..90e7ff16e 100644 --- a/app/Models/APIPermission.php +++ b/app/Models/APIPermission.php @@ -42,14 +42,14 @@ class APIPermission extends Model */ protected $guarded = ['id']; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'key_id' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'key_id' => 'integer', + ]; /** * Disable timestamps for this table. diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php index cdcf79782..d37e52a0e 100644 --- a/app/Models/Allocation.php +++ b/app/Models/Allocation.php @@ -56,7 +56,7 @@ class Allocation extends Model /** * Accessor to automatically provide the IP alias if defined. * - * @param null|string $value + * @param null|string $value * @return string */ public function getAliasAttribute($value) @@ -67,7 +67,7 @@ class Allocation extends Model /** * Accessor to quickly determine if this allocation has an alias. * - * @param null|string $value + * @param null|string $value * @return bool */ public function getHasAliasAttribute($value) diff --git a/app/Models/Database.php b/app/Models/Database.php index 624b2c228..20ad3c1b0 100644 --- a/app/Models/Database.php +++ b/app/Models/Database.php @@ -51,33 +51,33 @@ class Database extends Model 'server_id', 'database_host_id', 'database', 'username', 'remote', ]; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'server_id' => 'integer', - 'database_host_id' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'server_id' => 'integer', + 'database_host_id' => 'integer', + ]; - /** - * Gets the host database server associated with a database. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function host() - { - return $this->belongsTo(DatabaseHost::class, 'database_host_id'); - } + /** + * Gets the host database server associated with a database. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function host() + { + return $this->belongsTo(DatabaseHost::class, 'database_host_id'); + } - /** - * Gets the server associated with a database. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function server() - { - return $this->belongsTo(Server::class); - } + /** + * Gets the server associated with a database. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function server() + { + return $this->belongsTo(Server::class); + } } diff --git a/app/Models/DatabaseHost.php b/app/Models/DatabaseHost.php index 0d5eaf30a..2ad5b13eb 100644 --- a/app/Models/DatabaseHost.php +++ b/app/Models/DatabaseHost.php @@ -51,34 +51,34 @@ class DatabaseHost extends Model 'name', 'host', 'port', 'username', 'max_databases', 'node_id', ]; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'id' => 'integer', - 'max_databases' => 'integer', - 'node_id' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'id' => 'integer', + 'max_databases' => 'integer', + 'node_id' => 'integer', + ]; - /** - * Gets the node associated with a database host. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function node() - { - return $this->belongsTo(Node::class); - } + /** + * Gets the node associated with a database host. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function node() + { + return $this->belongsTo(Node::class); + } - /** - * Gets the databases assocaited with this host. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function databases() - { - return $this->hasMany(Database::class); - } + /** + * Gets the databases assocaited with this host. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function databases() + { + return $this->hasMany(Database::class); + } } diff --git a/app/Models/Node.php b/app/Models/Node.php index f1a3159be..5b0464561 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -75,6 +75,11 @@ class Node extends Model 'daemonSFTP', 'daemonListen', ]; + /** + * Fields that are searchable. + * + * @var array + */ protected $searchable = [ 'columns' => [ 'nodes.name' => 10, @@ -90,7 +95,7 @@ class Node extends Model /** * Return an instance of the Guzzle client for this specific node. * - * @param array $headers + * @param array $headers * @return \GuzzleHttp\Client */ public function guzzleClient($headers = []) @@ -106,8 +111,8 @@ class Node extends Model /** * Returns the configuration in JSON format. * - * @param bool $pretty Wether to pretty print the JSON or not - * @return string The configration in JSON format + * @param bool $pretty + * @return string */ public function getConfigurationAsJson($pretty = false) { diff --git a/app/Models/Pack.php b/app/Models/Pack.php index 0a6310660..9cda19790 100644 --- a/app/Models/Pack.php +++ b/app/Models/Pack.php @@ -83,7 +83,7 @@ class Pack extends Model /** * Returns all of the archived files for a given pack. * - * @param bool $collection + * @param bool $collection * @return \Illuminate\Support\Collection|object */ public function files($collection = false) diff --git a/app/Models/Server.php b/app/Models/Server.php index c341aad70..fdeca115a 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -115,8 +115,11 @@ class Server extends Model * DO NOT USE THIS TO MODIFY SERVER DETAILS OR SAVE THOSE DETAILS. * YOU WILL OVERWRITE THE SECRET KEY AND BREAK THINGS. * - * @param string $uuid The Short-UUID of the server to return an object about. - * @return \Illuminate\Database\Eloquent\Collection + * @param string $uuid + * @param array $with + * @param array $withCount + * @return \Pterodactyl\Models\Server + * @todo Remove $with and $withCount due to cache issues, they aren't used anyways. */ public static function byUuid($uuid, array $with = [], array $withCount = []) { @@ -147,7 +150,6 @@ class Server extends Model /** * Returns non-administrative headers for accessing a server on the daemon. * - * @param string $uuid * @return array */ public function guzzleHeaders() @@ -171,6 +173,8 @@ class Server extends Model /** * Returns javascript object to be embedded on server view pages with relevant information. * + * @param array|null $additional + * @param array|null $overwrite * @return \Laracasts\Utilities\JavaScript\JavaScriptFacade */ public function js($additional = null, $overwrite = null) diff --git a/app/Models/ServiceOption.php b/app/Models/ServiceOption.php index a0f76df23..9e29fe8a6 100644 --- a/app/Models/ServiceOption.php +++ b/app/Models/ServiceOption.php @@ -42,63 +42,63 @@ class ServiceOption extends Model */ protected $guarded = ['id', 'created_at', 'updated_at']; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'service_id' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'service_id' => 'integer', + ]; - /** - * Returns the display startup string for the option and will use the parent - * service one if the option does not have one defined. - * - * @return string - */ - public function getDisplayStartupAttribute($value) - { - return (is_null($this->startup)) ? $this->service->startup : $this->startup; - } + /** + * Returns the display startup string for the option and will use the parent + * service one if the option does not have one defined. + * + * @return string + */ + public function getDisplayStartupAttribute($value) + { + return (is_null($this->startup)) ? $this->service->startup : $this->startup; + } - /** - * Gets service associated with a service option. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function service() - { - return $this->belongsTo(Service::class); - } + /** + * Gets service associated with a service option. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function service() + { + return $this->belongsTo(Service::class); + } - /** - * Gets all servers associated with this service option. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function servers() - { - return $this->hasMany(Server::class, 'option_id'); - } + /** + * Gets all servers associated with this service option. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function servers() + { + return $this->hasMany(Server::class, 'option_id'); + } - /** - * Gets all variables associated with this service. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function variables() - { - return $this->hasMany(ServiceVariable::class, 'option_id'); - } + /** + * Gets all variables associated with this service. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function variables() + { + return $this->hasMany(ServiceVariable::class, 'option_id'); + } - /** - * Gets all packs associated with this service. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function packs() - { - return $this->hasMany(Pack::class, 'option_id'); - } + /** + * Gets all packs associated with this service. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function packs() + { + return $this->hasMany(Pack::class, 'option_id'); + } } diff --git a/app/Models/ServiceVariable.php b/app/Models/ServiceVariable.php index 3d4647583..ac3d47c69 100644 --- a/app/Models/ServiceVariable.php +++ b/app/Models/ServiceVariable.php @@ -57,7 +57,7 @@ class ServiceVariable extends Model * Returns the display executable for the option and will use the parent * service one if the option does not have one defined. * - * @return string + * @return bool */ public function getRequiredAttribute($value) { diff --git a/app/Models/Session.php b/app/Models/Session.php index 9af347bbe..4794d8e04 100644 --- a/app/Models/Session.php +++ b/app/Models/Session.php @@ -35,13 +35,13 @@ class Session extends Model */ protected $table = 'sessions'; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'id' => 'string', - 'user_id' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'id' => 'string', + 'user_id' => 'integer', + ]; } diff --git a/app/Models/Task.php b/app/Models/Task.php index 7f5e18182..46123cb93 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -42,16 +42,16 @@ class Task extends Model */ protected $guarded = ['id', 'created_at', 'updated_at']; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'id' => 'integer', - 'server' => 'integer', - 'queued' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'id' => 'integer', + 'server' => 'integer', + 'queued' => 'integer', + ]; /** * The attributes that should be mutated to dates. diff --git a/app/Models/TaskLog.php b/app/Models/TaskLog.php index 0ec947ae9..578c625c5 100644 --- a/app/Models/TaskLog.php +++ b/app/Models/TaskLog.php @@ -42,16 +42,16 @@ class TaskLog extends Model */ protected $guarded = ['id', 'created_at', 'updated_at']; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'id' => 'integer', - 'task_id' => 'integer', - 'run_status' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'id' => 'integer', + 'task_id' => 'integer', + 'run_status' => 'integer', + ]; /** * The attributes that should be mutated to dates. diff --git a/app/Models/User.php b/app/Models/User.php index 62ced4e72..5dc828a35 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -70,16 +70,16 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac */ protected $fillable = ['username', 'email', 'name_first', 'name_last', 'password', 'language', 'use_totp', 'totp_secret', 'gravatar', 'root_admin']; - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'root_admin' => 'integer', - 'use_totp' => 'integer', - 'gravatar' => 'integer', - ]; + /** + * Cast values to correct type. + * + * @var array + */ + protected $casts = [ + 'root_admin' => 'integer', + 'use_totp' => 'integer', + 'gravatar' => 'integer', + ]; /** * The attributes excluded from the model's JSON form. @@ -106,7 +106,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac /** * Enables or disables TOTP on an account if the token is valid. * - * @param int $token The token that we want to verify. + * @param int $token * @return bool */ public function toggleTotp($token) @@ -116,9 +116,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac } $this->use_totp = ! $this->use_totp; - $this->save(); - - return true; + return $this->save(); } /** @@ -128,8 +126,8 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac * - at least one lowercase character * - at least one number. * - * @param string $password The raw password to set the account password to. - * @param string $regex The regex to use when validating the password. Defaults to '((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})'. + * @param string $password + * @param string $regex * @return void */ public function setPassword($password, $regex = '((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})') @@ -156,7 +154,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac /** * Return true or false depending on wether the user is root admin or not. * - * @return bool the user is root admin + * @return bool */ public function isRootAdmin() { @@ -165,7 +163,8 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac /** * Returns the user's daemon secret for a given server. - * @param Server $server \Pterodactyl\Models\Server + * + * @param \Pterodactyl\Models\Server $server * @return null|string */ public function daemonToken(Server $server) @@ -200,7 +199,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac * Returns an array of all servers a user is able to access. * Note: does not account for user admin status. * - * @return Collection + * @param int|null $paginate + * @param array $load + * @return \Illuminate\Pagination\LengthAwarePagination|\Illuiminate\Database\Eloquent\Collection */ public function serverAccessCollection($paginate = null, $load = ['service', 'node', 'allocation']) { diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index b7f86361c..f92a7a477 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -36,13 +36,14 @@ class AccountCreated extends Notification implements ShouldQueue /** * The password reset token to send. * - * @var string + * @var object */ public $user; /** * Create a new notification instance. * + * @param aray $user * @return void */ public function __construct(array $user) diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 243584f13..415b39fb0 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -33,12 +33,15 @@ class AddedToServer extends Notification implements ShouldQueue { use Queueable; + /** + * @var object + */ public $server; /** * Create a new notification instance. * - * @param array $server + * @param array $server * @return void */ public function __construct(array $server) diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index d2a7599dc..d4831dbe4 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -33,12 +33,15 @@ class RemovedFromServer extends Notification implements ShouldQueue { use Queueable; + /** + * @var object + */ public $server; /** * Create a new notification instance. * - * @param array $server + * @param array $server * @return void */ public function __construct(array $server) diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 0037fb7f3..367f863ed 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -43,6 +43,7 @@ class SendPasswordReset extends Notification implements ShouldQueue /** * Create a new notification instance. * + * @param string $token * @return void */ public function __construct($token) diff --git a/app/Notifications/ServerCreated.php b/app/Notifications/ServerCreated.php index a867e26c7..9f881729a 100644 --- a/app/Notifications/ServerCreated.php +++ b/app/Notifications/ServerCreated.php @@ -33,6 +33,9 @@ class ServerCreated extends Notification implements ShouldQueue { use Queueable; + /** + * @var object + */ public $server; /** diff --git a/app/Observers/ServerObserver.php b/app/Observers/ServerObserver.php index 2229154e3..9866cb661 100644 --- a/app/Observers/ServerObserver.php +++ b/app/Observers/ServerObserver.php @@ -40,7 +40,7 @@ class ServerObserver /** * Listen to the Server creating event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function creating(Server $server) @@ -51,7 +51,7 @@ class ServerObserver /** * Listen to the Server created event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function created(Server $server) @@ -72,7 +72,7 @@ class ServerObserver /** * Listen to the Server deleting event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function deleting(Server $server) @@ -85,7 +85,7 @@ class ServerObserver /** * Listen to the Server deleted event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function deleted(Server $server) @@ -102,7 +102,7 @@ class ServerObserver /** * Listen to the Server saving event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function saving(Server $server) @@ -113,7 +113,7 @@ class ServerObserver /** * Listen to the Server saved event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function saved(Server $server) @@ -124,7 +124,7 @@ class ServerObserver /** * Listen to the Server updating event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function updating(Server $server) @@ -135,7 +135,7 @@ class ServerObserver /** * Listen to the Server saved event. * - * @param Server $server The server model. + * @param \Pterodactyl\Models\Server $server * @return void */ public function updated(Server $server) diff --git a/app/Observers/SubuserObserver.php b/app/Observers/SubuserObserver.php index b3d64d7d1..57eab2680 100644 --- a/app/Observers/SubuserObserver.php +++ b/app/Observers/SubuserObserver.php @@ -34,7 +34,7 @@ class SubuserObserver /** * Listen to the Subuser creating event. * - * @param Subuser $subuser The eloquent Subuser model. + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function creating(Subuser $subuser) @@ -45,7 +45,7 @@ class SubuserObserver /** * Listen to the Subuser created event. * - * @param Subuser $subuser The eloquent Subuser model. + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function created(Subuser $subuser) @@ -62,7 +62,7 @@ class SubuserObserver /** * Listen to the Subuser deleting event. * - * @param Subuser $subuser The eloquent Subuser model. + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function deleting(Subuser $subuser) @@ -73,7 +73,7 @@ class SubuserObserver /** * Listen to the Subuser deleted event. * - * @param Subuser $subuser The eloquent Subuser model. + * @param \Pterodactyl\Models\Subuser $subuser * @return void */ public function deleted(Subuser $subuser) diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 258174ffb..6caf8008d 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -34,7 +34,7 @@ class UserObserver /** * Listen to the User creating event. * - * @param User $user The eloquent User model. + * @param \Pterodactyl\Models\User $user * @return void */ public function creating(User $user) @@ -45,7 +45,7 @@ class UserObserver /** * Listen to the User created event. * - * @param User $user The eloquent User model. + * @param \Pterodactyl\Models\User $user * @return void */ public function created(User $user) @@ -63,7 +63,7 @@ class UserObserver /** * Listen to the User deleting event. * - * @param User $user The eloquent User model. + * @param \Pterodactyl\Models\User $user * @return void */ public function deleting(User $user) @@ -74,7 +74,7 @@ class UserObserver /** * Listen to the User deleted event. * - * @param User $user The eloquent User model. + * @param \Pterodactyl\Models\User $user * @return void */ public function deleted(User $user) diff --git a/app/Policies/ServerPolicy.php b/app/Policies/ServerPolicy.php index 7079aaa19..f375afecc 100644 --- a/app/Policies/ServerPolicy.php +++ b/app/Policies/ServerPolicy.php @@ -31,22 +31,12 @@ use Pterodactyl\Models\Server; class ServerPolicy { - /** - * Create a new policy instance. - * - * @return void - */ - public function __construct() - { - // - } - /** * Checks if the user has the given permission on/for the server. * * @param \Pterodactyl\Models\User $user * @param \Pterodactyl\Models\Server $server - * @param $permission + * @param string $permission * @return bool */ private function checkPermission(User $user, Server $server, $permission) @@ -93,8 +83,8 @@ class ServerPolicy /** * Check if user has permission to control power for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function power(User $user, Server $server) @@ -105,8 +95,8 @@ class ServerPolicy /** * Check if user has permission to start a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function powerStart(User $user, Server $server) @@ -117,8 +107,8 @@ class ServerPolicy /** * Check if user has permission to stop a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function powerStop(User $user, Server $server) @@ -129,8 +119,8 @@ class ServerPolicy /** * Check if user has permission to restart a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function powerRestart(User $user, Server $server) @@ -141,8 +131,8 @@ class ServerPolicy /** * Check if user has permission to kill a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function powerKill(User $user, Server $server) @@ -153,8 +143,8 @@ class ServerPolicy /** * Check if user has permission to run a command on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function sendCommand(User $user, Server $server) @@ -165,8 +155,8 @@ class ServerPolicy /** * Check if user has permission to list files on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function listFiles(User $user, Server $server) @@ -177,8 +167,8 @@ class ServerPolicy /** * Check if user has permission to edit files on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function editFiles(User $user, Server $server) @@ -189,8 +179,8 @@ class ServerPolicy /** * Check if user has permission to save files on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function saveFiles(User $user, Server $server) @@ -201,8 +191,8 @@ class ServerPolicy /** * Check if user has permission to move and rename files and folders on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function moveFiles(User $user, Server $server) @@ -213,8 +203,8 @@ class ServerPolicy /** * Check if user has permission to copy folders and files on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function copyFiles(User $user, Server $server) @@ -225,8 +215,8 @@ class ServerPolicy /** * Check if user has permission to compress files and folders on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function compressFiles(User $user, Server $server) @@ -237,8 +227,8 @@ class ServerPolicy /** * Check if user has permission to decompress files on a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function decompressFiles(User $user, Server $server) @@ -249,8 +239,8 @@ class ServerPolicy /** * Check if user has permission to add files to a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function createFiles(User $user, Server $server) @@ -262,8 +252,8 @@ class ServerPolicy * Check if user has permission to upload files to a server. * This permission relies on the user having the 'create-files' permission as well due to page authorization. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function uploadFiles(User $user, Server $server) @@ -274,8 +264,8 @@ class ServerPolicy /** * Check if user has permission to download files from a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function downloadFiles(User $user, Server $server) @@ -286,8 +276,8 @@ class ServerPolicy /** * Check if user has permission to delete files from a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function deleteFiles(User $user, Server $server) @@ -298,8 +288,8 @@ class ServerPolicy /** * Check if user has permission to view subusers for the server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function listSubusers(User $user, Server $server) @@ -310,8 +300,8 @@ class ServerPolicy /** * Check if user has permission to view specific subuser permissions. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewSubuser(User $user, Server $server) @@ -322,8 +312,8 @@ class ServerPolicy /** * Check if user has permission to edit a subuser. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function editSubuser(User $user, Server $server) @@ -334,8 +324,8 @@ class ServerPolicy /** * Check if user has permission to delete a subuser. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function deleteSubuser(User $user, Server $server) @@ -346,8 +336,8 @@ class ServerPolicy /** * Check if user has permission to edit a subuser. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function createSubuser(User $user, Server $server) @@ -358,8 +348,8 @@ class ServerPolicy /** * Check if user has permission to set the default connection for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function setConnection(User $user, Server $server) @@ -370,8 +360,8 @@ class ServerPolicy /** * Check if user has permission to view the startup command used for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewStartup(User $user, Server $server) @@ -382,8 +372,8 @@ class ServerPolicy /** * Check if user has permission to edit the startup command used for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function editStartup(User $user, Server $server) @@ -394,8 +384,8 @@ class ServerPolicy /** * Check if user has permission to view the SFTP information for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewSftp(User $user, Server $server) @@ -406,8 +396,8 @@ class ServerPolicy /** * Check if user has permission to reset the SFTP password for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function resetSftp(User $user, Server $server) @@ -418,8 +408,8 @@ class ServerPolicy /** * Check if user has permission to view the SFTP password for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewSftpPassword(User $user, Server $server) @@ -430,8 +420,8 @@ class ServerPolicy /** * Check if user has permission to view databases for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewDatabases(User $user, Server $server) @@ -442,8 +432,8 @@ class ServerPolicy /** * Check if user has permission to reset database passwords. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function resetDbPassword(User $user, Server $server) @@ -454,8 +444,8 @@ class ServerPolicy /** * Check if user has permission to view all tasks for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function listTasks(User $user, Server $server) @@ -466,8 +456,8 @@ class ServerPolicy /** * Check if user has permission to view a specific task for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewTask(User $user, Server $server) @@ -478,8 +468,8 @@ class ServerPolicy /** * Check if user has permission to view a toggle a task for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function toggleTask(User $user, Server $server) @@ -490,8 +480,8 @@ class ServerPolicy /** * Check if user has permission to queue a task for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function queueTask(User $user, Server $server) @@ -502,8 +492,8 @@ class ServerPolicy /** * Check if user has permission to delete a specific task for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function deleteTask(User $user, Server $server) @@ -514,8 +504,8 @@ class ServerPolicy /** * Check if user has permission to create a task for a server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function createTask(User $user, Server $server) @@ -526,8 +516,8 @@ class ServerPolicy /** * Check if user has permission to view server allocations. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function viewAllocation(User $user, Server $server) @@ -538,8 +528,8 @@ class ServerPolicy /** * Check if user has permission to set the default allocation. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server + * @param \Pterodactyl\Models\User $user + * @param \Pterodactyl\Models\Server $server * @return bool */ public function setAllocation(User $user, Server $server) diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 86c94d99f..3a27f5d20 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -25,7 +25,5 @@ class AuthServiceProvider extends ServiceProvider public function boot(GateContract $gate) { parent::registerPolicies($gate); - - // } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 0e31100c3..9126aa6ae 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -22,7 +22,5 @@ class EventServiceProvider extends ServiceProvider public function boot() { parent::boot(); - - // } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index f25c59471..1066cd262 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -19,13 +19,10 @@ class RouteServiceProvider extends ServiceProvider /** * Define your route model bindings, pattern filters, etc. * - * @param \Illuminate\Routing\Router $router * @return void */ public function boot() { - // - parent::boot(); } diff --git a/app/Repositories/APIRepository.php b/app/Repositories/APIRepository.php index dc856e188..ff2c15c87 100644 --- a/app/Repositories/APIRepository.php +++ b/app/Repositories/APIRepository.php @@ -37,6 +37,7 @@ class APIRepository { /** * Valid API permissions. + * * @var array */ protected $permissions = [ @@ -89,14 +90,23 @@ class APIRepository /** * Holder for listing of allowed IPs when creating a new key. + * * @var array */ protected $allowed = []; + /** + * The eloquent model for a user. + * + * @var \Pterodactyl\Models\User + */ protected $user; /** - * Constructor. + * Constructor for API Repository. + * + * @param null|\Pterodactyl\Models\User $user + * @return void */ public function __construct(Models\User $user = null) { @@ -109,12 +119,11 @@ class APIRepository /** * Create a New API Keypair on the system. * - * @param array $data An array with a permissions and allowed_ips key. + * @param array $data + * @return string * - * @throws Pterodactyl\Exceptions\DisplayException if there was an error that can be safely displayed to end-users. - * @throws Pterodactyl\Exceptions\DisplayValidationException if there was a validation error. - * - * @return string Returns the generated secret token. + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create(array $data) { @@ -213,11 +222,10 @@ class APIRepository /** * Revokes an API key and associated permissions. * - * @param string $key The public key. - * - * @throws Illuminate\Database\Eloquent\ModelNotFoundException - * + * @param string $key * @return void + * + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ public function revoke($key) { diff --git a/app/Repositories/Daemon/CommandRepository.php b/app/Repositories/Daemon/CommandRepository.php index 76ac93178..d14895b3c 100644 --- a/app/Repositories/Daemon/CommandRepository.php +++ b/app/Repositories/Daemon/CommandRepository.php @@ -30,19 +30,32 @@ use Pterodactyl\Exceptions\DisplayException; class CommandRepository { + /** + * The Eloquent Model associated with the requested server. + * + * @var \Pterodactyl\Models\Server + */ protected $server; + /** + * Constuctor for repository. + * + * @param int|\Pterodactyl\Models\Server $server + * @return void + */ public function __construct($server) { $this->server = ($server instanceof Models\Server) ? $server : Models\Server::findOrFail($server); } /** - * [send description]. - * @param string $command - * @return bool - * @throws DisplayException - * @throws RequestException + * Sends a command to the daemon. + * + * @param string $command + * @return string + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \GuzzleHttp\Exception\RequestException */ public function send($command) { diff --git a/app/Repositories/Daemon/FileRepository.php b/app/Repositories/Daemon/FileRepository.php index 5fc2245fb..cc415793a 100644 --- a/app/Repositories/Daemon/FileRepository.php +++ b/app/Repositories/Daemon/FileRepository.php @@ -35,14 +35,15 @@ class FileRepository /** * The Eloquent Model associated with the requested server. * - * @var \Illuminate\Database\Eloquent\Model + * @var \Pterodactyl\Models\Server */ protected $server; /** * Constructor. * - * @param string $server The server Short UUID + * @param string $uuid + * @return void */ public function __construct($uuid) { @@ -52,8 +53,11 @@ class FileRepository /** * Get the contents of a requested file for the server. * - * @param string $file + * @param string $file * @return array + * + * @throws \GuzzleHttp\Exception\RequestException + * @throws \Pterodactyl\Exceptions\DisplayException */ public function returnFileContents($file) { @@ -95,9 +99,12 @@ class FileRepository /** * Save the contents of a requested file on the daemon. * - * @param string $file - * @param string $content + * @param string $file + * @param string $content * @return bool + * + * @throws \GuzzleHttp\Exception\RequestException + * @throws \Pterodactyl\Exceptions\DisplayException */ public function saveFileContents($file, $content) { @@ -125,8 +132,11 @@ class FileRepository /** * Returns a listing of all files and folders within a specified directory on the daemon. * - * @param string $directory + * @param string $directory * @return object + * + * @throws \GuzzleHttp\Exception\RequestException + * @throws \Pterodactyl\Exceptions\DisplayException */ public function returnDirectoryListing($directory) { diff --git a/app/Repositories/Daemon/PowerRepository.php b/app/Repositories/Daemon/PowerRepository.php index b31c0cda0..e4b4cbb18 100644 --- a/app/Repositories/Daemon/PowerRepository.php +++ b/app/Repositories/Daemon/PowerRepository.php @@ -29,13 +29,33 @@ use Pterodactyl\Exceptions\DisplayException; class PowerRepository { + /** + * The Eloquent Model associated with the requested server. + * + * @var \Pterodactyl\Models\Server + */ protected $server; + /** + * Constuctor for repository. + * + * @param int|\Pterodactyl\Models\Server $server + * @return void + */ public function __construct($server) { $this->server = ($server instanceof Models\Server) ? $server : Models\Server::findOrFail($server); } + /** + * Sends a power option to the daemon. + * + * @param string $action + * @return string + * + * @throws \GuzzleHttp\Exception\RequestException + * @throws \Pterodactyl\Exceptions\DisplayException + */ public function do($action) { // We don't use the user's specific daemon secret here since we @@ -58,21 +78,41 @@ class PowerRepository } } + /** + * Starts a server. + * + * @return void + */ public function start() { $this->do('start'); } + /** + * Stops a server. + * + * @return void + */ public function stop() { $this->do('stop'); } + /** + * Restarts a server. + * + * @return void + */ public function restart() { $this->do('restart'); } + /** + * Kills a server. + * + * @return void + */ public function kill() { $this->do('kill'); diff --git a/app/Repositories/DatabaseRepository.php b/app/Repositories/DatabaseRepository.php index 346d33376..6c38583d1 100644 --- a/app/Repositories/DatabaseRepository.php +++ b/app/Repositories/DatabaseRepository.php @@ -39,8 +39,8 @@ class DatabaseRepository /** * Adds a new database to a specified database host server. * - * @param int $id - * @param array $data + * @param int $id + * @param array $data * @return \Pterodactyl\Models\Database * * @throws \Pterodactyl\Exceptions\DisplayException @@ -128,8 +128,8 @@ class DatabaseRepository /** * Updates the password for a given database. * - * @param int $id - * @param string $password + * @param int $id + * @param string $password * @return void * * @todo Fix logic behind resetting passwords. @@ -174,7 +174,7 @@ class DatabaseRepository /** * Drops a database from the associated database host. * - * @param int $id + * @param int $id * @return void */ public function drop($id) @@ -204,7 +204,7 @@ class DatabaseRepository /** * Deletes a database host from the system if it has no associated databases. * - * @param int $server + * @param int $id * @return void * * @throws \Pterodactyl\Exceptions\DisplayException @@ -223,7 +223,7 @@ class DatabaseRepository /** * Adds a new Database Host to the system. * - * @param array $data + * @param array $data * @return \Pterodactyl\Models\DatabaseHost * * @throws \Pterodactyl\Exceptions\DisplayValidationException @@ -281,8 +281,8 @@ class DatabaseRepository /** * Updates a Database Host on the system. * - * @param int $id - * @param array $data + * @param int $id + * @param array $data * @return \Pterodactyl\Models\DatabaseHost * * @throws \Pterodactyl\Exceptions\DisplayValidationException diff --git a/app/Repositories/HelperRepository.php b/app/Repositories/HelperRepository.php index 1e3248173..204480ec2 100644 --- a/app/Repositories/HelperRepository.php +++ b/app/Repositories/HelperRepository.php @@ -28,6 +28,7 @@ class HelperRepository { /** * Listing of editable files in the control panel. + * * @var array */ protected static $editable = [ @@ -44,17 +45,13 @@ class HelperRepository 'inode/x-empty', ]; - public function __construct() - { - // - } - /** * Converts from bytes to the largest possible size that is still readable. * - * @param int $bytes - * @param int $decimals + * @param int $bytes + * @param int $decimals * @return string + * @deprecated */ public static function bytesToHuman($bytes, $decimals = 2) { @@ -64,6 +61,11 @@ class HelperRepository return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . $sz[$factor]; } + /** + * Returns array of editable files. + * + * @return array + */ public static function editableFiles() { return self::$editable; diff --git a/app/Repositories/LocationRepository.php b/app/Repositories/LocationRepository.php index d3efb5d25..5f08cfc17 100644 --- a/app/Repositories/LocationRepository.php +++ b/app/Repositories/LocationRepository.php @@ -35,8 +35,9 @@ class LocationRepository * Creates a new location on the system. * * @param array $data - * @throws \Pterodactyl\Exceptions\DisplayValidationException * @return \Pterodactyl\Models\Location + * + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create(array $data) { @@ -58,11 +59,11 @@ class LocationRepository /** * Modifies a location. * - * @param int $id - * @param array $data + * @param int $id + * @param array $data * @return \Pterodactyl\Models\Location * - * @throws Pterodactyl\Exceptions\DisplayValidationException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function update($id, array $data) { @@ -85,10 +86,10 @@ class LocationRepository /** * Deletes a location from the system. * - * @param int $id + * @param int $id * @return void * - * @throws Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete($id) { diff --git a/app/Repositories/NodeRepository.php b/app/Repositories/NodeRepository.php index ec6ce15ec..51a91cfe3 100644 --- a/app/Repositories/NodeRepository.php +++ b/app/Repositories/NodeRepository.php @@ -34,11 +34,15 @@ use Pterodactyl\Exceptions\DisplayValidationException; class NodeRepository { - public function __construct() - { - // - } - + /** + * Creates a new node on the system. + * + * @param array $data + * @return \Pterodactyl\Models\Node + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException + */ public function create(array $data) { // Validate Fields @@ -84,6 +88,16 @@ class NodeRepository return Models\Node::create($data); } + /** + * Updates a node on the system. + * + * @param int $id + * @param array $data + * @return \Pterodactyl\Models\Node + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException + */ public function update($id, array $data) { $node = Models\Node::findOrFail($id); @@ -179,8 +193,13 @@ class NodeRepository /** * Adds allocations to a provided node. - * @param int $id - * @param array $data + * + * @param int $id + * @param array $data + * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function addAllocations($id, array $data) { @@ -243,6 +262,14 @@ class NodeRepository }); } + /** + * Deletes a node on the system. + * + * @param int $id + * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException + */ public function delete($id) { $node = Models\Node::withCount('servers')->findOrFail($id); diff --git a/app/Repositories/OptionRepository.php b/app/Repositories/OptionRepository.php index d0535b575..518858928 100644 --- a/app/Repositories/OptionRepository.php +++ b/app/Repositories/OptionRepository.php @@ -73,7 +73,7 @@ class OptionRepository /** * Deletes a service option from the system. * - * @param int $id + * @param int $id * @return void * * @throws \Pterodactyl\Exceptions\DisplayException diff --git a/app/Repositories/PackRepository.php b/app/Repositories/PackRepository.php index fdc5fbd5d..f7a2c2d2a 100644 --- a/app/Repositories/PackRepository.php +++ b/app/Repositories/PackRepository.php @@ -38,7 +38,7 @@ class PackRepository /** * Creates a new pack on the system. * - * @param array $data + * @param array $data * @return \Pterodactyl\Models\Pack * * @throws \Pterodactyl\Exceptions\DisplayException @@ -101,7 +101,7 @@ class PackRepository /** * Creates a new pack on the system given a template file. * - * @param array $data + * @param array $data * @return \Pterodactyl\Models\Pack * * @throws \Pterodactyl\Exceptions\DisplayException @@ -173,8 +173,8 @@ class PackRepository /** * Updates a pack on the system. * - * @param int $id - * @param array $data + * @param int $id + * @param array $data * @return \Pterodactyl\Models\Pack * * @throws \Pterodactyl\Exceptions\DisplayException diff --git a/app/Repositories/ServerRepository.php b/app/Repositories/ServerRepository.php index 8eb87f5fe..a9ebf2628 100644 --- a/app/Repositories/ServerRepository.php +++ b/app/Repositories/ServerRepository.php @@ -37,21 +37,21 @@ use Pterodactyl\Exceptions\DisplayValidationException; class ServerRepository { + /** + * An array of daemon permission to assign to this server. + * + * @var array + */ protected $daemonPermissions = [ 's:*', ]; - public function __construct() - { - // - } - /** * Generates a SFTP username for a server given a server name. * format: mumble_67c7a4b0. * - * @param string $name - * @param string $identifier + * @param string $name + * @param null|string $identifier * @return string */ protected function generateSFTPUsername($name, $identifier = null) @@ -75,8 +75,12 @@ class ServerRepository /** * Adds a new server to the system. - * @param array $data An array of data descriptors for creating the server. These should align to the columns in the database. - * @return int + * + * @param array $data + * @return \Pterodactyl\Models\Server + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create(array $data) { @@ -341,10 +345,14 @@ class ServerRepository } /** - * [updateDetails description]. - * @param int $id - * @param array $data + * Update the details for a server. + * + * @param int $id + * @param array $data * @return bool + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function updateDetails($id, array $data) { @@ -424,10 +432,14 @@ class ServerRepository } /** - * [updateContainer description]. - * @param int $id - * @param array $data + * Update the container for a server. + * + * @param int $id + * @param array $data * @return bool + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function updateContainer($id, array $data) { @@ -472,10 +484,14 @@ class ServerRepository } /** - * [changeBuild description]. - * @param int $id - * @param array $data - * @return bool + * Update the build details for a server. + * + * @param int $id + * @param array $data + * @return \Pterodactyl\Models\Server + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function changeBuild($id, array $data) { @@ -614,6 +630,18 @@ class ServerRepository } } + /** + * Update the startup details for a server. + * + * @param int $id + * @param array $data + * @param bool $admin + * @return void + * + * @throws \GuzzleHttp\Exception\RequestException + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException + */ public function updateStartup($id, array $data, $admin = false) { $server = Models\Server::with('variables', 'option.variables')->findOrFail($id); @@ -691,25 +719,34 @@ class ServerRepository }); } + /** + * Queue a server for deletion + * + * @param int $id + * @param bool $force + * @return void + */ public function queueDeletion($id, $force = false) { $server = Models\Server::findOrFail($id); - DB::beginTransaction(); - try { - if ($force) { - $server->installed = 3; - $server->save(); - } + DB::transaction(function () use ($force, $server) { + $server->installed = $force ? 3 : $server->installed; + $server->save(); + $server->delete(); - - return DB::commit(); - } catch (\Exception $ex) { - DB::rollBack(); - throw $ex; - } + }); } + /** + * Delete a server from the system permanetly. + * + * @param int $id + * @param bool $force + * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException + */ public function delete($id, $force = false) { $server = Models\Server::withTrashed()->with('node', 'allocations', 'variables')->findOrFail($id); @@ -774,6 +811,12 @@ class ServerRepository }); } + /** + * Cancel the deletion of a server. + * + * @param int $id + * @return void + */ public function cancelDeletion($id) { $server = Models\Server::withTrashed()->findOrFail($id); @@ -783,6 +826,14 @@ class ServerRepository $server->save(); } + /** + * Toggle the install status of a serve. + * + * @param int $id + * @return bool + * + * @throws \Pterodactyl\Exceptions\DisplayException + */ public function toggleInstall($id) { $server = Models\Server::findOrFail($id); @@ -795,9 +846,13 @@ class ServerRepository } /** - * Suspends a server instance making it unable to be booted or used by a user. - * @param int $id - * @return bool + * Suspends a server. + * + * @param int $id + * @param bool $deleted + * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException */ public function suspend($id, $deleted = false) { @@ -831,9 +886,12 @@ class ServerRepository } /** - * Unsuspends a server instance. - * @param int $id - * @return bool + * Unsuspends a server. + * + * @param int $id + * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException */ public function unsuspend($id) { @@ -866,6 +924,16 @@ class ServerRepository } } + /** + * Updates the SFTP password for a server. + * + * @param int $id + * @param string $password + * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException + */ public function updateSFTPPassword($id, $password) { $server = Models\Server::with('node')->findOrFail($id); diff --git a/app/Repositories/ServiceRepository.php b/app/Repositories/ServiceRepository.php index 126feb647..a0d1716cc 100644 --- a/app/Repositories/ServiceRepository.php +++ b/app/Repositories/ServiceRepository.php @@ -37,6 +37,8 @@ class ServiceRepository * * @param array $data * @return \Pterodactyl\Models\Service + * + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create(array $data) { @@ -80,6 +82,8 @@ class ServiceRepository * @param int $id * @param array $data * @return \Pterodactyl\Models\Service + * + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function update($id, array $data) { @@ -109,6 +113,8 @@ class ServiceRepository * * @param int $id * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete($id) { diff --git a/app/Repositories/SubuserRepository.php b/app/Repositories/SubuserRepository.php index a6e0123ce..3b74ad1ad 100644 --- a/app/Repositories/SubuserRepository.php +++ b/app/Repositories/SubuserRepository.php @@ -37,6 +37,7 @@ class SubuserRepository * Core permissions required for every subuser on the daemon. * Without this we cannot connect the websocket or get basic * information about the server. + * * @var array */ protected $coreDaemonPermissions = [ @@ -46,6 +47,7 @@ class SubuserRepository /** * Allowed permissions and their related daemon permission. + * * @var array */ protected $permissions = [ @@ -99,18 +101,15 @@ class SubuserRepository 'reset-db-password' => null, ]; - public function __construct() - { - // - } - /** * Creates a new subuser on the server. - * @param int $id The ID of the server to add this subuser to. + * + * @param int $sid * @param array $data - * @throws DisplayValidationException - * @throws DisplayException * @return \Pterodactyl\Models\Subuser + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create($sid, array $data) { @@ -202,11 +201,11 @@ class SubuserRepository /** * Revokes a users permissions on a server. - * @param int $id The ID of the subuser row in MySQL. - * @param array $data - * @throws DisplayValidationException - * @throws DisplayException + * + * @param int $id * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete($id) { @@ -232,8 +231,6 @@ class SubuserRepository } $subuser->delete(); DB::commit(); - - return true; } catch (\GuzzleHttp\Exception\TransferException $ex) { DB::rollBack(); throw new DisplayException('There was an error attempting to connect to the daemon to delete this subuser.', $ex); @@ -241,17 +238,17 @@ class SubuserRepository DB::rollBack(); throw $ex; } - - return false; } /** * Updates permissions for a given subuser. - * @param int $id The ID of the subuser row in MySQL. (Not the user ID) + * + * @param int $id * @param array $data - * @throws DisplayValidationException - * @throws DisplayException * @return void + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function update($id, array $data) { @@ -304,8 +301,6 @@ class SubuserRepository ]); DB::commit(); - - return true; } catch (\GuzzleHttp\Exception\TransferException $ex) { DB::rollBack(); throw new DisplayException('There was an error attempting to connect to the daemon to update permissions.', $ex); @@ -313,7 +308,5 @@ class SubuserRepository DB::rollBack(); throw $ex; } - - return false; } } diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php index c42a00482..e8aff6c45 100644 --- a/app/Repositories/TaskRepository.php +++ b/app/Repositories/TaskRepository.php @@ -32,6 +32,11 @@ use Pterodactyl\Exceptions\DisplayValidationException; class TaskRepository { + /** + * The default values to use for new tasks. + * + * @var array + */ protected $defaults = [ 'year' => '*', 'day_of_week' => '*', @@ -41,20 +46,20 @@ class TaskRepository 'minute' => '*/30', ]; + /** + * Task action types. + * + * @var array + */ protected $actions = [ 'command', 'power', ]; - public function __construct() - { - // - } - /** * Deletes a given task. - * @param int $id * + * @param int $id * @return bool */ public function delete($id) @@ -71,8 +76,8 @@ class TaskRepository /** * Toggles a task active or inactive. - * @param int $id * + * @param int $id * @return int */ public function toggle($id) @@ -91,12 +96,13 @@ class TaskRepository /** * Create a new scheduled task for a given server. - * @param int $id - * @param array $data * - * @throws DisplayException - * @throws DisplayValidationException - * @return void + * @param int $id + * @param array $data + * @return bool + * + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create($id, $data) { diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 714718cbd..5619f26d5 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -38,19 +38,13 @@ use Pterodactyl\Exceptions\DisplayValidationException; class UserRepository { - public function __construct() - { - // - } - /** * Creates a user on the panel. Returns the created user's ID. * - * @param string $email - * @param string|null $password An unhashed version of the user's password. - * @param bool $admin Boolean value if user should be an admin or not. - * @param int $token A custom user ID. - * @return bool|int + * @param array $data + * @return \Pterodactyl\Models\User + * + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function create(array $data) { @@ -118,9 +112,11 @@ class UserRepository /** * Updates a user on the panel. * - * @param int $id - * @param array $data An array of columns and their associated values to update for the user. + * @param int $id + * @param array $data * @return bool + * + * @throws \Pterodactyl\Exceptions\DisplayValidationException */ public function update($id, array $data) { @@ -157,10 +153,13 @@ class UserRepository } /** - * Deletes a user on the panel, returns the number of records deleted. + * Deletes a user on the panel. * * @param int $id - * @return int + * @return void + * @todo Move user self-deletion checking to the controller, rather than the repository. + * + * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete($id) { @@ -168,8 +167,7 @@ class UserRepository throw new DisplayException('Cannot delete a user with active servers attached to thier account.'); } - // @TODO: this should probably be checked outside of this method because we won't always have Auth::user() - if (! is_null(Auth::user()) && Auth::user()->id === $id) { + if (! is_null(Auth::user()) && (int) Auth::user()->id === (int) $id) { throw new DisplayException('Cannot delete your own account.'); } @@ -186,8 +184,6 @@ class UserRepository Models\User::destroy($id); DB::commit(); - - return true; } catch (\Exception $ex) { DB::rollBack(); throw $ex; diff --git a/app/Repositories/VariableRepository.php b/app/Repositories/VariableRepository.php index ee6885280..4584d2bba 100644 --- a/app/Repositories/VariableRepository.php +++ b/app/Repositories/VariableRepository.php @@ -91,7 +91,7 @@ class VariableRepository * Deletes a specified option variable as well as all server * variables currently assigned. * - * @param int $id + * @param int $id * @return void */ public function delete($id) diff --git a/app/Services/APILogService.php b/app/Services/APILogService.php index f43693aca..ce9fd56ee 100644 --- a/app/Services/APILogService.php +++ b/app/Services/APILogService.php @@ -30,11 +30,14 @@ use Pterodactyl\Models\APILog; class APILogService { - public function __constructor() - { - // - } - + /** + * Log an API Request + * + * @param \Illuminate\Http\Request $request + * @param null|string $error + * @param bool $authorized + * @return void + */ public static function log(Request $request, $error = null, $authorized = false) { if ($request->bearerToken() && ! empty($request->bearerToken())) { diff --git a/app/Services/DeploymentService.php b/app/Services/DeploymentService.php index d4d28e9a9..b0befe8c0 100644 --- a/app/Services/DeploymentService.php +++ b/app/Services/DeploymentService.php @@ -30,20 +30,13 @@ use Pterodactyl\Exceptions\DisplayException; class DeploymentService { - public function __constructor() - { - // - } - /** * Return a random location model. DO NOT USE. - * @return \Pterodactyl\Models\Node * - * @TODO Actually make this smarter. If we're selecting a random location + * @return \Pterodactyl\Models\Node + * @todo Actually make this smarter. If we're selecting a random location * but then it has no nodes we should probably continue attempting all locations * until we hit one. - * - * Currently you should just pick a location and go from there. */ public static function randomLocation() { @@ -52,8 +45,8 @@ class DeploymentService /** * Return a model instance of a random node. - * @param int $location - * @param array $not + * @param int $location + * @param array $not * @return \Pterodactyl\Models\Node * * @throws \Pterodactyl\Exceptions\DisplayException @@ -76,9 +69,9 @@ class DeploymentService /** * Selects a random node ensuring it does not put the node * over allocation limits. - * @param int $memory - * @param int $disk - * @param int $location + * @param int $memory + * @param int $disk + * @param null|int $location * @return \Pterodactyl\Models\Node * * @throws \Pterodactyl\Exceptions\DisplayException @@ -102,7 +95,7 @@ class DeploymentService /** * Returns a random allocation for a node. - * @param int $node + * @param int $node * @return \Models\Pterodactyl\Allocation */ public static function randomAllocation($node) @@ -118,8 +111,8 @@ class DeploymentService /** * Checks that a node's allocation limits will not be passed with the given information. * @param \Pterodactyl\Models\Node $node - * @param int $memory - * @param int $disk + * @param int $memory + * @param int $disk * @return bool Returns true if this information would not put the node over it's limit. */ protected static function checkNodeAllocation(Models\Node $node, $memory, $disk) diff --git a/app/Services/FileService.php b/app/Services/FileService.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/Services/UuidService.php b/app/Services/UuidService.php index 6f81f1465..2b043731a 100644 --- a/app/Services/UuidService.php +++ b/app/Services/UuidService.php @@ -29,21 +29,13 @@ use Uuid; class UuidService { - /** - * Constructor. - */ - public function __construct() - { - // - } - /** * Generate a unique UUID validating against specified table and column. * Defaults to `users.uuid`. * - * @param string $table - * @param string $field - * @param int $type The type of UUID to generate. + * @param string $table + * @param string $field + * @param int $type * @return string */ public function generate($table = 'users', $field = 'uuid', $type = 4) @@ -62,8 +54,9 @@ class UuidService /** * Generates a ShortUUID code which is 8 characters long and is used for identifying servers in the system. * - * @param string $table - * @param string $field + * @param string $table + * @param string $field + * @param null|string $attachedUuid * @return string */ public function generateShort($table = 'servers', $field = 'uuidShort', $attachedUuid = null) diff --git a/app/Services/VersionService.php b/app/Services/VersionService.php index 819bf4755..e3eaf8ade 100644 --- a/app/Services/VersionService.php +++ b/app/Services/VersionService.php @@ -29,10 +29,17 @@ use GuzzleHttp\Client; class VersionService { + /** + * The cached CDN response. + * + * @var object + */ protected static $versions; /** - * Constructor. + * Version constructor. + * + * @return void */ public function __construct() { @@ -58,26 +65,51 @@ class VersionService }); } + /** + * Return current panel version from CDN. + * + * @return string + */ public static function getPanel() { return self::$versions->panel; } + /** + * Return current daemon version from CDN. + * + * @return string + */ public static function getDaemon() { return self::$versions->daemon; } + /** + * Return Discord link from CDN. + * + * @return string + */ public static function getDiscord() { return self::$versions->discord; } + /** + * Return current panel version. + * + * @return null|string + */ public function getCurrentPanel() { return config('app.version'); } + /** + * Determine if panel is latest version. + * + * @return bool + */ public static function isLatestPanel() { if (config('app.version') === 'canary') { @@ -87,6 +119,11 @@ class VersionService return version_compare(config('app.version'), self::$versions->panel) >= 0; } + /** + * Determine if daemon is latest version. + * + * @return bool + */ public static function isLatestDaemon($daemon) { if ($daemon === '0.0.0-canary') { diff --git a/app/Transformers/AllocationTransformer.php b/app/Transformers/AllocationTransformer.php deleted file mode 100644 index 8ca06a9c8..000000000 --- a/app/Transformers/AllocationTransformer.php +++ /dev/null @@ -1,41 +0,0 @@ -. - * - * 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\Transformers; - -use Pterodactyl\Models\Allocation; -use League\Fractal\TransformerAbstract; - -class AllocationTransformer extends TransformerAbstract -{ - /** - * Turn this item object into a generic array. - * - * @return array - */ - public function transform(Allocation $allocation) - { - return array_except($allocation, ['created_at', 'updated_at']); - } -} diff --git a/app/Transformers/NodeTransformer.php b/app/Transformers/NodeTransformer.php deleted file mode 100755 index 01d707f37..000000000 --- a/app/Transformers/NodeTransformer.php +++ /dev/null @@ -1,41 +0,0 @@ -. - * - * 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\Transformers; - -use Pterodactyl\Models\Node; -use League\Fractal\TransformerAbstract; - -class NodeTransformer extends TransformerAbstract -{ - /** - * Turn this item object into a generic array. - * - * @return array - */ - public function transform(Node $node) - { - return $node; - } -} diff --git a/app/Transformers/ServerTransformer.php b/app/Transformers/ServerTransformer.php deleted file mode 100755 index 12707cd04..000000000 --- a/app/Transformers/ServerTransformer.php +++ /dev/null @@ -1,41 +0,0 @@ -. - * - * 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\Transformers; - -use Pterodactyl\Models\Server; -use League\Fractal\TransformerAbstract; - -class ServerTransformer extends TransformerAbstract -{ - /** - * Turn this item object into a generic array. - * - * @return array - */ - public function transform(Server $server) - { - return $server; - } -} diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php deleted file mode 100755 index c36baaa69..000000000 --- a/app/Transformers/UserTransformer.php +++ /dev/null @@ -1,41 +0,0 @@ -. - * - * 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\Transformers; - -use Pterodactyl\Models\User; -use League\Fractal\TransformerAbstract; - -class UserTransformer extends TransformerAbstract -{ - /** - * Turn this item object into a generic array. - * - * @return array - */ - public function transform(User $user) - { - return $user; - } -}