diff options
author | Minteck <nekostarfan@gmail.com> | 2021-08-08 12:04:30 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-08-08 12:04:30 +0200 |
commit | 95112b1eb06a4be531ded59563d53a63a8d614e8 (patch) | |
tree | fd3dc676227309c87a39feab9ca458985e327907 /admin/api | |
parent | 87303b0d3540037fb94efdde24dbaacb2880d6cb (diff) | |
download | main-95112b1eb06a4be531ded59563d53a63a8d614e8.tar.gz main-95112b1eb06a4be531ded59563d53a63a8d614e8.tar.bz2 main-95112b1eb06a4be531ded59563d53a63a8d614e8.zip |
Opening!
Diffstat (limited to 'admin/api')
-rw-r--r-- | admin/api/_demo.php | 8 | ||||
-rw-r--r-- | admin/api/autosave.php | 31 | ||||
-rw-r--r-- | admin/api/draftvslive.php | 41 | ||||
-rw-r--r-- | admin/api/getQuota.php | 54 | ||||
-rw-r--r-- | admin/api/getUbuntuUpgrades.php | 18 | ||||
-rw-r--r-- | admin/api/getUpdates.php | 50 | ||||
-rw-r--r-- | admin/api/refreshUpdates.php | 6 | ||||
-rw-r--r-- | admin/api/serverLogSummary.php | 14 | ||||
-rw-r--r-- | admin/api/serverTemp.php | 38 | ||||
-rw-r--r-- | admin/api/serverTime.php | 22 | ||||
-rw-r--r-- | admin/api/setlive.php | 33 | ||||
-rw-r--r-- | admin/api/terminateAllSessions.php | 66 | ||||
-rw-r--r-- | admin/api/terminateGameSessions.php | 46 | ||||
-rw-r--r-- | admin/api/terminateWebSessions.php | 44 |
14 files changed, 315 insertions, 156 deletions
diff --git a/admin/api/_demo.php b/admin/api/_demo.php index e4651f1..68b5ad6 100644 --- a/admin/api/_demo.php +++ b/admin/api/_demo.php @@ -1,5 +1,5 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
// Do your API stuff here!
\ No newline at end of file diff --git a/admin/api/autosave.php b/admin/api/autosave.php new file mode 100644 index 0000000..67943cb --- /dev/null +++ b/admin/api/autosave.php @@ -0,0 +1,31 @@ +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_POST['document']) && strpos($_POST['document'], "/") === false) {
+ $doc = $_POST['document'];
+} else {
+ echo("E_ABORT: document");
+ die();
+}
+
+if (isset($_POST['article']) && strpos($_POST['article'], "/") === false) {
+ $blog = $_POST['article'];
+}
+
+if (isset($_POST['content'])) {
+ $data = $_POST['content'];
+} else {
+ echo("E_ABORT: content");
+ die();
+}
+
+echo("STEP");
+if ($_POST["document"] === "blog.en") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-" . $blog . ".json.html", $data);
+} else if ($_POST["document"] === "blog.fr") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-" . $blog . ".json.fr.html", $data);
+} else {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html", $data);
+}
+echo("SUCCESS");
\ No newline at end of file diff --git a/admin/api/draftvslive.php b/admin/api/draftvslive.php new file mode 100644 index 0000000..cc5e325 --- /dev/null +++ b/admin/api/draftvslive.php @@ -0,0 +1,41 @@ +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_POST['document']) && strpos($_POST['document'], "/") === false) {
+ $doc = $_POST['document'];
+} else {
+ die();
+}
+
+if ($doc === "conduct.fr") {
+ if (file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html") === file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/code/fr.html")) {
+ die("true");
+ } else {
+ die("false");
+ }
+}
+
+if ($doc === "conduct.en") {
+ if (file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html") === file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/code/en.html")) {
+ die("true");
+ } else {
+ die("false");
+ }
+}
+
+if ($doc === "blog.en") {
+ if (file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-{$_POST['article']}.json.html") === file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/blog/data/{$_POST['article']}.json.html")) {
+ die("true");
+ } else {
+ die("false");
+ }
+}
+
+if ($doc === "blog.fr") {
+ if (file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-{$_POST['article']}.json.fr.html") === file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/blog/data/{$_POST['article']}.json.fr.html")) {
+ die("true");
+ } else {
+ die("false");
+ }
+}
\ No newline at end of file diff --git a/admin/api/getQuota.php b/admin/api/getQuota.php new file mode 100644 index 0000000..7b4e8e9 --- /dev/null +++ b/admin/api/getQuota.php @@ -0,0 +1,54 @@ +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) {
+ $arg = $_GET['_'];
+} else {
+ die();
+}
+
+$webs = scandir("/mnt/minteckrolt-cloud");
+
+if (in_array($arg, $webs)) {
+ $tier = trim(file_get_contents("/mnt/minteckrolt-cloud/" . $arg . "/Tier"));
+
+ exec("du -hs /mnt/minteckrolt-cloud/" . $arg, $ret);
+ $parts = explode(" ", $ret[0]);
+
+ exec("du -s /mnt/minteckrolt-cloud/" . $arg, $ret2);
+ $parts2 = explode(" ", $ret2[0]);
+
+ if ($tier === "3") {
+ $perc = ($parts2[0] / 100000) * 100;
+ if ($perc > 75) {
+ die("<span class='text-danger'>Using " . $parts[0] . "/100M (" . round($perc, 2) . "%)</span>");
+ } else if ($perc > 50) {
+ die("<span class='text-warning'>Using " . $parts[0] . "/100M (" . round($perc, 2) . "%)</span>");
+ } else {
+ die("<span class='text-success'>Using " . $parts[0] . "/100M (" . round($perc, 2) . "%)</span>");
+ }
+ } else if ($tier === "5") {
+ $perc = ($parts2[0] / 250000) * 100;
+ if ($perc > 75) {
+ die("<span class='text-danger'>Using " . $parts[0] . "/250M (" . round($perc, 2) . "%)</span>");
+ } else if ($perc > 50) {
+ die("<span class='text-warning'>Using " . $parts[0] . "/250M (" . round($perc, 2) . "%)</span>");
+ } else {
+ die("<span class='text-success'>Using " . $parts[0] . "/250M (" . round($perc, 2) . "%)</span>");
+ }
+ } else if ($tier === "7") {
+ $perc = ($parts2[0] / 500000) * 100;
+ if ($perc > 75) {
+ die("<span class='text-danger'>Using " . $parts[0] . "/500M (" . round($perc, 2) . "%)</span>");
+ } else if ($perc > 50) {
+ die("<span class='text-warning'>Using " . $parts[0] . "/500M (" . round($perc, 2) . "%)</span>");
+ } else {
+ die("<span class='text-success'>Using " . $parts[0] . "/500M (" . round($perc, 2) . "%)</span>");
+ }
+ } else {
+ die("<span class='text-success'>Using " . $parts[0] . "</span>");
+ }
+}
+
+die("Unable to calculate data usage");
\ No newline at end of file diff --git a/admin/api/getUbuntuUpgrades.php b/admin/api/getUbuntuUpgrades.php index dcf06ce..7da6259 100644 --- a/admin/api/getUbuntuUpgrades.php +++ b/admin/api/getUbuntuUpgrades.php @@ -1,10 +1,10 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -exec("bash -c \"sudo do-release-upgrade -c | grep 'New release'\"", $ret); -if (count($ret) === 1) { - echo("<b>Ubuntu " . explode("'", $ret[0])[1] . "</b> is available, use <code>do-release-upgrade</code> to upgrade"); -} else { - echo("This server is running the latest version of Ubuntu"); +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+exec("bash -c \"sudo do-release-upgrade -c | grep 'New release'\"", $ret);
+if (count($ret) === 1) {
+ echo("<b>Ubuntu " . explode("'", $ret[0])[1] . "</b> is available, use <code>do-release-upgrade</code> to upgrade");
+} else {
+ echo("This server is running the latest version of Ubuntu");
}
\ No newline at end of file diff --git a/admin/api/getUpdates.php b/admin/api/getUpdates.php index 57ce275..099dd67 100644 --- a/admin/api/getUpdates.php +++ b/admin/api/getUpdates.php @@ -1,26 +1,26 @@ -<?php - -header("Content-Type: application/json"); -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -exec("bash -c \"sudo apt-get upgrade -s| grep ^Inst\"", $ret); -$data = []; -$data["count"] = count($ret); -$data["packages"] = []; - -foreach ($ret as $package) { - $parts = explode(" ", trim($package)); - $pkg = [ - "name" => trim($parts[1]), - "version" => [ - "local" => trim(explode("]", explode("[", $parts[2])[1])[0]), - "remote" => trim(explode("(", $parts[3])[1]), - ], - "repos" => trim(explode(":", explode("(", explode("[", trim($package))[1])[1])[1]), - "architecture" => trim(explode("]", explode("[", trim($package))[2])[0]) - ]; - - $data["packages"][] = $pkg; -} - +<?php
+
+header("Content-Type: application/json");
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+exec("bash -c \"sudo apt-get upgrade -s| grep ^Inst\"", $ret);
+$data = [];
+$data["count"] = count($ret);
+$data["packages"] = [];
+
+foreach ($ret as $package) {
+ $parts = explode(" ", trim($package));
+ $pkg = [
+ "name" => trim($parts[1]),
+ "version" => [
+ "local" => trim(explode("]", explode("[", $parts[2])[1])[0]),
+ "remote" => trim(explode("(", $parts[3])[1]),
+ ],
+ "repos" => trim(explode(":", explode("(", explode("[", trim($package))[1])[1])[1]),
+ "architecture" => trim(explode("]", explode("[", trim($package))[2])[0])
+ ];
+
+ $data["packages"][] = $pkg;
+}
+
echo(json_encode($data, JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/admin/api/refreshUpdates.php b/admin/api/refreshUpdates.php index ea6f991..39ac9ed 100644 --- a/admin/api/refreshUpdates.php +++ b/admin/api/refreshUpdates.php @@ -1,4 +1,4 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
exec("bash -c \"sudo apt-get update", $ret);
\ No newline at end of file diff --git a/admin/api/serverLogSummary.php b/admin/api/serverLogSummary.php index 2d90fe1..78c0a2c 100644 --- a/admin/api/serverLogSummary.php +++ b/admin/api/serverLogSummary.php @@ -1,8 +1,8 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -exec("journalctl -b --quiet", $ret); -$cnt = count($ret); - +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+exec("journalctl -b --quiet", $ret);
+$cnt = count($ret);
+
echo("<b>" . $cnt . "</b> system log messages since last system startup");
\ No newline at end of file diff --git a/admin/api/serverTemp.php b/admin/api/serverTemp.php index 19e383a..55cf34b 100644 --- a/admin/api/serverTemp.php +++ b/admin/api/serverTemp.php @@ -1,20 +1,20 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -echo("Server running at <b>"); -exec("sensors -j", $out); -$outp = implode("\n", $out); -$outd = json_decode($outp, true); - -echo(round($outd["cpu_thermal-virtual-0"]["temp1"]["temp1_input"], 1)); - -?>°C</b>, <?php - -if ($outd["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] > 90) { - echo("completely overheating!"); -} else if ($outd["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] > 60) { - echo("starting to throttle!"); -} else { - echo("under normal temperatures"); +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+echo("Server running at <b>");
+exec("sensors -j", $out);
+$outp = implode("\n", $out);
+$outd = json_decode($outp, true);
+
+echo(round($outd["cpu_thermal-virtual-0"]["temp1"]["temp1_input"], 1));
+
+?>°C</b>, <?php
+
+if ($outd["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] > 90) {
+ echo("completely overheating!");
+} else if ($outd["cpu_thermal-virtual-0"]["temp1"]["temp1_input"] > 60) {
+ echo("starting to throttle!");
+} else {
+ echo("under normal temperatures");
}
\ No newline at end of file diff --git a/admin/api/serverTime.php b/admin/api/serverTime.php index d0db5e3..77ba321 100644 --- a/admin/api/serverTime.php +++ b/admin/api/serverTime.php @@ -1,12 +1,12 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -$str = file_get_contents('/proc/uptime'); -$num = floatval($str); -$secs = fmod($num, 60); $num = intdiv($num, 60); -$mins = $num % 60; $num = intdiv($num, 60); -$hours = $num % 24; $num = intdiv($num, 24); -$days = $num; - +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+$str = file_get_contents('/proc/uptime');
+$num = floatval($str);
+$secs = fmod($num, 60); $num = intdiv($num, 60);
+$mins = $num % 60; $num = intdiv($num, 60);
+$hours = $num % 24; $num = intdiv($num, 24);
+$days = $num;
+
echo($days . " day·s, " . $hours . " hour·s, " . $mins . " minute·s, " . ceil($secs) . " second·s");
\ No newline at end of file diff --git a/admin/api/setlive.php b/admin/api/setlive.php new file mode 100644 index 0000000..0ef8b94 --- /dev/null +++ b/admin/api/setlive.php @@ -0,0 +1,33 @@ +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_POST['document']) && strpos($_POST['document'], "/") === false) {
+ $doc = $_POST['document'];
+} else {
+ die();
+}
+
+if ($doc === "conduct.fr") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/code/fr.html", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html"));
+}
+
+if ($doc === "conduct.en") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/code/en.html", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html"));
+}
+
+if ($doc === "blog.en") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/blog/data/{$_POST['article']}.json.html", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-{$_POST['article']}.json.html"));
+}
+
+if ($doc === "blog.fr") {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/blog/data/{$_POST['article']}.json.fr.html", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-{$_POST['article']}.json.fr.html"));
+}
+
+if ($doc === "blog.en") {
+ unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-{$_POST['article']}.json.html");
+} else if ($doc === "blog.fr") {
+ unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/blog-{$_POST['article']}.json.fr.html");
+} else {
+ unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/drafts/" . $doc . ".html");
+}
\ No newline at end of file diff --git a/admin/api/terminateAllSessions.php b/admin/api/terminateAllSessions.php index 2aa5c5f..46c1b33 100644 --- a/admin/api/terminateAllSessions.php +++ b/admin/api/terminateAllSessions.php @@ -1,34 +1,34 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) { - $arg = $_GET['_']; -} else { - die(); -} - -$webs = scandir("/mnt/kartik/online/private/tokens"); - -foreach ($webs as $webt) { - if (!is_dir("/mnt/kartik/online/private/tokens/" . $webt)) { - $d = json_decode(file_get_contents("/mnt/kartik/online/private/tokens/" . $webt), true); - if ($d["id"] === $arg) { - unlink("/mnt/kartik/online/private/tokens/" . $webt); - } - } -} - -$webs = scandir("/mnt/kartik/online/private/gametokens"); - -foreach ($webs as $webt) { - if (!is_dir("/mnt/kartik/online/private/gametokens/" . $webt)) { - $d = json_decode(file_get_contents("/mnt/kartik/online/private/gametokens/" . $webt), true); - if ($d["id"] === $arg) { - unlink("/mnt/kartik/online/private/gametokens/" . $webt); - } - } -} - -header("Location: /admin/panes/kartik.php"); +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) {
+ $arg = $_GET['_'];
+} else {
+ die();
+}
+
+$webs = scandir("/mnt/kartik/online/private/tokens");
+
+foreach ($webs as $webt) {
+ if (!is_dir("/mnt/kartik/online/private/tokens/" . $webt)) {
+ $d = json_decode(file_get_contents("/mnt/kartik/online/private/tokens/" . $webt), true);
+ if ($d["id"] === $arg) {
+ unlink("/mnt/kartik/online/private/tokens/" . $webt);
+ }
+ }
+}
+
+$webs = scandir("/mnt/kartik/online/private/gametokens");
+
+foreach ($webs as $webt) {
+ if (!is_dir("/mnt/kartik/online/private/gametokens/" . $webt)) {
+ $d = json_decode(file_get_contents("/mnt/kartik/online/private/gametokens/" . $webt), true);
+ if ($d["id"] === $arg) {
+ unlink("/mnt/kartik/online/private/gametokens/" . $webt);
+ }
+ }
+}
+
+header("Location: /admin/panes/kartik.php");
die();
\ No newline at end of file diff --git a/admin/api/terminateGameSessions.php b/admin/api/terminateGameSessions.php index 2f895b1..6975e81 100644 --- a/admin/api/terminateGameSessions.php +++ b/admin/api/terminateGameSessions.php @@ -1,23 +1,23 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) { - $arg = $_GET['_']; -} else { - die(); -} - -$webs = scandir("/mnt/kartik/online/private/gametokens"); - -foreach ($webs as $webt) { - if (!is_dir("/mnt/kartik/online/private/gametokens/" . $webt)) { - $d = json_decode(file_get_contents("/mnt/kartik/online/private/gametokens/" . $webt), true); - if ($d["id"] === $arg) { - unlink("/mnt/kartik/online/private/gametokens/" . $webt); - } - } -} - -header("Location: /admin/panes/kartik.php"); -die(); +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) {
+ $arg = $_GET['_'];
+} else {
+ die();
+}
+
+$webs = scandir("/mnt/kartik/online/private/gametokens");
+
+foreach ($webs as $webt) {
+ if (!is_dir("/mnt/kartik/online/private/gametokens/" . $webt)) {
+ $d = json_decode(file_get_contents("/mnt/kartik/online/private/gametokens/" . $webt), true);
+ if ($d["id"] === $arg) {
+ unlink("/mnt/kartik/online/private/gametokens/" . $webt);
+ }
+ }
+}
+
+header("Location: /admin/panes/kartik.php");
+die();
diff --git a/admin/api/terminateWebSessions.php b/admin/api/terminateWebSessions.php index 956782f..170f4d8 100644 --- a/admin/api/terminateWebSessions.php +++ b/admin/api/terminateWebSessions.php @@ -1,23 +1,23 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php"; - -if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) { - $arg = $_GET['_']; -} else { - die(); -} - -$webs = scandir("/mnt/kartik/online/private/tokens"); - -foreach ($webs as $webt) { - if (!is_dir("/mnt/kartik/online/private/tokens/" . $webt)) { - $d = json_decode(file_get_contents("/mnt/kartik/online/private/tokens/" . $webt), true); - if ($d["id"] === $arg) { - unlink("/mnt/kartik/online/private/tokens/" . $webt); - } - } -} - -header("Location: /admin/panes/kartik.php"); +<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";
+
+if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) {
+ $arg = $_GET['_'];
+} else {
+ die();
+}
+
+$webs = scandir("/mnt/kartik/online/private/tokens");
+
+foreach ($webs as $webt) {
+ if (!is_dir("/mnt/kartik/online/private/tokens/" . $webt)) {
+ $d = json_decode(file_get_contents("/mnt/kartik/online/private/tokens/" . $webt), true);
+ if ($d["id"] === $arg) {
+ unlink("/mnt/kartik/online/private/tokens/" . $webt);
+ }
+ }
+}
+
+header("Location: /admin/panes/kartik.php");
die();
\ No newline at end of file |