Skip to content

Commit 1489f7a

Browse files
committed
Initial Commit of Files
PufferPanel v0.9 (Laravel) is now Pterodactyl 1.0
0 parents  commit 1489f7a

File tree

154 files changed

+10159
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+10159
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor
2+
*.DS_Store*
3+
.env
4+
5+
composer.lock

LICENSE

Lines changed: 621 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Pterodactyl Panel
2+
Pterodactyl is the free game server management panel designed by users, for users. Featuring support for Vanilla Minecraft, Spigot, Source Dedicated Servers, BungeeCord, and many more. Pterodactyl is built on the `Laravel PHP Framework (v5.1) LTS`.
3+
4+
Pterodactyl is forked from PufferPanel and is developed by the core developer that brought you PufferPanel. The features are similar, but the code is new.
5+
6+
## Documentation
7+
Support for using Pterodactyl can be found on our [community forums](https://community.pterodactyl.io) or on our [Discord chat](https://discord.gg/0gYt8oU8QOkDhKLS).
8+
9+
## License
10+
```
11+
Copyright (c) 2015 Pterodactyl Software & Design (Dane Everitt)
12+
13+
This program is free software: you can redistribute it and/or modify
14+
it under the terms of the GNU General Public License as published by
15+
the Free Software Foundation, either version 3 of the License, or
16+
(at your option) any later version.
17+
18+
This program is distributed in the hope that it will be useful,
19+
but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
GNU General Public License for more details.
22+
23+
You should have received a copy of the GNU General Public License
24+
along with this program. If not, see <http://www.gnu.org/licenses/>.
25+
```
26+
27+
### Additional License Information
28+
Some Javascript and CSS used within the panel is licensed under a `MIT`, `Apache 2.0`, or `GPL` license. Please check their respective header files for more information information.
29+
30+
Some images used within Pterodactyl are Copyright (c) their respective owners.
31+
32+
`/public/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/)
33+
34+
`/public/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/)

app/Console/Commands/Inspire.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Pterodactyl\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Foundation\Inspiring;
7+
8+
class Inspire extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'inspire';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Display an inspiring quote';
23+
24+
/**
25+
* Execute the console command.
26+
*
27+
* @return mixed
28+
*/
29+
public function handle()
30+
{
31+
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
32+
}
33+
}

app/Console/Kernel.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Pterodactyl\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
\Pterodactyl\Console\Commands\Inspire::class,
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
$schedule->command('inspire')
28+
->hourly();
29+
}
30+
}

app/Events/Event.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Pterodactyl\Events;
4+
5+
abstract class Event
6+
{
7+
//
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions;
4+
5+
class AccountNotFoundException extends \Exception
6+
{
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions;
4+
5+
class DisplayException extends \Exception
6+
{
7+
8+
}

app/Exceptions/Handler.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions;
4+
5+
use Exception;
6+
use DisplayException;
7+
use Debugbar;
8+
use Illuminate\Database\Eloquent\ModelNotFoundException;
9+
use Symfony\Component\HttpKernel\Exception\HttpException;
10+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
11+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
12+
13+
class Handler extends ExceptionHandler
14+
{
15+
/**
16+
* A list of the exception types that should not be reported.
17+
*
18+
* @var array
19+
*/
20+
protected $dontReport = [
21+
HttpException::class,
22+
ModelNotFoundException::class,
23+
];
24+
25+
/**
26+
* Report or log an exception.
27+
*
28+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29+
*
30+
* @param \Exception $e
31+
* @return void
32+
*/
33+
public function report(Exception $e)
34+
{
35+
return parent::report($e);
36+
}
37+
38+
/**
39+
* Render an exception into an HTTP response.
40+
*
41+
* @param \Illuminate\Http\Request $request
42+
* @param \Exception $e
43+
* @return \Illuminate\Http\Response
44+
*/
45+
public function render($request, Exception $e)
46+
{
47+
if ($e instanceof ModelNotFoundException) {
48+
$e = new NotFoundHttpException($e->getMessage(), $e);
49+
}
50+
51+
if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('/api/*')) {
52+
53+
$exception = 'An exception occured while attempting to perform this action, please try again.';
54+
55+
if ($e instanceof DisplayException) {
56+
$exception = $e->getMessage();
57+
}
58+
59+
// Live environment, just return a nice error.
60+
if(!env('APP_DEBUG', false)) {
61+
return response()->json([
62+
'error' => $exception
63+
], 500);
64+
}
65+
66+
// If we are debugging, return the exception in it's full manner.
67+
return response()->json([
68+
'error' => $e->getMessage(),
69+
'code' => $e->getCode(),
70+
'file' => $e->getFile(),
71+
'line' => $e->getLine()
72+
], 500);
73+
74+
}
75+
76+
return parent::render($request, $e);
77+
}
78+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace Pterodactyl\Http\Controllers\API;
4+
5+
use Gate;
6+
use Log;
7+
use Debugbar;
8+
use Pterodactyl\Models\API;
9+
use Pterodactyl\Models\User;
10+
11+
use Pterodactyl\Http\Controllers\Controller;
12+
use Illuminate\Http\Request;
13+
14+
class UserController extends Controller
15+
{
16+
17+
/**
18+
* Constructor
19+
*/
20+
public function __construct()
21+
{
22+
$this->middleware('api');
23+
}
24+
25+
public function getAllUsers(Request $request)
26+
{
27+
28+
// Policies don't work if the user isn't logged in for whatever reason in Laravel...
29+
if(!API::checkPermission($request->header('X-Authorization'), 'get-users')) {
30+
return API::noPermissionError();
31+
}
32+
33+
return response()->json([
34+
'users' => User::all()
35+
]);
36+
}
37+
38+
/**
39+
* Returns JSON response about a user given their ID.
40+
* If fields are provided only those fields are returned.
41+
*
42+
* Does not return protected fields (i.e. password & totp_secret)
43+
*
44+
* @param Request $request
45+
* @param int $id
46+
* @param string $fields
47+
* @return Response
48+
*/
49+
public function getUser(Request $request, $id, $fields = null)
50+
{
51+
52+
// Policies don't work if the user isn't logged in for whatever reason in Laravel...
53+
if(!API::checkPermission($request->header('X-Authorization'), 'get-users')) {
54+
return API::noPermissionError();
55+
}
56+
57+
if (is_null($fields)) {
58+
return response()->json(User::find($id));
59+
}
60+
61+
$query = User::where('id', $id);
62+
$explode = explode(',', $fields);
63+
64+
foreach($explode as &$exploded) {
65+
if(!empty($exploded)) {
66+
$query->addSelect($exploded);
67+
}
68+
}
69+
70+
try {
71+
return response()->json($query->get());
72+
} catch (\Exception $e) {
73+
if ($e instanceof \Illuminate\Database\QueryException) {
74+
return response()->json([
75+
'error' => 'One of the fields provided in your argument list is invalid.'
76+
], 500);
77+
}
78+
throw $e;
79+
}
80+
81+
}
82+
83+
}

0 commit comments

Comments
 (0)