Browse code

Created repository.

DoubleBastionAdmin authored on 29/11/2024 03:10:08
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,56 @@
1
+<?php
2
+
3
+/**
4
+ * @copyright 2024 Double Bastion LLC <www.doublebastion.com>
5
+ *
6
+ * @author Double Bastion LLC
7
+ *
8
+ * @license GNU AGPL version 3 or any later version
9
+ *
10
+ * This program is free software; you can redistribute it and/or
11
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
12
+ * License as published by the Free Software Foundation; either
13
+ * version 3 of the License, or any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
19
+ *
20
+ * You should have received a copy of the GNU Affero General Public
21
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
+ *
23
+ */
24
+
25
+session_start();
26
+
27
+if ($_SESSION['loggedtorspanel'] == true) {
28
+
29
+ $stat1_init = shell_exec("free");
30
+ $stat1 = explode("\n", $stat1_init);
31
+
32
+ $ram1_init = explode(" ", $stat1[1]);
33
+ $getnonemptyram1 = array_filter($ram1_init, 'strlen');
34
+ $ram1 = array_values($getnonemptyram1);
35
+
36
+ $swap1_init = explode(" ", $stat1[2]);
37
+ $getnonemptyswap1 = array_filter($swap1_init, 'strlen');
38
+ $swap1 = array_values($getnonemptyswap1);
39
+
40
+ $ramtotal = $ram1[1];
41
+ $swaptotal = $swap1[1];
42
+
43
+ $rampercent = round(($ram1[2] * 100) / $ramtotal, 2);
44
+ $swappercent = round(($swap1[2] * 100) / $swaptotal, 2);
45
+
46
+ $memory = array();
47
+ $memory['ram'] = $rampercent;
48
+ $memory['swap'] = $swappercent;
49
+
50
+ echo json_encode($memory);
51
+
52
+} else {
53
+      header("Location: panel-login.php");
54
+}
55
+
56
+?>