aboutsummaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/api/_demo.php5
-rw-r--r--admin/api/getUbuntuUpgrades.php10
-rw-r--r--admin/api/getUpdates.php26
-rw-r--r--admin/api/refreshUpdates.php4
-rw-r--r--admin/api/serverLogSummary.php8
-rw-r--r--admin/api/serverTemp.php20
-rw-r--r--admin/api/serverTime.php12
-rw-r--r--admin/api/terminateAllSessions.php34
-rw-r--r--admin/api/terminateGameSessions.php23
-rw-r--r--admin/api/terminateWebSessions.php23
-rw-r--r--admin/callback/index.php48
-rw-r--r--admin/index.php181
-rw-r--r--admin/panes/home.php136
-rw-r--r--admin/panes/kartik.php111
-rw-r--r--admin/panes/unchained.php81
-rw-r--r--admin/panes/uptime.php87
-rw-r--r--admin/panes/version.php139
-rw-r--r--admin/private/footer.php2
-rw-r--r--admin/private/header.api.php11
-rw-r--r--admin/private/header.php28
-rw-r--r--admin/session/index.php6
21 files changed, 995 insertions, 0 deletions
diff --git a/admin/api/_demo.php b/admin/api/_demo.php
new file mode 100644
index 0000000..e4651f1
--- /dev/null
+++ b/admin/api/_demo.php
@@ -0,0 +1,5 @@
+<?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/getUbuntuUpgrades.php b/admin/api/getUbuntuUpgrades.php
new file mode 100644
index 0000000..dcf06ce
--- /dev/null
+++ b/admin/api/getUbuntuUpgrades.php
@@ -0,0 +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");
+} \ No newline at end of file
diff --git a/admin/api/getUpdates.php b/admin/api/getUpdates.php
new file mode 100644
index 0000000..57ce275
--- /dev/null
+++ b/admin/api/getUpdates.php
@@ -0,0 +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;
+}
+
+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
new file mode 100644
index 0000000..ea6f991
--- /dev/null
+++ b/admin/api/refreshUpdates.php
@@ -0,0 +1,4 @@
+<?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
new file mode 100644
index 0000000..2d90fe1
--- /dev/null
+++ b/admin/api/serverLogSummary.php
@@ -0,0 +1,8 @@
+<?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
new file mode 100644
index 0000000..19e383a
--- /dev/null
+++ b/admin/api/serverTemp.php
@@ -0,0 +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");
+} \ No newline at end of file
diff --git a/admin/api/serverTime.php b/admin/api/serverTime.php
new file mode 100644
index 0000000..d0db5e3
--- /dev/null
+++ b/admin/api/serverTime.php
@@ -0,0 +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;
+
+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/terminateAllSessions.php b/admin/api/terminateAllSessions.php
new file mode 100644
index 0000000..2aa5c5f
--- /dev/null
+++ b/admin/api/terminateAllSessions.php
@@ -0,0 +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");
+die(); \ No newline at end of file
diff --git a/admin/api/terminateGameSessions.php b/admin/api/terminateGameSessions.php
new file mode 100644
index 0000000..2f895b1
--- /dev/null
+++ b/admin/api/terminateGameSessions.php
@@ -0,0 +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();
diff --git a/admin/api/terminateWebSessions.php b/admin/api/terminateWebSessions.php
new file mode 100644
index 0000000..956782f
--- /dev/null
+++ b/admin/api/terminateWebSessions.php
@@ -0,0 +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");
+die(); \ No newline at end of file
diff --git a/admin/callback/index.php b/admin/callback/index.php
new file mode 100644
index 0000000..d5462f9
--- /dev/null
+++ b/admin/callback/index.php
@@ -0,0 +1,48 @@
+<?php
+
+// TODO: handle errors
+
+if (!isset($_GET['code'])) {
+ die();
+}
+
+$appdata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/admin/private/app.json"), true);
+
+$crl = curl_init('https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/token');
+curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($crl, CURLINFO_HEADER_OUT, true);
+curl_setopt($crl, CURLOPT_POST, true);
+curl_setopt($crl, CURLOPT_HTTPHEADER, [
+ "Authorization: Basic " . base64_encode($appdata["id"] . ":" . $appdata["secret"]),
+ "Content-Type: application/x-www-form-urlencoded",
+ "Accept: application/json"
+]);
+curl_setopt($crl, CURLOPT_POSTFIELDS, "grant_type=authorization_code&redirect_uri=" . urlencode("https://minteck.ro.lt/admin/callback") . "&code=" . $_GET['code']);
+
+$result = curl_exec($crl);
+$result = json_decode($result, true);
+
+curl_close($crl);
+
+if (isset($result["access_token"])) {
+ $crl = curl_init('https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/users/me');
+ curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($crl, CURLINFO_HEADER_OUT, true);
+ curl_setopt($crl, CURLOPT_HTTPHEADER, [
+ "Authorization: Bearer " . $result["access_token"],
+ "Accept: application/json"
+ ]);
+
+ $result = curl_exec($crl);
+ $result = json_decode($result, true);
+
+ if ($result["id"] === "74bca7d2-4694-477c-8bc1-9003315abbee") {
+ $token = bin2hex(random_bytes(32));
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/admin/private/tokens/" . $token, json_encode($result));
+ setcookie("ADMIN_TOKEN", $token, 0, "/", ".minteck.ro.lt", true, true);
+
+ header("Location: /admin");
+ } else {
+ header("Location: /");
+ }
+} \ No newline at end of file
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..edfa596
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,181 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php"; ?>
+
+<!--suppress CssFloatPxLength -->
+<style>
+ .section {
+ color: gray;
+ font-variant: all-petite-caps;
+ font-size: 18px;
+ margin: 20px 20px 5px;
+ padding: 5px 7.5px 0 7.5px;
+ border-top: 1px solid rgba(128, 128, 128, 0.25);
+ }
+
+ .item {
+ cursor: pointer;
+ margin: 0 20px;
+ border-radius: 5px;
+ padding: 2.5px 7.5px;
+ color: lightgray;
+ }
+
+ .item:hover {
+ background: rgba(255, 255, 255, .1);
+ color: #c2c2c2;
+ }
+
+ .item:active, .item:focus, .item.selected {
+ color: #e7e7e7 !important;
+ background: rgba(255, 255, 255, .2) !important;
+ cursor: default;
+ }
+
+ ::-webkit-scrollbar {
+ width: 5px;
+ }
+
+ ::-webkit-scrollbar-track {
+ border-radius: 9999px;
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9999px;
+ background-color: rgba(136, 136, 136, 0.5);
+ transition: background 200ms;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(85, 85, 85, 0.75);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background-color: #222;
+ }
+
+ .credits {
+ margin: 15px 20px 0 20px;
+ border-radius: 5px;
+ padding: 2.5px 7.5px;
+ color: lightgray;
+ opacity: .25;
+ font-size: 12px;
+ }
+
+ .reloadbtn {
+ vertical-align: middle;
+ float: right;
+ display: none;
+ opacity: 0;
+ transition: opacity 200ms, transform 500ms;
+ transform: rotate(0deg);
+ }
+
+ .item.selected .reloadbtn {
+ display: inline-block;
+ opacity: 1;
+ }
+</style>
+
+<div style="position: fixed;inset: 0;z-index: 5;backdrop-filter:blur(10px);background:rgba(47,49,54,1);height:100%;display:grid;grid-template-columns: 256px 1fr;">
+ <div id="menu" style="height:100%;overflow-y: scroll;">
+ <div class="item selected" id="activity-home" style="margin-top:15vh;">
+ Home
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+
+ <h3 class="section">System</h3>
+ <div class="item" id="activity-uptime">
+ Uptime
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+ <div class="item" id="activity-version">
+ Software Versions
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+
+ <h3 class="section">Member Management</h3>
+ <div class="item" id="activity-unchained">
+ UnchainedTech
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+ <div class="item" id="activity-kartik">
+ Kartik Online
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+
+ <h3 class="section">Minteck Space</h3>
+ <div class="item" id="activity-blog">
+ Blog
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+ <div class="item" id="activity-telemetry">
+ Telemetry
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+ <div class="item" id="activity-code">
+ Code of Conduct
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+
+ <h3 class="section">Neutron Cloud</h3>
+ <div class="item" id="activity-quotas">
+ Quotas
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+ <div class="item" id="activity-neutroning">
+ Sites Map
+ <img alt="" src="/static/reload.png" class="reloadbtn">
+ </div>
+
+ <div class="credits" style="margin-bottom:15vh;">
+ Release <?= substr(md5_file($_SERVER['DOCUMENT_ROOT'] . "/admin/index.php"), 0, 7); ?><br>
+ Host <?= PHP_VERSION ?><br>
+ <?= php_uname('s') ?> <?= php_uname('r') ?>
+ </div>
+ </div>
+
+ <div id="content" style="background:rgba(54,57,63,1);">
+ <iframe id="content-frame" src="/admin/panes/home.php" style="background: transparent;border: none;height: 100%;width: 100%;"></iframe>
+ </div>
+
+ <script>
+
+ function activity(id, url, target) {
+ if (target.classList.contains("selected")) return;
+ if (target.classList.contains("reloadbtn")) return;
+
+ Array.from(document.getElementsByClassName("item")).forEach((item) => {
+ item.classList.remove("selected");
+ })
+
+ document.getElementById(id).classList.add("selected");
+ document.getElementById("content-frame").src = url;
+ }
+
+ document.getElementById("activity-home").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/home.php", event.target); }, true)
+ document.getElementById("activity-uptime").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/uptime.php", event.target); }, true)
+ document.getElementById("activity-version").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/version.php", event.target); }, true)
+ document.getElementById("activity-kartik").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/kartik.php", event.target); }, true)
+ document.getElementById("activity-blog").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/blog.php", event.target); }, true)
+ document.getElementById("activity-code").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/code.php", event.target); }, true)
+ document.getElementById("activity-quotas").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/quotas.php", event.target); }, true)
+ document.getElementById("activity-neutroning").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/neutroning.php", event.target); }, true)
+ document.getElementById("activity-telemetry").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/telemetry.php", event.target); }, true)
+ document.getElementById("activity-unchained").addEventListener("click", (event) => { activity(event.target.id, "/admin/panes/unchained.php", event.target); }, true)
+
+ Array.from(document.getElementsByClassName("reloadbtn")).forEach((item) => {
+ item.addEventListener("click", (event) => {
+ if (event.target.style.transform === "rotate(-360deg)") {
+ event.target.style.transform = "rotate(0deg)";
+ } else {
+ event.target.style.transform = "rotate(-360deg)";
+ }
+ document.getElementById("content-frame").contentWindow.location.reload(true);
+ })
+ })
+
+ </script>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?> \ No newline at end of file
diff --git a/admin/panes/home.php b/admin/panes/home.php
new file mode 100644
index 0000000..ac106e4
--- /dev/null
+++ b/admin/panes/home.php
@@ -0,0 +1,136 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>
+
+<style>
+ ::-webkit-scrollbar {
+ width: 5px;
+ }
+
+ ::-webkit-scrollbar-track {
+ border-radius: 9999px;
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9999px;
+ background-color: rgba(136, 136, 136, 0.5);
+ transition: background 200ms;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(85, 85, 85, 0.75);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background-color: #222;
+ }
+
+ .list-group-item {
+ background: #34373c;
+ }
+</style>
+
+<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;">
+ <h2 style="text-align:center;">Welcome back <?= $_DATA["name"] ?>!</h2>
+ <ul class="list-group" style="margin-top:30px;">
+ <li class="list-group-item">
+ <span id="temperature">Server running at <b><?php
+
+ 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");
+ }
+
+ ?></span> <a href="#" onclick="window.parent.activity('activity-version', '/admin/panes/version.php', window.parent.document.getElementById('activity-version'));" style="float:right;">Manage...</a></li><li class="list-group-item"><b><?php
+
+ $uca = scandir("/mnt/blogchain/_posts");
+ $uct = [];
+
+ foreach ($uca as $art) {
+ if (is_file("/mnt/blogchain/_posts/" . $art) && substr($art, 0, 1) !== "." && substr($art, 0, 1) !== "_") {
+ $uct[] = $art;
+ }
+ }
+
+ echo(count($uct));
+
+ ?></b> UnchainedTech article·s, <?php
+
+ $uca = scandir("/mnt/blogchain/_posts/_drafts");
+ $uct2 = [];
+
+ foreach ($uca as $art) {
+ if (is_file("/mnt/blogchain/_posts/_drafts/" . $art) && substr($art, 0, 1) !== "." && substr($art, 0, 1) !== "_") {
+ $uct2[] = $art;
+ }
+ }
+
+ echo(count($uct2));
+
+ ?> draft·s <a onclick="window.parent.activity('activity-unchained', '/admin/panes/unchained.php', window.parent.document.getElementById('activity-unchained'));" href="#" style="float:right;">Manage...</a></li>
+ <li class="list-group-item"><b><?php
+
+ $uca = scandir("/mnt/minteckrolt-cloud");
+ $uct3 = [];
+
+ foreach ($uca as $art) {
+ if (is_dir("/mnt/minteckrolt-cloud/" . $art) && substr($art, 0, 1) === "~") {
+ $uct3[] = $art;
+ }
+ }
+
+ echo(count($uct3));
+
+ ?></b> Neutron Cloud website·s <a onclick="window.parent.activity('activity-quotas', '/admin/panes/quotas.php', window.parent.document.getElementById('activity-quotas'));" href="#" style="float:right;">Manage...</a></li>
+ <li class="list-group-item"><b><?php
+
+ $uca = scandir("/mnt/kartik/online/private/stats");
+ $uct4 = [];
+
+ foreach ($uca as $art) {
+ if (is_file("/mnt/kartik/online/private/stats/" . $art)) {
+ $uct4[] = $art;
+ }
+ }
+
+ echo(count($uct4));
+
+ ?></b> Kartik Online player·s <a onclick="window.parent.activity('activity-kartik', '/admin/panes/kartik.php', window.parent.document.getElementById('activity-kartik'));" href="#" style="float:right;">Manage...</a></li>
+ <li class="list-group-item"><b><?php
+
+ $uca = scandir("/mnt/minteckrolt-main/includes/blog/data");
+ $uct5 = [];
+
+ foreach ($uca as $art) {
+ if (is_dir("/mnt/minteckrolt-main/includes/blog/data/" . $art)) {
+ $uct4[] = $art;
+ }
+ }
+
+ echo(count($uct4));
+
+ ?></b> blog article·s <a onclick="window.parent.activity('activity-blog', '/admin/panes/blog.php', window.parent.document.getElementById('activity-blog'));" href="#" style="float:right;">Manage...</a></li>
+ </ul>
+ <!--suppress JSUnresolvedVariable, JSUnresolvedFunction -->
+ <script>
+ setInterval(() => {
+ $.ajax("/admin/api/serverTemp.php", {
+ success: (data) => {
+ document.getElementById("temperature").innerHTML = data;
+ }
+ });
+ }, 500)
+ </script>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?> \ No newline at end of file
diff --git a/admin/panes/kartik.php b/admin/panes/kartik.php
new file mode 100644
index 0000000..87a975f
--- /dev/null
+++ b/admin/panes/kartik.php
@@ -0,0 +1,111 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>
+
+<style>
+ ::-webkit-scrollbar {
+ width: 5px;
+ }
+
+ ::-webkit-scrollbar-track {
+ border-radius: 9999px;
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9999px;
+ background-color: rgba(136, 136, 136, 0.5);
+ transition: background 200ms;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(85, 85, 85, 0.75);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background-color: #222;
+ }
+
+ .list-group-item {
+ background: #34373c;
+ }
+</style>
+
+<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;">
+ <div>
+ <h2 style="text-align:center;">Kartik Online</h2>
+ <h4 style="text-align:center;"><?php
+
+ $uca = scandir("/mnt/kartik/online/private/stats");
+ $uct4 = [];
+
+ foreach ($uca as $art) {
+ if (is_file("/mnt/kartik/online/private/stats/" . $art)) {
+ $uct4[] = $art;
+ }
+ }
+
+ echo(count($uct4));
+
+ ?> player·s</h4>
+
+ <ul class="list-group">
+ <?php
+
+ $uca = scandir("/mnt/kartik/online/private/stats");
+ $uct4 = [];
+
+ foreach ($uca as $art) {
+ if (is_file("/mnt/kartik/online/private/stats/" . $art)): ?>
+
+ <li class="list-group-item"><?= $art ?> <?php
+
+ $osession = 0;
+ $gsession = 0;
+ $tsession = 0;
+
+ $webs = scandir("/mnt/kartik/online/private/tokens");
+ $ings = scandir("/mnt/kartik/online/private/gametokens");
+
+ 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"] === $art) {
+ $osession++;
+ }
+ }
+ }
+
+ foreach ($ings 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"] === $art) {
+ $gsession++;
+ }
+ }
+ }
+
+ $tsession = $osession + $gsession;
+ if ($tsession > 1) {
+ $tsessions = "s";
+ } else {
+ $tsessions = "";
+ }
+
+ if ($osession > 0) {
+ echo("<span class='badge text-warning border-warning' style='border:1px solid;vertical-align: middle;'>{$tsession} session{$tsessions} ({$gsession}:{$osession})</span>");
+ } else if ($gsession > 0) {
+ echo("<span class='badge text-success border-success' style='border:1px solid;vertical-align: middle;'>{$tsession} session{$tsessions} ({$gsession}:0)</span>");
+ } else {
+ echo("<span class='badge text-light border-light' style='border:1px solid;vertical-align: middle;'>Offline (0:0)</span>");
+ }
+
+ ?> <span style="float:right;"><a href="/admin/api/terminateWebSessions.php?_=<?= $art ?>">Terminate Web</a> · <a href="/admin/api/terminateGameSessions.php?_=<?= $art ?>">Terminate Game</a> · <a href="/admin/api/terminateAllSessions.php?_=<?= $art ?>">Terminate All</a></span></li>
+
+ <?php endif;
+ }
+
+ ?>
+ </ul>
+ </div>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?> \ No newline at end of file
diff --git a/admin/panes/unchained.php b/admin/panes/unchained.php
new file mode 100644
index 0000000..cab35b5
--- /dev/null
+++ b/admin/panes/unchained.php
@@ -0,0 +1,81 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>
+
+<style>
+ ::-webkit-scrollbar {
+ width: 5px;
+ }
+
+ ::-webkit-scrollbar-track {
+ border-radius: 9999px;
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9999px;
+ background-color: rgba(136, 136, 136, 0.5);
+ transition: background 200ms;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(85, 85, 85, 0.75);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background-color: #222;
+ }
+
+ .list-group-item {
+ background: #34373c;
+ }
+</style>
+
+<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;display: flex;align-items:center;justify-content: center;height:100%;" id="main">
+ <div>
+ <p style="text-align: center;">
+ <img src="/logo.svg" width="96px"><span class="text-muted"> ⏵⏵⏵ </span><!--suppress CheckImageSize -->
+ <img src="/static/apps/unchainedtech.png" width="96px">
+ </p>
+ <br>
+ <h2 style="text-align:center;">You already have access to UnchainedTech Admin</h2>
+
+ <h4 style="text-align:center;">We automatically logged you into UnchainedTech Admin when you logged in to Minteck Admin</h4><br>
+
+ <div style="text-align: center;width:max-content;margin-left:auto;margin-right:auto;">
+ <p class="btn-group">
+ <a href="https://unchainedtech.minteck.ro.lt/articles" target="_blank" class="btn btn-outline-light">All Articles</a>
+ <a href="https://unchainedtech.minteck.ro.lt/admin" target="_blank" class="btn btn-outline-light">Admin Tasks</a>
+ </p>
+ </div>
+
+ <small><p style="text-align: center;">
+ v<?= trim(file_get_contents("/mnt/blogchain/version.txt")) ?> • <a href="#" onclick="document.getElementById('main').style.display='none';document.getElementById('secondary').style.display='';">Manage drafts</a>
+ </p></small>
+ </div>
+</div>
+
+ <div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;display:none;" id="secondary">
+ <div>
+ <h2 style="text-align:center;">UnchainedTech</h2>
+ <h4 style="text-align:center;">Drafts List</h4>
+
+ <small><p style="text-align: center;">
+ v<?= trim(file_get_contents("/mnt/blogchain/version.txt")) ?> • <a href="#" onclick="document.getElementById('main').style.display='flex';document.getElementById('secondary').style.display='none';">Hide drafts list</a>
+ </p></small>
+
+ <ul class="list-group">
+ <?php
+
+ $drafts = false;
+ foreach (scandir("/mnt/blogchain/_posts/_drafts") as $draft) {
+ if ($draft !== "." && $draft !== ".." && $draft !== ".gitkeep" && $draft !== "_template.md") {
+ $drafts = true;
+ echo('<li class="list-group-item">' . substr($draft, 0, -3) . '<span style="float:right;"><a href="https://unchainedtech.minteck.ro.lt/admin/article/' . substr($draft, 0, -3) . '" target="_blank">Preview</a> · <a href="https://github.com/Minteck/UnchainedTech-Content/edit/production/_drafts/' . $draft . '" target="_blank">Edit</a> · <a href="https://github.com/Minteck/UnchainedTech-Content/delete/production/_drafts/' . $draft . '" target="_blank">Delete</a></span></li>');
+ }
+ }
+
+ ?>
+ </ul>
+ </div>
+ </div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?> \ No newline at end of file
diff --git a/admin/panes/uptime.php b/admin/panes/uptime.php
new file mode 100644
index 0000000..71a6545
--- /dev/null
+++ b/admin/panes/uptime.php
@@ -0,0 +1,87 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>
+
+<style>
+ ::-webkit-scrollbar {
+ width: 5px;
+ }
+
+ ::-webkit-scrollbar-track {
+ border-radius: 9999px;
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9999px;
+ background-color: rgba(136, 136, 136, 0.5);
+ transition: background 200ms;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(85, 85, 85, 0.75);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background-color: #222;
+ }
+
+ .list-group-item {
+ background: #34373c;
+ }
+</style>
+
+<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;">
+ <h2 style="text-align:center;">The server has been running for</h2>
+
+ <h4 style="text-align:center;" id="uptime"><?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")
+
+ ?></h4>
+ <!--suppress JSUnresolvedVariable, JSUnresolvedFunction -->
+ <script>
+ setInterval(() => {
+ $.ajax("/admin/api/serverTime.php", {
+ success: (data) => {
+ document.getElementById("uptime").innerText = data;
+ }
+ });
+ }, 500)
+ </script>
+
+ <ul class="list-group" style="margin-top:20px;">
+ <li class="list-group-item">
+ <b><?php
+
+ exec("journalctl --disk-usage", $ret);
+ $data = trim(implode("\n", $ret));
+
+ $val = explode(" ", $data)[6];
+ echo($val);
+
+ ?></b> of data has been collected to ensure easy system maintenance and audit
+ </li>
+ <li class="list-group-item" id="logsummary">
+ Calculating...
+ </li>
+ <!--suppress JSUnresolvedVariable, JSUnresolvedFunction -->
+ <script>
+ $.ajax("/admin/api/serverLogSummary.php", {
+ success: (data) => {
+ document.getElementById("logsummary").innerHTML = data;
+ },
+ error: () => {
+ document.getElementById("logsummary").innerText = "An error occurred while loading this content";
+ }
+ });
+ </script>
+ </ul>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?> \ No newline at end of file
diff --git a/admin/panes/version.php b/admin/panes/version.php
new file mode 100644
index 0000000..04ef136
--- /dev/null
+++ b/admin/panes/version.php
@@ -0,0 +1,139 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>
+
+<style>
+ ::-webkit-scrollbar {
+ width: 5px;
+ }
+
+ ::-webkit-scrollbar-track {
+ border-radius: 9999px;
+ background: transparent;
+ }
+
+ ::-webkit-scrollbar-thumb {
+ border-radius: 9999px;
+ background-color: rgba(136, 136, 136, 0.5);
+ transition: background 200ms;
+ }
+
+ ::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(85, 85, 85, 0.75);
+ }
+
+ ::-webkit-scrollbar-thumb:active {
+ background-color: #222;
+ }
+
+ .list-group-item {
+ background: #34373c;
+ }
+</style>
+
+<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;">
+ <h2 style="text-align:center;">This server is running <?= php_uname('s') ?> version</h2>
+
+ <h4 style="text-align:center;"><?= php_uname('r') . " " . php_uname('v') ?></h4>
+
+ <ul class="list-group" style="margin-top:20px;">
+ <li class="list-group-item">PHP <?= PHP_VERSION ?></li>
+ <li class="list-group-item">UnchainedTech <?= trim(file_get_contents("/mnt/blogchain/version.txt")) ?></li>
+ <li class="list-group-item">Neutron Cloud <?= trim(file_get_contents("/mnt/minteckrolt-cloud/@BASE/source/api/version")) ?></li>
+ <li class="list-group-item">Neutron Copper <?= trim(file_get_contents("/mnt/minteckrolt-cloud/@BASE/source/api/cyclic_version")) ?></li>
+ <li class="list-group-item">Neutron Titanium <?= trim(file_get_contents("/mnt/minteckrolt-cloud/@BASE/source/api/jaw_version")) ?></li>
+ <li class="list-group-item">
+ <?php
+
+ $osr = [];
+ $lines = explode("\n", file_get_contents("/etc/os-release"));
+
+ foreach ($lines as $line) {
+ if (trim($line) !== "") {
+ $parts = explode("=", $line);
+ $osr[$parts[0]] = str_replace("\"", "", $parts[1]);
+ }
+ }
+
+ echo($osr["NAME"] . " " . $osr["VERSION"]);
+
+ ?>
+ </li>
+ <li class="list-group-item">Git <?php exec("git --version", $res);$p = explode(" ", $res[0]);array_shift($p);array_shift($p);echo(implode(" ", $p)) ?></li>
+ <li class="list-group-item"><?php
+
+ $soft = $_SERVER['SERVER_SOFTWARE'];
+
+ if (strpos(strtolower($soft), "apache") !== false) {
+ echo("Apache HTTP Server");
+ } else {
+ echo("nginx");
+ }
+
+ ?> <?php
+
+ $soft = $_SERVER['SERVER_SOFTWARE'];
+
+ if (strpos(strtolower($soft), "apache") !== false) {
+ exec("apache2 -v", $res2);$p = explode(" ", $res2[0]);array_shift($p);array_shift($p);$p2 = explode("/", implode(" ", $p));array_shift($p2);echo(implode(" ", $p2));
+ } else {
+ exec("nginx -v", $res2);$p = explode(" ", $res2[0]);array_shift($p);array_shift($p);$p2 = explode("/", implode(" ", $p));array_shift($p2);echo(implode(" ", $p2));
+ }
+
+ ?></li>
+ </ul>
+
+ <ul class="list-group" style="margin-top:20px;">
+ <li id="checking" class="list-group-item">Checking for updates...</li>
+ <li id="checking2" class="list-group-item" style="display:none;"></li>
+ <li id="found" class="list-group-item" style="display:none;">
+ <b id="updates-count">0</b> package·s have updates available
+
+ <details>
+ <summary>View details</summary>
+ <ul class="list-group" id="updates-list"></ul>
+ </details>
+ </li>
+ </ul>
+ <!--suppress JSUnresolvedVariable, JSUnresolvedFunction, JSUnfilteredForInLoop -->
+ <script>
+ $.ajax("/admin/api/refreshUpdates.php", {
+ success: (data) => {
+ document.getElementById("checking").innerText = "Checking for Ubuntu upgrades...";
+ $.ajax("/admin/api/getUbuntuUpgrades.php", {
+ success: (data) => {
+ document.getElementById("checking").innerHTML = data;
+ document.getElementById("checking2").style.display = "";
+ document.getElementById("checking2").innerText = "Reading package lists...";
+ $.ajax("/admin/api/getUpdates.php", {
+ success: (data) => {
+ document.getElementById("checking2").innerText = "Please wait...";
+ document.getElementById("updates-count").innerText = data.count;
+
+ dom = "";
+ for (let index in data.packages) {
+ item = data.packages[index];
+ dom += `<li class="list-group-item"><b>${item.name}</b> (<span style="color: orange;">${item.version.local}</span> → <span style="color: green;">${item.version.remote}</span>)<br>Provided by: <code>${item.repos}</code>, target architecture: <code>${item.architecture}</code></li>`
+ }
+
+ document.getElementById("updates-list").innerHTML = dom;
+
+ document.getElementById("checking2").outerHTML = "";
+ document.getElementById("found").style.display = "";
+ },
+ error: () => {
+ document.getElementById("checking2").innerText = "An error occurred while loading this content";
+ }
+ });
+ },
+ error: () => {
+ document.getElementById("checking").innerText = "An error occurred while loading this content";
+ }
+ });
+ },
+ error: () => {
+ document.getElementById("checking").innerText = "An error occurred while loading this content";
+ }
+ });
+ </script>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?> \ No newline at end of file
diff --git a/admin/private/footer.php b/admin/private/footer.php
new file mode 100644
index 0000000..691287b
--- /dev/null
+++ b/admin/private/footer.php
@@ -0,0 +1,2 @@
+</body>
+</html> \ No newline at end of file
diff --git a/admin/private/header.api.php b/admin/private/header.api.php
new file mode 100644
index 0000000..ce143f6
--- /dev/null
+++ b/admin/private/header.api.php
@@ -0,0 +1,11 @@
+<?php
+
+if (!isset($_COOKIE["ADMIN_TOKEN"])) {
+ header("Location: https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/auth?client_id=36245ba5-ee9f-44c1-a149-ab2006fcb226&response_type=code&redirect_uri=https://minteck.ro.lt/admin/callback&scope=hub&request_credentials=default&access_type=offline");
+ die();
+} else if (ctype_xdigit($_COOKIE["ADMIN_TOKEN"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN']), true);
+} else {
+ header("Location: https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/auth?client_id=36245ba5-ee9f-44c1-a149-ab2006fcb226&response_type=code&redirect_uri=https://minteck.ro.lt/admin/callback&scope=hub&request_credentials=default&access_type=offline");
+ die();
+} \ No newline at end of file
diff --git a/admin/private/header.php b/admin/private/header.php
new file mode 100644
index 0000000..409d8d1
--- /dev/null
+++ b/admin/private/header.php
@@ -0,0 +1,28 @@
+<?php
+
+if (!isset($_COOKIE["ADMIN_TOKEN"])) {
+ header("Location: https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/auth?client_id=36245ba5-ee9f-44c1-a149-ab2006fcb226&response_type=code&redirect_uri=https://minteck.ro.lt/admin/callback&scope=hub&request_credentials=default&access_type=offline");
+ die();
+} else if (ctype_xdigit($_COOKIE["ADMIN_TOKEN"]) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN'])) {
+ $_DATA = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/admin/private/tokens/" . $_COOKIE['ADMIN_TOKEN']), true);
+} else {
+ header("Location: https://jetbrains.minteck.ro.lt:1024/hub/hub/api/rest/oauth2/auth?client_id=36245ba5-ee9f-44c1-a149-ab2006fcb226&response_type=code&redirect_uri=https://minteck.ro.lt/admin/callback&scope=hub&request_credentials=default&access_type=offline");
+ die();
+}
+
+?>
+
+<!DOCTYPE html>
+<html lang="en" style="height:100%;">
+<head>
+ <meta charset="UTF-8">
+ <title>Minteck Admin</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="icon" href="/logo.svg">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
+ <link rel="stylesheet" href="/static/css/fonts">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
+</head>
+<body class="admin" style="background-color:transparent;height:100%;"> \ No newline at end of file
diff --git a/admin/session/index.php b/admin/session/index.php
new file mode 100644
index 0000000..3dbf45a
--- /dev/null
+++ b/admin/session/index.php
@@ -0,0 +1,6 @@
+<?php
+
+var_dump($_GET);
+var_dump($_POST);
+var_dump($_SERVER);
+die(); \ No newline at end of file