From b35e3fd4b48b5a547c39ed979c94aed3bf489f4c Mon Sep 17 00:00:00 2001
From: crazymath072 <102372274+CR072@users.noreply.github.com>
Date: Sat, 23 Dec 2023 17:23:17 +0530
Subject: [PATCH 1/6] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a1042fe..568ac06 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ If you download from the [Releases](https://github.com/ManucrackYT/LapsusClient/
The best way to contact the developers is on Discord.
-[![discord](https://discordapp.com/api/guilds/954138561509203978/embed.png?style=banner3)][discord]
+[![discord](https://discordapp.com/api/guilds/954138561509203978/embed.png?style=banner3)](https://discord.gg/)
---
From 9a7b4f3a0e5b746515f1ef430809bc9307ca686c Mon Sep 17 00:00:00 2001
From: crazymath072 <102372274+CR072@users.noreply.github.com>
Date: Sat, 23 Dec 2023 17:45:33 +0530
Subject: [PATCH 2/6] Added server control feature
---
api/power.js | 77 +++++++++++++++++++++++++++++++++++++++
settings.json | 3 +-
themes/lapsus/servers.ejs | 41 ++++++++++++++++++++-
3 files changed, 119 insertions(+), 2 deletions(-)
create mode 100644 api/power.js
diff --git a/api/power.js b/api/power.js
new file mode 100644
index 0000000..dd9c72b
--- /dev/null
+++ b/api/power.js
@@ -0,0 +1,77 @@
+const settings = require("../settings.json");
+const fetch = require('node-fetch');
+
+module.exports.load = async function(app, db) {
+ app.get("/api/servers/start", async (req, res) => {
+ if (!req.session.pterodactyl) return res.redirect("/login");
+ const id = req.query.id;
+ const user = req.query.user;
+
+ if (!id || !user) {
+ return;
+ }
+
+ if (user != req.session.userinfo.id) {
+ return res.json({ "success": false, "message": "Unauthorized request" });
+ }
+
+ try {
+ const response = await fetch(`${settings.pterodactyl.domain}/api/client/servers/${id}/power`, {
+ method: "POST",
+ headers: {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${settings.pterodactyl.account_key}`
+ },
+ body: JSON.stringify({ signal: "start" })
+ });
+
+ if (!response.ok) {
+ console.error(`Failed to start server. Status: ${response.status}`);
+ return res.json({ "success": false, "message": "Failed to start server" });
+ }
+
+ console.log("Server started successfully");
+ return res.json({ "success": true, "message": "Operation success!" });
+ } catch (error) {
+ console.error("Error during server start request:", error);
+ return res.json({ "success": false, "message": "Internal server error" });
+ }
+ });
+ app.get("/api/servers/stop", async (req, res) => {
+ if (!req.session.pterodactyl) return res.redirect("/login");
+ const id = req.query.id;
+ const user = req.query.user;
+
+ if (!id || !user) {
+ return;
+ }
+
+ if (user != req.session.userinfo.id) {
+ return res.json({ "success": false, "message": "Unauthorized request" });
+ }
+
+ try {
+ const response = await fetch(`${settings.pterodactyl.domain}/api/client/servers/${id}/power`, {
+ method: "POST",
+ headers: {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${settings.pterodactyl.account_key}`
+ },
+ body: JSON.stringify({ signal: "stop" })
+ });
+
+ if (!response.ok) {
+ console.error(`Failed to start server. Status: ${response.status}`);
+ return res.json({ "success": false, "message": "Failed to start server" });
+ }
+
+ console.log("Server started successfully");
+ return res.json({ "success": true, "message": "Operation success!" });
+ } catch (error) {
+ console.error("Error during server start request:", error);
+ return res.json({ "success": false, "message": "Internal server error" });
+ }
+ });
+}
\ No newline at end of file
diff --git a/settings.json b/settings.json
index 9918fde..f476020 100644
--- a/settings.json
+++ b/settings.json
@@ -33,7 +33,8 @@
},
"pterodactyl": {
"domain": "https://panel.yourdomain.com",
- "key": "ptla_"
+ "key": "ptla_",
+ "account_key": ""
},
"linkvertise": {
"userid": "679241",
diff --git a/themes/lapsus/servers.ejs b/themes/lapsus/servers.ejs
index e17d3c1..8cdfba0 100644
--- a/themes/lapsus/servers.ejs
+++ b/themes/lapsus/servers.ejs
@@ -104,11 +104,50 @@