| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727 |
- <?php
- use function Hestiacp\quoteshellarg\quoteshellarg;
- $TAB = "SERVER";
- // Main include
- include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
- // Check user
- if ($_SESSION["userContext"] != "admin") {
- header("Location: /list/user");
- exit();
- }
- // Get server hostname
- $v_hostname = exec("hostname");
- // List available timezones and get current one
- exec(HESTIA_CMD . "v-get-sys-timezone", $output, $return_var);
- $v_timezone = $output[0];
- unset($output);
- exec(HESTIA_CMD . "v-get-sys-timezones json", $output, $return_var);
- $v_timezones = json_decode(implode("", $output), true);
- unset($output);
- // List supported php versions
- exec(HESTIA_CMD . "v-list-web-templates-backend json", $output, $return_var);
- $backend_templates = json_decode(implode("", $output), true);
- unset($output);
- $v_php_versions = [
- "php-5.6",
- "php-7.0",
- "php-7.1",
- "php-7.2",
- "php-7.3",
- "php-7.4",
- "php-8.0",
- "php-8.1",
- "php-8.2",
- ];
- sort($v_php_versions);
- if (empty($backend_templates)) {
- $v_php_versions = [];
- }
- $backends_active = backendtpl_with_webdomains();
- $v_php_versions = array_map(function ($php_version) use ($backend_templates, $backends_active) {
- // Mark installed php versions
- if (stripos($php_version, "php") !== 0) {
- return false;
- }
- $phpinfo = (object) [
- "name" => $php_version,
- "tpl" => strtoupper(str_replace(".", "_", $php_version)),
- "version" => str_ireplace("php-", "", $php_version),
- "usedby" => [],
- "installed" => false,
- "protected" => false,
- ];
- if (in_array($phpinfo->tpl, $backend_templates)) {
- $phpinfo->installed = true;
- }
- if (array_key_exists($phpinfo->tpl, $backends_active)) {
- // Prevent used php version to be removed
- if ($phpinfo->installed) {
- $phpinfo->protected = true;
- }
- $phpinfo->usedby = $backends_active[$phpinfo->tpl];
- }
- if ($phpinfo->name == DEFAULT_PHP_VERSION) {
- // Prevent default php version to be removed
- if ($phpinfo->installed) {
- $phpinfo->protected = true;
- }
- if (!empty($backends_active["default"])) {
- $phpinfo->usedby = array_merge_recursive($phpinfo->usedby, $backends_active["default"]);
- }
- }
- return $phpinfo;
- }, $v_php_versions);
- // List languages
- exec(HESTIA_CMD . "v-list-sys-languages json", $output, $return_var);
- $language = json_decode(implode("", $output), true);
- foreach ($language as $lang) {
- $languages[$lang] = translate_json($lang);
- }
- asort($languages);
- unset($output);
- // List themes
- exec(HESTIA_CMD . "v-list-sys-themes json", $output, $return_var);
- $theme = json_decode(implode("", $output), true);
- unset($output);
- // List dns cluster hosts
- exec(HESTIA_CMD . "v-list-remote-dns-hosts json", $output, $return_var);
- $dns_cluster = json_decode(implode("", $output), true);
- unset($output);
- if (is_array($dns_cluster)) {
- foreach ($dns_cluster as $key => $value) {
- $v_dns_cluster = "yes";
- }
- }
- if (empty($v_dns_cluster)) {
- $v_dns_cluster = "";
- }
- $v_release_branch = $_SESSION["RELEASE_BRANCH"];
- // List smtp relay settings
- if (!empty($_SESSION["SMTP_RELAY"])) {
- $v_smtp_relay = $_SESSION["SMTP_RELAY"];
- } else {
- $v_smtp_relay = "";
- }
- if (!empty($_SESSION["SMTP_RELAY_HOST"])) {
- $v_smtp_relay_host = $_SESSION["SMTP_RELAY_HOST"];
- } else {
- $v_smtp_relay_host = "";
- }
- if (!empty($_SESSION["SMTP_RELAY_PORT"])) {
- $v_smtp_relay_port = $_SESSION["SMTP_RELAY_PORT"];
- } else {
- $v_smtp_relay_port = "";
- }
- if (!empty($_SESSION["SMTP_RELAY_USER"])) {
- $v_smtp_relay_user = $_SESSION["SMTP_RELAY_USER"];
- } else {
- $v_smtp_relay_user = "";
- }
- $v_smtp_relay_pass = "";
- if (empty($_POST["v_experimental_features"])) {
- $_POST["v_experimental_features"] = "false";
- }
- if (empty($_POST["v_policy_user_view_suspended"])) {
- $_POST["v_policy_user_view_suspended"] = "false";
- }
- // List Database hosts
- exec(HESTIA_CMD . "v-list-database-hosts json", $output, $return_var);
- $db_hosts = json_decode(implode("", $output), true);
- unset($output);
- $v_mysql_hosts = array_values(
- array_filter($db_hosts, function ($host) {
- return $host["TYPE"] === "mysql";
- }),
- );
- $v_mysql = count($v_mysql_hosts) ? "yes" : "no";
- $v_pgsql_hosts = array_values(
- array_filter($db_hosts, function ($host) {
- return $host["TYPE"] === "pgsql";
- }),
- );
- $v_pgsql = count($v_pgsql_hosts) ? "yes" : "no";
- unset($db_hosts);
- // List backup settings
- $v_backup_dir = "/backup";
- if (!empty($_SESSION["BACKUP"])) {
- $v_backup_dir = $_SESSION["BACKUP"];
- }
- $v_backup_gzip = "5";
- if (!empty($_SESSION["BACKUP_GZIP"])) {
- $v_backup_gzip = $_SESSION["BACKUP_GZIP"];
- }
- $v_backup_mode = "gzip";
- if (!empty($_SESSION["BACKUP_MODE"])) {
- $v_backup_mode = $_SESSION["BACKUP_MODE"];
- }
- $backup_types = explode(",", $_SESSION["BACKUP_SYSTEM"]);
- foreach ($backup_types as $backup_type) {
- if ($backup_type == "local") {
- $v_backup = "yes";
- } else {
- exec(
- HESTIA_CMD . "v-list-backup-host " . quoteshellarg($backup_type) . " json",
- $output,
- $return_var,
- );
- $v_remote_backup = json_decode(implode("", $output), true);
- unset($output);
- if (in_array($backup_type, ["ftp", "sftp"])) {
- $v_backup_host = $v_remote_backup[$backup_type]["HOST"];
- $v_backup_type = $v_remote_backup[$backup_type]["TYPE"];
- $v_backup_username = $v_remote_backup[$backup_type]["USERNAME"] ?? "";
- $v_backup_password = "";
- $v_backup_port = $v_remote_backup[$backup_type]["PORT"] ?? "";
- $v_backup_bpath = $v_remote_backup[$backup_type]["BPATH"];
- $v_backup_remote_adv = "yes";
- } elseif (in_array($backup_type, ["b2"])) {
- $v_backup_bucket = $v_remote_backup[$backup_type]["BUCKET"];
- $v_backup_type = $v_remote_backup[$backup_type]["TYPE"];
- $v_backup_application_id = $v_remote_backup[$backup_type]["B2_KEY_ID"];
- $v_backup_application_key = "";
- $v_backup_remote_adv = "yes";
- } elseif (in_array($backup_type, ["rclone"])) {
- $v_backup_type = $v_remote_backup[$backup_type]["TYPE"];
- $v_rclone_host = $v_remote_backup[$backup_type]["HOST"];
- $v_rclone_path = $v_remote_backup[$backup_type]["BPATH"];
- $v_backup_remote_adv = "yes";
- }
- }
- }
- if (empty($v_backup)) {
- $v_backup = "";
- }
- if (empty($v_backup_host)) {
- $v_backup_host = "";
- }
- if (empty($v_backup_type)) {
- $v_backup_type = "";
- }
- if (empty($v_backup_username)) {
- $v_backup_username = "";
- }
- if (empty($v_backup_password)) {
- $v_backup_password = "";
- }
- if (empty($v_backup_port)) {
- $v_backup_port = "";
- }
- if (empty($v_backup_bpath)) {
- $v_backup_bpath = "";
- }
- if (empty($v_backup_bucket)) {
- $v_backup_bucket = "";
- }
- if (empty($v_backup_application_id)) {
- $v_backup_application_id = "";
- }
- if (empty($v_backup_application_key)) {
- $v_backup_application_key = "";
- }
- if (empty($v_backup_remote_adv)) {
- $v_backup_remote_adv = "";
- }
- if (empty($v_rclone_host)) {
- $v_rclone_host = "";
- }
- if (empty($v_rclone_path)) {
- $v_rclone_path = "";
- }
- // List ssl certificate info
- exec(HESTIA_CMD . "v-list-sys-hestia-ssl json", $output, $return_var);
- $ssl_str = json_decode(implode("", $output), true);
- unset($output);
- $v_ssl_crt = $ssl_str["HESTIA"]["CRT"];
- $v_ssl_key = $ssl_str["HESTIA"]["KEY"];
- $v_ssl_ca = $ssl_str["HESTIA"]["CA"];
- $v_ssl_subject = $ssl_str["HESTIA"]["SUBJECT"];
- $v_ssl_aliases = $ssl_str["HESTIA"]["ALIASES"];
- $v_ssl_not_before = $ssl_str["HESTIA"]["NOT_BEFORE"];
- $v_ssl_not_after = $ssl_str["HESTIA"]["NOT_AFTER"];
- $v_ssl_signature = $ssl_str["HESTIA"]["SIGNATURE"];
- $v_ssl_pub_key = $ssl_str["HESTIA"]["PUB_KEY"];
- $v_ssl_issuer = $ssl_str["HESTIA"]["ISSUER"];
- // Check POST request
- if (!empty($_POST["save"])) {
- $require_refresh = false;
- // Check token
- verify_csrf($_POST);
- // Change hostname
- if (!empty($_POST["v_hostname"]) && $v_hostname != $_POST["v_hostname"]) {
- exec(
- HESTIA_CMD . "v-change-sys-hostname " . quoteshellarg($_POST["v_hostname"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_hostname = $_POST["v_hostname"];
- }
- if ($_SESSION["WEB_BACKEND"] == "php-fpm") {
- // Install/remove php versions
- if (empty($_SESSION["error_msg"])) {
- if (!empty($v_php_versions)) {
- $post_php = $_POST["v_php_versions"];
- if (empty($post_php)) {
- $post_php = [];
- }
- array_map(function ($php_version) use ($post_php) {
- if (array_key_exists($php_version->tpl, $post_php)) {
- if (!$php_version->installed) {
- exec(
- HESTIA_CMD .
- "v-add-web-php " .
- quoteshellarg($php_version->version),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $php_version->installed = true;
- }
- }
- } else {
- if ($php_version->installed && !$php_version->protected) {
- exec(
- HESTIA_CMD .
- "v-delete-web-php " .
- quoteshellarg($php_version->version),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $php_version->installed = false;
- }
- }
- }
- return $php_version;
- }, $v_php_versions);
- }
- }
- if (empty($_SESSION["error_msg"])) {
- if ("php-" . $_POST["v_php_default_version"] != DEFAULT_PHP_VERSION) {
- exec(
- HESTIA_CMD .
- "v-change-sys-php " .
- quoteshellarg($_POST["v_php_default_version"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- //force reload
- $require_refresh = true;
- }
- }
- }
- // Change timezone
- if (empty($_SESSION["error_msg"])) {
- if (!empty($_POST["v_timezone"])) {
- if ($v_timezone != $_POST["v_timezone"]) {
- exec(
- HESTIA_CMD . "v-change-sys-timezone " . quoteshellarg($_POST["v_timezone"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- $v_timezone = $_POST["v_timezone"];
- unset($output);
- }
- }
- }
- // Change default language
- if (empty($_SESSION["error_msg"])) {
- if (!empty($_POST["v_language"]) && $_SESSION["LANGUAGE"] != $_POST["v_language"]) {
- if (isset($_POST["v_language_update"])) {
- exec(
- HESTIA_CMD .
- "v-change-sys-language " .
- quoteshellarg($_POST["v_language"]) .
- " yes",
- $output,
- $return_var,
- );
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["LANGUAGE"] = $_POST["v_language"];
- }
- }
- exec(
- HESTIA_CMD . "v-change-sys-language " . quoteshellarg($_POST["v_language"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["LANGUAGE"] = $_POST["v_language"];
- }
- }
- }
- // Update theme
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_theme"] != $_SESSION["THEME"]) {
- exec(
- HESTIA_CMD . "v-change-sys-config-value THEME " . quoteshellarg($_POST["v_theme"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- }
- }
- // Update debug mode status
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_debug_mode"] == "on") {
- $_POST["v_debug_mode"] = "true";
- } else {
- $_POST["v_debug_mode"] = "false";
- }
- if ($_POST["v_debug_mode"] != $_SESSION["DEBUG_MODE"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value DEBUG_MODE " .
- quoteshellarg($_POST["v_debug_mode"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_debug_mode_adv = "yes";
- }
- }
- // Enable/Disable Quick App Installer
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_plugin_app_installer"] != $_SESSION["PLUGIN_APP_INSTALLER"]) {
- if ($_POST["v_plugin_app_installer"] == "true") {
- $_POST["v_plugin_app_installer"] = "true";
- } else {
- $_POST["v_plugin_app_installer"] = "false";
- }
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value PLUGIN_APP_INSTALLER " .
- quoteshellarg($_POST["v_plugin_app_installer"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- }
- }
- // Update experimental features status
- if (
- empty($_SESSION["error_msg"]) &&
- $_POST["v_experimental_features"] != $_SESSION["POLICY_SYSTEM_ENABLE_BACON"]
- ) {
- if ($_POST["v_experimental_features"] == "on") {
- $_POST["v_experimental_features"] = "true";
- } else {
- $_POST["v_experimental_features"] = "false";
- }
- if ($_POST["v_experimental_features"] != $_SESSION["POLICY_SYSTEM_ENABLE_BACON"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYSTEM_ENABLE_BACON " .
- quoteshellarg($_POST["v_experimental_features"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_debug_mode_adv = "yes";
- }
- if (
- $_POST["v_policy_user_view_suspended"] != $_SESSION["POLICY_SYSTEM_ENABLE_BACON"] &&
- $_POST["v_experimental_features"] == "false"
- ) {
- //disable preview mode
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED " .
- quoteshellarg($_POST["v_policy_user_view_suspended"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- }
- }
- // Set File Manager support
- if (empty($_SESSION["error_msg"])) {
- if (
- !empty($_POST["v_filemanager"]) &&
- $_SESSION["FILE_MANAGER"] != $_POST["v_filemanager"]
- ) {
- if ($_POST["v_filemanager"] == "true") {
- exec(HESTIA_CMD . "v-add-sys-filemanager", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["FILE_MANAGER"] = "true";
- }
- } else {
- exec(HESTIA_CMD . "v-delete-sys-filemanager", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["FILE_MANAGER"] = "false";
- }
- }
- }
- }
- // Set phpMyAdmin SSO key
- if (empty($_SESSION["error_msg"])) {
- if (!empty($_POST["v_phpmyadmin_key"])) {
- if ($_POST["v_phpmyadmin_key"] == "yes" && $_SESSION["PHPMYADMIN_KEY"] == "") {
- exec(HESTIA_CMD . "v-add-sys-pma-sso quiet", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["PHPMYADMIN_KEY"] != "";
- }
- } elseif ($_POST["v_phpmyadmin_key"] == "no" && $_SESSION["PHPMYADMIN_KEY"] != "") {
- exec(HESTIA_CMD . "v-delete-sys-pma-sso quiet", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["PHPMYADMIN_KEY"] = "";
- }
- }
- }
- }
- // Set disk_quota support
- if (empty($_SESSION["error_msg"])) {
- if (!empty($_POST["v_quota"]) && $_SESSION["DISK_QUOTA"] != $_POST["v_quota"]) {
- if ($_POST["v_quota"] == "yes") {
- exec(HESTIA_CMD . "v-add-sys-quota", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["DISK_QUOTA"] = "yes";
- }
- } else {
- exec(HESTIA_CMD . "v-delete-sys-quota", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["DISK_QUOTA"] = "no";
- }
- }
- }
- }
- // Set firewall support
- if (empty($_SESSION["error_msg"])) {
- if ($_SESSION["FIREWALL_SYSTEM"] == "iptables") {
- $v_firewall = "yes";
- }
- if ($_SESSION["FIREWALL_SYSTEM"] != "iptables") {
- $v_firewall = "no";
- }
- if (!empty($_POST["v_firewall"]) && $v_firewall != $_POST["v_firewall"]) {
- if ($_POST["v_firewall"] == "yes") {
- exec(HESTIA_CMD . "v-add-sys-firewall", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["FIREWALL_SYSTEM"] = "iptables";
- }
- } else {
- exec(HESTIA_CMD . "v-delete-sys-firewall", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["FIREWALL_SYSTEM"] = "";
- }
- }
- }
- }
- // Update mysql pasword
- if (empty($_SESSION["error_msg"])) {
- if (!empty($_POST["v_mysql_password"])) {
- exec(
- HESTIA_CMD .
- "v-change-database-host-password mysql localhost root " .
- quoteshellarg($_POST["v_mysql_password"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_db_adv = "yes";
- }
- }
- // Update webmail url
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_webmail_alias"] != $_SESSION["WEBMAIL_ALIAS"]) {
- exec(
- HESTIA_CMD . "v-change-sys-webmail " . quoteshellarg($_POST["v_webmail_alias"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_mail_adv = "yes";
- }
- }
- // Update system wide smtp relay
- if (empty($_SESSION["error_msg"])) {
- if (isset($_POST["v_smtp_relay"]) && !empty($_POST["v_smtp_relay_host"])) {
- if (
- $_POST["v_smtp_relay_host"] != $v_smtp_relay_host ||
- $_POST["v_smtp_relay_user"] != $v_smtp_relay_user ||
- $_POST["v_smtp_relay_port"] != $v_smtp_relay_port
- ) {
- $v_smtp_relay = true;
- $v_smtp_relay_host = quoteshellarg($_POST["v_smtp_relay_host"]);
- $v_smtp_relay_user = quoteshellarg($_POST["v_smtp_relay_user"]);
- $v_smtp_relay_pass = quoteshellarg($_POST["v_smtp_relay_pass"]);
- if (!empty($_POST["v_smtp_relay_port"])) {
- $v_smtp_relay_port = quoteshellarg($_POST["v_smtp_relay_port"]);
- } else {
- $v_smtp_relay_port = "587";
- }
- exec(
- HESTIA_CMD .
- "v-add-sys-smtp-relay " .
- $v_smtp_relay_host .
- " " .
- $v_smtp_relay_user .
- " " .
- $v_smtp_relay_pass .
- " " .
- $v_smtp_relay_port,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- }
- }
- if (!isset($_POST["v_smtp_relay"]) && $v_smtp_relay == true) {
- $v_smtp_relay = false;
- $v_smtp_relay_host = $v_smtp_relay_user = $v_smtp_relay_pass = $v_smtp_relay_port = "";
- exec(HESTIA_CMD . "v-delete-sys-smtp-relay", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- }
- }
- // Update phpMyAdmin url
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_mysql_url"] != $_SESSION["DB_PMA_ALIAS"]) {
- exec(
- HESTIA_CMD . "v-change-sys-db-alias pma " . quoteshellarg($_POST["v_mysql_url"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_db_adv = "yes";
- }
- }
- // Update phpPgAdmin url
- if (empty($_SESSION["error_msg"])) {
- if (empty($_POST["v_pgsql_url"])) {
- $_POST["v_pgsql_url"] = "";
- }
- if ($_POST["v_pgsql_url"] != $_SESSION["DB_PGA_ALIAS"]) {
- exec(
- HESTIA_CMD . "v-change-sys-db-alias pga " . quoteshellarg($_POST["v_pgsql_url"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_db_adv = "yes";
- }
- }
- // Update send notification setting
- if (empty($_SESSION["error_msg"])) {
- if ($_SESSION["UPGRADE_SEND_EMAIL"] == "true") {
- $ugrade_send_mail = "on";
- } else {
- $ugrade_send_mail = "";
- }
- if ($_POST["v_upgrade_send_notification_email"] != $ugrade_send_mail) {
- if ($_POST["v_upgrade_send_notification_email"] == "on") {
- $_POST["v_upgrade_send_notification_email"] = "true";
- } else {
- $_POST["v_upgrade_send_notification_email"] = "false";
- }
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value UPGRADE_SEND_EMAIL " .
- quoteshellarg($_POST["v_upgrade_send_notification_email"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_upgrade_notification_adv = "yes";
- }
- }
- // Update send log by email setting
- if (empty($_SESSION["error_msg"])) {
- if ($_SESSION["UPGRADE_SEND_EMAIL_LOG"] == "true") {
- $send_email_log = "on";
- } else {
- $send_email_log = "";
- }
- if (empty($_POST["v_upgrade_send_email_log"])) {
- $_POST["v_upgrade_send_email_log"] = "";
- }
- if ($_POST["v_upgrade_send_email_log"] != $send_email_log) {
- if ($_POST["v_upgrade_send_email_log"] == "on") {
- $_POST["v_upgrade_send_email_log"] = "true";
- } else {
- $_POST["v_upgrade_send_email_log"] = "false";
- }
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value UPGRADE_SEND_EMAIL_LOG " .
- quoteshellarg($_POST["v_upgrade_send_email_log"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_upgrade_send_log_adv = "yes";
- }
- }
- // Disable local backup
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_backup"] == "no" && $v_backup == "yes") {
- exec(HESTIA_CMD . "v-delete-backup-host local", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup = "no";
- }
- $v_backup_adv = "yes";
- }
- }
- // Enable local backups
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_backup"] == "yes" && $v_backup != "yes") {
- exec(HESTIA_CMD . "v-add-backup-host local", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup = "yes";
- }
- $v_backup_adv = "yes";
- }
- }
- // Change backup gzip level
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_backup_gzip"] != $v_backup_gzip) {
- if ($_POST["v_backup_mode"] == "gzip") {
- $_POST["v_backup_gzip"] = 9;
- }
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value BACKUP_GZIP " .
- quoteshellarg($_POST["v_backup_gzip"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_gzip = $_POST["v_backup_gzip"];
- }
- $v_backup_adv = "yes";
- }
- }
- // Change backup mode
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_backup_mode"] != $v_backup_mode) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value BACKUP_MODE " .
- quoteshellarg($_POST["v_backup_mode"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_mode = $_POST["v_backup_mode"];
- }
- $v_backup_adv = "yes";
- if ($_POST["v_backup_mode"] == "gzip") {
- $_POST["v_backup_gzip"] = 9;
- if (empty($_SESSION["error_msg"])) {
- $v_backup_gzip = $_POST["v_backup_gzip"];
- }
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value BACKUP_GZIP " .
- quoteshellarg($_POST["v_backup_gzip"]),
- $output,
- $return_var,
- );
- }
- }
- }
- // Change backup path
- if (empty($_SESSION["error_msg"])) {
- if (empty($_POST["v_backup_dir"])) {
- $_POST["v_backup_dir"] = "";
- }
- if ($_POST["v_backup_dir"] != $v_backup_dir) {
- /*
- See #1655
- exec (HESTIA_CMD."v-change-sys-config-value BACKUP ".quoteshellarg($_POST['v_backup_dir']), $output, $return_var);
- check_return_code($return_var,$output);
- unset($output);
- */
- if (empty($_SESSION["error_msg"])) {
- $v_backup_dir = $_POST["v_backup_dir"];
- }
- #$v_backup_adv = 'yes';
- }
- }
- // Add remote backup host
- if (empty($_SESSION["error_msg"])) {
- if (
- $v_backup_host == "" &&
- $v_backup_bucket == "" &&
- (!empty($_POST["v_backup_host"]) || !empty($_POST["v_backup_bucket"]))
- ) {
- if (in_array($_POST["v_backup_type"], ["ftp", "sftp"])) {
- $v_backup_host = quoteshellarg($_POST["v_backup_host"]);
- $v_backup_port = quoteshellarg($_POST["v_backup_port"]);
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- $v_backup_username = quoteshellarg($_POST["v_backup_username"]);
- $v_backup_password = quoteshellarg($_POST["v_backup_password"]);
- $v_backup_bpath = quoteshellarg($_POST["v_backup_bpath"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_backup_host .
- " " .
- $v_backup_username .
- " " .
- $v_backup_password .
- " " .
- $v_backup_bpath .
- " " .
- $v_backup_port,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_host = $_POST["v_backup_host"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_type = $_POST["v_backup_type"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_username = $_POST["v_backup_username"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_password = $_POST["v_backup_password"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bpath = $_POST["v_backup_bpath"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_port = $_POST["v_backup_port"];
- }
- $v_backup_new = "yes";
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- } elseif (in_array($_POST["v_backup_type"], ["b2"])) {
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
- $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
- $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_backup_bucket .
- " " .
- $v_backup_application_id .
- " " .
- $v_backup_application_key,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
- }
- $v_backup_new = "yes";
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- }
- }
- if (
- $v_rclone_host == "" &&
- !empty($_POST["v_rclone_host"]) &&
- $_POST["v_backup_type"] == "rclone"
- ) {
- $v_rclone_host = quoteshellarg($_POST["v_rclone_host"]);
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- $v_rclone_path = quoteshellarg($_POST["v_rclone_path"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_rclone_host .
- " '' '' " .
- $v_rclone_path,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_backup_new = "yes";
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- }
- }
- // Change remote backup host type
- if (empty($_SESSION["error_msg"])) {
- if (
- !empty($_POST["v_backup_host"]) &&
- $_POST["v_backup_type"] != $v_backup_type &&
- $v_backup_type != ""
- ) {
- exec(
- HESTIA_CMD . "v-delete-backup-host " . quoteshellarg($v_backup_type),
- $output,
- $return_var,
- );
- unset($output);
- if (in_array($_POST["v_backup_type"], ["ftp", "sftp"])) {
- $v_backup_host = quoteshellarg($_POST["v_backup_host"]);
- $v_backup_port = quoteshellarg($_POST["v_backup_port"]);
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- $v_backup_username = quoteshellarg($_POST["v_backup_username"]);
- $v_backup_password = quoteshellarg($_POST["v_backup_password"]);
- $v_backup_bpath = quoteshellarg($_POST["v_backup_bpath"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_backup_host .
- " " .
- $v_backup_username .
- " " .
- $v_backup_password .
- " " .
- $v_backup_bpath .
- " " .
- $v_backup_port,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_host = $_POST["v_backup_host"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_type = $_POST["v_backup_type"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_username = $_POST["v_backup_username"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_password = $_POST["v_backup_password"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bpath = $_POST["v_backup_bpath"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_port = $_POST["v_backup_port"];
- }
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- } elseif (in_array($_POST["v_backup_type"], ["b2"])) {
- $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
- $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
- $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_backup_bucket .
- " " .
- $v_backup_application_id .
- " " .
- $v_backup_application_key,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
- }
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- }
- }
- }
- // Change remote backup host
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_backup_type"] == $v_backup_type && !isset($v_backup_new)) {
- if (in_array($_POST["v_backup_type"], ["ftp", "sftp"])) {
- if (
- $_POST["v_backup_host"] != $v_backup_host ||
- $_POST["v_backup_username"] != $v_backup_username ||
- $_POST["v_backup_password"] != $v_backup_password ||
- ($_POST["v_backup_bpath"] != $v_backup_bpath ||
- $_POST["v_backup_port"] != $v_backup_port)
- ) {
- $v_backup_host = quoteshellarg($_POST["v_backup_host"]);
- $v_backup_port = quoteshellarg($_POST["v_backup_port"]);
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- $v_backup_username = quoteshellarg($_POST["v_backup_username"]);
- $v_backup_password = quoteshellarg($_POST["v_backup_password"]);
- $v_backup_bpath = quoteshellarg($_POST["v_backup_bpath"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_backup_host .
- " " .
- $v_backup_username .
- " " .
- $v_backup_password .
- " " .
- $v_backup_bpath .
- " " .
- $v_backup_port,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_host = $_POST["v_backup_host"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_type = $_POST["v_backup_type"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_username = $_POST["v_backup_username"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_password = $_POST["v_backup_password"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bpath = $_POST["v_backup_bpath"];
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_port = $_POST["v_backup_port"];
- }
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- }
- } elseif (in_array($_POST["v_backup_type"], ["b2"])) {
- if (
- $_POST["v_backup_bucket"] != $v_backup_bucket ||
- $_POST["v_backup_application_key"] != $v_backup_application_key ||
- $_POST["v_backup_application_id"] != $v_backup_application_id
- ) {
- $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
- $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
- $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
- $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
- exec(
- HESTIA_CMD .
- "v-add-backup-host " .
- $v_backup_type .
- " " .
- $v_backup_bucket .
- " " .
- $v_backup_application_id .
- " " .
- $v_backup_application_key,
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_key = quoteshellarg(
- $_POST["v_backup_application_key"],
- );
- }
- $v_backup_adv = "yes";
- $v_backup_remote_adv = "yes";
- }
- }
- }
- }
- // Delete remote backup host
- if (empty($_SESSION["error_msg"])) {
- if (empty($_POST["v_backup_remote_adv"]) && $v_backup_remote_adv != "") {
- exec(
- HESTIA_CMD . "v-delete-backup-host " . quoteshellarg($v_backup_type),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_backup_host = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_type = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_username = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_password = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bpath = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_bucket = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_id = "";
- }
- if (empty($_SESSION["error_msg"])) {
- $v_backup_application_key = "";
- }
- $v_backup_adv = "";
- $v_backup_remote_adv = "";
- }
- }
- // Change INACTIVE_SESSION_TIMEOUT
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_inactive_session_timeout"] != $_SESSION["INACTIVE_SESSION_TIMEOUT"]) {
- if ($_POST["v_inactive_session_timeout"] < 1) {
- $_SESSION["error_msg"] = _("Inactive session timeout can not lower than 1 minute.");
- } else {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value INACTIVE_SESSION_TIMEOUT " .
- quoteshellarg($_POST["v_inactive_session_timeout"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_inactive_session_timeout = $_POST["v_inactive_session_timeout"];
- }
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_CSRF_STRICTNESS
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_csrf_strictness"] != $_SESSION["POLICY_CSRF_STRICTNESS"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_CSRF_STRICTNESS " .
- quoteshellarg($_POST["v_policy_csrf_strictness"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_csrf_strictness = $_POST["v_inactive_session_timeout"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change ENFORCE_SUBDOMAIN_OWNERSHIP
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_enforce_subdomain_ownership"] != $_SESSION["ENFORCE_SUBDOMAIN_OWNERSHIP"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value ENFORCE_SUBDOMAIN_OWNERSHIP " .
- quoteshellarg($_POST["v_enforce_subdomain_ownership"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_enforce_subdomain_ownership = $_POST["v_enforce_subdomain_ownership"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_USER_EDIT_DETAILS
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_user_edit_details"] != $_SESSION["POLICY_USER_EDIT_DETAILS"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_EDIT_DETAILS " .
- quoteshellarg($_POST["v_policy_user_edit_details"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_edit_details = $_POST["v_policy_user_edit_details"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_USER_EDIT_WEB_TEMPLATES
- if (empty($_SESSION["error_msg"])) {
- if (
- $_POST["v_policy_user_edit_web_templates"] !=
- $_SESSION["POLICY_USER_EDIT_WEB_TEMPLATES"]
- ) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_EDIT_WEB_TEMPLATES " .
- quoteshellarg($_POST["v_policy_user_edit_web_templates"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_edit_details = $_POST["v_policy_user_edit_web_templates"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_USER_EDIT_DNS_TEMPLATES
- if (empty($_SESSION["error_msg"])) {
- if (
- $_POST["v_policy_user_edit_dns_templates"] !=
- $_SESSION["POLICY_USER_EDIT_DNS_TEMPLATES"]
- ) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_EDIT_DNS_TEMPLATES " .
- quoteshellarg($_POST["v_policy_user_edit_dns_templates"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_edit_details = $_POST["v_policy_user_edit_dns_templates"];
- }
- $v_security_adv = "yes";
- }
- }
- if (
- $_POST["v_api_system"] != $_SESSION["API_SYSTEM"] ||
- $_POST["v_api"] != $_SESSION["API"] ||
- $_POST["v_api_allowed_ip"] != $_SESSION["API_ALLOWED_IP"]
- ) {
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_api"] == "no" && $_POST["v_api_system"] === 0) {
- exec(HESTIA_CMD . "v-change-sys-api 'disable'", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- }
- if (
- $_POST["v_api"] == "yes" ||
- ($_POST["v_api_system"] !== 0 &&
- $_POST["v_api_system"] != $_SESSION["API_SYSTEM"]) ||
- $_POST["v_api"] != $_SESSION["API"]
- ) {
- exec(HESTIA_CMD . "v-change-sys-api 'enable'", $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- }
- }
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_api_system"] != $_SESSION["API_SYSTEM"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value API_SYSTEM " .
- quoteshellarg($_POST["v_api_system"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_edit_details = $_POST["v_api_system"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change API access
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_api"] != $_SESSION["API"]) {
- $api_status = "no";
- if ($_POST["v_api"] == "yes") {
- $api_status = "yes";
- }
- exec(
- HESTIA_CMD . "v-change-sys-config-value API " . quoteshellarg($api_status),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_api = $_POST["v_api"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change API allowed IPs
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_api_allowed_ip"] != $_SESSION["API_ALLOWED_IP"]) {
- $ips = [];
- foreach (explode("\n", $_POST["v_api_allowed_ip"]) as $ip) {
- if (trim($ip) != "allow-all") {
- if (filter_var(trim($ip), FILTER_VALIDATE_IP)) {
- $ips[] = trim($ip);
- }
- } else {
- $ips[] = trim($ip);
- }
- }
- if (implode(",", $ips) != $_SESSION["API_ALLOWED_IP"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value API_ALLOWED_IP " .
- quoteshellarg(implode(",", $ips)),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_api_allowed_ip = $_POST["v_api_allowed_ip"];
- }
- $v_security_adv = "yes";
- }
- }
- }
- }
- // Change POLICY_USER_VIEW_LOGS
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_user_view_logs"] != $_SESSION["POLICY_USER_VIEW_LOGS"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_VIEW_LOGS " .
- quoteshellarg($_POST["v_policy_user_view_logs"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_view_logs = $_POST["v_policy_user_view_logs"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_USER_DELETE_LOGS
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_user_delete_logs"] != $_SESSION["POLICY_USER_DELETE_LOGS"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_DELETE_LOGS " .
- quoteshellarg($_POST["v_policy_user_delete_logs"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_delete_logs = $_POST["v_policy_user_delete_logs"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_SYSTEM_PASSWORD_RESET
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_system_password_reset"] != $_SESSION["POLICY_SYSTEM_PASSWORD_RESET"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYSTEM_PASSWORD_RESET " .
- quoteshellarg($_POST["v_policy_system_password_reset"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_system_password_reset = $_POST["v_policy_system_password_reset"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_SYSTEM_PROTECTED_ADMIN
- if (empty($_SESSION["error_msg"])) {
- if (
- $_POST["v_policy_system_protected_admin"] != $_SESSION["POLICY_SYSTEM_PROTECTED_ADMIN"]
- ) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYSTEM_PROTECTED_ADMIN " .
- quoteshellarg($_POST["v_policy_system_protected_admin"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_system_protected_admin = $_POST["v_policy_system_protected_admin"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_USER_VIEW_SUSPENDED
- if (empty($_SESSION["error_msg"])) {
- if (
- $_POST["v_policy_user_view_suspended"] != $_SESSION["POLICY_USER_VIEW_SUSPENDED"] &&
- !empty($_SESSION["POLICY_USER_VIEW_SUSPENDED"])
- ) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED " .
- quoteshellarg($_POST["v_policy_user_view_suspended"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_system_hide_admin = $_POST["v_policy_user_view_suspended"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_USER_CHANGE_THEME
- if (empty($_SESSION["error_msg"])) {
- if (empty($_POST["v_policy_user_change_theme"])) {
- $_POST["v_policy_user_change_theme"] = "";
- }
- if ($_POST["v_policy_user_change_theme"] == "on") {
- $_POST["v_policy_user_change_theme"] = "no";
- } else {
- $_POST["v_policy_user_change_theme"] = "yes";
- }
- if ($_POST["v_policy_user_change_theme"] != $_SESSION["POLICY_USER_CHANGE_THEME"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_USER_CHANGE_THEME " .
- quoteshellarg($_POST["v_policy_user_change_theme"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if ($_POST["v_policy_user_change_theme"]) {
- unset($_SESSION["userTheme"]);
- $require_refresh = true;
- }
- if (empty($_SESSION["error_msg"])) {
- $v_policy_user_change_theme = $_POST["v_policy_user_change_theme"];
- }
- }
- }
- // Change POLICY_SYSTEM_HIDE_ADMIN
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_system_hide_admin"] != $_SESSION["POLICY_SYSTEM_HIDE_ADMIN"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYSTEM_HIDE_ADMIN " .
- quoteshellarg($_POST["v_policy_system_hide_admin"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_system_hide_admin = $_POST["v_policy_system_hide_admin"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_SYSTEM_HIDE_SERVICES
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_system_hide_services"] != $_SESSION["POLICY_SYSTEM_HIDE_SERVICES"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYSTEM_HIDE_SERVICES " .
- quoteshellarg($_POST["v_policy_system_hide_services"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_system_hide_services = $_POST["v_policy_system_hide_services"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change POLICY_SYSTEM_HIDE_SERVICES
- if (empty($_SESSION["error_msg"])) {
- if (
- $_POST["v_policy_backup_suspended_users"] != $_SESSION["POLICY_BACKUP_SUSPENDED_USERS"]
- ) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_BACKUP_SUSPENDED_USERS " .
- quoteshellarg($_POST["v_policy_backup_suspended_users"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_system_hide_services = $_POST["v_policy_backup_suspended_users"];
- }
- $v_security_adv = "yes";
- }
- }
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_sync_error_documents"] != $_SESSION["POLICY_SYNC_ERROR_DOCUMENTS"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYNC_ERROR_DOCUMENTS " .
- quoteshellarg($_POST["v_policy_sync_error_documents"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_sync_error_documents = $_POST["v_policy_sync_error_documents"];
- }
- $v_security_adv = "yes";
- }
- }
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_policy_sync_skeleton"] != $_SESSION["POLICY_SYNC_SKELETON"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value POLICY_SYNC_SKELETON " .
- quoteshellarg($_POST["v_policy_sync_skeleton"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_policy_sync_skeleton = $_POST["v_policy_sync_skeleton"];
- }
- $v_security_adv = "yes";
- }
- }
- // Change login style
- if (empty($_SESSION["error_msg"])) {
- if ($_POST["v_login_style"] != $_SESSION["LOGIN_STYLE"]) {
- exec(
- HESTIA_CMD .
- "v-change-sys-config-value LOGIN_STYLE " .
- quoteshellarg($_POST["v_login_style"]),
- $output,
- $return_var,
- );
- check_return_code($return_var, $output);
- unset($output);
- if (empty($_SESSION["error_msg"])) {
- $v_login_style = $_POST["v_login_style"];
- }
- $v_security_adv = "yes";
- }
- }
- // Update SSL certificate
- if (!empty($_POST["v_ssl_crt"]) && empty($_SESSION["error_msg"])) {
- if (
- $v_ssl_crt != str_replace("\r\n", "\n", $_POST["v_ssl_crt"]) ||
- $v_ssl_key != str_replace("\r\n", "\n", $_POST["v_ssl_key"])
- ) {
- exec("mktemp -d", $mktemp_output, $return_var);
- $tmpdir = $mktemp_output[0];
- // Certificate
- if (!empty($_POST["v_ssl_crt"])) {
- $fp = fopen($tmpdir . "/certificate.crt", "w");
- fwrite($fp, str_replace("\r\n", "\n", $_POST["v_ssl_crt"]));
- fwrite($fp, "\n");
- fclose($fp);
- }
- // Key
- if (!empty($_POST["v_ssl_key"])) {
- $fp = fopen($tmpdir . "/certificate.key", "w");
- fwrite($fp, str_replace("\r\n", "\n", $_POST["v_ssl_key"]));
- fwrite($fp, "\n");
- fclose($fp);
- }
- exec(HESTIA_CMD . "v-change-sys-hestia-ssl " . $tmpdir, $output, $return_var);
- check_return_code($return_var, $output);
- unset($output);
- // List ssl certificate info
- exec(HESTIA_CMD . "v-list-sys-hestia-ssl json", $output, $return_var);
- $ssl_str = json_decode(implode("", $output), true);
- unset($output);
- $v_ssl_crt = $ssl_str["HESTIA"]["CRT"];
- $v_ssl_key = $ssl_str["HESTIA"]["KEY"];
- $v_ssl_ca = $ssl_str["HESTIA"]["CA"];
- $v_ssl_subject = $ssl_str["HESTIA"]["SUBJECT"];
- $v_ssl_aliases = $ssl_str["HESTIA"]["ALIASES"];
- $v_ssl_not_before = $ssl_str["HESTIA"]["NOT_BEFORE"];
- $v_ssl_not_after = $ssl_str["HESTIA"]["NOT_AFTER"];
- $v_ssl_signature = $ssl_str["HESTIA"]["SIGNATURE"];
- $v_ssl_pub_key = $ssl_str["HESTIA"]["PUB_KEY"];
- $v_ssl_issuer = $ssl_str["HESTIA"]["ISSUER"];
- // Cleanup certificate tempfiles
- if (file_exists($tmpdir . "/certificate.crt")) {
- unlink($tmpdir . "/certificate.crt");
- }
- if (file_exists($tmpdir . "/certificate.key")) {
- unlink($tmpdir . "/certificate.key");
- }
- rmdir($tmpdir);
- }
- }
- // Flush field values on success
- if (empty($_SESSION["error_msg"])) {
- $_SESSION["ok_msg"] = _("Changes have been saved.");
- }
- if ($require_refresh == true) {
- $refresh = $_SERVER["REQUEST_URI"];
- $_SESSION["ok_msg"] = _("Changes have been saved.");
- header("Location: $refresh");
- die();
- }
- }
- // Check system configuration
- exec(HESTIA_CMD . "v-list-sys-config json", $output, $return_var);
- $data = json_decode(implode("", $output), true);
- unset($output);
- $sys_arr = $data["config"];
- foreach ($sys_arr as $key => $value) {
- $_SESSION[$key] = $value;
- }
- // Render page
- render_page($user, $TAB, "edit_server");
- // Flush session messages
- unset($_SESSION["error_msg"]);
- unset($_SESSION["ok_msg"]);
|