Skip to content

Commit

Permalink
Merge pull request #64
Browse files Browse the repository at this point in the history
-> Now you can customize the colors using a custom CSS inside the settings path. 
-> Now you can customize the header, so you can add Google AdSense, etc.
  • Loading branch information
NaysKutzu authored Oct 18, 2023
2 parents b794b72 + dbc036b commit e72ef80
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 2 deletions.
1 change: 1 addition & 0 deletions migrate/10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `customhead_enabled` ENUM('false','true') NOT NULL DEFAULT 'true' AFTER `customcss_code`, ADD `customhead_code` TEXT NOT NULL DEFAULT '<link rel=\"manifest\" href=\"/manifest.webmanifest\">' AFTER `customhead_enabled`;
1 change: 1 addition & 0 deletions migrate/8.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 '\'2.0.1\'';
1 change: 1 addition & 0 deletions migrate/9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `customcss_enabled` ENUM('false','true') NOT NULL DEFAULT 'false' AFTER `ads_code`, ADD `customcss_code` TEXT NOT NULL DEFAULT '.body { height: unset; }' AFTER `customcss_enabled`;
10 changes: 10 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@
require("../view/admin/settings/ads.php");
});

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

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

$router->add("/admin/settings/pterodactyl", function () {
require("../include/main.php");
require("../view/admin/settings/pterodactyl.php");
Expand Down
17 changes: 17 additions & 0 deletions view/admin/settings/customcss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
include(__DIR__ . '/../../requirements/page.php');
include(__DIR__ . '/../../requirements/admin.php');

if (isset($_GET['update_settings'])) {
$customcss_enabled = mysqli_real_escape_string($conn,$_GET['customcss:enabled']);
$customcss_code = mysqli_real_escape_string($conn,$_GET['customcss:code']);
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `customcss_enabled` = '" . $customcss_enabled . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `customcss_code` = '" . $customcss_code . "' WHERE `mythicaldash_settings`.`id` = 1;");
header('location: /admin/settings');
$conn->close();
die();
} else {
header('location: /admin/settings');
die();
}
?>
17 changes: 17 additions & 0 deletions view/admin/settings/customhead.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
include(__DIR__ . '/../../requirements/page.php');
include(__DIR__ . '/../../requirements/admin.php');

if (isset($_GET['update_settings'])) {
$customhead_enabled = mysqli_real_escape_string($conn,$_GET['customhead:enabled']);
$customhead_code = mysqli_real_escape_string($conn,$_GET['customhead:code']);
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `customhead_enabled` = '" . $customhead_enabled . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `customhead_code` = '" . $customhead_code . "' WHERE `mythicaldash_settings`.`id` = 1;");
header('location: /admin/settings');
$conn->close();
die();
} else {
header('location: /admin/settings');
die();
}
?>
98 changes: 98 additions & 0 deletions view/admin/settings/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,104 @@ 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">Custom CSS</h5>
<hr class="my-0">
<div class="card-body">
<form action="/admin/settings/customcss" method="GET">
<div class="row">
<div class="form-group col-md-2">
<label class="control-label">Status</label>
<div>
<?php
if ($settings['customcss_enabled'] == "true") {
?>
<select class="form-control" name="customcss:enabled">
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
<?php
} else {
?>
<select class="form-control" name="customcss:enabled">
<option value="false">Disabled</option>
<option value="true">Enabled</option>
</select>
<?php
}
?>

</div>
</div>
<br>
<div class="form-group">
<label class="control-label">Style.css</label>
<div>
<textarea type="text" required="" class="form-control"
name="customcss:code" rows="4"
value=""><?= $settings['customcss_code'] ?></textarea>
</div>
</div>
</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">Custom Header Code</h5>
<hr class="my-0">
<div class="card-body">
<form action="/admin/settings/customhead" method="GET">
<div class="row">
<div class="form-group col-md-2">
<label class="control-label">Status</label>
<div>
<?php
if ($settings['customhead_enabled'] == "true") {
?>
<select class="form-control" name="customhead:enabled">
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
<?php
} else {
?>
<select class="form-control" name="customhead:enabled">
<option value="false">Disabled</option>
<option value="true">Enabled</option>
</select>
<?php
}
?>

</div>
</div>
<br>
<div class="form-group">
<label class="control-label">Custom head code</label>
<div>
<textarea type="text" required="" class="form-control"
name="customhead:code" rows="4"
value=""><?= $settings['customhead_code'] ?></textarea>
</div>
</div>
</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>
<?php include(__DIR__ . '/../../components/footer.php') ?>
<div class="content-backdrop fade"></div>
Expand Down
17 changes: 15 additions & 2 deletions view/requirements/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class="template-customizer-theme-css" />
<script src="<?= $appURL ?>/assets/vendor/js/template-customizer.js"></script>
<script src="<?= $appURL ?>/assets/js/config.js"></script>
<link rel="stylesheet" href="<?= $appURL ?>/assets/css/preloader.css" />
<link rel="manifest" href="/manifest.webmanifest">
<style>
.badge.requestor-type {
font-size: 10px;
Expand All @@ -53,10 +52,24 @@ class="template-customizer-theme-css" />
}
</style>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<?php
<?php
if ($cfg_is_console_on == 'true') {
?>
<script src="<?= $appURL ?>/assets/js/disable-console.js"></script>
<?php
}

if ($settings['customcss_enabled'] == 'true') {
?>
<style type="text/css">
<?= $settings['customcss_code'] ?>
</style>
<?php
}

if ($settings['customhead_enabled'] == 'true') {
?>
<?= $settings['customhead_code'] ?>
<?php
}
?>

0 comments on commit e72ef80

Please sign in to comment.