Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.3 #1111

Merged
merged 123 commits into from
Jan 11, 2025
Merged

v1.0.3 #1111

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
3e6bcb5
Custom Error Messages
1day2die Nov 12, 2024
30788c8
translateable billing period server create
1day2die Nov 12, 2024
e53baac
Beautify and add 429 error
1day2die Nov 13, 2024
4a5917a
feat: Update dependencies
Zastinian Nov 16, 2024
1da3b32
Merge current Dev in v1.1 (#1036)
1day2die Nov 18, 2024
ef6720f
Merge branch 'development' into v1.1-custom-error-messages
1day2die Nov 18, 2024
bd1bfc6
[Feat.] Custom error Messages (#1037)
1day2die Nov 18, 2024
c5a8e65
[v1.1][Fix.] translateable billing period server create (#1025)
1day2die Nov 18, 2024
fb3d331
[v1.1]Updating Composer dependencies (#1034)
1day2die Nov 18, 2024
e7ca12e
merge Dev in 1.1 (#1039)
1day2die Nov 18, 2024
abb53c9
Product limits per user
1day2die Nov 18, 2024
80ed043
Merge branch 'Ctrlpanel-gg:main' into 1day-1.1
1day2die Nov 28, 2024
9bc9e6a
[Feat] Limit Products per user || Custom Error Messages || [Fix] Tran…
1day2die Nov 28, 2024
d379e96
Fix Recaptcha Keys
1day2die Nov 28, 2024
0647369
Update app.php
1day2die Nov 28, 2024
6ee4419
Rename ctrlpanel https://github.com/Ctrlpanel-gg/panel/issues/1060
1day2die Nov 28, 2024
ad85a8f
fix incorrect display conditions for buy more credits
1day2die Nov 28, 2024
7acc9b2
Fix minimum credits not working
1day2die Nov 28, 2024
7938f45
fix server creation
1day2die Nov 28, 2024
e782bfd
Fix Nodeselection if node is free but not permitted for product
1day2die Nov 28, 2024
4049599
Better activity log
1day2die Nov 28, 2024
af66670
cleaner Settingsprovider
1day2die Nov 28, 2024
b56055f
[Fix] Installer: Dynamic Paths
1day2die Nov 28, 2024
91369f3
Merge branch 'Ctrlpanel-gg:development' into development
1day2die Nov 28, 2024
04eb635
Merge branch 'development' of https://github.com/1day2die/cpgg into d…
1day2die Nov 28, 2024
da74132
Refactor getAvailableNode
1day2die Nov 28, 2024
ba7c7e7
Refactor Product Serverlimit
1day2die Nov 28, 2024
5d88974
[Fix] A lot of errors that came up in the past days (#1066)
1day2die Nov 28, 2024
24c710f
Update Ratelimiter and Validation on Tickets
1day2die Nov 28, 2024
be2b2ca
Better Ptero User handling
1day2die Dec 2, 2024
a1f23af
Update Ratelimiter and Validation on Tickets (#1068)
1day2die Dec 2, 2024
187f01a
Update User API
1day2die Dec 2, 2024
c38e26f
Update User API (#1073)
1day2die Dec 2, 2024
7bc037f
fix white page if unauthenticated
1day2die Dec 19, 2024
3d5214a
fix white page if unauthenticated (#1077)
1day2die Dec 19, 2024
c0bcd7c
Update file name to corresponding to class name.
Ferks-FK Dec 20, 2024
25c9202
Don't send notifications to suspended users (#918)
Ferks-FK Dec 20, 2024
92fc5c5
#833
Ferks-FK Dec 21, 2024
421cf5d
#833 (#1078)
Ferks-FK Dec 21, 2024
5924fae
Fixed #387
Ferks-FK Dec 21, 2024
eabdf8d
Fixed #387 (#1081)
Ferks-FK Dec 21, 2024
29d69ed
Fixed #248
Ferks-FK Dec 21, 2024
ac79a20
Fixed #1022
Ferks-FK Dec 22, 2024
5186d64
Fix typo
Ferks-FK Dec 22, 2024
abd6ebb
Fixed #248 (#1082)
1day2die Dec 24, 2024
218b41b
Fixing transferusers.php
RaphaelCapone Dec 24, 2024
8bcd334
Update transferusers.php
RaphaelCapone Dec 25, 2024
bfc3465
update: readme to add pelican warning
S0ly Dec 25, 2024
97359c4
remove: useless warning
S0ly Dec 25, 2024
580d121
docs: add docker docs
S0ly Dec 25, 2024
c5dbaaa
fix: Improve error handling for node connectivity issues during serve…
openhands-agent Dec 26, 2024
cf37af7
Merge branch 'development' into fix/pterodactyl-node-errors-v2
S0ly Dec 27, 2024
9fcb7b0
fix: register controller strange behaviour
S0ly Jan 1, 2025
f2d0a63
Merge branch 'development' into patch-1
S0ly Jan 1, 2025
b35d806
fix: error message in registration could be invalid
S0ly Jan 2, 2025
3f75f9d
Move settings to the settings provider.
Ferks-FK Jan 2, 2025
e24a5bd
Implement variable logic when creating the server.
Ferks-FK Jan 2, 2025
89fc831
Show description of inputs.
Ferks-FK Jan 2, 2025
56037ea
fix: transferusers.php (#1084)
1day2die Jan 3, 2025
c67d4d3
fix: Improve error handling for node connectivity issues during serve…
1day2die Jan 3, 2025
4a7b0b4
fix: #1022 (#1083)
1day2die Jan 3, 2025
1b3236b
Merge branch 'development' into 1089
Ferks-FK Jan 3, 2025
96f67b6
Merge branch 'development' into refactor/fixes-and-files
S0ly Jan 3, 2025
5724eb6
fix: re-adding edit resource warning
S0ly Jan 3, 2025
ac81d9a
refactor: details (#1085)
1day2die Jan 3, 2025
019e890
1089 (#1090)
1day2die Jan 3, 2025
16731b6
Allow floating inputs of type number.
Ferks-FK Jan 4, 2025
95a676a
Fix same name routes
Ferks-FK Jan 4, 2025
ae26a2b
Prevents blocking of users with more powers on the ticket black list.
Ferks-FK Jan 4, 2025
04a6ed5
Prevents blocking of users with more powers on the ticket black list.…
1day2die Jan 5, 2025
ea3d931
Allow floating inputs of type number. (#1091)
1day2die Jan 5, 2025
106e901
Fix duplicated route names (#1092)
1day2die Jan 5, 2025
c56bea5
HotFix: Credits not being added because of an incorrect operator.
Ferks-FK Jan 5, 2025
5ad23f3
Remove duplicated variable.
Ferks-FK Jan 5, 2025
b97dcdf
Fix mercadopago gateway
Ferks-FK Jan 6, 2025
9282384
Fix nodes (#1096)
Ferks-FK Jan 6, 2025
cba5358
refactor: servercontroller
S0ly Jan 6, 2025
0295e09
Hotfix: Set the value of the product input, x-model of alpine.js does…
Ferks-FK Jan 6, 2025
08745bb
Merge branch 'development' into fix/server-creation-error
S0ly Jan 6, 2025
aefdeb1
Revert "Hotfix: Set the value of the product input, x-model of alpine…
Ferks-FK Jan 6, 2025
ae00293
Merge branch 'development' into fix/server-creation-error
S0ly Jan 6, 2025
7135573
Server creation should work again.
Ferks-FK Jan 6, 2025
0c7a577
fix: inconsistency in serverController
S0ly Jan 7, 2025
0b19b39
fix: save updated server info
S0ly Jan 7, 2025
78d8fab
fix: typo in server controller
S0ly Jan 7, 2025
6112248
Merge branch 'development' into fix/server-creation-error
S0ly Jan 7, 2025
250835a
refactor: server controller (#1097)
Ferks-FK Jan 7, 2025
42ae238
fix: error occuring on server controller
S0ly Jan 7, 2025
fc696a5
fix: error occuring on server controller (#1098)
S0ly Jan 7, 2025
3f824d0
fix: more issue whit server controller
S0ly Jan 7, 2025
320b4a3
Merge branch 'Ctrlpanel-gg:development' into development
S0ly Jan 7, 2025
98f0d8c
fix: more issue whit serverController
S0ly Jan 7, 2025
c183084
fix: incorrect description for server limit settings
S0ly Jan 7, 2025
a238509
Merge branch 'Ctrlpanel-gg:development' into development
S0ly Jan 7, 2025
ed78929
fix: incorrect description for server limit settings (#1100)
S0ly Jan 7, 2025
d78f9ec
Do not allow the form to be sent without a product selected
Ferks-FK Jan 7, 2025
e937579
$server->egg doesn't exist, I guess?
Ferks-FK Jan 7, 2025
f66a68f
Remove eggs from products colletion.
Ferks-FK Jan 7, 2025
8e49c40
Update server_limit logic when user makes a purchase
Ferks-FK Jan 7, 2025
c8bd6af
Update server_limit logic when user makes a purchase (#1102)
Ferks-FK Jan 7, 2025
3ce2953
Revert "Update server_limit logic when user makes a purchase"
Ferks-FK Jan 7, 2025
04fa538
Revert "Update server_limit logic when user makes a purchase" (#1103)
Ferks-FK Jan 7, 2025
86bc702
Update user settings variables.
Ferks-FK Jan 8, 2025
c70419c
I'm sure that's better.
Ferks-FK Jan 8, 2025
1e53be1
Merge branch 'development' into product-upgrade
S0ly Jan 8, 2025
0d09d0e
Update gateways.
Ferks-FK Jan 9, 2025
9a165bf
Fix mollie (#1094)
Ferks-FK Jan 9, 2025
af4d7d1
Update user settings variables. (#1104)
Ferks-FK Jan 9, 2025
a4228b9
better activity log admin view
1day2die Jan 10, 2025
a6577a5
Enhance activity log search
1day2die Jan 10, 2025
bea1cac
Improved search of factivity logs
1day2die Jan 10, 2025
a37b138
Fix #1106
Ferks-FK Jan 10, 2025
f49c9a2
Fix #1106 (#1107)
Ferks-FK Jan 10, 2025
b4b2ff0
Add new code of Soly.
Ferks-FK Jan 11, 2025
ae0f1a3
Merge branch 'Ctrlpanel-gg:development' into development
1day2die Jan 11, 2025
4528b81
change RolesbyName to rolesByID
1day2die Jan 11, 2025
d7b003a
Fix typo
Ferks-FK Jan 11, 2025
cb0debe
Improve Admin-View of Activity logs // Roles by ID (#1105)
1day2die Jan 11, 2025
3322475
Product upgrade (#1101)
Ferks-FK Jan 11, 2025
cb84418
Update pterodactyl details to not log
1day2die Jan 11, 2025
29f9407
Update pterodactyl details to not log (#1109)
1day2die Jan 11, 2025
94e760d
Update User.php
1day2die Jan 11, 2025
61bbf82
Update User.php (#1110)
1day2die Jan 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

CtrlPanel offers an easy-to-use and free billing solution for all starting and experienced hosting providers that seamlessly integrates with the Pterodactyl panel. It facilitates account creation, server ordering, and management, while offering addons, multiple payment methods, and customizable themes for a comprehensive solution.

> ⚠️ **Important Notice:** CtrlPanel is **only compatible with Pterodactyl**. It does not support Pelican or any other hosting panels.

![GitHub tag](https://img.shields.io/github/tag/Ctrlpanel-gg/panel)
![Overall Installations](https://img.shields.io/badge/Overall%20Installations-5000%2B-green)
![GitHub stars](https://img.shields.io/github/stars/Ctrlpanel-gg/panel) <!--
Expand Down Expand Up @@ -41,15 +43,13 @@ Demo Server: [demo.CtrlPanel.gg](https://demo.CtrlPanel.gg)

### 🐳 Docker

*Soon...*

<!-- ```bash
docker run ...
```bash
docker run -d -p 8080:80 -p 8443:443 --name ctrlpanel ghcr.io/ctrlpanel-gg/panel:1.0.2
```

CtrlPanel is now running on [0.0.0.0:3001](http://0.0.0.0:3001). Don't forget to configure the database and Pterodactyl. [Documentation](documentation link here)
CtrlPanel is now running on [0.0.0.0:8080](http://0.0.0.0:8080). Don't forget to configure the database and Pterodactyl.

more info: [Docker](docker documentation link here) -->
more info: [Docker](https://github.com/Ctrlpanel-gg/panel/blob/main/.github/docker/README.md)

### 💪🏻 Non-Docker

Expand Down
File renamed without changes.
92 changes: 65 additions & 27 deletions app/Classes/PterodactylClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function clientAdmin(PterodactylSettings $ptero_settings)
private function getException(string $message = '', int $status = 0): Exception
{
if ($status == 404) {
return new Exception('Ressource does not exist on pterodactyl - ' . $message, 404);
return new Exception('Resource does not exist on pterodactyl - ' . $message, 404);
}

if ($status == 403) {
Expand All @@ -81,6 +81,14 @@ private function getException(string $message = '', int $status = 0): Exception
return new Exception('Pterodactyl server error - ' . $message, 500);
}

if ($status == 0) {
return new Exception('Unable to connect to Pterodactyl node - Please check if the node is online and accessible', 503);
}

if ($status >= 500 && $status < 600) {
return new Exception('Pterodactyl node error (HTTP ' . $status . ') - ' . $message, $status);
}

return new Exception('Request Failed, is pterodactyl set-up correctly? - ' . $message);
}

Expand Down Expand Up @@ -256,33 +264,47 @@ public function getAllocations(Node $node)
* @param int $allocationId
* @return Response
*/
public function createServer(Server $server, Egg $egg, int $allocationId)
public function createServer(Server $server, Egg $egg, int $allocationId, mixed $eggVariables = null)
{
return $this->application->post('application/servers', [
'name' => $server->name,
'external_id' => $server->id,
'user' => $server->user->pterodactyl_id,
'egg' => $egg->id,
'docker_image' => $egg->docker_image,
'startup' => $egg->startup,
'environment' => $egg->getEnvironmentVariables(),
'oom_disabled' => !$server->product->oom_killer,
'limits' => [
'memory' => $server->product->memory,
'swap' => $server->product->swap,
'disk' => $server->product->disk,
'io' => $server->product->io,
'cpu' => $server->product->cpu,
],
'feature_limits' => [
'databases' => $server->product->databases,
'backups' => $server->product->backups,
'allocations' => $server->product->allocations,
],
'allocation' => [
'default' => $allocationId,
],
]);
try {
$response = $this->application->post('application/servers', [
'name' => $server->name,
'external_id' => $server->id,
'user' => $server->user->pterodactyl_id,
'egg' => $egg->id,
'docker_image' => $egg->docker_image,
'startup' => $egg->startup,
'environment' => $this->getEnvironmentVariables($egg, $eggVariables),
'oom_disabled' => !$server->product->oom_killer,
'limits' => [
'memory' => $server->product->memory,
'swap' => $server->product->swap,
'disk' => $server->product->disk,
'io' => $server->product->io,
'cpu' => $server->product->cpu,
],
'feature_limits' => [
'databases' => $server->product->databases,
'backups' => $server->product->backups,
'allocations' => $server->product->allocations,
],
'allocation' => [
'default' => $allocationId,
],
]);

if ($response->failed()) {
throw self::getException('Failed to create server on pterodactyl', $response->status());
}

return $response;
} catch (Exception $e) {
// If it's a connection error (status 0), throw a specific exception
if ($e->getCode() === 0) {
throw self::getException('Unable to connect to Pterodactyl node - Please check if the node is online and accessible', 503);
}
throw $e;
}
}

public function suspendServer(Server $server)
Expand Down Expand Up @@ -452,4 +474,20 @@ public function checkNodeResources(Node $node, int $requireMemory, int $requireD

return true;
}

private function getEnvironmentVariables(Egg $egg, $variables)
{
$environment = [];
$variables = json_decode($variables, true);

foreach ($egg->environment as $envVariable) {
$matchedVariable = collect($variables)->firstWhere('env_variable', $envVariable['env_variable']);

$environment[$envVariable['env_variable']] = $matchedVariable
? $matchedVariable['filled_value']
: $envVariable['default_value'];
}

return $environment;
}
}
5 changes: 3 additions & 2 deletions app/Console/Commands/ChargeServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function handle()
} catch (\Exception $exception) {
$this->error($exception->getMessage());
}
return;
}

// charge credits to user
Expand All @@ -127,8 +126,10 @@ public function notifyUsers()
if (!empty($this->usersToNotify)) {
/** @var User $user */
foreach ($this->usersToNotify as $user) {
$suspendServers = $user->servers()->whereNotNull('suspended')->get();

$this->line("<fg=yellow>Notified user:</> <fg=blue>{$user->name}</>");
$user->notify(new ServersSuspendedNotification());
$user->notify(new ServersSuspendedNotification($suspendServers));
}
}

Expand Down
30 changes: 30 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

namespace App\Exceptions;

use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Throwable;

class Handler extends ExceptionHandler
{


/**
* A list of exception types with their corresponding custom log levels.
*
Expand Down Expand Up @@ -47,4 +52,29 @@ public function register()
//
});
}


/**
* @param $request
* @param Throwable $exception
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* @throws Throwable
*/
public function render($request, Throwable $exception)
{
Log::error($exception->getMessage()); // Log the exception

if ($this->isHttpException($exception)) {
if (view()->exists('errors.' . $exception->getStatusCode())) {
return response()->view(
'errors.' . $exception->getStatusCode(),
['exception' => $exception],
$exception->getStatusCode()
);
}
}

// Fallback to default behavior for non-HTTP exceptions
return parent::render($request, $exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Illuminate\Support\Facades\Http;
use App\Notifications\ConfirmPaymentNotification;
use App\Extensions\PaymentGateways\MercadoPago\MercadoPagoSettings;
use Illuminate\Http\RedirectResponse;

/**
* Summary of MercadoPagoExtension
Expand Down Expand Up @@ -62,6 +63,7 @@ public static function getRedirectUrl(Payment $payment, ShopProduct $shopProduct
'failure' => route('payment.Cancel'),
'pending' => route('payment.MercadoPagoSuccess'),
],
'auto_return' => 'approved',
'notification_url' => route('payment.MercadoPagoWebhook'),
'payer' => [
'email' => $user->email,
Expand All @@ -74,6 +76,7 @@ public static function getRedirectUrl(Payment $payment, ShopProduct $shopProduct
'currency_id' => $shopProduct->currency_code,
],
],
'external_reference' => $payment->id,
'metadata' => [
'credit_amount' => $shopProduct->quantity,
'user_id' => $user->id,
Expand All @@ -93,13 +96,19 @@ public static function getRedirectUrl(Payment $payment, ShopProduct $shopProduct
}
}

static function Success(Request $request): void
static function Success(Request $request): RedirectResponse
{
$payment = Payment::findOrFail($request->input('payment'));
$payment = Payment::findOrFail($request->input('external_reference'));

// In some cases, the webhook is received even before the success route.
if ($payment->status === PaymentStatus::PAID) {
return Redirect::route('home')->with('success', 'Your payment has already been processed!')->send();
}

$payment->status = PaymentStatus::PROCESSING;
$payment->save();
Redirect::route('home')->with('success', 'Your payment is being processed!')->send();
return;

return Redirect::route('home')->with('success', 'Your payment is being processed!')->send();
}

static function Webhook(Request $request): JsonResponse
Expand Down
28 changes: 15 additions & 13 deletions app/Extensions/PaymentGateways/Mollie/MollieExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
use App\Enums\PaymentStatus;
use App\Events\PaymentEvent;
use App\Events\UserUpdateCreditsEvent;
use App\Models\PartnerDiscount;
use App\Models\Payment;
use App\Models\ShopProduct;
use App\Models\User;
use App\Models\Coupon;
use App\Notifications\ConfirmPaymentNotification;
use App\Traits\Coupon as CouponTrait;
use App\Events\CouponUsedEvent;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Http;
Expand Down Expand Up @@ -52,9 +50,9 @@ public static function getRedirectUrl(Payment $payment, ShopProduct $shopProduct
'value' => $totalPriceString,
],
'description' => "Order #{$payment->id} - " . $shopProduct->name,
'redirectUrl' => route('payment.MollieSuccess'),
'redirectUrl' => route('payment.MollieSuccess', ['payment_id' => $payment->id]),
'cancelUrl' => route('payment.Cancel'),
'webhookUrl' => url('/extensions/payment/MollieWebhook'),
'webhookUrl' => route('payment.MollieWebhook'),
'metadata' => [
'payment_id' => $payment->id,
],
Expand All @@ -72,14 +70,18 @@ public static function getRedirectUrl(Payment $payment, ShopProduct $shopProduct
}
}

static function success(Request $request): void
static function success(Request $request): RedirectResponse
{
$payment = Payment::findOrFail($request->input('payment'));
$payment = Payment::findOrFail($request->input('payment_id'));

if ($payment->status === PaymentStatus::PAID) {
return Redirect::route('home')->with('success', 'Your payment has already been processed!')->send();
}

$payment->status = PaymentStatus::PROCESSING;
$payment->save();

Redirect::route('home')->with('success', 'Your payment is being processed')->send();
return;
return Redirect::route('home')->with('success', 'Your payment is being processed')->send();
}

static function webhook(Request $request): JsonResponse
Expand All @@ -97,15 +99,15 @@ static function webhook(Request $request): JsonResponse
return response()->json(['success' => false]);
}


$payment = Payment::findOrFail($response->json()['metadata']['payment_id']);
$user = User::findOrFail($payment->user_id);
$shopProduct = ShopProduct::findOrFail($payment->shop_item_product_id);
event(new PaymentEvent($payment, $payment, $shopProduct));

if ($response->json()['status'] == 'paid') {
$user = User::findOrFail($payment->user_id);
$payment->status = PaymentStatus::PAID;
$payment->save();
$user->notify(new ConfirmPaymentNotification($payment));
event(new PaymentEvent($user, $payment, $shopProduct));
event(new UserUpdateCreditsEvent($user));
}
} catch (Exception $ex) {
Expand Down
Loading