This commit is contained in:
Alexey Berezhok
2024-03-19 22:05:27 +03:00
commit 346a50856b
1572 changed files with 182163 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
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 == "admin" && $api_status < 1) || ($user_plain != "admin" && $api_status < 2)) {
header("Location: /edit/user/");
exit();
}
if (empty($_POST["key"])) {
header("Location: /list/access-key/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/access-key/");
exit();
}
$key = $_POST["key"];
$action = $_POST["action"];
switch ($action) {
case "delete":
$cmd = "v-delete-access-key";
break;
default:
header("Location: /list/access-key/");
exit();
}
foreach ($key as $value) {
$v_key = quoteshellarg(trim($value));
// 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) {
exec(HESTIA_CMD . $cmd . " " . $v_key, $output, $return_var);
unset($output);
}
}
header("Location: /list/access-key/");

36
web/bulk/backup/index.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
if (empty($_POST["backup"])) {
header("Location: /list/backup/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/backup/");
exit();
}
$backup = $_POST["backup"];
$action = $_POST["action"];
// Check token
verify_csrf($_POST);
switch ($action) {
case "delete":
$cmd = "v-delete-user-backup";
break;
default:
header("Location: /list/backup/");
exit();
}
foreach ($backup as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $value, $output, $return_var);
}
header("Location: /list/backup/");

90
web/bulk/cron/index.php Normal file
View File

@@ -0,0 +1,90 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["job"])) {
header("Location: /list/cron/");
exit();
}
$job = $_POST["job"];
if (empty($_POST["action"])) {
header("Location: /list/cron/");
exit();
}
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "delete":
$cmd = "v-delete-cron-job";
break;
case "suspend":
$cmd = "v-suspend-cron-job";
break;
case "unsuspend":
$cmd = "v-unsuspend-cron-job";
break;
case "delete-cron-reports":
$cmd = "v-delete-cron-reports";
exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
$_SESSION["error_msg"] = _("Cron job email reporting has been successfully disabled.");
unset($output);
header("Location: /list/cron/");
exit();
break;
case "add-cron-reports":
$cmd = "v-add-cron-reports";
exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
$_SESSION["error_msg"] = _("Cron job email reporting has been successfully enabled.");
unset($output);
header("Location: /list/cron/");
exit();
break;
default:
header("Location: /list/cron/");
exit();
}
} else {
switch ($action) {
case "delete":
$cmd = "v-delete-cron-job";
break;
case "delete-cron-reports":
$cmd = "v-delete-cron-reports";
exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
$_SESSION["error_msg"] = _("Cron job email reporting has been successfully disabled.");
unset($output);
header("Location: /list/cron/");
exit();
break;
case "add-cron-reports":
$cmd = "v-add-cron-reports";
exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
$_SESSION["error_msg"] = _("Cron job email reporting has been successfully enabled.");
unset($output);
header("Location: /list/cron/");
exit();
break;
default:
header("Location: /list/cron/");
exit();
}
}
foreach ($job as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $value . " no", $output, $return_var);
$restart = "yes";
}
if (!empty($restart)) {
exec(HESTIA_CMD . "v-restart-cron", $output, $return_var);
}
header("Location: /list/cron/");

63
web/bulk/db/index.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["database"])) {
header("Location: /list/db/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/db/");
exit();
}
$database = $_POST["database"];
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "rebuild":
$cmd = "v-rebuild-database";
break;
case "delete":
$cmd = "v-delete-database";
break;
case "suspend":
$cmd = "v-suspend-database";
break;
case "unsuspend":
$cmd = "v-unsuspend-database";
break;
default:
header("Location: /list/db/");
exit();
}
} else {
switch ($action) {
case "delete":
$cmd = "v-delete-database";
break;
case "suspend":
$cmd = "v-suspend-database";
break;
case "unsuspend":
$cmd = "v-unsuspend-database";
break;
default:
header("Location: /list/db/");
exit();
}
}
foreach ($database as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $value, $output, $return_var);
}
header("Location: /list/db/");

121
web/bulk/dns/index.php Normal file
View File

@@ -0,0 +1,121 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["domain"])) {
header("Location: /list/dns/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/dns/");
exit();
}
$domain = $_POST["domain"];
if (empty($_POST["record"])) {
$record = "";
} else {
$record = $_POST["record"];
}
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
if (empty($_POST["record"])) {
switch ($action) {
case "rebuild":
$cmd = "v-rebuild-dns-domain";
break;
case "delete":
$cmd = "v-delete-dns-domain";
break;
case "suspend":
$cmd = "v-suspend-dns-domain";
break;
case "unsuspend":
$cmd = "v-unsuspend-dns-domain";
break;
default:
header("Location: /list/dns/");
exit();
}
} else {
switch ($action) {
case "delete":
$cmd = "v-delete-dns-record";
break;
case "suspend":
$cmd = "v-suspend-dns-record";
break;
case "unsuspend":
$cmd = "v-unsuspend-dns-record";
break;
default:
header("Location: /list/dns/?domain=" . $domain);
exit();
}
}
} else {
if (empty($_POST["record"])) {
switch ($action) {
case "delete":
$cmd = "v-delete-dns-domain";
break;
default:
header("Location: /list/dns/");
exit();
}
} else {
switch ($action) {
case "delete":
$cmd = "v-delete-dns-record";
break;
default:
header("Location: /list/dns/?domain=" . $domain);
exit();
}
}
}
if (empty($_POST["record"])) {
if (is_array($_POST["domain"])) {
foreach ($domain as $value) {
// DNS
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $value . " no", $output, $return_var);
$restart = "yes";
}
} else {
header("Location: /list/dns/?domain=" . $domain);
}
} else {
foreach ($record as $value) {
// DNS Record
$value = quoteshellarg($value);
$dom = quoteshellarg($domain);
exec(
HESTIA_CMD . $cmd . " " . $user . " " . $dom . " " . $value . " no",
$output,
$return_var,
);
$restart = "yes";
}
}
if (!empty($restart)) {
exec(HESTIA_CMD . "v-restart-dns", $output, $return_var);
}
if (empty($_POST["record"])) {
header("Location: /list/dns/");
exit();
} else {
header("Location: /list/dns/?domain=" . $domain);
exit();
}

View File

@@ -0,0 +1,46 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
// Main include
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
// Check user
if ($_SESSION["userContext"] != "admin") {
header("Location: /list/user");
exit();
}
if (empty($_POST["ipchain"])) {
header("Location: /list/firewall/banlist/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/firewall/banlist/");
exit();
}
$ipchain = $_POST["ipchain"];
$action = $_POST["action"];
switch ($action) {
case "delete":
$cmd = "v-delete-firewall-ban";
break;
default:
header("Location: /list/firewall/banlist/");
exit();
}
foreach ($ipchain as $value) {
[$ip, $chain] = explode(":", $value);
$v_ip = quoteshellarg($ip);
$v_chain = quoteshellarg($chain);
exec(HESTIA_CMD . $cmd . " " . $v_ip . " " . $v_chain, $output, $return_var);
}
header("Location: /list/firewall/banlist");

View File

@@ -0,0 +1,51 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
// Main include
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
// Check user
if ($_SESSION["userContext"] != "admin") {
header("Location: /list/user");
exit();
}
if (empty($_POST["rule"])) {
header("Location: /list/firewall/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/firewall/");
exit();
}
$rule = $_POST["rule"];
$action = $_POST["action"];
switch ($action) {
case "delete":
$cmd = "v-delete-firewall-rule";
break;
case "suspend":
$cmd = "v-suspend-firewall-rule";
break;
case "unsuspend":
$cmd = "v-unsuspend-firewall-rule";
break;
default:
header("Location: /list/firewall/");
exit();
}
foreach ($rule as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $value, $output, $return_var);
$restart = "yes";
}
header("Location: /list/firewall/");

View File

@@ -0,0 +1,43 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
// Main include
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
// Check user
if ($_SESSION["userContext"] != "admin") {
header("Location: /list/user");
exit();
}
if (empty($_POST["setname"])) {
header("Location: /list/firewall/ipset/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/firewall/ipset/");
exit();
}
$setname = $_POST["setname"];
$action = $_POST["action"];
switch ($action) {
case "delete":
$cmd = "v-delete-firewall-ipset";
break;
default:
header("Location: /list/firewall/ipset/");
exit();
}
foreach ($setname as $value) {
$v_name = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $v_name, $output, $return_var);
}
header("Location: /list/firewall/ipset/");

47
web/bulk/ip/index.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["ip"])) {
header("Location: /list/ip");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/ip");
exit();
}
$ip = $_POST["ip"];
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "reread IP":
exec(HESTIA_CMD . "v-update-sys-ip", $output, $return_var);
header("Location: /list/ip/");
exit();
break;
case "delete":
$cmd = "v-delete-sys-ip";
break;
default:
header("Location: /list/ip/");
exit();
}
} else {
header("Location: /list/ip/");
exit();
}
foreach ($ip as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $value, $output, $return_var);
}
header("Location: /list/ip/");

125
web/bulk/mail/index.php Normal file
View File

@@ -0,0 +1,125 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["domain"])) {
header("Location: /list/mail");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/mail");
exit();
}
$domain = $_POST["domain"];
if (empty($_POST["account"])) {
$account = "";
} else {
$account = $_POST["account"];
}
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
if (empty($_POST["account"])) {
switch ($action) {
case "rebuild":
$cmd = "v-rebuild-mail-domain";
break;
case "delete":
$cmd = "v-delete-mail-domain";
break;
case "suspend":
$cmd = "v-suspend-mail-domain";
break;
case "unsuspend":
$cmd = "v-unsuspend-mail-domain";
break;
default:
header("Location: /list/mail/");
exit();
}
} else {
switch ($_POST["account"]) {
case "delete":
$cmd = "v-delete-mail-account";
break;
case "suspend":
$cmd = "v-suspend-mail-account";
break;
case "unsuspend":
$cmd = "v-unsuspend-mail-account";
break;
default:
header("Location: /list/mail/?domain=" . $domain);
exit();
}
}
} else {
if (empty($_POST["account"])) {
switch ($action) {
case "delete":
$cmd = "v-delete-mail-domain";
break;
case "suspend":
$cmd = "v-suspend-mail-domain";
break;
case "unsuspend":
$cmd = "v-unsuspend-mail-domain";
break;
default:
header("Location: /list/mail/");
exit();
}
} else {
switch ($_POST["account"]) {
case "delete":
$cmd = "v-delete-mail-account";
break;
case "suspend":
$cmd = "v-suspend-mail-account";
break;
case "unsuspend":
$cmd = "v-unsuspend-mail-account";
break;
default:
header("Location: /list/mail/?domain=" . $domain);
exit();
}
}
}
if (empty($_POST["account"])) {
if (is_array($domain)) {
foreach ($domain as $value) {
// Mail
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $value, $output, $return_var);
$restart = "yes";
}
} else {
header("Location: /list/mail/?domain=" . $domain);
exit();
}
} else {
foreach ($account as $value) {
// Mail Account
$value = quoteshellarg($value);
$dom = quoteshellarg($domain);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $dom . " " . $value, $output, $return_var);
$restart = "yes";
}
}
if (empty($account)) {
header("Location: /list/mail/");
exit();
} else {
header("Location: /list/mail/?domain=" . $domain);
exit();
}

View File

@@ -0,0 +1,43 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["package"])) {
header("Location: /list/package");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/package");
exit();
}
$package = $_POST["package"];
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "delete":
$cmd = "v-delete-user-package";
break;
default:
header("Location: /list/package/");
exit();
}
} else {
header("Location: /list/package/");
exit();
}
foreach ($package as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $value, $output, $return_var);
$restart = "yes";
}
header("Location: /list/package/");

View File

@@ -0,0 +1,88 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["backup"])) {
header("Location: /list/backup/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/backup");
exit();
}
$action = $_POST["action"];
$backup = quoteshellarg($_POST["backup"]);
$web = "no";
$dns = "no";
$mail = "no";
$db = "no";
$cron = "no";
$udir = "no";
if (!empty($_POST["web"])) {
$web = quoteshellarg(implode(",", $_POST["web"]));
}
if (!empty($_POST["dns"])) {
$dns = quoteshellarg(implode(",", $_POST["dns"]));
}
if (!empty($_POST["mail"])) {
$mail = quoteshellarg(implode(",", $_POST["mail"]));
}
if (!empty($_POST["db"])) {
$db = quoteshellarg(implode(",", $_POST["db"]));
}
if (!empty($_POST["cron"])) {
$cron = "yes";
}
if (!empty($_POST["udir"])) {
$udir = quoteshellarg(implode(",", $_POST["udir"]));
}
if ($action == "restore") {
exec(
HESTIA_CMD .
"v-schedule-user-restore " .
$user .
" " .
$backup .
" " .
$web .
" " .
$dns .
" " .
$mail .
" " .
$db .
" " .
$cron .
" " .
$udir,
$output,
$return_var,
);
if ($return_var == 0) {
$_SESSION["error_msg"] = _(
"Task has been added to the queue. You will receive an email notification when your restore has been completed.",
);
} else {
$_SESSION["error_msg"] = implode("<br>", $output);
if (empty($_SESSION["error_msg"])) {
$_SESSION["error_msg"] = _("Error: Hestia did not return any output.");
}
if ($return_var == 4) {
$_SESSION["error_msg"] = _(
"An existing restoration task is already running. Please wait for it to finish before launching it again.",
);
}
}
}
header("Location: /list/backup/?backup=" . $_POST["backup"]);

View File

@@ -0,0 +1,53 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["service"])) {
header("Location: /list/server/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/server/");
exit();
}
$service = $_POST["service"];
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "stop":
$cmd = "v-stop-service";
break;
case "start":
$cmd = "v-start-service";
break;
case "restart":
$cmd = "v-restart-service";
break;
default:
header("Location: /list/server/");
exit();
}
if (!empty($_POST["system"]) && $action == "restart") {
$_SESSION["error_srv"] = _("The system is going down for reboot NOW!");
exec(HESTIA_CMD . "v-restart-system yes", $output, $return_var);
unset($output);
header("Location: /list/server/");
exit();
}
foreach ($service as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $value, $output, $return_var);
}
}
header("Location: /list/server/");

85
web/bulk/user/index.php Normal file
View File

@@ -0,0 +1,85 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["user"])) {
header("Location: /list/user");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/user");
exit();
}
$user = $_POST["user"];
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "delete":
$cmd = "v-delete-user";
$restart = "no";
break;
case "suspend":
$cmd = "v-suspend-user";
$restart = "no";
break;
case "unsuspend":
$cmd = "v-unsuspend-user";
$restart = "no";
break;
case "update counters":
$cmd = "v-update-user-counters";
break;
case "rebuild":
$cmd = "v-rebuild-all";
$restart = "no";
break;
case "rebuild user":
$cmd = "v-rebuild-user";
$restart = "no";
break;
case "rebuild web":
$cmd = "v-rebuild-web-domains";
$restart = "no";
break;
case "rebuild dns":
$cmd = "v-rebuild-dns-domains";
$restart = "no";
break;
case "rebuild mail":
$cmd = "v-rebuild-mail-domains";
break;
case "rebuild db":
$cmd = "v-rebuild-databases";
break;
case "rebuild cron":
$cmd = "v-rebuild-cron-jobs";
break;
default:
header("Location: /list/user/");
exit();
}
} else {
switch ($action) {
case "update counters":
$cmd = "v-update-user-counters";
break;
default:
header("Location: /list/user/");
exit();
}
}
foreach ($user as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $value . " " . $restart, $output, $return_var);
$changes = "yes";
}
header("Location: /list/user/");

71
web/bulk/web/index.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
use function Hestiacp\quoteshellarg\quoteshellarg;
ob_start();
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
// Check token
verify_csrf($_POST);
if (empty($_POST["domain"])) {
header("Location: /list/web/");
exit();
}
if (empty($_POST["action"])) {
header("Location: /list/web");
exit();
}
$domain = $_POST["domain"];
$action = $_POST["action"];
if ($_SESSION["userContext"] === "admin") {
switch ($action) {
case "delete":
$cmd = "v-delete-web-domain";
break;
case "rebuild":
$cmd = "v-rebuild-web-domain";
break;
case "suspend":
$cmd = "v-suspend-web-domain";
break;
case "unsuspend":
$cmd = "v-unsuspend-web-domain";
break;
default:
header("Location: /list/web/");
exit();
}
} else {
switch ($action) {
case "delete":
$cmd = "v-delete-web-domain";
break;
case "suspend":
$cmd = "v-suspend-web-domain";
break;
case "unsuspend":
$cmd = "v-unsuspend-web-domain";
break;
default:
header("Location: /list/web/");
exit();
}
}
foreach ($domain as $value) {
$value = quoteshellarg($value);
exec(HESTIA_CMD . $cmd . " " . $user . " " . $value . " no", $output, $return_var);
$restart = "yes";
}
if (isset($restart)) {
exec(HESTIA_CMD . "v-restart-web", $output, $return_var);
exec(HESTIA_CMD . "v-restart-proxy", $output, $return_var);
exec(HESTIA_CMD . "v-restart-dns", $output, $return_var);
exec(HESTIA_CMD . "v-restart-web-backend", $output, $return_var);
}
header("Location: /list/web/");