Merge pull request #949 from Pterodactyl/release/v0.7.0

Merge v0.7.0 into master
This commit is contained in:
Dane Everitt 2018-02-17 20:49:48 -06:00 committed by GitHub
commit 4927af220a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
961 changed files with 51858 additions and 21070 deletions

View File

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

View File

@ -65,8 +65,8 @@ composer install --no-progress
php artisan key:generate --force php artisan key:generate --force
php artisan migrate php artisan migrate
php artisan db:seed php artisan db:seed
php artisan pterodactyl:user --firstname Test --lastname Admin --username admin --email testadmin@pterodactyl.io --password Ptero123 --admin 1 php artisan p:user:make --name-first Test --name-last Admin --username admin --email testadmin@pterodactyl.io --password Ptero123 --admin 1
php artisan pterodactyl:user --firstname Test --lastname User --username user --email testuser@pterodactyl.io --password Ptero123 --admin 0 php artisan p:user:make --name-first Test --name-last User --username user --email testuser@pterodactyl.io --password Ptero123 --admin 0
echo "Add queue cronjob and start queue worker" echo "Add queue cronjob and start queue worker"
(crontab -l 2>/dev/null; echo "* * * * * php /var/www/html/pterodactyl/artisan schedule:run >> /dev/null 2>&1") | crontab - (crontab -l 2>/dev/null; echo "* * * * * php /var/www/html/pterodactyl/artisan schedule:run >> /dev/null 2>&1") | crontab -

View File

@ -1,38 +1,29 @@
APP_ENV=production APP_ENV=production
APP_DEBUG=false APP_DEBUG=false
APP_KEY=SomeRandomString3232RandomString APP_KEY=
APP_THEME=pterodactyl APP_THEME=pterodactyl
APP_TIMEZONE=UTC APP_TIMEZONE=America/New_York
APP_CLEAR_TASKLOG=720 APP_CLEAR_TASKLOG=720
APP_DELETE_MINUTES=10 APP_DELETE_MINUTES=10
APP_URL=http://yoursite.com/ APP_ENVIRONMENT_ONLY=true
DB_HOST=localhost DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=3306
DB_DATABASE=homestead DB_DATABASE=panel
DB_USERNAME=homestead DB_USERNAME=pterodactyl
DB_PASSWORD=secret DB_PASSWORD=
CACHE_DRIVER=file HASHIDS_SALT=
SESSION_DRIVER=database HASHIDS_LENGTH=8
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io MAIL_HOST=mailtrap.io
MAIL_PORT=2525 MAIL_PORT=2525
MAIL_USERNAME=null MAIL_USERNAME=
MAIL_PASSWORD=null MAIL_PASSWORD=
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=tls
MAIL_FROM=you@example.com MAIL_FROM=no-reply@example.com
API_PREFIX=api
API_VERSION=v1
API_DEBUG=false
QUEUE_DRIVER=database
QUEUE_HIGH=high QUEUE_HIGH=high
QUEUE_STANDARD=standard QUEUE_STANDARD=standard
QUEUE_LOW=low QUEUE_LOW=low
SQS_KEY=aws-public
SQS_SECRET=aws-secret
SQS_QUEUE_PREFIX=aws-queue-prefix

19
.env.travis Normal file
View File

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

View File

@ -4,3 +4,11 @@ If you're just making a suggestion, be descriptive, and link to any issues that
You can delete from this line up. You can delete from this line up.
--------------------- ---------------------
* Panel or Daemon:
* Version of Panel/Daemon:
* Server's OS:
* Your Computer's OS & Browser:
## Add Details Below:

3
.gitignore vendored
View File

@ -5,7 +5,9 @@
.vscode/* .vscode/*
storage/framework/* storage/framework/*
/.idea /.idea
/nbproject
package-lock.json
composer.lock composer.lock
node_modules node_modules
@ -23,3 +25,4 @@ docker-compose.yml
# for image related files # for image related files
misc misc
.phpstorm.meta.php .phpstorm.meta.php
.php_cs.cache

56
.php_cs
View File

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

View File

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

31
.travis.yml Normal file
View File

@ -0,0 +1,31 @@
language: php
dist: trusty
php:
- 7.2
sudo: false
cache:
directories:
- $HOME/.composer/cache
services:
- mysql
before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
before_script:
- echo 'opcache.enable_cli=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- cp .env.travis .env
- travis_retry composer install --no-interaction --prefer-dist --no-suggest
- php artisan migrate --seed
script:
- vendor/bin/phpunit --coverage-clover coverage.xml
notifications:
email: false
webhooks:
urls:
- https://misc.schrej.net/travistodiscord/pterodev.php
on_success: change
on_failure: always
on_error: always
on_cancel: always
on_start: never
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -3,6 +3,209 @@ This file is a running track of new features and fixes to each version of the pa
This project follows [Semantic Versioning](http://semver.org) guidelines. This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.0 (Derelict Dermodactylus)
### Fixed
* `[rc.2]` — Fixes bad API behavior on `/user` routes.
* `[rc.2]` — Fixes Admin CP user editing resetting a password on users unintentionally.
* `[rc.2]` — Fixes bug with server creation API endpoint that would fail to validate `allocation.default` correctly.
* `[rc.2]` — Fix data integrity exception occuring due to invalid data being passed to server creation service on the API.
* `[rc.2]` — Fix data integrity exception that could occur when an email containing non-username characters was passed.
* `[rc.2]` — Fix data integrity exception occurring when no default value is provided for an egg variable.
* `[rc.2]` — Fixes a bug that would cause non-editable variables on the front-end to throw a validation error.
* `[rc.2]` — Fixes a data integrity exception occurring when saving egg variables with no value.
* Fixes a design bug in the database that prevented the storage of negative numbers, thus preventing a server from being assigned unlimited swap.
* Fixes a bug where the 'Assign New Allocations' box would only show IPs that were present in the current pagination block.
* Unable to change the daemon secret for a server via the Admin CP.
* Using default value in rules when creating a new variable if the rules is empty.
* Fixes a design-flaw in the allocation management part of nodes that would run a MySQL query for each port being allocated. This behavior is now changed to only execute one query to add multiple ports at once.
* Attempting to create a server when no nodes are configured now redirects to the node creation page.
* Fixes missing library issue for teamspeak when used with mariadb.
* Fixes inability to change the default port on front-end when viewing a server.
* Fixes bug preventing deletion of nests that have other nests referencing them as children.
* Fixes console sometimes not loading properly on slow connections
### Added
* Added ability to search the following API endpoints: list users, list servers, and list locations.
* Add support for finding a user by external ID using `/api/application/users/external/<id>` or by passing it as the search term when listing all users.
* Added a unique key to the servers table to data integrity issues where an allocation would be assigned to more than one server at once.
* Added support for editing an existing schedule.
* Added support for editing symlinked files on the Panel.
* Added new application specific API to Panel with endpoints at `/api/application`. Includes new Admin CP interface for managing keys and an easier permissions system.
* Nest and Egg listings now show the associated ID in order to make API requests easier.
* Added star indicators to user listing in Admin CP to indicate users who are set as a root admin.
* Creating a new node will now requires a SSL connection if the Panel is configured to use SSL as well.
* Socketio error messages due to permissions are now rendered correctly in the UI rather than causing a silent failure.
* File manager now supports mass deletion option for files and folders.
* Support for CS:GO as a default service option selection.
* Support for GMOD as a default service option selection.
* Added test suite for core aspects of the project (Services, Repositories, Commands, etc.) to lessen the chances for bugs to escape into releases.
* New CLI command to disabled 2-Factor Authentication on an account if necessary.
* Ability to delete users and locations via the CLI.
* You can now require 2FA for all users, admins only, or at will using a simple configuration in the Admin CP.
* **Added ability to export and import service options and their associated settings and environment variables via the Admin CP.**
* Default allocation for a server can be changed on the front-end by users. This includes two new subuser permissions as well.
* Significant improvements to environment variable control for servers. Now ships with built-in abilities to define extra variables in the Panel's configuration file, or in-code for those heavily modifying the Panel.
* Quick link to server edit view in ACP on frontend when viewing servers.
* Databases created in the Panel now include `EXECUTE` privilege.
### Changed
* PHP 7.2 is now the minimum required version for this software.
* Egg variable default values are no longer validated aganist the ruleset when configuring them. Validation of those rules will only occur when editing or creating a server.
* Changed logger to skip reporting stack-traces on PDO exceptions due to sensitive information being contained within.
* Changed behavior of allocation IP Address/Ports box to automatically store the value entered if a user unfocuses the field without hitting space.
* Changed order in which allocations are displayed to prioritize those with servers attached (in ascending IP & port order) followed by ascending IP & port order where no server is attached.
* Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account.
* Updated core framework to Laravel 5.5. This includes many dependency updates.
* Certain AWS specific environment keys were changed, this should have minimal impact on users unless you specifically enabled AWS specific features. The renames are: `AWS_KEY -> AWS_ACCESS_KEY_ID`, `AWS_SECRET -> AWS_SECRET_ACCESS_KEY`, `AWS_REGION -> AWS_DEFAULT_REGION`
* API keys have been changed to only use a single public key passed in a bearer token. All existing keys can continue being used, however only the first 32 characters should be sent.
* Moved Docker image setting to be on the startup management page for a server rather than the details page. This value changes based on the Nest and Egg that are selected.
* Two-Factor authentication tokens are now 32 bytes in length, and are stored encrypted at rest in the database.
* Login page UI has been improved to be more sleek and welcoming to users.
* Changed 2FA login process to be more secure. Previously authentication checking happened on the 2FA post page, now it happens prior and is passed along to the 2FA page to avoid storing any credentials.
* **Services renamed to Nests. Service Options renamed to Eggs.** 🥚
* Theme colors and login pages updated to give a more unique feel to the project.
* Massive overhaul to the backend code that allows for much easier updating of core functionality as well as support for better testing. This overhaul also reduces complex code logic, and allows for faster response times in the application.
* CLI commands updated to be easier to type, now stored in the `p:` namespace.
* Logout icon is now more universal and not just a power icon.
* Administrative logout notice now uses SWAL rather than a generic javascript popup.
* Server creation page now only asks for a node to deploy to, rather than requiring a location and then a node.
* Database passwords are now hidden by default and will only show if clicked on. In addition, database view in ACP now indicates that passwords must be viewed on the front-end.
* Localhost cannot be used as a connection address in the environment configuration script. `127.0.0.1` is allowed.
* Application locale can now be quickly set using an environment variable `APP_LOCALE` rather than having to edit core files.
### Removed
* OOM exceptions can no longer be disabled on servers due to a startling number of users that were using it to avoid allocating proper amounts of resources to servers.
* SFTP settings page now only displays connection address and username. Password setting was removed as it is no longer necessary with Daemon changes.
## v0.7.0-rc.2 (Derelict Dermodactylus)
### Fixed
* `[rc.1]` — Fixes exception thrown when revoking user sessions.
* `[rc.1]` — Fixes exception that would occur when trying to delete allocations from a node.
* `[rc.1]` — Fixes exception thown when attempting to adjust mail settings as well as a validation error thrown afterwards.
* `[rc.1]` — Fixes bug preventing modification of the default value for an Egg variable.
* `[rc.1]` — Fixed a bug that would occur when attempting to reset the daemon secret for a node.
* `[rc.1]` — Fix exception thrown when attempting to modify an existing database host.
* `[rc.1]` — Fix an auto deployment bug causing a node to be ignored if it had no servers already attached to it.
### Changed
* Changed logger to skip reporting stack-traces on PDO exceptions due to sensitive information being contained within.
### Added
* Added support for editing an existing schedule.
## v0.7.0-rc.1 (Derelict Dermodactylus)
### Fixed
* `[beta.4]` — Fixes some bad search and replace action that happened previously and was throwing errors when validating user permissions.
* `[beta.4]` — Fixes behavior of variable validation to not break the page when no rules are provided.
* `[beta.4]` — Fix bug preventing the editing of files in the file manager.
### Added
* Added support for editing symlinked files on the Panel.
* Added new application specific API to Panel with endpoints at `/api/application`. Includes new Admin CP interface for managing keys and an easier permissions system.
## v0.7.0-beta.4 (Derelict Dermodactylus)
### Fixed
* `[beta.3]` — Fixes a bug with the default environment file that was causing an inability to perform a fresh install when running package discovery.
* `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check aganist a null value.
* `[beta.3]` — Fixes a bug that would cause an error when attempting to create a new user on the Panel.
* `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run.
* `[beta.3]` — Fixes validation error when trying to use 'None' as the 'Copy Script From' option for an egg script.
* Fixes a design bug in the database that prevented the storage of negative numbers, thus preventing a server from being assigned unlimited swap.
* Fixes a bug where the 'Assign New Allocations' box would only show IPs that were present in the current pagination block.
### Added
* Nest and Egg listings now show the associated ID in order to make API requests easier.
### Changed
* Changed behavior of allocation IP Address/Ports box to automatically store the value entered if a user unfocuses the field without hitting space.
* Changed order in which allocations are displayed to prioritize those with servers attached (in ascending IP & port order) followed by ascending IP & port order where no server is attached.
### Removed
* OOM exceptions can no longer be disabled on servers due to a startling number of users that were using it to avoid allocating proper amounts of resources to servers.
## v0.7.0-beta.3 (Derelict Dermodactylus)
### Fixed
* `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances.
* `[beta.2]` — Fixes a bug causing the dropdown menu for a server's egg to display the wrong selected value.
* `[beta.2]` — Fixes a bug that would throw a red page of death when submitting an invalid egg variable value for a server in the Admin CP.
* `[beta.2]` — Someone found a `@todo` that I never `@todid` and thus database hosts could not be created without being linked to a node. This is fixed...
* `[beta.2]` — Fixes bug that caused incorrect rendering of CPU usage on server graphs due to missing variable.
* `[beta.2]` — Fixes bug causing schedules to be un-deletable.
* `[beta.2]` — Fixes bug that prevented the deletion of nodes due to an allocation deletion cascade issue with the SQL schema.
* `[beta.2]` — Fixes a bug causing eggs not extending other eggs to fail validation.
### Changed
* Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account.
* Updated core framework to Laravel 5.5. This includes many dependency updates.
* Certain AWS specific environment keys were changed, this should have minimal impact on users unless you specifically enabled AWS specific features. The renames are: `AWS_KEY -> AWS_ACCESS_KEY_ID`, `AWS_SECRET -> AWS_SECRET_ACCESS_KEY`, `AWS_REGION -> AWS_DEFAULT_REGION`
* API keys have been changed to only use a single public key passed in a bearer token. All existing keys can continue being used, however only the first 32 characters should be sent.
### Added
* Added star indicators to user listing in Admin CP to indicate users who are set as a root admin.
* Creating a new node will now requires a SSL connection if the Panel is configured to use SSL as well.
## v0.7.0-beta.2 (Derelict Dermodactylus)
### Fixed
* `[beta.1]` — Fixes a CORS header issue due to a wrong API endpoint being provided in the administrative node listing.
* `[beta.1]` — Fixes bug that would prevent root admins from accessing servers they were not set as the owner of.
* `[beta.1]` — Fixes wrong URL redirect being provided when creating a subuser.
* `[beta.1]` — Fixes missing check in environment setup that would leave the Hashids salt empty.
* `[beta.1]` — Fixes bug preventing loading of allocations when trying to create a new server.
* `[beta.1]` — Fixes bug causing inability to create new servers on the Panel.
* `[beta.1]` — Fixes bug causing inability to delete an allocation due to misconfigured JS.
* `[beta.1]` — Fixes bug causing inability to set the IP alias for an allocation to an empty value.
* `[beta.1]` — Fixes bug that caused startup changes to not propigate to the server correctly on the first save.
* `[beta.1]` — Fixes bug that prevented subusers from accessing anything over socketio due to a missing permission.
### Changed
* Moved Docker image setting to be on the startup management page for a server rather than the details page. This value changes based on the Nest and Egg that are selected.
* Two-Factor authentication tokens are now 32 bytes in length, and are stored encrypted at rest in the database.
* Login page UI has been improved to be more sleek and welcoming to users.
* Changed 2FA login process to be more secure. Previously authentication checking happened on the 2FA post page, now it happens prior and is passed along to the 2FA page to avoid storing any credentials.
### Added
* Socketio error messages due to permissions are now rendered correctly in the UI rather than causing a silent failure.
## v0.7.0-beta.1 (Derelict Dermodactylus)
### Added
* File manager now supports mass deletion option for files and folders.
* Support for CS:GO as a default service option selection.
* Support for GMOD as a default service option selection.
* Added test suite for core aspects of the project (Services, Repositories, Commands, etc.) to lessen the chances for bugs to escape into releases.
* New CLI command to disabled 2-Factor Authentication on an account if necessary.
* Ability to delete users and locations via the CLI.
* You can now require 2FA for all users, admins only, or at will using a simple configuration in the Admin CP.
* **Added ability to export and import service options and their associated settings and environment variables via the Admin CP.**
* Default allocation for a server can be changed on the front-end by users. This includes two new subuser permissions as well.
* Significant improvements to environment variable control for servers. Now ships with built-in abilities to define extra variables in the Panel's configuration file, or in-code for those heavily modifying the Panel.
* Quick link to server edit view in ACP on frontend when viewing servers.
* Databases created in the Panel now include `EXECUTE` privilege.
### Changed
* **Services renamed to Nests. Service Options renamed to Eggs.** 🥚
* Theme colors and login pages updated to give a more unique feel to the project.
* Massive overhaul to the backend code that allows for much easier updating of core functionality as well as support for better testing. This overhaul also reduces complex code logic, and allows for faster response times in the application.
* CLI commands updated to be easier to type, now stored in the `p:` namespace.
* Logout icon is now more universal and not just a power icon.
* Administrative logout notice now uses SWAL rather than a generic javascript popup.
* Server creation page now only asks for a node to deploy to, rather than requiring a location and then a node.
* Database passwords are now hidden by default and will only show if clicked on. In addition, database view in ACP now indicates that passwords must be viewed on the front-end.
* Localhost cannot be used as a connection address in the environment configuration script. `127.0.0.1` is allowed.
* Application locale can now be quickly set using an environment variable `APP_LOCALE` rather than having to edit core files.
### Fixed
* Unable to change the daemon secret for a server via the Admin CP.
* Using default value in rules when creating a new variable if the rules is empty.
* Fixes a design-flaw in the allocation management part of nodes that would run a MySQL query for each port being allocated. This behavior is now changed to only execute one query to add multiple ports at once.
* Attempting to create a server when no nodes are configured now redirects to the node creation page.
* Fixes missing library issue for teamspeak when used with mariadb.
* Fixes inability to change the default port on front-end when viewing a server.
* Fixes bug preventing deletion of nests that have other nests referencing them as children.
* Fixes console sometimes not loading properly on slow connections
### Removed
* SFTP settings page now only displays connection address and username. Password setting was removed as it is no longer necessary with Daemon changes.
## v0.6.4 (Courageous Carniadactylus) ## v0.6.4 (Courageous Carniadactylus)
### Fixed ### Fixed
* Fixed the console rendering on page load, I guess people don't like watching it load line-by-line for 10 minutes. Who would have guessed... * Fixed the console rendering on page load, I guess people don't like watching it load line-by-line for 10 minutes. Who would have guessed...
@ -240,7 +443,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* New theme applied to Admin CP. Many graphical changes were made, some data was moved around and some display data changed. Too much was changed to feasibly log it all in here. Major breaking changes or notable new features will be logged. * New theme applied to Admin CP. Many graphical changes were made, some data was moved around and some display data changed. Too much was changed to feasibly log it all in here. Major breaking changes or notable new features will be logged.
* New server creation page now makes significantly less AJAX calls and is much quicker to respond. * New server creation page now makes significantly less AJAX calls and is much quicker to respond.
* Server and Node view pages wee modified to split tabs into individual pages to make re-themeing and modifications significantly easier, and reduce MySQL query loads on page. * Server and Node view pages wee modified to split tabs into individual pages to make re-themeing and modifications significantly easier, and reduce MySQL query loads on page.
* `[pre.4]` — Services and Pack magement overhauled to be faster, cleaner, and more extensible in the future. * `[pre.4]` — Service and Pack magement overhauled to be faster, cleaner, and more extensible in the future.
* Most of the backend `UnhandledException` display errors now include a clearer error that directs admins to the program's logs. * Most of the backend `UnhandledException` display errors now include a clearer error that directs admins to the program's logs.
* Table seeders for services now can be run during upgrades and will attempt to locate and update, or create new if not found in the database. * Table seeders for services now can be run during upgrades and will attempt to locate and update, or create new if not found in the database.
* Many structural changes to the database and `Pterodactyl\Models` classes that would flood this changelog if they were all included. All required migrations included to handle database changes. * Many structural changes to the database and `Pterodactyl\Models` classes that would flood this changelog if they were all included. All required migrations included to handle database changes.

View File

@ -1,12 +1,35 @@
# Contributing # Contributing
We're glad you want to help us out and make this panel the best that it can be! We have a few simple things to follow when making changes to files and adding new features. We're glad you want to help us out and make this panel the best that it can be! We have a few simple things to follow when making changes to files and adding new features.
### Project Branches
This section mainly applies to those with read/write access to our repositories, but can be helpful for others.
The `develop` branch should always be in a runnable state, and not contain any major breaking features. For the most part this means you will need to create `feature/` branches in order to add new functionality, or change how things work. When making a feature branch, if it is referencing something in the issue tracker, please title the branch `feature/PTDL-###` where `###` is the issue number.
Moving forward all commits from contributors should be in the form of a PR, unless it is something we have previous discussed as being able to be pushed right into `develop`.
All new code should contain unit tests at minimum (where applicable). There is a lot of un-covered code currently, so as you are doing things please be looking for places that you can write tests.
### Update the CHANGELOG
When adding something that is new, fixed, changed, or security related for the next release you should be adding a note to the CHANGELOG. If something is changing within the same version (i.e. fixing a bug introduced but not released) it should _not_ go into the CHANGELOG.
### Code Guidelines ### Code Guidelines
*This section is still under construction.* We are a `PSR-4` and `PSR-0` compliant project, so please follow those guidelines at a minimum. In addition, StyleCI runs on all of our code to ensure the formatting is standardized across everything. When a PR is made StyleCI will analyze your code and make a pull to that branch if necessary to fix any formatting issues. This project also ships with a PHP-CS configuration file and you are welcome to configure your local environment to make use of that.
We are a `PSR-4` and `PSR-0` compliant project, so please follow those guidelines at a minimum. In addition, StyleCI runs on all of our code to ensure the formatting is standardized across everything. Please follow the existing code formatting, I will write up more detailed documentation at a later time. All class variable declarations should be in alphabetical order, and constructor arguments should be in alphabetical order based on the classname. See the example below for how this should look, or check out any of the `app/Service` files for examples.
In addition, all functions must be properly Doc-Block'd. ```php
class ProcessScheduleService
{
protected $repository;
protected $runnerService;
public function __construct(RunTaskService $runnerService, ScheduleRepositoryInterface $repository)
{
$this->repository = $repository;
$this->runnerService = $runnerService;
}
```
### Responsible Disclosure ### Responsible Disclosure
This is a fairly in-depth project, and makes use of a lot of parts. We strive to keep everything as secure as possible, and welcome you to take a look into it yourself. We do ask that you be considerate of others who are using the software and not publicly disclose security issues without contacting us first by email. This is a fairly in-depth project, and makes use of a lot of parts. We strive to keep everything as secure as possible, and welcome you to take a look into it yourself. We do ask that you be considerate of others who are using the software and not publicly disclose security issues without contacting us first by email.
@ -18,4 +41,4 @@ If you've found what you believe is a security issue please email us at `support
### Where to find Us ### Where to find Us
You can find us in a couple places online. First and foremost, we're active right here on Github. If you encounter a bug or other problem open an issue on here for us to take a look at it. We also accept feature requests here as well. You can find us in a couple places online. First and foremost, we're active right here on Github. If you encounter a bug or other problem open an issue on here for us to take a look at it. We also accept feature requests here as well.
You can also find us on [Discord](https://pterodactyl.io/discord) or our [community forums](https://forums.pterodactyl.io/). In the event that you need to get in contact with us privately feel free to contact us at `support@pterodactyl.io`. Try not to email us with requests for support regarding the panel, we'll probably just direct you to our forums or here. You can also find us on [Discord](https://pterodactyl.io/discord). In the event that you need to get in contact with us privately feel free to contact us at `support@pterodactyl.io`. Try not to email us with requests for support regarding the panel, we'll probably just direct you to our forums or Discord.

View File

@ -1,5 +1,7 @@
[![Logo Image](https://cdn.pterodactyl.io/logos/Banner%20Logo%20Black@2x.png)](https://pterodactyl.io) [![Logo Image](https://cdn.pterodactyl.io/logos/Banner%20Logo%20Black@2x.png)](https://pterodactyl.io)
[![Build Status](https://travis-ci.org/Pterodactyl/Panel.svg?branch=develop)](https://travis-ci.org/Pterodactyl/Panel) [![StyleCI](https://styleci.io/repos/47508644/shield?branch=develop)](https://styleci.io/repos/47508644) [![codecov](https://codecov.io/gh/Pterodactyl/Panel/branch/develop/graph/badge.svg)](https://codecov.io/gh/Pterodactyl/Panel)
## Pterodactyl Panel ## Pterodactyl Panel
Pterodactyl Panel is the free, open-source, game agnostic, self-hosted control panel for users, networks, and game service providers. Pterodactyl supports games and servers such as Minecraft (including Spigot, Bungeecord, and Sponge), ARK: Evolution Evolved, CS:GO, Team Fortress 2, Insurgency, Teamspeak 3, Mumble, and many more. Control all of your games from one unified interface. Pterodactyl Panel is the free, open-source, game agnostic, self-hosted control panel for users, networks, and game service providers. Pterodactyl supports games and servers such as Minecraft (including Spigot, Bungeecord, and Sponge), ARK: Evolution Evolved, CS:GO, Team Fortress 2, Insurgency, Teamspeak 3, Mumble, and many more. Control all of your games from one unified interface.
@ -33,47 +35,43 @@ SOFTWARE.
![](http://static.s3.pterodactyl.io/PhraseApp-parrot.png) ![](http://static.s3.pterodactyl.io/PhraseApp-parrot.png)
A huge thanks to [PhraseApp](https://phraseapp.com) who provide us the software to help translate this project. A huge thanks to [PhraseApp](https://phraseapp.com) who provide us the software to help translate this project.
Ace Editor - [license](https://github.com/ajaxorg/ace/blob/master/LICENSE) - [homepage](https://ace.c9.io) Ace Editor — [license](https://github.com/ajaxorg/ace/blob/master/LICENSE) — [homepage](https://ace.c9.io)
AdminLTE - [license](https://github.com/almasaeed2010/AdminLTE/blob/master/LICENSE) - [homepage](https://almsaeedstudio.com) AdminLTE — [license](https://github.com/almasaeed2010/AdminLTE/blob/master/LICENSE) — [homepage](https://almsaeedstudio.com)
Animate.css - [license](https://github.com/daneden/animate.css/blob/master/LICENSE) - [homepage](http://daneden.github.io/animate.css/) Animate.css — [license](https://github.com/daneden/animate.css/blob/master/LICENSE) — [homepage](http://daneden.github.io/animate.css/)
AnsiUp - [license](https://github.com/drudru/ansi_up/blob/master/Readme.md#license) - [homepage](https://github.com/drudru/ansi_up) AnsiUp — [license](https://github.com/drudru/ansi_up/blob/master/Readme.md#license) — [homepage](https://github.com/drudru/ansi_up)
Async.js - [license](https://github.com/caolan/async/blob/master/LICENSE) - [homepage](https://github.com/caolan/async/) Async.js — [license](https://github.com/caolan/async/blob/master/LICENSE) — [homepage](https://github.com/caolan/async/)
Bootstrap - [license](https://github.com/twbs/bootstrap/blob/master/LICENSE) - [homepage](http://getbootstrap.com) Bootstrap — [license](https://github.com/twbs/bootstrap/blob/master/LICENSE) — [homepage](http://getbootstrap.com)
BootStrap Notify - [license](https://github.com/mouse0270/bootstrap-notify/blob/master/LICENSE) - [homepage](http://bootstrap-notify.remabledesigns.com) BootStrap Notify — [license](https://github.com/mouse0270/bootstrap-notify/blob/master/LICENSE) — [homepage](http://bootstrap-notify.remabledesigns.com)
Chart.js - [license](https://github.com/chartjs/Chart.js/blob/master/LICENSE.md) - [homepage](http://www.chartjs.org) Chart.js — [license](https://github.com/chartjs/Chart.js/blob/master/LICENSE.md) — [homepage](http://www.chartjs.org)
FontAwesome - [license](http://fontawesome.io/license/) - [homepage](http://fontawesome.io) FontAwesome — [license](http://fontawesome.io/license/) — [homepage](http://fontawesome.io)
FontAwesome Animations - [license](https://github.com/l-lin/font-awesome-animation#license) - [homepage](https://github.com/l-lin/font-awesome-animation) FontAwesome Animations — [license](https://github.com/l-lin/font-awesome-animation#license) — [homepage](https://github.com/l-lin/font-awesome-animation)
jQuery - [license](https://github.com/jquery/jquery/blob/master/LICENSE.txt) - [homepage](http://jquery.com) jQuery — [license](https://github.com/jquery/jquery/blob/master/LICENSE.txt) — [homepage](http://jquery.com)
Laravel Framework - [license](https://github.com/laravel/framework/blob/5.4/LICENSE.md) - [homepage](https://laravel.com) Laravel Framework — [license](https://github.com/laravel/framework/blob/5.4/LICENSE.md) — [homepage](https://laravel.com)
Lodash - [license](https://github.com/lodash/lodash/blob/master/LICENSE) - [homepage](https://lodash.com/) Lodash — [license](https://github.com/lodash/lodash/blob/master/LICENSE) — [homepage](https://lodash.com/)
Select2 - [license](https://github.com/select2/select2/blob/master/LICENSE.md) - [homepage](https://select2.github.io) Select2 — [license](https://github.com/select2/select2/blob/master/LICENSE.md) — [homepage](https://select2.github.io)
Socket.io - [license](https://github.com/socketio/socket.io/blob/master/LICENSE) - [homepage](http://socket.io) Socket.io — [license](https://github.com/socketio/socket.io/blob/master/LICENSE) — [homepage](http://socket.io)
Socket.io File Upload - [license](https://github.com/vote539/socketio-file-upload/blob/master/server.js#L1-L27) - [homepage](https://github.com/vote539/socketio-file-upload) Socket.io File Upload [license](https://github.com/vote539/socketio-file-upload/blob/master/server.js#L1-L27) [homepage](https://github.com/vote539/socketio-file-upload)
SweetAlert - [license](https://github.com/t4t5/sweetalert/blob/master/LICENSE) - [homepage](http://t4t5.github.io/sweetalert/) SweetAlert — [license](https://github.com/t4t5/sweetalert/blob/master/LICENSE) — [homepage](http://t4t5.github.io/sweetalert/)
Typeahead — [license](https://github.com/bassjobsen/Bootstrap-3-Typeahead/blob/master/bootstrap3-typeahead.js) — [homepage](https://github.com/bassjobsen/Bootstrap-3-Typeahead) Typeahead — [license](https://github.com/bassjobsen/Bootstrap-3-Typeahead/blob/master/bootstrap3-typeahead.js) — [homepage](https://github.com/bassjobsen/Bootstrap-3-Typeahead)
particles.js — [license](https://github.com/VincentGarreau/particles.js/blob/master/LICENSE.md) — [homepage](http://vincentgarreau.com/particles.js/)
### Additional License Information ### Additional License Information
Some Javascript and CSS used within the panel is licensed under a `MIT` or `Apache 2.0`. Please check their respective header files for more information. Some Javascript and CSS used within the panel is licensed under a `MIT` or `Apache 2.0`. Please check their respective header files for more information.
Some images used within Pterodactyl are Copyright (c) their respective owners.
`/public/themes/default/images/403.jpg` is licensed under a [CC BY 2.0](http://creativecommons.org/licenses/by/2.0/) by [BigTallGuy](http://flickr.com/photos/bigtallguy/)
`/public/themes/default/images/404.jpg` is licensed under a [CC BY-SA 2.0](http://creativecommons.org/licenses/by-sa/2.0/) by [nicsuzor](http://flickr.com/photos/nicsuzor/)

View File

@ -1,75 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
use Pterodactyl\Repositories\LocationRepository;
class AddLocation extends Command
{
protected $data = [];
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:location
{--short= : The shortcode name of this location (ex. us1).}
{--long= : A longer description of this location.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Creates a new location on the system via the CLI.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->data['short'] = (is_null($this->option('short'))) ? $this->ask('Location Short Code') : $this->option('short');
$this->data['long'] = (is_null($this->option('long'))) ? $this->ask('Location Description') : $this->option('long');
$repo = new LocationRepository;
$id = $repo->create($this->data);
$this->info('Location ' . $this->data['short'] . ' created with ID: ' . $id);
}
}

View File

@ -1,112 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
use Pterodactyl\Models\Location;
use Pterodactyl\Repositories\NodeRepository;
class AddNode extends Command
{
protected $data = [];
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:node
{--name= : Name of the node.}
{--location= : The shortcode of the location to add this node to.}
{--fqdn= : The fully-qualified domain for the node.}
{--ssl= : Should the daemon use SSL for connections (T/F).}
{--memory= : The total memory available on this node for servers.}
{--disk= : The total disk space available on this node for servers.}
{--daemonBase= : The directory in which server files will be stored.}
{--daemonListen= : The port the daemon will listen on for connections.}
{--daemonSFTP= : The port to be used for SFTP conncetions to the daemon.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Adds a new node to the system via the CLI.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$locations = Location::all(['id', 'short', 'long']);
$this->data['name'] = (is_null($this->option('name'))) ? $this->ask('Node Name') : $this->option('name');
if (is_null($this->option('location'))) {
$this->table(['ID', 'Short Code', 'Description'], $locations->toArray());
$selectedLocation = $this->anticipate('Node Location (Short Name)', $locations->pluck('short')->toArray());
} else {
$selectedLocation = $this->option('location');
}
$this->data['location_id'] = $locations->where('short', $selectedLocation)->first()->id;
if (is_null($this->option('fqdn'))) {
$this->line('Please enter domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.');
$this->data['fqdn'] = $this->ask('Fully Qualified Domain Name');
} else {
$this->data['fqdn'] = $this->option('fqdn');
}
$useSSL = (is_null($this->option('ssl'))) ? $this->confirm('Use SSL', true) : $this->option('ssl');
$this->data['scheme'] = ($useSSL) ? 'https' : 'http';
$this->data['memory'] = (is_null($this->option('memory'))) ? $this->ask('Total Memory (in MB)') : $this->option('memory');
$this->data['memory_overallocate'] = 0;
$this->data['disk'] = (is_null($this->option('disk'))) ? $this->ask('Total Disk Space (in MB)') : $this->option('disk');
$this->data['disk_overallocate'] = 0;
$this->data['public'] = 1;
$this->data['daemonBase'] = (is_null($this->option('daemonBase'))) ? $this->ask('Daemon Server File Location', '/srv/daemon-data') : $this->option('daemonBase');
$this->data['daemonListen'] = (is_null($this->option('daemonListen'))) ? $this->ask('Daemon Listening Port', 8080) : $this->option('daemonListen');
$this->data['daemonSFTP'] = (is_null($this->option('daemonSFTP'))) ? $this->ask('Daemon SFTP Port', 2022) : $this->option('daemonSFTP');
$repo = new NodeRepository;
$id = $repo->create($this->data);
$this->info('Node created with ID: ' . $id);
}
}

View File

@ -1,74 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Carbon;
use Storage;
use Illuminate\Console\Command;
class CleanServiceBackup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:cleanservices';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Cleans .bak files assocaited with service backups whene editing files through the panel.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$files = Storage::files('services/.bak');
foreach ($files as $file) {
$lastModified = Carbon::createFromTimestamp(Storage::lastModified($file));
if ($lastModified->diffInMinutes(Carbon::now()) > 5) {
$this->info('Deleting ' . $file);
Storage::delete($file);
}
}
}
}

View File

@ -1,89 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use DB;
use Illuminate\Console\Command;
class ClearServices extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:clear-services';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Removes all services from the database for installing updated ones as needed.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (! $this->confirm('This is a destructive operation, are you sure you wish to continue?')) {
$this->error('Canceling.');
exit();
}
$bar = $this->output->createProgressBar(3);
DB::beginTransaction();
try {
DB::table('services')->truncate();
$bar->advance();
DB::table('service_options')->truncate();
$bar->advance();
DB::table('service_variables')->truncate();
$bar->advance();
DB::commit();
} catch (\Exception $ex) {
DB::rollBack();
}
$this->info("\n");
$this->info('All services have been removed. Consider running `php artisan pterodactyl:service-defaults` at this time.');
}
}

View File

@ -1,80 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Carbon;
use Pterodactyl\Models;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
class ClearTasks extends Command
{
use DispatchesJobs;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:tasks:clearlog';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clears old log entires (> 2 months) from the last log.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$entries = Models\TaskLog::where('run_time', '<=', Carbon::now()->subHours(config('pterodactyl.tasks.clear_log'))->toAtomString())->get();
$this->info(sprintf('Preparing to delete %d old task log entries.', count($entries)));
$bar = $this->output->createProgressBar(count($entries));
foreach ($entries as &$entry) {
$entry->delete();
$bar->advance();
}
$bar->finish();
$this->info("\nFinished deleting old logs.");
}
}

View File

@ -0,0 +1,194 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Environment;
use DateTimeZone;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class AppSettingsCommand extends Command
{
use EnvironmentWriterTrait;
const ALLOWED_CACHE_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
];
const ALLOWED_SESSION_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
'database' => 'MySQL Database',
'file' => 'Filesystem',
'cookie' => 'Cookie',
];
const ALLOWED_QUEUE_DRIVERS = [
'redis' => 'Redis (recommended)',
'database' => 'MySQL Database',
'sync' => 'Sync',
];
/**
* @var \Illuminate\Contracts\Console\Kernel
*/
protected $command;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var string
*/
protected $description = 'Configure basic environment settings for the Panel.';
/**
* @var string
*/
protected $signature = 'p:environment:setup
{--new-salt : Wether or not to generate a new salt for Hashids.}
{--author= : The email that services created on this instance should be linked to.}
{--url= : The URL that this Panel is running on.}
{--timezone= : The timezone to use for Panel times.}
{--cache= : The cache driver backend to use.}
{--session= : The session driver backend to use.}
{--queue= : The queue driver backend to use.}
{--redis-host= : Redis host to use for connections.}
{--redis-pass= : Password used to connect to redis.}
{--redis-port= : Port to connect to redis over.}
{--disable-settings-ui}';
/**
* @var array
*/
protected $variables = [];
/**
* AppSettingsCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Console\Kernel $command
*/
public function __construct(ConfigRepository $config, Kernel $command)
{
parent::__construct();
$this->command = $command;
$this->config = $config;
}
/**
* Handle command execution.
*
* @throws \Pterodactyl\Exceptions\PterodactylException
*/
public function handle()
{
if (empty($this->config->get('hashids.salt')) || $this->option('new-salt')) {
$this->variables['HASHIDS_SALT'] = str_random(20);
}
$this->output->comment(trans('command/messages.environment.app.author_help'));
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
trans('command/messages.environment.app.author'), $this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
);
$this->output->comment(trans('command/messages.environment.app.app_url_help'));
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
trans('command/messages.environment.app.app_url'), $this->config->get('app.url', 'http://example.org')
);
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
trans('command/messages.environment.app.timezone'),
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
$this->config->get('app.timezone')
);
$selected = $this->config->get('cache.default', 'redis');
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
trans('command/messages.environment.app.cache_driver'),
self::ALLOWED_CACHE_DRIVERS,
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
);
$selected = $this->config->get('session.driver', 'redis');
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
trans('command/messages.environment.app.session_driver'),
self::ALLOWED_SESSION_DRIVERS,
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
);
$selected = $this->config->get('queue.default', 'redis');
$this->variables['QUEUE_DRIVER'] = $this->option('queue') ?? $this->choice(
trans('command/messages.environment.app.queue_driver'),
self::ALLOWED_QUEUE_DRIVERS,
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
);
if ($this->option('disable-settings-ui')) {
$this->variables['APP_ENVIRONMENT_ONLY'] = 'true';
} else {
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
}
$this->checkForRedis();
$this->writeToEnvironment($this->variables);
$this->info($this->command->output());
}
/**
* Check if redis is selected, if so, request connection details and verify them.
*/
private function checkForRedis()
{
$items = collect($this->variables)->filter(function ($item) {
return $item === 'redis';
});
// Redis was not selected, no need to continue.
if (count($items) === 0) {
return;
}
$this->output->note(trans('command/messages.environment.app.using_redis'));
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
trans('command/messages.environment.app.redis_host'), $this->config->get('database.redis.default.host')
);
$askForRedisPassword = true;
if (! empty($this->config->get('database.redis.default.password'))) {
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
}
if ($askForRedisPassword) {
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
trans('command/messages.environment.app.redis_password'), function () {
return '';
}
);
}
if (empty($this->variables['REDIS_PASSWORD'])) {
$this->variables['REDIS_PASSWORD'] = 'null';
}
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
trans('command/messages.environment.app.redis_port'), $this->config->get('database.redis.default.port')
);
}
}

View File

@ -0,0 +1,152 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Environment;
use PDOException;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Database\DatabaseManager;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class DatabaseSettingsCommand extends Command
{
use EnvironmentWriterTrait;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Illuminate\Contracts\Console\Kernel
*/
protected $console;
/**
* @var \Illuminate\Database\DatabaseManager
*/
protected $database;
/**
* @var string
*/
protected $description = 'Configure database settings for the Panel.';
/**
* @var string
*/
protected $signature = 'p:environment:database
{--host= : The connection address for the MySQL server.}
{--port= : The connection port for the MySQL server.}
{--database= : The database to use.}
{--username= : Username to use when connecting.}
{--password= : Password to use for this database.}';
/**
* @var array
*/
protected $variables = [];
/**
* DatabaseSettingsCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Database\DatabaseManager $database
* @param \Illuminate\Contracts\Console\Kernel $console
*/
public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console)
{
parent::__construct();
$this->config = $config;
$this->console = $console;
$this->database = $database;
}
/**
* Handle command execution.
*
* @return int
*
* @throws \Pterodactyl\Exceptions\PterodactylException
*/
public function handle()
{
$this->output->note(trans('command/messages.environment.database.host_warning'));
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
trans('command/messages.environment.database.host'), $this->config->get('database.connections.mysql.host', '127.0.0.1')
);
$this->variables['DB_PORT'] = $this->option('port') ?? $this->ask(
trans('command/messages.environment.database.port'), $this->config->get('database.connections.mysql.port', 3306)
);
$this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask(
trans('command/messages.environment.database.database'), $this->config->get('database.connections.mysql.database', 'panel')
);
$this->output->note(trans('command/messages.environment.database.username_warning'));
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.database.username'), $this->config->get('database.connections.mysql.username', 'pterodactyl')
);
$askForMySQLPassword = true;
if (! empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
}
if ($askForMySQLPassword) {
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret(trans('command/messages.environment.database.password'));
}
try {
$this->testMySQLConnection();
} catch (PDOException $exception) {
$this->output->error(trans('command/messages.environment.database.connection_error', ['error' => $exception->getMessage()]));
$this->output->error(trans('command/messages.environment.database.creds_not_saved'));
if ($this->confirm(trans('command/messages.environment.database.try_again'))) {
$this->database->disconnect('_pterodactyl_command_test');
return $this->handle();
}
return 1;
}
$this->writeToEnvironment($this->variables);
$this->info($this->console->output());
return 0;
}
/**
* Test that we can connect to the provided MySQL instance and perform a selection.
*/
private function testMySQLConnection()
{
$this->config->set('database.connections._pterodactyl_command_test', [
'driver' => 'mysql',
'host' => $this->variables['DB_HOST'],
'port' => $this->variables['DB_PORT'],
'database' => $this->variables['DB_DATABASE'],
'username' => $this->variables['DB_USERNAME'],
'password' => $this->variables['DB_PASSWORD'],
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'strict' => true,
]);
$this->database->connection('_pterodactyl_command_test')->getPdo();
}
}

View File

@ -0,0 +1,156 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Environment;
use Illuminate\Console\Command;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class EmailSettingsCommand extends Command
{
use EnvironmentWriterTrait;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var string
*/
protected $description = 'Set or update the email sending configuration for the Panel.';
/**
* @var string
*/
protected $signature = 'p:environment:mail
{--driver= : The mail driver to use.}
{--email= : Email address that messages from the Panel will originate from.}
{--from= : The name emails from the Panel will appear to be from.}
{--encryption=}
{--host=}
{--port=}
{--username=}
{--password=}';
/**
* @var array
*/
protected $variables = [];
/**
* EmailSettingsCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct(ConfigRepository $config)
{
parent::__construct();
$this->config = $config;
}
/**
* Handle command execution.
*/
public function handle()
{
$this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice(
trans('command/messages.environment.mail.ask_driver'), [
'smtp' => 'SMTP Server',
'mail' => 'PHP\'s Internal Mail Function',
'mailgun' => 'Mailgun Transactional Email',
'mandrill' => 'Mandrill Transactional Email',
'postmark' => 'Postmarkapp Transactional Email',
], $this->config->get('mail.driver', 'smtp')
);
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
if (method_exists($this, $method)) {
$this->{$method}();
}
$this->variables['MAIL_FROM'] = $this->option('email') ?? $this->ask(
trans('command/messages.environment.mail.ask_mail_from'), $this->config->get('mail.from.address')
);
$this->variables['MAIL_FROM_NAME'] = $this->option('from') ?? $this->ask(
trans('command/messages.environment.mail.ask_mail_name'), $this->config->get('mail.from.name')
);
$this->variables['MAIL_ENCRYPTION'] = $this->option('encryption') ?? $this->choice(
trans('command/messages.environment.mail.ask_encryption'), ['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'], $this->config->get('mail.encryption', 'tls')
);
$this->writeToEnvironment($this->variables);
$this->line('Updating stored environment configuration file.');
$this->line('');
}
/**
* Handle variables for SMTP driver.
*/
private function setupSmtpDriverVariables()
{
$this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask(
trans('command/messages.environment.mail.ask_smtp_host'), $this->config->get('mail.host')
);
$this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask(
trans('command/messages.environment.mail.ask_smtp_port'), $this->config->get('mail.port')
);
$this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.mail.ask_smtp_username'), $this->config->get('mail.username')
);
$this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret(
trans('command/messages.environment.mail.ask_smtp_password')
);
}
/**
* Handle variables for mailgun driver.
*/
private function setupMailgunDriverVariables()
{
$this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask(
trans('command/messages.environment.mail.ask_mailgun_domain'), $this->config->get('services.mailgun.domain')
);
$this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask(
trans('command/messages.environment.mail.ask_mailgun_secret'), $this->config->get('services.mailgun.secret')
);
}
/**
* Handle variables for mandrill driver.
*/
private function setupMandrillDriverVariables()
{
$this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask(
trans('command/messages.environment.mail.ask_mandrill_secret'), $this->config->get('services.mandrill.secret')
);
}
/**
* Handle variables for postmark driver.
*/
private function setupPostmarkDriverVariables()
{
$this->variables['MAIL_DRIVER'] = 'smtp';
$this->variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
$this->variables['MAIL_PORT'] = 587;
$this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.mail.ask_postmark_username'), $this->config->get('mail.username')
);
}
}

View File

@ -0,0 +1,113 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
use Pterodactyl\Services\Helpers\SoftwareVersionService;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class InfoCommand extends Command
{
/**
* @var string
*/
protected $description = 'Displays the application, database, and email configurations along with the panel version.';
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var string
*/
protected $signature = 'p:info';
/**
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
*/
protected $versionService;
/**
* VersionCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
*/
public function __construct(ConfigRepository $config, SoftwareVersionService $versionService)
{
parent::__construct();
$this->config = $config;
$this->versionService = $versionService;
}
/**
* Handle execution of command.
*/
public function handle()
{
$this->output->title('Version Information');
$this->table([], [
['Panel Version', $this->config->get('app.version')],
['Latest Version', $this->versionService->getPanel()],
['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')],
['Unique Identifier', $this->config->get('pterodactyl.service.author')],
], 'compact');
$this->output->title('Application Configuration');
$this->table([], [
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', ! $this->config->get('app.debug') ?: 'bg=red')],
['Installation URL', $this->config->get('app.url')],
['Installation Directory', base_path()],
['Timezone', $this->config->get('app.timezone')],
['Cache Driver', $this->config->get('cache.default')],
['Queue Driver', $this->config->get('queue.default')],
['Session Driver', $this->config->get('session.driver')],
['Filesystem Driver', $this->config->get('filesystems.default')],
['Default Theme', $this->config->get('themes.active')],
['Proxies', $this->config->get('trustedproxies.proxies')],
], 'compact');
$this->output->title('Database Configuration');
$driver = $this->config->get('database.default');
$this->table([], [
['Driver', $driver],
['Host', $this->config->get("database.connections.{$driver}.host")],
['Port', $this->config->get("database.connections.{$driver}.port")],
['Database', $this->config->get("database.connections.{$driver}.database")],
['Usernamne', $this->config->get("database.connections.{$driver}.username")],
], 'compact');
$this->output->title('Email Configuration');
$this->table([], [
['Driver', $this->config->get('mail.driver')],
['Host', $this->config->get('mail.host')],
['Port', $this->config->get('mail.port')],
['Username', $this->config->get('mail.username')],
['From Address', $this->config->get('mail.from.address')],
['From Name', $this->config->get('mail.from.name')],
['Encryption', $this->config->get('mail.encryption')],
], 'compact');
}
/**
* Format output in a Name: Value manner.
*
* @param string $value
* @param string $opts
* @return string
*/
private function formatText($value, $opts = '')
{
return sprintf('<%s>%s</>', $opts, $value);
}
}

View File

@ -1,33 +0,0 @@
<?php
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL . Inspiring::quote() . PHP_EOL);
}
}

View File

@ -0,0 +1,85 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Location;
use Illuminate\Console\Command;
use Pterodactyl\Services\Locations\LocationDeletionService;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
class DeleteLocationCommand extends Command
{
/**
* @var \Pterodactyl\Services\Locations\LocationDeletionService
*/
protected $deletionService;
/**
* @var string
*/
protected $description = 'Deletes a location from the Panel.';
/**
* @var \Illuminate\Support\Collection
*/
protected $locations;
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $repository;
/**
* @var string
*/
protected $signature = 'p:location:delete {--short= : The short code of the location to delete.}';
/**
* DeleteLocationCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
* @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService
*/
public function __construct(
LocationDeletionService $deletionService,
LocationRepositoryInterface $repository
) {
parent::__construct();
$this->deletionService = $deletionService;
$this->repository = $repository;
}
/**
* Respond to the command request.
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
*/
public function handle()
{
$this->locations = $this->locations ?? $this->repository->all();
$short = $this->option('short') ?? $this->anticipate(
trans('command/messages.location.ask_short'), $this->locations->pluck('short')->toArray()
);
$location = $this->locations->where('short', $short)->first();
if (is_null($location)) {
$this->error(trans('command/messages.location.no_location_found'));
if ($this->input->isInteractive()) {
$this->handle();
}
return;
}
$this->deletionService->handle($location->id);
$this->line(trans('command/messages.location.deleted'));
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Location;
use Illuminate\Console\Command;
use Pterodactyl\Services\Locations\LocationCreationService;
class MakeLocationCommand extends Command
{
/**
* @var \Pterodactyl\Services\Locations\LocationCreationService
*/
protected $creationService;
/**
* @var string
*/
protected $signature = 'p:location:make
{--short= : The shortcode name of this location (ex. us1).}
{--long= : A longer description of this location.}';
/**
* @var string
*/
protected $description = 'Creates a new location on the system via the CLI.';
/**
* Create a new command instance.
*
* @param \Pterodactyl\Services\Locations\LocationCreationService $creationService
*/
public function __construct(LocationCreationService $creationService)
{
parent::__construct();
$this->creationService = $creationService;
}
/**
* Handle the command execution process.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function handle()
{
$short = $this->option('short') ?? $this->ask(trans('command/messages.location.ask_short'));
$long = $this->option('long') ?? $this->ask(trans('command/messages.location.ask_long'));
$location = $this->creationService->handle(compact('short', 'long'));
$this->line(trans('command/messages.location.created', [
'name' => $location->short,
'id' => $location->id,
]));
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Pterodactyl\Console\Commands\Maintenance;
use SplFileInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
class CleanServiceBackupFilesCommand extends Command
{
const BACKUP_THRESHOLD_MINUTES = 5;
/**
* @var string
*/
protected $description = 'Clean orphaned .bak files created when modifying services.';
/**
* @var \Illuminate\Contracts\Filesystem\Filesystem
*/
protected $disk;
/**
* @var string
*/
protected $signature = 'p:maintenance:clean-service-backups';
/**
* CleanServiceBackupFilesCommand constructor.
*
* @param \Illuminate\Contracts\Filesystem\Factory $filesystem
*/
public function __construct(FilesystemFactory $filesystem)
{
parent::__construct();
$this->disk = $filesystem->disk();
}
/**
* Handle command execution.
*/
public function handle()
{
$files = $this->disk->files('services/.bak');
collect($files)->each(function (SplFileInfo $file) {
$lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file->getPath());
$this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file->getFilename()]));
}
});
}
}

View File

@ -1,91 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
use Pterodactyl\Repositories\UserRepository;
class MakeUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:user
{--firstname= : First name to use for this account.}
{--lastname= : Last name to use for this account.}
{--username= : Username to use for this account.}
{--email= : Email address to use for this account.}
{--password= : Password to assign to the user.}
{--admin= : Boolean flag for if user should be an admin.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a user within the panel.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$data['name_first'] = is_null($this->option('firstname')) ? $this->ask('First Name') : $this->option('firstname');
$data['name_last'] = is_null($this->option('lastname')) ? $this->ask('Last Name') : $this->option('lastname');
$data['username'] = is_null($this->option('username')) ? $this->ask('Username') : $this->option('username');
$data['email'] = is_null($this->option('email')) ? $this->ask('Email') : $this->option('email');
$data['password'] = is_null($this->option('password')) ? $this->secret('Password') : $this->option('password');
$password_confirmation = is_null($this->option('password')) ? $this->secret('Confirm Password') : $this->option('password');
if ($data['password'] !== $password_confirmation) {
return $this->error('The passwords provided did not match!');
}
$data['root_admin'] = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
try {
$user = new UserRepository;
$user->create($data);
return $this->info('User successfully created.');
} catch (\Exception $ex) {
return $this->error($ex->getMessage());
}
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Pterodactyl\Console\Commands\Migration;
use Pterodactyl\Models\ApiKey;
use Illuminate\Console\Command;
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
class CleanOrphanedApiKeysCommand extends Command
{
/**
* @var \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface
*/
private $repository;
/**
* @var string
*/
protected $signature = 'p:migration:clean-orphaned-keys';
/**
* @var string
*/
protected $description = 'Cleans API keys from the database that are not assigned a specific role.';
/**
* CleanOrphanedApiKeysCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository
*/
public function __construct(ApiKeyRepositoryInterface $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**
* Delete all orphaned API keys from the database when upgrading from 0.6 to 0.7.
*
* @return null|void
*/
public function handle()
{
$count = $this->repository->findCountWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
$continue = $this->confirm(
'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?', false
);
if (! $continue) {
return null;
}
$this->info('Deleting keys...');
$this->repository->deleteWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
$this->info('Keys were successfully deleted.');
}
}

View File

@ -1,146 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\Server;
use Illuminate\Console\Command;
class RebuildServer extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:rebuild
{--all}
{--node= : Id of node to rebuild all servers on.}
{--server= : UUID of server to rebuild.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Rebuild docker containers for a server or multiple servers.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ($this->option('all')) {
$servers = Server::all();
} elseif ($this->option('node')) {
$servers = Server::where('node_id', $this->option('node'))->get();
} elseif ($this->option('server')) {
$servers = Server::where('id', $this->option('server'))->get();
} else {
$this->error('You must pass a flag to determine which server(s) to rebuild.');
return;
}
$servers->load('node', 'service', 'option.variables', 'pack');
$this->line('Beginning processing, do not exit this script.');
$bar = $this->output->createProgressBar(count($servers));
$results = collect([]);
foreach ($servers as $server) {
try {
$environment = $server->option->variables->map(function ($item, $key) use ($server) {
$display = $server->variables->where('variable_id', $item->id)->pluck('variable_value')->first();
return [
'variable' => $item->env_variable,
'value' => (! is_null($display)) ? $display : $item->default_value,
];
});
$server->node->guzzleClient([
'X-Access-Server' => $server->uuid,
'X-Access-Token' => $server->node->daemonSecret,
])->request('PATCH', '/server', [
'json' => [
'build' => [
'image' => $server->image,
'env|overwrite' => $environment->pluck('value', 'variable')->merge(['STARTUP' => $server->startup]),
],
'service' => [
'type' => $server->service->folder,
'option' => $server->option->tag,
'pack' => ! is_null($server->pack) ? $server->pack->uuid : null,
],
],
]);
$results = $results->merge([
$server->uuid => [
'status' => 'info',
'messages' => [
'[✓] Processed rebuild request for ' . $server->uuid,
],
],
]);
} catch (\Exception $ex) {
$results = $results->merge([
$server->uuid => [
'status' => 'error',
'messages' => [
'[✗] Failed to process rebuild request for ' . $server->uuid,
$ex->getMessage(),
],
],
]);
}
$bar->advance();
}
$bar->finish();
$console = $this;
$this->line("\n");
$results->each(function ($item, $key) use ($console) {
foreach ($item['messages'] as $line) {
$console->{$item['status']}($line);
}
});
$this->line("\nCompleted rebuild command processing.");
}
}

View File

@ -1,81 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Carbon;
use Pterodactyl\Models\Task;
use Illuminate\Console\Command;
use Pterodactyl\Jobs\SendScheduledTask;
use Illuminate\Foundation\Bus\DispatchesJobs;
class RunTasks extends Command
{
use DispatchesJobs;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:tasks';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Find and run scheduled tasks.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$tasks = Task::where('queued', false)->where('active', true)->where('next_run', '<=', Carbon::now()->toAtomString())->get();
$this->info(sprintf('Preparing to queue %d tasks.', count($tasks)));
$bar = $this->output->createProgressBar(count($tasks));
foreach ($tasks as &$task) {
$bar->advance();
$this->dispatch((new SendScheduledTask($task))->onQueue(config('pterodactyl.queues.low')));
}
$bar->finish();
$this->info("\nFinished queuing tasks for running.");
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Schedule;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Pterodactyl\Services\Schedules\ProcessScheduleService;
use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface;
class ProcessRunnableCommand extends Command
{
/**
* @var \Carbon\Carbon
*/
protected $carbon;
/**
* @var string
*/
protected $description = 'Process schedules in the database and determine which are ready to run.';
/**
* @var \Pterodactyl\Services\Schedules\ProcessScheduleService
*/
protected $processScheduleService;
/**
* @var \Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface
*/
protected $repository;
/**
* @var string
*/
protected $signature = 'p:schedule:process';
/**
* ProcessRunnableCommand constructor.
*
* @param \Carbon\Carbon $carbon
* @param \Pterodactyl\Services\Schedules\ProcessScheduleService $processScheduleService
* @param \Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface $repository
*/
public function __construct(
Carbon $carbon,
ProcessScheduleService $processScheduleService,
ScheduleRepositoryInterface $repository
) {
parent::__construct();
$this->carbon = $carbon;
$this->processScheduleService = $processScheduleService;
$this->repository = $repository;
}
/**
* Handle command execution.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function handle()
{
$schedules = $this->repository->getSchedulesToProcess($this->carbon->now()->toAtomString());
$bar = $this->output->createProgressBar(count($schedules));
$schedules->each(function ($schedule) use ($bar) {
if ($schedule->tasks instanceof Collection && count($schedule->tasks) > 0) {
$this->processScheduleService->handle($schedule);
if ($this->input->isInteractive()) {
$bar->clear();
$this->line(trans('command/messages.schedule.output_line', [
'schedule' => $schedule->name,
'hash' => $schedule->hashid,
]));
}
}
$bar->advance();
$bar->display();
});
$this->line('');
}
}

View File

@ -0,0 +1,109 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Server;
use Webmozart\Assert\Assert;
use Illuminate\Console\Command;
use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface;
class RebuildServerCommand extends Command
{
/**
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
*/
protected $configurationStructureService;
/**
* @var \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface
*/
protected $daemonRepository;
/**
* @var string
*/
protected $description = 'Rebuild a single server, all servers on a node, or all servers on the panel.';
/**
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
*/
protected $repository;
/**
* @var string
*/
protected $signature = 'p:server:rebuild
{server? : The ID of the server to rebuild.}
{--node= : ID of the node to rebuild all servers on. Ignored if server is passed.}';
/**
* RebuildServerCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface $daemonRepository
* @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
*/
public function __construct(
DaemonServerRepositoryInterface $daemonRepository,
ServerConfigurationStructureService $configurationStructureService,
ServerRepositoryInterface $repository
) {
parent::__construct();
$this->configurationStructureService = $configurationStructureService;
$this->daemonRepository = $daemonRepository;
$this->repository = $repository;
}
/**
* Handle command execution.
*/
public function handle()
{
$servers = $this->getServersToProcess();
$bar = $this->output->createProgressBar(count($servers));
$servers->each(function ($server) use ($bar) {
$bar->clear();
$json = array_merge($this->configurationStructureService->handle($server), ['rebuild' => true]);
try {
$this->daemonRepository->setServer($server)->update($json);
} catch (RequestException $exception) {
$this->output->error(trans('command/messages.server.rebuild_failed', [
'name' => $server->name,
'id' => $server->id,
'node' => $server->node->name,
'message' => $exception->getMessage(),
]));
}
$bar->advance();
$bar->display();
});
$this->line('');
}
/**
* Return the servers to be rebuilt.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
private function getServersToProcess()
{
Assert::nullOrIntegerish($this->argument('server'), 'Value passed in server argument must be null or an integer, received %s.');
Assert::nullOrIntegerish($this->option('node'), 'Value passed in node option must be null or integer, received %s.');
return $this->repository->getDataForRebuild($this->argument('server'), $this->option('node'));
}
}

View File

@ -1,65 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Version;
use Illuminate\Console\Command;
class ShowVersion extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:version';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display current panel version.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('You are running Pterodactyl Panel v' . Version::getCurrentPanel() . ' (' . ((Version::isLatestPanel()) ? 'Up to Date' : 'Latest: ' . Version::getDaemon()) . ')');
}
}

View File

@ -1,170 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Illuminate\Console\Command;
class UpdateEmailSettings extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:mail
{--driver=}
{--email=}
{--from-name=}
{--host=}
{--port=}
{--username=}
{--password=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Sets or updates email settings for the .env file.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$variables = [];
$file = base_path() . '/.env';
if (! file_exists($file)) {
$this->error('Missing environment file! It appears that you have not installed this panel correctly.');
exit();
}
$envContents = file_get_contents($file);
$this->table([
'Option',
'Description',
], [
[
'smtp',
'SMTP Server Email',
],
[
'mail',
'PHP\'s Internal Mail Server',
],
[
'mailgun',
'Mailgun Email Service',
],
[
'mandrill',
'Mandrill Transactional Email Service',
],
[
'postmark',
'Postmark Transactional Email Service',
],
]);
$variables['MAIL_DRIVER'] = is_null($this->option('driver')) ? $this->choice('Which email driver would you like to use?', [
'smtp',
'mail',
'mailgun',
'mandrill',
'postmark',
]) : $this->option('driver');
switch ($variables['MAIL_DRIVER']) {
case 'smtp':
$variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)', config('mail.host')) : $this->option('host');
$variables['MAIL_PORT'] = is_null($this->option('port')) ? $this->anticipate('SMTP Host Port (e.g 587)', ['587', config('mail.port')], config('mail.port')) : $this->option('port');
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username', config('mail.username')) : $this->option('password');
$variables['MAIL_PASSWORD'] = is_null($this->option('password')) ? $this->secret('SMTP Password') : $this->option('password');
break;
case 'mail':
break;
case 'mailgun':
$variables['MAILGUN_DOMAIN'] = is_null($this->option('host')) ? $this->ask('Mailgun Domain') : $this->option('host');
$variables['MAILGUN_KEY'] = is_null($this->option('username')) ? $this->ask('Mailgun Key') : $this->option('username');
break;
case 'mandrill':
$variables['MANDRILL_SECRET'] = is_null($this->option('username')) ? $this->ask('Mandrill Secret') : $this->option('username');
break;
case 'postmark':
$variables['MAIL_DRIVER'] = 'smtp';
$variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
$variables['MAIL_PORT'] = 587;
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token', config('mail.username')) : $this->option('username');
$variables['MAIL_PASSWORD'] = $variables['MAIL_USERNAME'];
break;
default:
$this->error('No email service was defined!');
exit();
break;
}
$variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from', config('mail.from.address')) : $this->option('email');
$variables['MAIL_FROM_NAME'] = is_null($this->option('from-name')) ? $this->ask('Name emails should appear to be from', config('mail.from.name')) : $this->option('from-name');
$variables['MAIL_FROM_NAME'] = '"' . $variables['MAIL_FROM_NAME'] . '"';
$variables['MAIL_ENCRYPTION'] = 'tls';
$bar = $this->output->createProgressBar(count($variables));
$this->line('Writing new email environment configuration to file.');
foreach ($variables as $key => $value) {
if (str_contains($value, ' ') && ! str_contains($value, '"')) {
$value = '"' . $value . '"';
}
$newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:mail';
if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
$envContents = $envContents . "\n" . $newValue;
} else {
$envContents = preg_replace('/^' . $key . '=(.*)$/m', $newValue, $envContents);
}
$bar->advance();
}
file_put_contents($file, $envContents);
$bar->finish();
$this->line('Updating evironment configuration cache file.');
$this->call('config:cache');
echo "\n";
}
}

View File

@ -1,208 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Console\Commands;
use Uuid;
use Illuminate\Console\Command;
class UpdateEnvironment extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pterodactyl:env
{--dbhost=}
{--dbport=}
{--dbname=}
{--dbuser=}
{--dbpass=}
{--url=}
{--driver=}
{--session-driver=}
{--queue-driver=}
{--timezone=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update environment settings automatically.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$variables = [];
$file = base_path() . '/.env';
if (! file_exists($file)) {
$this->error('Missing environment file! It appears that you have not installed this panel correctly.');
exit();
}
$envContents = file_get_contents($file);
$this->info('Simply leave blank and press enter to fields that you do not wish to update.');
if (is_null(config('pterodactyl.service.author', null))) {
$this->info('No service author set, setting one now.');
$variables['SERVICE_AUTHOR'] = (string) Uuid::generate(4);
}
if (isset($variables['APP_THEME'])) {
if ($variables['APP_THEME'] === 'default') {
$variables['APP_THEME'] = 'pterodactyl';
}
}
if (is_null($this->option('dbhost'))) {
$variables['DB_HOST'] = $this->anticipate('Database Host', ['localhost', '127.0.0.1', config('database.connections.mysql.host')], config('database.connections.mysql.host'));
} else {
$variables['DB_HOST'] = $this->option('dbhost');
}
if (is_null($this->option('dbport'))) {
$variables['DB_PORT'] = $this->anticipate('Database Port', [3306, config('database.connections.mysql.port')], config('database.connections.mysql.port'));
} else {
$variables['DB_PORT'] = $this->option('dbport');
}
if (is_null($this->option('dbname'))) {
$variables['DB_DATABASE'] = $this->anticipate('Database Name', ['pterodactyl', 'homestead', config('database.connections.mysql.database')], config('database.connections.mysql.database'));
} else {
$variables['DB_DATABASE'] = $this->option('dbname');
}
if (is_null($this->option('dbuser'))) {
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [config('database.connections.mysql.username')], config('database.connections.mysql.username'));
} else {
$variables['DB_USERNAME'] = $this->option('dbuser');
}
if (is_null($this->option('dbpass'))) {
$this->line('The Database Password field is required; you cannot hit enter and use a default value.');
$variables['DB_PASSWORD'] = $this->secret('Database User Password');
} else {
$variables['DB_PASSWORD'] = $this->option('dbpass');
}
if (is_null($this->option('url'))) {
$variables['APP_URL'] = $this->ask('Panel URL (include http(s)://)', config('app.url'));
} else {
$variables['APP_URL'] = $this->option('url');
}
if (is_null($this->option('timezone'))) {
$this->line('The timezone should match one of the supported timezones according to http://php.net/manual/en/timezones.php');
$variables['APP_TIMEZONE'] = $this->anticipate('Panel Timezone', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL), config('app.timezone'));
} else {
$variables['APP_TIMEZONE'] = $this->option('timezone');
}
if (is_null($this->option('driver'))) {
$options = [
'memcached' => 'Memcache',
'redis' => 'Redis (recommended)',
'apc' => 'APC',
'array' => 'PHP Array',
];
$default = (in_array(config('cache.default', 'memcached'), $options)) ? config('cache.default', 'memcached') : 'memcached';
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
$variables['CACHE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', $options, $default);
} else {
$variables['CACHE_DRIVER'] = $this->option('driver');
}
if (is_null($this->option('session-driver'))) {
$options = [
'database' => 'MySQL (recommended)',
'redis' => 'Redis',
'file' => 'File',
'cookie' => 'Cookie',
'apc' => 'APC',
'array' => 'PHP Array',
];
$default = (in_array(config('session.driver', 'database'), $options)) ? config('cache.default', 'database') : 'database';
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
$variables['SESSION_DRIVER'] = $this->choice('Which session driver backend would you like to use?', $options, $default);
} else {
$variables['SESSION_DRIVER'] = $this->option('session-driver');
}
if (is_null($this->option('queue-driver'))) {
$options = [
'database' => 'Database (recommended)',
'redis' => 'Redis',
'sqs' => 'Amazon SQS',
'sync' => 'Sync',
'null' => 'None',
];
$default = (in_array(config('queue.driver', 'database'), $options)) ? config('queue.driver', 'database') : 'database';
$this->line('If you chose redis as your queue driver backend, you *must* have a redis server configured already.');
$variables['QUEUE_DRIVER'] = $this->choice('Which queue driver backend would you like to use?', $options, $default);
} else {
$variables['QUEUE_DRIVER'] = $this->option('queue-driver');
}
$bar = $this->output->createProgressBar(count($variables));
foreach ($variables as $key => $value) {
if (str_contains($value, ' ') && ! str_contains($value, '"')) {
$value = '"' . $value . '"';
}
$newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:env';
if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
$envContents = $envContents . "\n" . $newValue;
} else {
$envContents = preg_replace('/^' . $key . '=(.*)$/m', $newValue, $envContents);
}
$bar->advance();
}
file_put_contents($file, $envContents);
$bar->finish();
$this->call('config:cache');
$this->line("\n");
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\User;
use Webmozart\Assert\Assert;
use Illuminate\Console\Command;
use Pterodactyl\Services\Users\UserDeletionService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class DeleteUserCommand extends Command
{
/**
* @var \Pterodactyl\Services\Users\UserDeletionService
*/
protected $deletionService;
/**
* @var string
*/
protected $description = 'Deletes a user from the Panel if no servers are attached to their account.';
/**
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
*/
protected $repository;
/**
* @var string
*/
protected $signature = 'p:user:delete {--user=}';
/**
* DeleteUserCommand constructor.
*
* @param \Pterodactyl\Services\Users\UserDeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(
UserDeletionService $deletionService,
UserRepositoryInterface $repository
) {
parent::__construct();
$this->deletionService = $deletionService;
$this->repository = $repository;
}
/**
* @return bool
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function handle()
{
$search = $this->option('user') ?? $this->ask(trans('command/messages.user.search_users'));
Assert::notEmpty($search, 'Search term must be a non-null value, received %s.');
$results = $this->repository->setSearchTerm($search)->all();
if (count($results) < 1) {
$this->error(trans('command/messages.user.no_users_found'));
if ($this->input->isInteractive()) {
return $this->handle();
}
return false;
}
if ($this->input->isInteractive()) {
$tableValues = [];
foreach ($results as $user) {
$tableValues[] = [$user->id, $user->email, $user->name];
}
$this->table(['User ID', 'Email', 'Name'], $tableValues);
if (! $deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) {
return $this->handle();
}
} else {
if (count($results) > 1) {
$this->error(trans('command/messages.user.multiple_found'));
return false;
}
$deleteUser = $results->first();
}
if ($this->confirm(trans('command/messages.user.confirm_delete')) || ! $this->input->isInteractive()) {
$this->deletionService->handle($deleteUser);
$this->info(trans('command/messages.user.deleted'));
}
}
}

View File

@ -0,0 +1,65 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\User;
use Illuminate\Console\Command;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class DisableTwoFactorCommand extends Command
{
/**
* @var string
*/
protected $description = 'Disable two-factor authentication for a specific user in the Panel.';
/**
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
*/
protected $repository;
/**
* @var string
*/
protected $signature = 'p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}';
/**
* DisableTwoFactorCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(UserRepositoryInterface $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**
* Handle command execution process.
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function handle()
{
if ($this->input->isInteractive()) {
$this->output->warning(trans('command/messages.user.2fa_help_text'));
}
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
$user = $this->repository->setColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]);
$this->repository->withoutFreshModel()->update($user->id, [
'use_totp' => false,
'totp_secret' => null,
]);
$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));
}
}

View File

@ -0,0 +1,73 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\User;
use Illuminate\Console\Command;
use Pterodactyl\Services\Users\UserCreationService;
class MakeUserCommand extends Command
{
/**
* @var \Pterodactyl\Services\Users\UserCreationService
*/
protected $creationService;
/**
* @var string
*/
protected $description = 'Creates a user on the system via the CLI.';
/**
* @var string
*/
protected $signature = 'p:user:make {--email=} {--username=} {--name-first=} {--name-last=} {--password=} {--admin=} {--no-password}';
/**
* MakeUserCommand constructor.
*
* @param \Pterodactyl\Services\Users\UserCreationService $creationService
*/
public function __construct(UserCreationService $creationService)
{
parent::__construct();
$this->creationService = $creationService;
}
/**
* Handle command request to create a new user.
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function handle()
{
$root_admin = $this->option('admin') ?? $this->confirm(trans('command/messages.user.ask_admin'));
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
$username = $this->option('username') ?? $this->ask(trans('command/messages.user.ask_username'));
$name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first'));
$name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last'));
if (is_null($password = $this->option('password')) && ! $this->option('no-password')) {
$this->warn(trans('command/messages.user.ask_password_help'));
$this->line(trans('command/messages.user.ask_password_tip'));
$password = $this->secret(trans('command/messages.user.ask_password'));
}
$user = $this->creationService->handle(compact('email', 'username', 'name_first', 'name_last', 'password', 'root_admin'));
$this->table(['Field', 'Value'], [
['UUID', $user->uuid],
['Email', $user->email],
['Username', $user->username],
['Name', $user->name],
['Admin', $user->root_admin ? 'Yes' : 'No'],
]);
}
}

View File

@ -8,35 +8,21 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/** /**
* The Artisan commands provided by your application. * Register the commands for the application.
*
* @var array
*/ */
protected $commands = [ protected function commands()
\Pterodactyl\Console\Commands\Inspire::class, {
\Pterodactyl\Console\Commands\MakeUser::class, $this->load(__DIR__ . '/Commands');
\Pterodactyl\Console\Commands\ShowVersion::class, }
\Pterodactyl\Console\Commands\UpdateEnvironment::class,
\Pterodactyl\Console\Commands\RunTasks::class,
\Pterodactyl\Console\Commands\ClearTasks::class,
\Pterodactyl\Console\Commands\ClearServices::class,
\Pterodactyl\Console\Commands\UpdateEmailSettings::class,
\Pterodactyl\Console\Commands\CleanServiceBackup::class,
\Pterodactyl\Console\Commands\AddNode::class,
\Pterodactyl\Console\Commands\AddLocation::class,
\Pterodactyl\Console\Commands\RebuildServer::class,
];
/** /**
* Define the application's command schedule. * Define the application's command schedule.
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
$schedule->command('pterodactyl:tasks')->everyMinute()->withoutOverlapping(); $schedule->command('p:schedule:process')->everyMinute()->withoutOverlapping();
$schedule->command('pterodactyl:tasks:clearlog')->twiceDaily(3, 15); $schedule->command('p:maintenance:clean-service-backups')->daily();
$schedule->command('pterodactyl:cleanservices')->twiceDaily(1, 13);
} }
} }

View File

@ -0,0 +1,24 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Criteria;
use Pterodactyl\Repositories\Repository;
interface CriteriaInterface
{
/**
* Apply selected criteria to a repository call.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Pterodactyl\Repositories\Repository $repository
* @return mixed
*/
public function apply($model, Repository $repository);
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Extensions;
use Hashids\HashidsInterface as VendorHashidsInterface;
interface HashidsInterface extends VendorHashidsInterface
{
/**
* Decode an encoded hashid and return the first result.
*
* @param string $encoded
* @param null $default
* @return mixed
*
* @throws \InvalidArgumentException
*/
public function decodeFirst($encoded, $default = null);
}

View File

@ -0,0 +1,83 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
interface AllocationRepositoryInterface extends RepositoryInterface
{
/**
* Set an array of allocation IDs to be assigned to a specific server.
*
* @param int|null $server
* @param array $ids
* @return int
*/
public function assignAllocationsToServer(int $server = null, array $ids): int;
/**
* Return all of the allocations for a specific node.
*
* @param int $node
* @return \Illuminate\Support\Collection
*/
public function getAllocationsForNode(int $node): Collection;
/**
* Return all of the allocations for a node in a paginated format.
*
* @param int $node
* @param int $perPage
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getPaginatedAllocationsForNode(int $node, int $perPage = 100): LengthAwarePaginator;
/**
* Return all of the unique IPs that exist for a given node.
*
* @param int $node
* @return \Illuminate\Support\Collection
*/
public function getUniqueAllocationIpsForNode(int $node): Collection;
/**
* Return all of the allocations that exist for a node that are not currently
* allocated.
*
* @param int $node
* @return array
*/
public function getUnassignedAllocationIds(int $node): array;
/**
* Get an array of all allocations that are currently assigned to a given server.
*
* @param int $server
* @return array
*/
public function getAssignedAllocationIds(int $server): array;
/**
* Return a concated result set of node ips that already have at least one
* server assigned to that IP. This allows for filtering out sets for
* dedicated allocation IPs.
*
* If an array of nodes is passed the results will be limited to allocations
* in those nodes.
*
* @param array $nodes
* @return array
*/
public function getDiscardableDedicatedAllocations(array $nodes = []): array;
/**
* Return a single allocation from those meeting the requirements.
*
* @param array $nodes
* @param array $ports
* @param bool $dedicated
* @return \Pterodactyl\Models\Allocation|null
*/
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false);
}

View File

@ -0,0 +1,43 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\User;
use Illuminate\Support\Collection;
interface ApiKeyRepositoryInterface extends RepositoryInterface
{
/**
* Get all of the account API keys that exist for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @return \Illuminate\Support\Collection
*/
public function getAccountKeys(User $user): Collection;
/**
* Get all of the application API keys that exist for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @return \Illuminate\Support\Collection
*/
public function getApplicationKeys(User $user): Collection;
/**
* Delete an account API key from the panel for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @param string $identifier
* @return int
*/
public function deleteAccountKey(User $user, string $identifier): int;
/**
* Delete an application API key from the panel for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @param string $identifier
* @return int
*/
public function deleteApplicationKey(User $user, string $identifier): int;
}

View File

@ -0,0 +1,14 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Repository;
interface ApiPermissionRepositoryInterface extends RepositoryInterface
{
}

View File

@ -0,0 +1,38 @@
<?php
namespace Pterodactyl\Contracts\Repository\Attributes;
interface SearchableInterface
{
/**
* Set the search term.
*
* @param string|null $term
* @return $this
* @deprecated
*/
public function search($term);
/**
* Set the search term to use when requesting all records from
* the model.
*
* @param string|null $term
* @return $this
*/
public function setSearchTerm(string $term = null);
/**
* Determine if a valid search term is set on this repository.
*
* @return bool
*/
public function hasSearchTerm(): bool;
/**
* Return the search term.
*
* @return string|null
*/
public function getSearchTerm();
}

View File

@ -0,0 +1,65 @@
<?php
namespace Pterodactyl\Contracts\Repository\Daemon;
use GuzzleHttp\Client;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\Server;
interface BaseRepositoryInterface
{
/**
* Set the node model to be used for this daemon connection.
*
* @param \Pterodactyl\Models\Node $node
* @return $this
*/
public function setNode(Node $node);
/**
* Return the node model being used.
*
* @return \Pterodactyl\Models\Node|null
*/
public function getNode();
/**
* Set the Server model to use when requesting information from the Daemon.
*
* @param \Pterodactyl\Models\Server $server
* @return $this
*/
public function setServer(Server $server);
/**
* Return the Server model.
*
* @return \Pterodactyl\Models\Server|null
*/
public function getServer();
/**
* Set the token to be used in the X-Access-Token header for requests to the daemon.
*
* @param string $token
* @return $this
*/
public function setToken(string $token);
/**
* Return the access token being used for requests.
*
* @return string|null
*/
public function getToken();
/**
* Return an instance of the Guzzle HTTP Client to be used for requests.
*
* @param array $headers
* @return \GuzzleHttp\Client
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getHttpClient(array $headers = []): Client;
}

View File

@ -0,0 +1,16 @@
<?php
namespace Pterodactyl\Contracts\Repository\Daemon;
use Psr\Http\Message\ResponseInterface;
interface CommandRepositoryInterface extends BaseRepositoryInterface
{
/**
* Send a command to a server.
*
* @param string $command
* @return \Psr\Http\Message\ResponseInterface
*/
public function send(string $command): ResponseInterface;
}

View File

@ -0,0 +1,16 @@
<?php
namespace Pterodactyl\Contracts\Repository\Daemon;
use Psr\Http\Message\ResponseInterface;
interface ConfigurationRepositoryInterface extends BaseRepositoryInterface
{
/**
* Update the configuration details for the specified node using data from the database.
*
* @param array $overrides
* @return \Psr\Http\Message\ResponseInterface
*/
public function update(array $overrides = []): ResponseInterface;
}

View File

@ -0,0 +1,50 @@
<?php
namespace Pterodactyl\Contracts\Repository\Daemon;
use stdClass;
use Psr\Http\Message\ResponseInterface;
interface FileRepositoryInterface extends BaseRepositoryInterface
{
/**
* Return stat information for a given file.
*
* @param string $path
* @return \stdClass
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public function getFileStat(string $path): stdClass;
/**
* Return the contents of a given file if it can be edited in the Panel.
*
* @param string $path
* @return string
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public function getContent(string $path): string;
/**
* Save new contents to a given file.
*
* @param string $path
* @param string $content
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public function putContent(string $path, string $content): ResponseInterface;
/**
* Return a directory listing for a given path.
*
* @param string $path
* @return array
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public function getDirectory(string $path): array;
}

View File

@ -0,0 +1,23 @@
<?php
namespace Pterodactyl\Contracts\Repository\Daemon;
use Psr\Http\Message\ResponseInterface;
interface PowerRepositoryInterface extends BaseRepositoryInterface
{
const SIGNAL_START = 'start';
const SIGNAL_STOP = 'stop';
const SIGNAL_RESTART = 'restart';
const SIGNAL_KILL = 'kill';
/**
* Send a power signal to a server.
*
* @param string $signal
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
*/
public function sendSignal(string $signal): ResponseInterface;
}

View File

@ -0,0 +1,80 @@
<?php
namespace Pterodactyl\Contracts\Repository\Daemon;
use Psr\Http\Message\ResponseInterface;
interface ServerRepositoryInterface extends BaseRepositoryInterface
{
/**
* Create a new server on the daemon for the panel.
*
* @param array $structure
* @param array $overrides
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public function create(array $structure, array $overrides = []): ResponseInterface;
/**
* Update server details on the daemon.
*
* @param array $data
* @return \Psr\Http\Message\ResponseInterface
*/
public function update(array $data): ResponseInterface;
/**
* Mark a server to be reinstalled on the system.
*
* @param array|null $data
* @return \Psr\Http\Message\ResponseInterface
*/
public function reinstall(array $data = null): ResponseInterface;
/**
* Mark a server as needing a container rebuild the next time the server is booted.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function rebuild(): ResponseInterface;
/**
* Suspend a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function suspend(): ResponseInterface;
/**
* Un-suspend a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function unsuspend(): ResponseInterface;
/**
* Delete a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function delete(): ResponseInterface;
/**
* Return detials on a specific server.
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function details(): ResponseInterface;
/**
* Revoke an access key on the daemon before the time is expired.
*
* @param string|array $key
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public function revokeAccessKey($key): ResponseInterface;
}

View File

@ -0,0 +1,52 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\User;
use Pterodactyl\Models\DaemonKey;
use Illuminate\Support\Collection;
interface DaemonKeyRepositoryInterface extends RepositoryInterface
{
/**
* String prepended to keys to identify that they are managed internally and not part of the user API.
*/
const INTERNAL_KEY_IDENTIFIER = 'i_';
/**
* Load the server and user relations onto a key model.
*
* @param \Pterodactyl\Models\DaemonKey $key
* @param bool $refresh
* @return \Pterodactyl\Models\DaemonKey
*/
public function loadServerAndUserRelations(DaemonKey $key, bool $refresh = false): DaemonKey;
/**
* Return a daemon key with the associated server relation attached.
*
* @param string $key
* @return \Pterodactyl\Models\DaemonKey
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getKeyWithServer(string $key): DaemonKey;
/**
* Get all of the keys for a specific user including the information needed
* from their server relation for revocation on the daemon.
*
* @param \Pterodactyl\Models\User $user
* @return \Illuminate\Support\Collection
*/
public function getKeysForRevocation(User $user): Collection;
/**
* Delete an array of daemon keys from the database. Used primarily in
* conjunction with getKeysForRevocation.
*
* @param array $ids
* @return bool|int
*/
public function deleteKeys(array $ids);
}

View File

@ -0,0 +1,28 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
use Pterodactyl\Models\DatabaseHost;
interface DatabaseHostRepositoryInterface extends RepositoryInterface
{
/**
* Return database hosts with a count of databases and the node
* information for which it is attached.
*
* @return \Illuminate\Support\Collection
*/
public function getWithViewDetails(): Collection;
/**
* Return a database host with the databases and associated servers
* that are attached to said databases.
*
* @param int $id
* @return \Pterodactyl\Models\DatabaseHost
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithServers(int $id): DatabaseHost;
}

View File

@ -0,0 +1,105 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Database;
use Illuminate\Support\Collection;
interface DatabaseRepositoryInterface extends RepositoryInterface
{
const DEFAULT_CONNECTION_NAME = 'dynamic';
/**
* Set the connection name to execute statements against.
*
* @param string $connection
* @return $this
*/
public function setConnection(string $connection);
/**
* Return the connection to execute statements aganist.
*
* @return string
*/
public function getConnection(): string;
/**
* Return all of the databases belonging to a server.
*
* @param int $server
* @return \Illuminate\Support\Collection
*/
public function getDatabasesForServer(int $server): Collection;
/**
* Create a new database if it does not already exist on the host with
* the provided details.
*
* @param array $data
* @return \Pterodactyl\Models\Database
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException
*/
public function createIfNotExists(array $data): Database;
/**
* Create a new database on a given connection.
*
* @param string $database
* @return bool
*/
public function createDatabase(string $database): bool;
/**
* Create a new database user on a given connection.
*
* @param string $username
* @param string $remote
* @param string $password
* @return bool
*/
public function createUser(string $username, string $remote, string $password): bool;
/**
* Give a specific user access to a given database.
*
* @param string $database
* @param string $username
* @param string $remote
* @return bool
*/
public function assignUserToDatabase(string $database, string $username, string $remote): bool;
/**
* Flush the privileges for a given connection.
*
* @return bool
*/
public function flush(): bool;
/**
* Drop a given database on a specific connection.
*
* @param string $database
* @return bool
*/
public function dropDatabase(string $database): bool;
/**
* Drop a given user on a specific connection.
*
* @param string $username
* @param string $remote
* @return mixed
*/
public function dropUser(string $username, string $remote): bool;
}

View File

@ -0,0 +1,61 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Egg;
use Illuminate\Database\Eloquent\Collection;
interface EggRepositoryInterface extends RepositoryInterface
{
/**
* Return an egg with the variables relation attached.
*
* @param int $id
* @return \Pterodactyl\Models\Egg
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithVariables(int $id): Egg;
/**
* Return all eggs and their relations to be used in the daemon API.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getAllWithCopyAttributes(): Collection;
/**
* Return an egg with the scriptFrom and configFrom relations loaded onto the model.
*
* @param int|string $value
* @param string $column
* @return \Pterodactyl\Models\Egg
*/
public function getWithCopyAttributes($value, string $column = 'id'): Egg;
/**
* Return all of the data needed to export a service.
*
* @param int $id
* @return \Pterodactyl\Models\Egg
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithExportAttributes(int $id): Egg;
/**
* Confirm a copy script belongs to the same nest as the item trying to use it.
*
* @param int $copyFromId
* @param int $service
* @return bool
*/
public function isCopiableScript(int $copyFromId, int $service): bool;
}

View File

@ -0,0 +1,24 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
interface EggVariableRepositoryInterface extends RepositoryInterface
{
/**
* Return editable variables for a given egg. Editable variables must be set to
* user viewable in order to be picked up by this function.
*
* @param int $egg
* @return \Illuminate\Support\Collection
*/
public function getEditableVariables(int $egg): Collection;
}

View File

@ -0,0 +1,44 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Location;
use Illuminate\Support\Collection;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface LocationRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Return locations with a count of nodes and servers attached to it.
*
* @return \Illuminate\Support\Collection
*/
public function getAllWithDetails(): Collection;
/**
* Return all of the available locations with the nodes as a relationship.
*
* @return \Illuminate\Support\Collection
*/
public function getAllWithNodes(): Collection;
/**
* Return all of the nodes and their respective count of servers for a location.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithNodes(int $id): Location;
/**
* Return a location and the count of nodes in that location.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithNodeCount(int $id): Location;
}

View File

@ -0,0 +1,45 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Nest;
interface NestRepositoryInterface extends RepositoryInterface
{
/**
* Return a nest or all nests with their associated eggs, variables, and packs.
*
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithEggs(int $id = null);
/**
* Return a nest or all nests and the count of eggs, packs, and servers for that nest.
*
* @param int|null $id
* @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithCounts(int $id = null);
/**
* Return a nest along with its associated eggs and the servers relation on those eggs.
*
* @param int $id
* @return \Pterodactyl\Models\Nest
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithEggServers(int $id): Nest;
}

View File

@ -0,0 +1,77 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Generator;
use Pterodactyl\Models\Node;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterface
{
const THRESHOLD_PERCENTAGE_LOW = 75;
const THRESHOLD_PERCENTAGE_MEDIUM = 90;
/**
* Return the usage stats for a single node.
*
* @param \Pterodactyl\Models\Node $node
* @return array
*/
public function getUsageStats(Node $node): array;
/**
* Return all available nodes with a searchable interface.
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getNodeListingData(): LengthAwarePaginator;
/**
* Return a single node with location and server information.
*
* @param \Pterodactyl\Models\Node $node
* @param bool $refresh
* @return \Pterodactyl\Models\Node
*/
public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node;
/**
* Attach a paginated set of allocations to a node mode including
* any servers that are also attached to those allocations.
*
* @param \Pterodactyl\Models\Node $node
* @param bool $refresh
* @return \Pterodactyl\Models\Node
*/
public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
/**
* Return a node with all of the servers attached to that node.
*
* @param int $id
* @return \Pterodactyl\Models\Node
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getNodeServers(int $id): Node;
/**
* Return a collection of nodes for all locations to use in server creation UI.
*
* @return \Illuminate\Support\Collection
*/
public function getNodesForServerCreation(): Collection;
/**
* Return the IDs of all nodes that exist in the provided locations and have the space
* available to support the additional disk and memory provided.
*
* @param array $locations
* @param int $disk
* @param int $memory
* @return \Generator
*/
public function getNodesWithResourceUse(array $locations, int $disk, int $memory): Generator;
}

View File

@ -0,0 +1,26 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Pack;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface PackRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Return a pack with the associated server models attached to it.
*
* @param \Pterodactyl\Models\Pack $pack
* @param bool $refresh
* @return \Pterodactyl\Models\Pack
*/
public function loadServerData(Pack $pack, bool $refresh = false): Pack;
/**
* Return a paginated listing of packs with their associated egg and server count.
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginateWithEggAndServerCount(): LengthAwarePaginator;
}

View File

@ -0,0 +1,14 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Contracts\Repository;
interface PermissionRepositoryInterface extends RepositoryInterface
{
}

View File

@ -0,0 +1,203 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
interface RepositoryInterface
{
/**
* Return an identifier or Model object to be used by the repository.
*
* @return string|\Closure|object
*/
public function model();
/**
* Return the model being used for this repository instance.
*
* @return mixed
*/
public function getModel();
/**
* Returns an instance of a query builder.
*
* @return mixed
*/
public function getBuilder();
/**
* Returns the colummns to be selected or returned by the query.
*
* @return mixed
*/
public function getColumns();
/**
* An array of columns to filter the response by.
*
* @param array|string $columns
* @return $this
*/
public function setColumns($columns = ['*']);
/**
* Stop repository update functions from returning a fresh
* model when changes are committed.
*
* @return $this
*/
public function withoutFreshModel();
/**
* Return a fresh model with a repository updates a model.
*
* @return $this
*/
public function withFreshModel();
/**
* Set wether or not the repository should return a fresh model
* when changes are committed.
*
* @param bool $fresh
* @return $this
*/
public function setFreshModel(bool $fresh = true);
/**
* Create a new model instance and persist it to the database.
*
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function create(array $fields, bool $validate = true, bool $force = false);
/**
* Find a model that has the specific ID passed.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function find(int $id);
/**
* Find a model matching an array of where clauses.
*
* @param array $fields
* @return \Illuminate\Support\Collection
*/
public function findWhere(array $fields): Collection;
/**
* Find and return the first matching instance for the given fields.
*
* @param array $fields
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function findFirstWhere(array $fields);
/**
* Return a count of records matching the passed arguments.
*
* @param array $fields
* @return int
*/
public function findCountWhere(array $fields): int;
/**
* Delete a given record from the database.
*
* @param int $id
* @return int
*/
public function delete(int $id): int;
/**
* Delete records matching the given attributes.
*
* @param array $attributes
* @return int
*/
public function deleteWhere(array $attributes): int;
/**
* Update a given ID with the passed array of fields.
*
* @param int $id
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update($id, array $fields, bool $validate = true, bool $force = false);
/**
* Perform a mass update where matching records are updated using whereIn.
* This does not perform any model data validation.
*
* @param string $column
* @param array $values
* @param array $fields
* @return int
*/
public function updateWhereIn(string $column, array $values, array $fields): int;
/**
* Update a record if it exists in the database, otherwise create it.
*
* @param array $where
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function updateOrCreate(array $where, array $fields, bool $validate = true, bool $force = false);
/**
* Return all records associated with the given model.
*
* @return Collection
*/
public function all(): Collection;
/**
* Return a paginated result set using a search term if set on the repository.
*
* @param int $perPage
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginated(int $perPage): LengthAwarePaginator;
/**
* Insert a single or multiple records into the database at once skipping
* validation and mass assignment checking.
*
* @param array $data
* @return bool
*/
public function insert(array $data): bool;
/**
* Insert multiple records into the database and ignore duplicates.
*
* @param array $values
* @return bool
*/
public function insertIgnore(array $values): bool;
}

View File

@ -0,0 +1,45 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Schedule;
use Illuminate\Support\Collection;
interface ScheduleRepositoryInterface extends RepositoryInterface
{
/**
* Return all of the schedules for a given server.
*
* @param int $server
* @return \Illuminate\Support\Collection
*/
public function findServerSchedules(int $server): Collection;
/**
* Load the tasks relationship onto the Schedule module if they are not
* already present.
*
* @param \Pterodactyl\Models\Schedule $schedule
* @param bool $refresh
* @return \Pterodactyl\Models\Schedule
*/
public function loadTasks(Schedule $schedule, bool $refresh = false): Schedule;
/**
* Return a schedule model with all of the associated tasks as a relationship.
*
* @param int $schedule
* @return \Pterodactyl\Models\Schedule
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getScheduleWithTasks(int $schedule): Schedule;
/**
* Return all of the schedules that should be processed.
*
* @param string $timestamp
* @return \Illuminate\Support\Collection
*/
public function getSchedulesToProcess(string $timestamp): Collection;
}

View File

@ -0,0 +1,119 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface ServerRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Returns a listing of all servers that exist including relationships.
*
* @param int $paginate
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getAllServers(int $paginate): LengthAwarePaginator;
/**
* Load the egg relations onto the server model.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function loadEggRelations(Server $server, bool $refresh = false): Server;
/**
* Return a collection of servers with their associated data for rebuild operations.
*
* @param int|null $server
* @param int|null $node
* @return \Illuminate\Support\Collection
*/
public function getDataForRebuild(int $server = null, int $node = null): Collection;
/**
* Return a server model and all variables associated with the server.
*
* @param int $id
* @return \Pterodactyl\Models\Server
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function findWithVariables(int $id): Server;
/**
* Get the primary allocation for a given server. If a model is passed into
* the function, load the allocation relationship onto it. Otherwise, find and
* return the server from the database.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function getPrimaryAllocation(Server $server, bool $refresh = false): Server;
/**
* Return all of the server variables possible and default to the variable
* default if there is no value defined for the specific server requested.
*
* @param int $id
* @param bool $returnAsObject
* @return array|object
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getVariablesWithValues(int $id, bool $returnAsObject = false);
/**
* Return enough data to be used for the creation of a server via the daemon.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function getDataForCreation(Server $server, bool $refresh = false): Server;
/**
* Load associated databases onto the server model.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function loadDatabaseRelations(Server $server, bool $refresh = false): Server;
/**
* Get data for use when updating a server on the Daemon. Returns an array of
* the egg and pack UUID which are used for build and rebuild. Only loads relations
* if they are missing, or refresh is set to true.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return array
*/
public function getDaemonServiceData(Server $server, bool $refresh = false): array;
/**
* Return a paginated list of servers that a user can access at a given level.
*
* @param \Pterodactyl\Models\User $user
* @param int $level
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public function filterUserAccessServers(User $user, int $level): LengthAwarePaginator;
/**
* Return a server by UUID.
*
* @param string $uuid
* @return \Pterodactyl\Models\Server
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getByUuid(string $uuid): Server;
}

View File

@ -0,0 +1,7 @@
<?php
namespace Pterodactyl\Contracts\Repository;
interface ServerVariableRepositoryInterface extends RepositoryInterface
{
}

View File

@ -0,0 +1,25 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
interface SessionRepositoryInterface extends RepositoryInterface
{
/**
* Return all of the active sessions for a user.
*
* @param int $user
* @return \Illuminate\Support\Collection
*/
public function getUserSessions(int $user): Collection;
/**
* Delete a session for a given user.
*
* @param int $user
* @param string $session
* @return null|int
*/
public function deleteUserSession(int $user, string $session);
}

View File

@ -0,0 +1,33 @@
<?php
namespace Pterodactyl\Contracts\Repository;
interface SettingsRepositoryInterface extends RepositoryInterface
{
/**
* Store a new persistent setting in the database.
*
* @param string $key
* @param string|null $value
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function set(string $key, string $value = null);
/**
* Retrieve a persistent setting from the database.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get(string $key, $default);
/**
* Remove a key from the database cache.
*
* @param string $key
*/
public function forget(string $key);
}

View File

@ -0,0 +1,37 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Subuser;
interface SubuserRepositoryInterface extends RepositoryInterface
{
/**
* Return a subuser with the associated server relationship.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @param bool $refresh
* @return \Pterodactyl\Models\Subuser
*/
public function loadServerAndUserRelations(Subuser $subuser, bool $refresh = false): Subuser;
/**
* Return a subuser with the associated permissions relationship.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @param bool $refresh
* @return \Pterodactyl\Models\Subuser
*/
public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser;
/**
* Return a subuser and associated permissions given a user_id and server_id.
*
* @param int $user
* @param int $server
* @return \Pterodactyl\Models\Subuser
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser;
}

View File

@ -0,0 +1,27 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Task;
interface TaskRepositoryInterface extends RepositoryInterface
{
/**
* Get a task and the server relationship for that task.
*
* @param int $id
* @return \Pterodactyl\Models\Task
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getTaskForJobProcess(int $id): Task;
/**
* Returns the next task in a schedule.
*
* @param int $schedule
* @param int $index
* @return null|\Pterodactyl\Models\Task
*/
public function getNextTask(int $schedule, int $index);
}

View File

@ -0,0 +1,25 @@
<?php
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface UserRepositoryInterface extends RepositoryInterface, SearchableInterface
{
/**
* Return all users with counts of servers and subusers of servers.
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getAllUsersWithCounts(): LengthAwarePaginator;
/**
* Return all matching models for a user in a format that can be used for dropdowns.
*
* @param string $query
* @return \Illuminate\Support\Collection
*/
public function filterUsersByQuery(string $query): Collection;
}

View File

@ -1,26 +1,11 @@
<?php <?php
/** /**
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Auth; namespace Pterodactyl\Events\Auth;
@ -47,9 +32,8 @@ class FailedCaptcha
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param string $ip * @param string $ip
* @param string $domain * @param string $domain
* @return void
*/ */
public function __construct($ip, $domain) public function __construct($ip, $domain)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Auth; namespace Pterodactyl\Events\Auth;
@ -47,9 +32,8 @@ class FailedPasswordReset
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param string $ip * @param string $ip
* @param string $email * @param string $email
* @return void
*/ */
public function __construct($ip, $email) public function __construct($ip, $email)
{ {

View File

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

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Created
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Creating
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Deleted
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Deleting
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Saved
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Saving
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Updated
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Server; namespace Pterodactyl\Events\Server;
@ -41,8 +26,7 @@ class Updating
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Server $server
* @return void
*/ */
public function __construct(Server $server) public function __construct(Server $server)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Subuser; namespace Pterodactyl\Events\Subuser;
@ -41,8 +26,7 @@ class Created
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Subuser $subuser * @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/ */
public function __construct(Subuser $subuser) public function __construct(Subuser $subuser)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Subuser; namespace Pterodactyl\Events\Subuser;
@ -41,8 +26,7 @@ class Creating
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Subuser $subuser * @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/ */
public function __construct(Subuser $subuser) public function __construct(Subuser $subuser)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Subuser; namespace Pterodactyl\Events\Subuser;
@ -41,8 +26,7 @@ class Deleted
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Subuser $subuser * @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/ */
public function __construct(Subuser $subuser) public function __construct(Subuser $subuser)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\Subuser; namespace Pterodactyl\Events\Subuser;
@ -41,8 +26,7 @@ class Deleting
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\Subuser $subuser * @param \Pterodactyl\Models\Subuser $subuser
* @return void
*/ */
public function __construct(Subuser $subuser) public function __construct(Subuser $subuser)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\User; namespace Pterodactyl\Events\User;
@ -41,8 +26,7 @@ class Created
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\User $user * @param \Pterodactyl\Models\User $user
* @return void
*/ */
public function __construct(User $user) public function __construct(User $user)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\User; namespace Pterodactyl\Events\User;
@ -41,8 +26,7 @@ class Creating
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\User $user * @param \Pterodactyl\Models\User $user
* @return void
*/ */
public function __construct(User $user) public function __construct(User $user)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\User; namespace Pterodactyl\Events\User;
@ -41,8 +26,7 @@ class Deleted
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\User $user * @param \Pterodactyl\Models\User $user
* @return void
*/ */
public function __construct(User $user) public function __construct(User $user)
{ {

View File

@ -3,23 +3,8 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* 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\Events\User; namespace Pterodactyl\Events\User;
@ -41,8 +26,7 @@ class Deleting
/** /**
* Create a new event instance. * Create a new event instance.
* *
* @param \Pterodactyl\Models\User $user * @param \Pterodactyl\Models\User $user
* @return void
*/ */
public function __construct(User $user) public function __construct(User $user)
{ {

View File

@ -3,28 +3,12 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/ */
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
class AccountNotFoundException extends \Exception class AccountNotFoundException extends \Exception
{ {
//
} }

View File

@ -3,28 +3,12 @@
* Pterodactyl - Panel * Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>. * Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * This software is licensed under the terms of the MIT license.
* of this software and associated documentation files (the "Software"), to deal * https://opensource.org/licenses/MIT
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/ */
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
class AutoDeploymentException extends \Exception class AutoDeploymentException extends \Exception
{ {
//
} }

View File

@ -1,46 +1,77 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Log; use Log;
use Throwable;
use Illuminate\Http\Response;
use Prologue\Alerts\AlertsMessageBag;
class DisplayException extends \Exception class DisplayException extends PterodactylException
{ {
const LEVEL_DEBUG = 'debug';
const LEVEL_INFO = 'info';
const LEVEL_WARNING = 'warning';
const LEVEL_ERROR = 'error';
/**
* @var string
*/
protected $level;
/** /**
* Exception constructor. * Exception constructor.
* *
* @param string $message * @param string $message
* @param mixed $log * @param Throwable|null $previous
* @return void * @param string $level
* @param int $code
*/ */
public function __construct($message, $log = null) public function __construct($message, Throwable $previous = null, $level = self::LEVEL_ERROR, $code = 0)
{ {
if (! is_null($log)) { parent::__construct($message, $code, $previous);
Log::error($log);
if (! is_null($previous)) {
Log::{$level}($previous);
} }
parent::__construct($message); $this->level = $level;
}
/**
* @return string
*/
public function getErrorLevel()
{
return $this->level;
}
/**
* @return int
*/
public function getStatusCode()
{
return Response::HTTP_BAD_REQUEST;
}
/**
* Render the exception to the user by adding a flashed message to the session
* and then redirecting them back to the page that they came from. If the
* request originated from an API hit, return the error in JSONAPI spec format.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*/
public function render($request)
{
if ($request->expectsJson()) {
return response()->json(Handler::convertToArray($this, [
'detail' => $this->getMessage(),
]), method_exists($this, 'getStatusCode') ? $this->getStatusCode() : Response::HTTP_BAD_REQUEST);
}
app()->make(AlertsMessageBag::class)->danger($this->getMessage())->flash();
return redirect()->back()->withInput();
} }
} }

View File

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

View File

@ -2,9 +2,16 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Log;
use Exception; use Exception;
use PDOException;
use Psr\Log\LoggerInterface;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
@ -15,62 +22,147 @@ class Handler extends ExceptionHandler
* @var array * @var array
*/ */
protected $dontReport = [ protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class, AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class, AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class, DisplayException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class, HttpException::class,
\Illuminate\Session\TokenMismatchException::class, ModelNotFoundException::class,
\Illuminate\Validation\ValidationException::class, RecordNotFoundException::class,
TokenMismatchException::class,
ValidationException::class,
]; ];
/** /**
* Report or log an exception. * A list of the inputs that are never flashed for validation exceptions.
* *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * @var array
*/
protected $dontFlash = [
'token',
'secret',
'password',
'password_confirmation',
];
/**
* Report or log an exception. Skips Laravel's internal reporter since we
* don't need or want the user information in our logs by default.
* *
* @param \Exception $exception * If you want to implement logging in a different format to integrate with
* @return void * services such as AWS Cloudwatch or other monitoring you can replace the
* contents of this function with a call to the parent reporter.
*
* @param \Exception $exception
* @return mixed
*
* @throws \Exception
*/ */
public function report(Exception $exception) public function report(Exception $exception)
{ {
return parent::report($exception); if (! config('app.exceptions.report_all', false) && $this->shouldntReport($exception)) {
return null;
}
if (method_exists($exception, 'report')) {
return $exception->report();
}
try {
$logger = $this->container->make(LoggerInterface::class);
} catch (Exception $ex) {
throw $exception;
}
return $logger->error($exception instanceof PDOException ? $exception->getMessage() : $exception);
} }
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $exception * @param \Exception $exception
* @return \Illuminate\Http\Response * @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)
{ {
if ($request->expectsJson() || $request->isJson() || $request->is(...config('pterodactyl.json_routes'))) { return parent::render($request, $exception);
$exception = $this->prepareException($exception); }
if (config('app.debug') || $this->isHttpException($exception)) { /**
$displayError = $exception->getMessage(); * Transform a validation exception into a consistent format to be returned for
} else { * calls to the API.
$displayError = 'An unhandled exception was encountered with this request.'; *
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Validation\ValidationException $exception
* @return \Illuminate\Http\JsonResponse
*/
public function invalidJson($request, ValidationException $exception)
{
$codes = collect($exception->validator->failed())->mapWithKeys(function ($reasons, $field) {
$cleaned = [];
foreach ($reasons as $reason => $attrs) {
$cleaned[] = snake_case($reason);
} }
$response = response()->json([ return [str_replace('.', '_', $field) => $cleaned];
'error' => $displayError, })->toArray();
'http_code' => (! $this->isHttpException($exception)) ?: $exception->getStatusCode(),
'trace' => (! config('app.debug')) ? null : class_basename($exception) . ' in ' . $exception->getFile() . ' on line ' . $exception->getLine(),
], ($this->isHttpException($exception)) ? $exception->getStatusCode() : 500, [], JSON_UNESCAPED_SLASHES);
parent::report($exception); $errors = collect($exception->errors())->map(function ($errors, $field) use ($codes) {
$response = [];
foreach ($errors as $key => $error) {
$response[] = [
'code' => array_get($codes, str_replace('.', '_', $field) . '.' . $key),
'detail' => $error,
'source' => ['field' => $field],
];
}
return $response;
})->flatMap(function ($errors) {
return $errors;
})->toArray();
return response()->json(['errors' => $errors], $exception->status);
}
/**
* Return the exception as a JSONAPI representation for use on API requests.
*
* @param \Exception $exception
* @param array $override
* @return array
*/
public static function convertToArray(Exception $exception, array $override = []): array
{
$error = [
'code' => class_basename($exception),
'status' => method_exists($exception, 'getStatusCode') ? strval($exception->getStatusCode()) : '500',
'detail' => 'An error was encountered while processing this request.',
];
if (config('app.debug')) {
$error = array_merge($error, [
'detail' => $exception->getMessage(),
'source' => [
'line' => $exception->getLine(),
'file' => str_replace(base_path(), '', $exception->getFile()),
],
'meta' => [
'trace' => explode("\n", $exception->getTraceAsString()),
],
]);
} }
return (isset($response)) ? $response : parent::render($request, $exception); return ['errors' => [array_merge($error, $override)]];
} }
/** /**
* Convert an authentication exception into an unauthenticated response. * Convert an authentication exception into an unauthenticated response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception * @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
protected function unauthenticated($request, AuthenticationException $exception) protected function unauthenticated($request, AuthenticationException $exception)
@ -81,4 +173,16 @@ class Handler extends ExceptionHandler
return redirect()->guest(route('auth.login')); return redirect()->guest(route('auth.login'));
} }
/**
* Converts an exception into an array to render in the response. Overrides
* Laravel's built-in converter to output as a JSONAPI spec compliant object.
*
* @param \Exception $exception
* @return array
*/
protected function convertExceptionToArray(Exception $exception)
{
return self::convertToArray($exception);
}
} }

View File

@ -0,0 +1,16 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Http\Base;
use Pterodactyl\Exceptions\DisplayException;
class InvalidPasswordProvidedException extends DisplayException
{
}

View File

@ -0,0 +1,45 @@
<?php
namespace Pterodactyl\Exceptions\Http\Connection;
use Illuminate\Http\Response;
use GuzzleHttp\Exception\GuzzleException;
use Pterodactyl\Exceptions\DisplayException;
class DaemonConnectionException extends DisplayException
{
/**
* @var int
*/
private $statusCode = Response::HTTP_GATEWAY_TIMEOUT;
/**
* Throw a displayable exception caused by a daemon connection error.
*
* @param \GuzzleHttp\Exception\GuzzleException $previous
* @param bool $useStatusCode
*/
public function __construct(GuzzleException $previous, bool $useStatusCode = false)
{
/** @var \GuzzleHttp\Psr7\Response|null $response */
$response = method_exists($previous, 'getResponse') ? $previous->getResponse() : null;
if ($useStatusCode) {
$this->statusCode = is_null($response) ? 500 : $response->getStatusCode();
}
parent::__construct(trans('admin/server.exceptions.daemon_exception', [
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
]), $previous, DisplayException::LEVEL_WARNING);
}
/**
* Return the HTTP status code for this exception.
*
* @return int
*/
public function getStatusCode()
{
return $this->statusCode;
}
}

View File

@ -0,0 +1,16 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Http\Server;
use Pterodactyl\Exceptions\DisplayException;
class FileSizeTooLargeException extends DisplayException
{
}

View File

@ -0,0 +1,16 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Http\Server;
use Pterodactyl\Exceptions\DisplayException;
class FileTypeNotEditableException extends DisplayException
{
}

View File

@ -0,0 +1,60 @@
<?php
namespace Pterodactyl\Exceptions\Model;
use Illuminate\Contracts\Validation\Validator;
use Pterodactyl\Exceptions\PterodactylException;
use Illuminate\Contracts\Support\MessageProvider;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class DataValidationException extends PterodactylException implements HttpExceptionInterface, MessageProvider
{
/**
* The validator instance.
*
* @var \Illuminate\Contracts\Validation\Validator
*/
public $validator;
/**
* DataValidationException constructor.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
*/
public function __construct(Validator $validator)
{
parent::__construct(
'Data integrity exception encountered while performing database write operation. ' . $validator->errors()->toJson()
);
$this->validator = $validator;
}
/**
* Return the validator message bag.
*
* @return \Illuminate\Support\MessageBag
*/
public function getMessageBag()
{
return $this->validator->errors();
}
/**
* Return the status code for this request.
*
* @return int
*/
public function getStatusCode()
{
return 500;
}
/**
* @return array
*/
public function getHeaders()
{
return [];
}
}

View File

@ -0,0 +1,7 @@
<?php
namespace Pterodactyl\Exceptions;
class PterodactylException extends \Exception
{
}

View File

@ -0,0 +1,9 @@
<?php
namespace Pterodactyl\Exceptions\Repository\Daemon;
use Pterodactyl\Exceptions\Repository\RepositoryException;
class InvalidPowerSignalException extends RepositoryException
{
}

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