Skip to content

Commit a22e03a

Browse files
committed
PUSH
-> Core addons now shows dash logs -> Update the paths for the project -> Fixed the bug with the security options not being updated -> Core addon now helps the developers debug what is wrong with the dash!
1 parent 70a43c2 commit a22e03a

File tree

13 files changed

+299
-21
lines changed

13 files changed

+299
-21
lines changed

addons/core/routes.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@
22

33
return [
44
[
5-
'path' => '/addon-route',
5+
'path' => '/mythicaldash/php',
66
'view' => 'about.php',
7-
'addon' => __DIR__, // Assuming the routes.php file is in the root of the addon folder
7+
'addon' => __DIR__,
8+
],
9+
[
10+
'path' => '/mythicaldash/info',
11+
'view' => 'info.php',
12+
'addon' => __DIR__,
13+
],
14+
[
15+
'path' => '/mythicaldash/system',
16+
'view' => 'sysinfo.php',
17+
'addon' => __DIR__,
18+
],
19+
[
20+
'path' => '/mythicaldash/addons',
21+
'view' => 'addons.php',
22+
'addon' => __DIR__,
23+
],
24+
[
25+
'path' => '/mythicaldash/logs',
26+
'view' => 'logs.php',
27+
'addon' => __DIR__,
828
],
9-
// Add more routes as needed
1029
];
1130
?>

addons/core/view/about.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
<head>
33
<meta charset="UTF-8">
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5-
<title>Addon Manager</title>
5+
<title>MythicalDash - PhP Info</title>
66
</head>
77
<body>
8-
<nav>
9-
<h1>TEst</h1>
10-
</nav>
8+
<p><?= phpinfo() ?></p>
119
</body>
1210
</html>

addons/core/view/addons.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
use MythicalDash\Database\Connect;
3+
use MythicalDash\AddonsManager;
4+
use MythicalDash\ErrorHandler;
5+
6+
$addonsManager = new AddonsManager();
7+
$loadedAddons = $addonsManager->loadAddons();
8+
$conn = new Connect();
9+
$conn = $conn->connectToDatabase();
10+
11+
header('Content-type: application/json');
12+
ini_set('display_errors', 0);
13+
ini_set('display_startup_errors', 0);
14+
15+
if (!is_writable(__DIR__)) {
16+
http_response_code(500);
17+
$rsp = array(
18+
'code' => 500,
19+
'error' => 'The server is not ready to handle the request.',
20+
'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*'
21+
);
22+
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
23+
}
24+
25+
try {
26+
$addonsData = [];
27+
28+
foreach ($loadedAddons as $addon) {
29+
$addonDetails = $addon['details'];
30+
$addonsData[] = [
31+
'name' => $addonDetails['name'],
32+
'description' => $addonDetails['description'],
33+
'version' => $addonDetails['version'],
34+
'author' => $addonDetails['author'],
35+
];
36+
}
37+
38+
$rsp = array(
39+
'code' => 200,
40+
'error' => null,
41+
'data' => $addonsData,
42+
);
43+
44+
$conn->close();
45+
http_response_code(200);
46+
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
47+
} catch (Exception $e) {
48+
ErrorHandler::Critical('Settings DB ', $e);
49+
$rsp = array(
50+
'code' => 500,
51+
'error' => "The server encountered a situation it doesn't know how to handle.",
52+
'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!'
53+
);
54+
http_response_code(500);
55+
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
56+
}

addons/core/view/info.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
use MythicalDash\Database\Connect;
3+
use MythicalDash\SettingsManager;
4+
use MythicalDash\ErrorHandler;
5+
6+
$conn = new Connect();
7+
$conn = $conn->connectToDatabase();
8+
header('Content-type: application/json');
9+
ini_set('display_errors', 0);
10+
ini_set('display_startup_errors', 0);
11+
if (!is_writable(__DIR__)) {
12+
http_response_code(500);
13+
$rsp = array(
14+
'code' => 500,
15+
'error' => 'The server is not ready to handle the request.',
16+
'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*'
17+
);
18+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
19+
}
20+
21+
try {
22+
$rsp = array(
23+
'code' => 200,
24+
'error' => null,
25+
'data' => array(
26+
'dash_name' => SettingsManager::getSetting('name'),
27+
'dash_version' => SettingsManager::getSetting('version'),
28+
'security_modules' => array(
29+
'turnstile' => SettingsManager::getSetting('enable_turnstile'),
30+
'anti-adblocker' => SettingsManager::getSetting('enable_adblocker_detection'),
31+
'anti-alting' => SettingsManager::getSetting('enable_alting'),
32+
'anti-vpn' => SettingsManager::getSetting('enable_anti_vpn'),
33+
'purge' => SettingsManager::getSetting("server_purge")
34+
),
35+
'stripe' => array(
36+
'enabled' => SettingsManager::getSetting("enable_stripe"),
37+
'public-key' => SettingsManager::getSetting("stripe_publishable_key"),
38+
'currency' => SettingsManager::getSetting("stripe_currency"),
39+
),
40+
'linkvertise' => array(
41+
'enabled' => SettingsManager::getSetting("linkvertise_enabled"),
42+
'code' => SettingsManager::getSetting("linkvertise_code"),
43+
'coins' => SettingsManager::getSetting("linkvertise_coins")
44+
),
45+
'pterodactyl' => array(
46+
'url' => SettingsManager::getSetting("PterodactylURL")
47+
),
48+
'smtp' => array(
49+
'enabled' => SettingsManager::getSetting("enable_smtp"),
50+
'encryption' => SettingsManager::getSetting("smtpSecure"),
51+
'port' => SettingsManager::getSetting("smtpPort"),
52+
'from' => SettingsManager::getSetting("fromEmail")
53+
),
54+
'discord' => array(
55+
'account_link' => SettingsManager::getSetting("enable_discord_link"),
56+
'server_id' => SettingsManager::getSetting("discord_serverid"),
57+
"client_id" => SettingsManager::getSetting("discord_clientid")
58+
)
59+
),
60+
);
61+
$conn->close();
62+
http_response_code(200);
63+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
64+
} catch (Exception $e) {
65+
ErrorHandler::Critical('Settings DB ', $e);
66+
$rsp = array(
67+
'code' => 500,
68+
'error' => "The server encountered a situation it doesn't know how to handle.",
69+
'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!'
70+
);
71+
http_response_code(500);
72+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
73+
}
74+
?>

addons/core/view/logs.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
use MythicalDash\Database\Connect;
3+
use MythicalDash\ErrorHandler;
4+
5+
$conn = new Connect();
6+
$conn = $conn->connectToDatabase();
7+
header('Content-type: application/json');
8+
ini_set('display_errors', 0);
9+
ini_set('display_startup_errors', 0);
10+
if (!is_writable(__DIR__)) {
11+
http_response_code(500);
12+
$rsp = array(
13+
'code' => 500,
14+
'error' => 'The server is not ready to handle the request.',
15+
'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*'
16+
);
17+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
18+
}
19+
try {
20+
$logFilePath = '../logs/mythicaldash.app-error.log';
21+
$logContent = file_get_contents($logFilePath);
22+
23+
$conn->close();
24+
http_response_code(200);
25+
if ($logContent == null)
26+
{
27+
die("No logs to show");
28+
} else {
29+
die ($logContent);
30+
}
31+
} catch (Exception $e) {
32+
ErrorHandler::Critical('Settings DB ', $e);
33+
$rsp = array(
34+
'code' => 500,
35+
'error' => "The server encountered a situation it doesn't know how to handle.",
36+
'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!'
37+
);
38+
http_response_code(500);
39+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
40+
}
41+
?>

addons/core/view/sysinfo.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
use MythicalDash\Database\Connect;
3+
use MythicalDash\ErrorHandler;
4+
5+
$conn = new Connect();
6+
$conn = $conn->connectToDatabase();
7+
header('Content-type: application/json');
8+
ini_set('display_errors', 0);
9+
ini_set('display_startup_errors', 0);
10+
if (!is_writable(__DIR__)) {
11+
http_response_code(500);
12+
$rsp = array(
13+
'code' => 500,
14+
'error' => 'The server is not ready to handle the request.',
15+
'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*'
16+
);
17+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
18+
}
19+
try {
20+
$rsp = array(
21+
'code' => 200,
22+
'error' => null,
23+
'data' => array(
24+
'os' => php_uname('s'),
25+
'hostname' => php_uname('n'),
26+
'kernel' => php_uname('r'),
27+
'version' => php_uname("v"),
28+
'arch' => php_uname("m")
29+
),
30+
);
31+
$conn->close();
32+
http_response_code(200);
33+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
34+
} catch (Exception $e) {
35+
ErrorHandler::Critical('Settings DB ', $e);
36+
$rsp = array(
37+
'code' => 500,
38+
'error' => "The server encountered a situation it doesn't know how to handle.",
39+
'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!'
40+
);
41+
http_response_code(500);
42+
die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
43+
}
44+
?>

api/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$rsp = array(
1111
"code" => 500,
1212
"error" => "The server is not ready to handle the request.",
13-
"message" => "We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/client/ && chown -R www-data:www-data /var/www/client/*"
13+
"message" => "We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*"
1414
);
1515
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
1616
}

cli/Program.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,32 @@ public static void Main(string[] args)
154154
Environment.Exit(0x0);
155155
}
156156
}
157+
else if (args.Contains("-environment:down"))
158+
{
159+
try
160+
{
161+
sh.SetMaintenance(true);
162+
Environment.Exit(0x0);
163+
}
164+
catch (Exception ex)
165+
{
166+
logger.Log(LogType.Error, "Failed to update config: " + ex.Message);
167+
Environment.Exit(0x0);
168+
}
169+
}
170+
else if (args.Contains("-environment:up"))
171+
{
172+
try
173+
{
174+
sh.SetMaintenance(false);
175+
Environment.Exit(0x0);
176+
}
177+
catch (Exception ex)
178+
{
179+
logger.Log(LogType.Error, "Failed to update config: " + ex.Message);
180+
Environment.Exit(0x0);
181+
}
182+
}
157183
else if (args.Contains("-debug:disable"))
158184
{
159185
try

cli/build.bash

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
runtimes=("linux-x64" "linux-x86" "linux-arm64" "linux-arm")
44
rm -r bin/Release
55
rm -r obj/
6-
rm /var/www/client/MythicalDashARM32
7-
rm /var/www/client/MythicalDashARM64
8-
rm /var/www/client/MythicalDash64
6+
rm /var/www/mythicaldash/MythicalDashARM32
7+
rm /var/www/mythicaldash/MythicalDashARM64
8+
rm /var/www/mythicaldash/MythicalDash64
99

1010
for runtime in "${runtimes[@]}"; do
1111
echo "Publishing for runtime: $runtime"
@@ -14,9 +14,9 @@ for runtime in "${runtimes[@]}"; do
1414
dotnet publish -c Release -r "$runtime" --self-contained true /p:PublishSingleFile=true -p:Version=1.0.0.1
1515
echo "----------------------------------"
1616
done
17-
mv /var/www/client/cli/bin/Release/net7.0/linux-arm/publish/MythicalDash /var/www/client
18-
mv /var/www/client/MythicalDash /var/www/client/MythicalDashARM32
19-
mv /var/www/client/cli/bin/Release/net7.0/linux-arm64/publish/MythicalDash /var/www/client
20-
mv /var/www/client/MythicalDash /var/www/client/MythicalDashARM64
21-
mv /var/www/client/cli/bin/Release/net7.0/linux-x64/publish/MythicalDash /var/www/client
22-
mv /var/www/client/MythicalDash /var/www/client/MythicalDash64
17+
mv /var/www/mythicaldash/cli/bin/Release/net7.0/linux-arm/publish/MythicalDash /var/www/client
18+
mv /var/www/mythicaldash/MythicalDash /var/www/mythicaldash/MythicalDashARM32
19+
mv /var/www/mythicaldash/cli/bin/Release/net7.0/linux-arm64/publish/MythicalDash /var/www/client
20+
mv /var/www/mythicaldash/MythicalDash /var/www/mythicaldash/MythicalDashARM64
21+
mv /var/www/mythicaldash/cli/bin/Release/net7.0/linux-x64/publish/MythicalDash /var/www/client
22+
mv /var/www/mythicaldash/MythicalDash /var/www/mythicaldash/MythicalDash64

cli/scripts/SettingsHandler.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ public void Setup()
8686
}
8787
}
8888

89+
public void SetMaintenance(bool status)
90+
{
91+
try
92+
{
93+
if (status == true)
94+
{
95+
96+
}
97+
else if (status == false)
98+
{
99+
100+
}
101+
}
102+
catch (Exception ex)
103+
{
104+
Program.logger.Log(LogType.Error, "Sorry but the auto settings throws this error: " + ex.Message);
105+
}
106+
}
107+
89108
public void PurgeCache()
90109
{
91110
if (fm.ConfigExists() == true)
@@ -107,7 +126,7 @@ public void PurgeCache()
107126
{
108127
File.Delete(logFile);
109128
}
110-
Program.logger.Log(LogType.Info,"Done");
129+
Program.logger.Log(LogType.Info, "Done");
111130
}
112131
catch (Exception ex)
113132
{

0 commit comments

Comments
 (0)