-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-> Finish #78 -> Fixed server creation page with no name
- Loading branch information
Showing
14 changed files
with
223 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `mythicaldash_servers` ADD `purge` ENUM('true','false') NOT NULL DEFAULT 'true' AFTER `uid`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `mythicaldash_settings` ADD `server_purge` ENUM('false','true') NOT NULL AFTER `privacy_policy` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
use MythicalDash\SettingsManager; | ||
include(__DIR__ . '/../../requirements/page.php'); | ||
include(__DIR__ . '/../../requirements/admin.php'); | ||
|
||
function PurgeServers($dbconn) | ||
{ | ||
$dbconn->query("TRUNCATE TABLE `mythicaldash`.`mythicaldash_servers_queue`"); | ||
$query = "SELECT * FROM mythicaldash_servers WHERE mythicaldash_servers.purge = 'true'"; | ||
$resultdb = mysqli_query($dbconn, $query); | ||
if ($resultdb) { | ||
while ($row = mysqli_fetch_assoc($resultdb)) { | ||
$delete_server = curl_init(SettingsManager::getSetting("PterodactylURL") . "/api/application/servers/" . $row['pid'] . "/force"); | ||
curl_setopt($delete_server, CURLOPT_CUSTOMREQUEST, "DELETE"); | ||
$headers = array( | ||
'Accept: application/json', | ||
'Content-Type: application/json', | ||
"Authorization: Bearer " . SettingsManager::getSetting("PterodactylAPIKey") | ||
); | ||
curl_setopt($delete_server, CURLOPT_HTTPHEADER, $headers); | ||
curl_setopt($delete_server, CURLOPT_RETURNTRANSFER, 1); | ||
$result = curl_exec($delete_server); | ||
curl_close($delete_server); | ||
if (!empty($result)) { | ||
header('location: /admin/settings?e=There was an error while deleting a server.'); | ||
$dbconn->close(); | ||
die(); | ||
} | ||
if (mysqli_query($dbconn, "DELETE FROM mythicaldash_servers WHERE pid = '" . mysqli_real_escape_string($dbconn, $row['pid']) . "'")) { | ||
|
||
} else { | ||
header('location: /admin/settings?e=There was an error while deleting a server.'); | ||
$dbconn->close(); | ||
die(); | ||
} | ||
} | ||
} else { | ||
$dbconn->close(); | ||
header('location: /admin/settings?e=Database query error'); | ||
die(); | ||
} | ||
} | ||
try { | ||
PurgeServers($conn); | ||
header('location: /admin/settings?s=We purged every server that was not active'); | ||
die(); | ||
} catch (Exception $ex) { | ||
header('location: /admin/settings?e=Failed to run the purge'); | ||
die(); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
include(__DIR__ . '/../../requirements/page.php'); | ||
include(__DIR__ . '/../../requirements/admin.php'); | ||
try { | ||
if (isset($_GET['update_settings'])) { | ||
$enable_purge = mysqli_real_escape_string($conn, $_GET['purge:enabled']); | ||
if ($enable_purge == "true") { | ||
$conn->query("UPDATE mythicaldash_servers SET `purge` = 'true'"); | ||
} else { | ||
$conn->query("UPDATE mythicaldash_servers SET `purge` = 'false'"); | ||
} | ||
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `server_purge` = '" . $enable_purge . "' WHERE `mythicaldash_settings`.`id` = 1;"); | ||
|
||
$conn->close(); | ||
header('location: /admin/settings?s=We updated the settings inside the database'); | ||
die(); | ||
} else { | ||
header('location: /admin/settings'); | ||
die(); | ||
} | ||
} catch (Exception $ex) { | ||
header('location: /admin/settings?e=Failed to update the settings inside the database'); | ||
die(); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
include(__DIR__ . '/../requirements/page.php'); | ||
if (isset($_GET['id'])) { | ||
$ownsServer = mysqli_query($conn, "SELECT * FROM mythicaldash_servers WHERE id = '" . mysqli_real_escape_string($conn, $_GET["id"]) . "' AND uid = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "'"); | ||
if ($ownsServer->num_rows == 0) { | ||
header('location: /dashboard?e=Sorry but you don`t own this server'); | ||
$conn->close(); | ||
die(); | ||
} | ||
$conn->query("UPDATE `mythicaldash_servers` SET `purge` = 'false' WHERE `mythicaldash_servers`.`id` = " . mysqli_real_escape_string($conn, $_GET['id']) . ";"); | ||
$conn->close(); | ||
header("location: /dashboard?s=We've updated your server settings. Your server will now skip the next purge."); | ||
die(); | ||
} else { | ||
header('location: /dashboard'); | ||
die(); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.