Skip to content

Commit

Permalink
Release0.7
Browse files Browse the repository at this point in the history
Release0.7
  • Loading branch information
1day2die authored Feb 6, 2022
2 parents 74e26ca + dd49f55 commit babf8a5
Show file tree
Hide file tree
Showing 179 changed files with 21,894 additions and 3,777 deletions.
37 changes: 10 additions & 27 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
APP_NAME=Dashboard
### --- App Settings --- ###
APP_NAME=Controlpanel.gg
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost
#list with timezones https://www.php.net/manual/en/timezones.php
# List with timezones https://www.php.net/manual/en/timezones.php
APP_TIMEZONE=UTC
### --- App Settings End --- ###

### --- DB Settings (required) --- ###
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=dashboard
DB_USERNAME=dashboarduser
DB_PASSWORD=
### --- DB Settings End --- ###

#without a pterodactyl api token, this panel won't work!
PTERODACTYL_TOKEN=

#paypal details, you only need sandbox for testing! you can do this by setting the APP_ENV to local
PAYPAL_SANDBOX_SECRET=
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SECRET=
PAYPAL_CLIENT_ID=
PAYPAL_EMAIL=

#set-up for extra discord verification
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
#set-up will join users automaticly to your discord
DISCORD_BOT_TOKEN=
DISCORD_GUILD_ID=
#set-up will give the verified user the given role
DISCORD_ROLE_ID=

#nesseary URL's
PTERODACTYL_URL=https://panel.controlpanel.gg
PHPMYADMIN_URL=https://mysql.controlpanel.gg #optional. remove to remove database button
DISCORD_INVITE_URL=https://discord.gg/vrUYdxG4wZ

#GOOGLE RECAPTCHA
# Google Recaptcha API Credentials - https://www.google.com/recaptcha/admin - reCaptcha V2 (not v3)
RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe

# Mail Server Settings - (HOST -> SMTP Server)
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
Expand All @@ -51,10 +33,11 @@ MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"


#you can leave everything below the way it is
# Laravel Logging Settings - https://laravel.com/docs/5.7/logging - Not needed to be changed
LOG_CHANNEL=stack
LOG_LEVEL=debug

# Do not change anything below this line
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ yarn-error.log
.gitignore
.env.dev
.env.testing
storage/invoices.zip
storage/app/public/logo.png
*vscode
- Kopie.env
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ When contributing to this repository, please go through the open issues to see i

Please note we have a code of conduct, please follow it in all your interactions with the project.

If you added any Strings which are displayed at the frontend please localize them (e.g. "New String" -> {{ __('New String') }}) and run the localization string generation:

```cmd
php artisan translatable:export en
```

## Pull request process

1. Give your PR a good descriptive title, so we can view immediately what the PR is about.
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
### Features

- PayPal Integration
- Email Verification
- Audit Log
- Admin Dashboard
- User/Server Management
- Store (credit system)
- Vouchers
- and so much more!
- PayPal Integration
- Stripe Integration
- Email Verification
- Audit Log
- Admin Dashboard
- User/Server Management
- Store (credit system)
- Vouchers
- and so much more!

# ControlPanel-gg
![controlpanel](https://user-images.githubusercontent.com/45005889/123518824-06b05000-d6a8-11eb-91b9-d1ed36bd2317.png)

![](https://img.shields.io/github/stars/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/forks/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/tag/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/issues/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/license/ControlPanel-gg/dashboard) ![](https://img.shields.io/discord/787829714483019826)
![controlpanel](https://user-images.githubusercontent.com/45005889/123518824-06b05000-d6a8-11eb-91b9-d1ed36bd2317.png)

![](https://img.shields.io/github/stars/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/forks/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/tag/ControlPanel-gg/dashboard) [![Crowdin](https://badges.crowdin.net/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ControlPanel-gg/dashboard) ![](https://img.shields.io/github/license/ControlPanel-gg/dashboard) ![](https://img.shields.io/discord/787829714483019826)
## About

ControlPanel's Dashboard is a dashboard application designed to offer clients a management tool to manage their pterodactyl servers. This dashboard comes with a credit-based billing solution that credits users hourly for each server they have and suspends them if they run out of credits.

This dashboard offers an easy to use and free billing solution for all starting and experienced hosting providers. This dashboard has many customization options and added discord 0auth verification to offer a solid link between your discord server and your dashboard.

### [Installation](https://controlpanel.gg/docs/intro "Installation")

### [Updating](https://controlpanel.gg/docs/Installation/updating "Updating")

### [Discord](https://discord.gg/4Y6HjD2uyU "discord")

### [Contributing](https://controlpanel.gg/docs/Contributing/contributing "Contributing")

### [Donating](https://controlpanel.gg/docs/Contributing/donating "Donating")
83 changes: 67 additions & 16 deletions app/Classes/Pterodactyl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace App\Classes;

use App\Models\Configuration;
use App\Models\Egg;
use App\Models\Nest;
use App\Models\Node;
use App\Models\Server;
use App\Models\Settings;
use Exception;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\Response;
Expand All @@ -17,7 +17,7 @@ class Pterodactyl
/**
* @description per_page option to pull more than the default 50 from pterodactyl
*/
public CONST PER_PAGE = 200;
public const PER_PAGE = 200;

//TODO: Extend error handling (maybe logger for more errors when debugging)

Expand All @@ -27,10 +27,10 @@ class Pterodactyl
public static function client()
{
return Http::withHeaders([
'Authorization' => 'Bearer ' . env('PTERODACTYL_TOKEN', false),
'Authorization' => 'Bearer ' . config("SETTINGS::SYSTEM:PTERODACTYL:TOKEN"),
'Content-type' => 'application/json',
'Accept' => 'Application/vnd.pterodactyl.v1+json',
])->baseUrl(env('PTERODACTYL_URL') . '/api');
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
}

/**
Expand All @@ -48,7 +48,11 @@ private static function getException(): Exception
*/
public static function getEggs(Nest $nest)
{
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . self::PER_PAGE);
try {
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . self::PER_PAGE);
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand All @@ -59,7 +63,11 @@ public static function getEggs(Nest $nest)
*/
public static function getNodes()
{
$response = self::client()->get('/application/nodes?per_page=' . self::PER_PAGE);
try {
$response = self::client()->get('/application/nodes?per_page=' . self::PER_PAGE);
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand All @@ -70,7 +78,11 @@ public static function getNodes()
*/
public static function getNests()
{
$response = self::client()->get('/application/nests?per_page=' . self::PER_PAGE);
try {
$response = self::client()->get('/application/nests?per_page=' . self::PER_PAGE);
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
Expand All @@ -81,8 +93,13 @@ public static function getNests()
*/
public static function getLocations()
{
$response = self::client()->get('/application/locations?per_page=' . self::PER_PAGE);
try {
$response = self::client()->get('/application/locations?per_page=' . self::PER_PAGE);
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();

return $response->json()['data'];
}

Expand Down Expand Up @@ -124,9 +141,14 @@ public static function getFreeAllocations(Node $node)
*/
public static function getAllocations(Node $node)
{
$per_page = Configuration::getValueByKey('ALLOCATION_LIMIT', 200);
$response = self::client()->get("/application/nodes/{$node->id}/allocations?per_page={$per_page}");
$per_page = config('SETTINGS::SERVER:ALLOCATION_LIMIT', 200);
try {
$response = self::client()->get("/application/nodes/{$node->id}/allocations?per_page={$per_page}");
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();

return $response->json();
}

Expand All @@ -136,7 +158,7 @@ public static function getAllocations(Node $node)
*/
public static function url(string $route): string
{
return env('PTERODACTYL_URL') . $route;
return config("SETTINGS::SYSTEM:PTERODACTYL:URL") . $route;
}

/**
Expand Down Expand Up @@ -171,20 +193,29 @@ public static function createServer(Server $server, Egg $egg, int $allocationId)
"default" => $allocationId
]
]);

}

public static function suspendServer(Server $server)
{
$response = self::client()->post("/application/servers/$server->pterodactyl_id/suspend");
try {
$response = self::client()->post("/application/servers/$server->pterodactyl_id/suspend");
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();

return $response;
}

public static function unSuspendServer(Server $server)
{
$response = self::client()->post("/application/servers/$server->pterodactyl_id/unsuspend");
try {
$response = self::client()->post("/application/servers/$server->pterodactyl_id/unsuspend");
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();

return $response;
}

Expand All @@ -195,9 +226,29 @@ public static function unSuspendServer(Server $server)
*/
public function getUser(int $pterodactylId)
{
$response = self::client()->get("/application/users/{$pterodactylId}");
try {
$response = self::client()->get("/application/users/{$pterodactylId}");
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();

return $response->json()['attributes'];
}

if ($response->failed()) return $response->json();
/**
* Get serverAttributes by pterodactyl id
* @param int $pterodactylId
* @return mixed
*/
public static function getServerAttributes(string $pterodactylId)
{
try {
$response = self::client()->get("/application/servers/{$pterodactylId}?include=egg,node,nest,location");
} catch (Exception $e) {
throw self::getException();
}
if ($response->failed()) throw self::getException();
return $response->json()['attributes'];
}
}
50 changes: 50 additions & 0 deletions app/Classes/Settings/Invoices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Classes\Settings;

use App\Models\Settings;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;

class Invoices
{
public function __construct()
{
return;
}


public function updateSettings(Request $request)
{
$request->validate([
'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg',
]);

$values = [
//SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form)
"SETTINGS::INVOICE:COMPANY_NAME" => "company-name",
"SETTINGS::INVOICE:COMPANY_ADDRESS" => "company-address",
"SETTINGS::INVOICE:COMPANY_PHONE" => "company-phone",
"SETTINGS::INVOICE:COMPANY_MAIL" => "company-mail",
"SETTINGS::INVOICE:COMPANY_VAT" => "company-vat",
"SETTINGS::INVOICE:COMPANY_WEBSITE" => "company-web",
"SETTINGS::INVOICE:PREFIX" => "invoice-prefix",
"SETTINGS::INVOICE:ENABLED" => "enable-invoices",
];

foreach ($values as $key => $value) {
$param = $request->get($value);

Settings::where('key', $key)->updateOrCreate(['key' => $key], ['value' => $param]);
Cache::forget("setting" . ':' . $key);
}


if ($request->hasFile('logo')) {
$request->file('logo')->storeAs('public', 'logo.png');
}


return redirect(route('admin.settings.index') . '#invoices')->with('success', __('Invoice settings updated!'));
}
}
Loading

0 comments on commit babf8a5

Please sign in to comment.