Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Fix bug that you can't delete servers in the waiting list
-> Disable snow
-> Added some developer options
-> Bump some composer packages to the latest version!
-> Now you can perform sql commands from the dashboard iself
-> Now you can purge the caches from the ui and you don't need to use the cli anymore!
  • Loading branch information
NaysKutzu committed Jan 14, 2024
1 parent 1730833 commit 8f9131b
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 20 deletions.
39 changes: 20 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions migrate/49.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE `mythicaldash_settings` SET `version` = '3.1.2' WHERE `mythicaldash_settings`.`id` = 1;
1 change: 1 addition & 0 deletions migrate/50.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE `mythicaldash_settings` SET `show_snow` = 'false' WHERE `mythicaldash_settings`.`id` = 1;
6 changes: 6 additions & 0 deletions routes/admin/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@
require("../include/main.php");
require("../view/admin/servers/logs.php");
});

$router->add("/admin/server/queue/delete", function () {
require("../include/main.php");
require("../view/admin/servers/deleteq.php");
});

?>
10 changes: 10 additions & 0 deletions routes/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,14 @@
require("../include/main.php");
require("../view/admin/settings/tos.php");
});

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

$router->add("/admin/purgecache", function () {
require("../include/main.php");
require("../view/admin/settings/cachepurge.php");
});
?>
29 changes: 29 additions & 0 deletions view/admin/settings/cachepurge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
use MythicalDash\ErrorHandler;

include(__DIR__ . '/../../requirements/page.php');
include(__DIR__ . '/../../requirements/admin.php');

try {
try {
try {
$conn->query("TRUNCATE `mythicaldash_servers_logs`");
$conn->query("TRUNCATE `mythicaldash_resetpasswords`");
$conn->query("TRUNCATE `mythicaldash_login_logs`");
$message = 'Query executed successfully';
} catch (Exception $e) {
$message = $e->getMessage();
}
header('location: /admin/settings?e=' . $message);
die();
} catch (Exception $e) {
$message = 'Failed to run SQL script: ' . $e->getMessage();
header('location: /admin/settings?e=' . $message);
die();
}
} catch (Exception $e) {
ErrorHandler::Critical("MYSQL", "Failed to run SQL script: " . $e->getMessage());
header('location: /admin/settings?e=Failed to run SQL script: ' . $e->getMessage());
die();
}
?>
66 changes: 65 additions & 1 deletion view/admin/settings/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<div class="container-xxl flex-grow-1 container-p-y">
<h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Admin /</span> Settings</h4>
<?php include(__DIR__ . '/../../components/alert.php') ?>
<?php
if (isset($_GET['sqlr'])) {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<code><?= $_GET['sqlr'] ?></code>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php
}
?>
<div class="card mb-4">
<h5 class="card-header text-center">General</h5>
<div class="card-text text-center">
Expand Down Expand Up @@ -623,7 +633,8 @@ class="field-optional"></span></label>
<div>
<input type="text" class="form-control" name="mail:from:address"
value="<?= SettingsManager::getSetting("fromEmail") ?>">
<p class="text-muted small">The email address where you send emails from.</p>
<p class="text-muted small">The email address where you send emails
from.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -1138,6 +1149,27 @@ 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 text-center">Developer Options</h5>
<div class="card-text text-center">
<label>THIS IS THE DANGER ZONE DO NOT RUN ANYTHING OR TOUCH ANYTHING HERE IF NOT TOLD SO
BY THE ORIGINAL DEV <code>mythicaldoggo</code> aka <code>nayskutzu</code>
&NewLine;</label><br>
<p></p>
</div>
<hr class="my-0">
<div class="card-body">
<div class="row">
<div class="form-group col-md-2">
<button type="button" data-bs-toggle="modal" data-bs-target="#executesql"
class="btn btn-primary me-2 waves-effect waves-light" value="true">Run SQL
SCRIPT</button><br><br>&NewLine;&nbsp;
<a href="/admin/purgecache"
class="btn btn-primary me-2 waves-effect waves-light" value="true">Purge Internal Caches</a>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="runpurge" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-simple modal-edit-user">
Expand Down Expand Up @@ -1178,6 +1210,38 @@ functions work or how to use them! If you want to continue, please press
</div>
</div>
</div>
<div class="modal fade" id="executesql" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-simple modal-edit-user">
<div class="modal-content p-3 p-md-5">
<div class="modal-body">
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
<div class="text-center mb-4">
<h3 class="mb-2">Woah, buddy, are you sure you want to run this?</h3>
<p class="form-check-label">This thing is only for debug and fixing MythicalDash
SQL structure</p>
</div>
<form method="POST" action="/admin/sql" class="row g-3">

<div class="mb-3">
<div class="form-check">
<label class="control-label">SQL</label>
<div>
<textarea type="text" required="" class="form-control" name="cmd"
rows="4" value=""></textarea>
</div>
</div>
</div>
<div class="col-12 text-center">
<button type="submit" class="btn btn-danger me-sm-3 me-1">Run</button>
<button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal"
aria-label="Close">Cancel </button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php include(__DIR__ . '/../../components/footer.php') ?>
<div class="content-backdrop fade"></div>
</div>
Expand Down
32 changes: 32 additions & 0 deletions view/admin/settings/sql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
use MythicalDash\ErrorHandler;
include (__DIR__ . '/../../requirements/page.php');
include (__DIR__ . '/../../requirements/admin.php');

try {
if (isset($_POST['cmd']) && !empty($_POST['cmd'])) {
try {
$result = $conn->query($_POST['cmd']);

if ($result !== false) {
$message = 'Query executed successfully';
} else {
$message = 'Query executed successfully, but no results returned.';
}
header('location: /admin/settings?sqlr='.$message);
die();
} catch (Exception $e) {
$message = 'Failed to run SQL script: ' . $e->getMessage();
header('location: /admin/settings?sqlr='.$message);
die();
}
} else {
$message = 'Failed to run SQL script: Null';
header('location: /admin/settings?e=' . $message);
die();
}
} catch (Exception $e) {
ErrorHandler::Critical("MYSQL","Failed to run SQL script: " . $e->getMessage());
header('location: /admin/settings?e=Failed to run SQL script: ' . $e->getMessage());
die();
}

0 comments on commit 8f9131b

Please sign in to comment.