Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Adding Stripe
-> Updated readme with new dash list
-> Moved install location to view since it is a view
  • Loading branch information
NaysKutzu committed Nov 1, 2023
1 parent 51ef93b commit 07b50c7
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 21 deletions.
20 changes: 9 additions & 11 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@ Well, we created a table to compare the most commonly used pterodactyl clients,
| Feature | MythicalDash | Dashactyl | Heliactyl | NorthClient | HolaClient | Meteor |
| :---: | :---: | :---: | :--: | :--: | :--: | :--: |
| Essentials Options |||||||
| API (Client/Admin) |||||||
| API (Client/Admin) |||||||
| Payment Options | 🔄|🔄|||||
| J4R | 🔄||||||
| Referrals |🔄||||||
| Linkvertise |||||||
| Custom Ads |||||||
| Purge System ||⚠️|⚠️|⚠️|||
| Anti CSRF |||||||
| Anti Bot |||||||
|Telemetry||⚠️|⚠️|⚠️|⚠️||
| Purge System |||||||
| Legal (Terms / Privacy)|||||||
| Leaderboards |||||||
| Support System |||||||
| Anti Bot |||||||
|Telemetry|||||||
| CLI |||||||
| Support System ||||||⚠️|
| Easy Customizations ||||||⚠️|
| Custom (CSS/Header/HTML) |||||||
| Leaderboards |||||||
| Runs everywhere ||||||⚠️|
| CLI |||||||

| Anti CSRF |||||||
| Custom (CSS/Header/HTML) |||||||
| Leaderboards |||||||

## Demo

Expand Down
1 change: 1 addition & 0 deletions migrate/27.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `stripe_publishable_key` TEXT NOT NULL DEFAULT 'none' AFTER `discord_webhook`, ADD `stripe_secret_key` TEXT NOT NULL DEFAULT 'none' AFTER `stripe_publishable_key`;
1 change: 1 addition & 0 deletions migrate/28.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` CHANGE `version` `version` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '3.0.2';
1 change: 1 addition & 0 deletions migrate/29.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `enable_stripe` ENUM('false','true') NOT NULL DEFAULT 'false' AFTER `discord_webhook`;
1 change: 1 addition & 0 deletions migrate/30.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `stripe_coin_per_balance` TEXT NOT NULL DEFAULT '0.25' AFTER `stripe_secret_key`;
1 change: 1 addition & 0 deletions migrate/31.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `stripe_currency` TEXT NOT NULL DEFAULT 'eur' AFTER `stripe_coin_per_balance`;
8 changes: 5 additions & 3 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
}

if (!is_writable(__DIR__)) {
ErrorHandler::ShowCritical("We have no access to our client directory. Open the terminal and run: chown -R www-data:www-data /var/www/client/*");
ErrorHandler::ShowCritical("We have no access to our client directory. Open the terminal and run: chown -R www-data:www-data /var/www/mythicaldash/*");
die();
}

$router = new \Router\Router();

if (file_exists('FIRST_INSTALL')) {
$router->add("/", function () {
require("../install/welcome.php");
require("../view/install/welcome.php");
});
$router->add("/server/check", function () {
require("../install/servercheck.php");
require("../view/install/servercheck.php");
});

$router->add("/(.*)", function () {
Expand All @@ -54,6 +54,8 @@
include(__DIR__ . '/../routes/user.php');
//Routes for /earn/
include(__DIR__ . '/../routes/earn.php');
//Routes for /store/buy/
include(__DIR__ . '/../routes/payments.php');
//Routes for /admin/api/
include(__DIR__ . '/../routes/admin/api.php');
//Routes for /admin/servers/
Expand Down
5 changes: 5 additions & 0 deletions routes/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
require("../view/admin/settings/customcss.php");
});

$router->add("/admin/settings/stripe", function () {
require("../include/main.php");
require("../view/admin/settings/stripe.php");
});

$router->add("/admin/settings/customhead", function () {
require("../include/main.php");
require("../view/admin/settings/customhead.php");
Expand Down
12 changes: 12 additions & 0 deletions routes/payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$router->add("/store/buy/stripe/coins", function () {
require("../include/main.php");
require("../view/stripe/buy_coins.php");
});

$router->add("/store/get/stripe/coins", function () {
require("../include/main.php");
require("../view/stripe/get_coins.php");
});

?>
65 changes: 64 additions & 1 deletion view/admin/settings/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,69 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
</form>
</div>
</div>
<div class="card mb-4">
<h5 class="card-header">Stripe</h5>
<hr class="my-0">
<div class="card-body">
<form action="/admin/settings/stripe" method="GET">
<div class="row">
<div class="form-group col-md-2">
<label class="control-label">Status</label>
<div>
<?php
if (SettingsManager::getSetting("enable_stripe") == 'true') {
?>
<select class="form-control" name="stripe:enabled">
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
<?php
} else {
?>
<select class="form-control" name="stripe:enabled">
<option value="false">Disabled</option>
<option value="true">Enabled</option>
</select>
<?php
}
?>

</div>
</div>
<div class="form-group col-md-4">
<label class="control-label">Currency ISO (ALL LOWERCASE) <a href="https://stripe.com/docs/currencies#presentment-currencies" target="_blank">list</a></label>
<div>
<input type="text" required="" class="form-control" name="stripe:stripe_currency"
value="<?= SettingsManager::getSetting("stripe_currency") ?>">
</div>
</div>
<div class="form-group col-md-3">
<label class="control-label">Public Key</label>
<div>
<input type="text" required="" class="form-control" name="stripe:public_key"
value="<?= SettingsManager::getSetting("stripe_publishable_key") ?>">
</div>
</div>
<div class="form-group col-md-3">
<label class="control-label">Secret Key</label>
<div>
<input type="password" required="" class="form-control" name="stripe:private_key"
value="<?= SettingsManager::getSetting("stripe_secret_key") ?>">
</div>
</div>
<br>

</div>
<br>
<div class="mt-2">
<button type="submit" name="update_settings"
class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
changes</button>
<a href="/admin" class="btn btn-label-secondary waves-effect">Cancel</a>
</div>
</form>
</div>
</div>
<div class="card mb-4">
<h5 class="card-header">Discord Settings</h5>
<hr class="my-0">
Expand Down Expand Up @@ -514,7 +577,7 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
<div class="form-group col-md-5">
<label class="control-label">Secret Key</label>
<div>
<input type="text" required="" class="form-control"
<input type="password" required="" class="form-control"
name="recaptcha:secret_key"
value="<?= SettingsManager::getSetting("turnstile_secretkey") ?>">
</div>
Expand Down
30 changes: 30 additions & 0 deletions view/admin/settings/stripe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
use MythicalDash\ErrorHandler;
include (__DIR__ . '/../../requirements/page.php');
include (__DIR__ . '/../../requirements/admin.php');

try {
if (isset($_GET['update_settings'])) {
$enable_stripe = mysqli_real_escape_string($conn, $_GET['stripe:enabled']);
$stripe_publishable_key = mysqli_real_escape_string($conn, $_GET['stripe:public_key']);
$stripe_secret_key = mysqli_real_escape_string($conn, $_GET['stripe:private_key']);
$stripe_coin_per_balance = mysqli_real_escape_string($conn, $_GET['stripe:coin_per_balance']);
$stripe_currency = mysqli_real_escape_string($conn, $_GET['stripe:stripe_currency']);
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `enable_stripe` = '" . $enable_stripe . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `stripe_publishable_key` = '" . $stripe_publishable_key . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `stripe_secret_key` = '" . $stripe_secret_key . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `stripe_coin_per_balance` = '" . $stripe_coin_per_balance . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `stripe_currency` = '" . $stripe_currency . "' WHERE `mythicaldash_settings`.`id` = 1;");
header('location: /admin/settings?s=We updated the settings inside the database');
$conn->close();
die ();
} else {
header('location: /admin/settings');
die ();
}
} catch (Exception $ex) {
ErrorHandler::Critical("Failed to update settings ",$e);
header('location: /admin/settings?e=Failed to update the settings inside the database');
die ();
}
?>
2 changes: 1 addition & 1 deletion install/servercheck.php → view/install/servercheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ class="h-auto rounded-circle" />
<br>
<h1 class="text-center">No write permission</h1>
<p class="text-center">We don't have access to the folder, make sure to give us permission by:</p>
<div class="alert alert-danger text-center">chown -R www-data:www-data /var/www/client/*</div>
<div class="alert alert-danger text-center">chown -R www-data:www-data /var/www/mythicaldash/*</div>
<div class="text-center">
<br>
<a href="/server/check" class="btn btn-primary">&nbsp; Reload &nbsp;</a>
Expand Down
File renamed without changes.
15 changes: 10 additions & 5 deletions view/server/create.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
use MythicalDash\SettingsManager;

include(__DIR__ . '/../requirements/page.php');
$csrf = new MythicalDash\CSRF();
use MythicalDash\Telemetry;

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['createsv'])) {
if ($csrf->validate('create-server-form')) {
Expand Down Expand Up @@ -192,7 +194,6 @@
header("location: /server/create?e=CSRF Verification Failed");
die();
}

}
}
?>
Expand Down Expand Up @@ -294,7 +295,8 @@
</select>
<br>
<label for="memory">RAM:</label>
<input type="number" name="memory" class="form-control" id="ram" value="" required placeholder="RAM">
<input type="number" name="memory" class="form-control" id="ram" value="" required
placeholder="RAM">
<br>
<label for="disk">DISK:</label>
<input type="number" name="disk" class="form-control" id="disk" required placeholder="DISK">
Expand All @@ -303,13 +305,16 @@
<input type="number" name="cores" class="form-control" id="cpu" required placeholder="CPU">
<br>
<label for="allocations">PORTS:</label>
<input type="number" name="ports" class="form-control" id="allocations" required placeholder="PORTS">
<input type="number" name="ports" class="form-control" id="allocations" required
placeholder="PORTS">
<br>
<label for="databases">DATABASES:</label>
<input type="number" name="databases" class="form-control" id="databases" required placeholder="DATABASES">
<input type="number" name="databases" class="form-control" id="databases" required
placeholder="DATABASES">
<br>
<label for="backups">BACKUPS:</label>
<input type="number" name="backups" class="form-control" id="backups" required placeholder="BACKUPS">
<input type="number" name="backups" class="form-control" id="backups" required
placeholder="BACKUPS">
<br>
<?= $csrf->input('create-server-form'); ?>
<button action="submit" name="createsv" class="btn btn-primary">Create</button>
Expand Down
11 changes: 11 additions & 0 deletions view/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@
}
?>
</div>
<?php
if (SettingsManager::getSetting("enable_stripe") == "true") {
?>
<div class="alert alert-warning" role="alert">
You don't have enough coins. <a href="/store/buy/stripe/coins">Would you like to buy more
coins?</a>
</div>
<?php
}
?>

<div class="row mb-5">
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
Expand Down
Loading

0 comments on commit 07b50c7

Please sign in to comment.