forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
53 lines (43 loc) · 1.23 KB
/
index.php
File metadata and controls
53 lines (43 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_GET);
if ($_SESSION["userContext"] === "admin" && !empty($_GET["user"])) {
$user = quoteshellarg($_GET["user"]);
$user_plain = $_GET["user"];
}
// Checks if API access is enabled
$api_status =
!empty($_SESSION["API_SYSTEM"]) && is_numeric($_SESSION["API_SYSTEM"])
? $_SESSION["API_SYSTEM"]
: 0;
if (
($user_plain == $_SESSION["ROOT_USER"] && $api_status < 1) ||
($user_plain != $_SESSION["ROOT_USER"] && $api_status < 2)
) {
header("Location: /edit/user/");
exit();
}
if (!empty($_GET["key"])) {
$v_key = quoteshellarg(trim($_GET["key"]));
// Key data
exec(HESTIA_CMD . "v-list-access-key " . $v_key . " json", $output, $return_var);
$key_data = json_decode(implode("", $output), true);
unset($output);
if (empty($key_data) || $key_data["USER"] != $user_plain) {
header("Location: /list/access-key/");
exit();
}
exec(HESTIA_CMD . "v-delete-access-key " . $v_key, $output, $return_var);
check_return_code($return_var, $output);
unset($output);
}
$back = $_SESSION["back"];
if (!empty($back)) {
header("Location: " . $back);
exit();
}
header("Location: /list/key/");
exit();