index.php 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. $TAB = "SERVER";
  4. // Main include
  5. include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
  6. // Check user
  7. if ($_SESSION["userContext"] != "admin") {
  8. header("Location: /list/user");
  9. exit();
  10. }
  11. // Get server hostname
  12. $v_hostname = exec("hostname");
  13. // List available timezones and get current one
  14. exec(HESTIA_CMD . "v-get-sys-timezone", $output, $return_var);
  15. $v_timezone = $output[0];
  16. unset($output);
  17. exec(HESTIA_CMD . "v-get-sys-timezones json", $output, $return_var);
  18. $v_timezones = json_decode(implode("", $output), true);
  19. unset($output);
  20. // List supported php versions
  21. exec(HESTIA_CMD . "v-list-web-templates-backend json", $output, $return_var);
  22. $backend_templates = json_decode(implode("", $output), true);
  23. unset($output);
  24. $v_php_versions = [
  25. "php-5.6",
  26. "php-7.0",
  27. "php-7.1",
  28. "php-7.2",
  29. "php-7.3",
  30. "php-7.4",
  31. "php-8.0",
  32. "php-8.1",
  33. "php-8.2",
  34. ];
  35. sort($v_php_versions);
  36. if (empty($backend_templates)) {
  37. $v_php_versions = [];
  38. }
  39. $backends_active = backendtpl_with_webdomains();
  40. $v_php_versions = array_map(function ($php_version) use ($backend_templates, $backends_active) {
  41. // Mark installed php versions
  42. if (stripos($php_version, "php") !== 0) {
  43. return false;
  44. }
  45. $phpinfo = (object) [
  46. "name" => $php_version,
  47. "tpl" => strtoupper(str_replace(".", "_", $php_version)),
  48. "version" => str_ireplace("php-", "", $php_version),
  49. "usedby" => [],
  50. "installed" => false,
  51. "protected" => false,
  52. ];
  53. if (in_array($phpinfo->tpl, $backend_templates)) {
  54. $phpinfo->installed = true;
  55. }
  56. if (array_key_exists($phpinfo->tpl, $backends_active)) {
  57. // Prevent used php version to be removed
  58. if ($phpinfo->installed) {
  59. $phpinfo->protected = true;
  60. }
  61. $phpinfo->usedby = $backends_active[$phpinfo->tpl];
  62. }
  63. if ($phpinfo->name == DEFAULT_PHP_VERSION) {
  64. // Prevent default php version to be removed
  65. if ($phpinfo->installed) {
  66. $phpinfo->protected = true;
  67. }
  68. if (!empty($backends_active["default"])) {
  69. $phpinfo->usedby = array_merge_recursive($phpinfo->usedby, $backends_active["default"]);
  70. }
  71. }
  72. return $phpinfo;
  73. }, $v_php_versions);
  74. // List languages
  75. exec(HESTIA_CMD . "v-list-sys-languages json", $output, $return_var);
  76. $language = json_decode(implode("", $output), true);
  77. foreach ($language as $lang) {
  78. $languages[$lang] = translate_json($lang);
  79. }
  80. asort($languages);
  81. unset($output);
  82. // List themes
  83. exec(HESTIA_CMD . "v-list-sys-themes json", $output, $return_var);
  84. $theme = json_decode(implode("", $output), true);
  85. unset($output);
  86. // List dns cluster hosts
  87. exec(HESTIA_CMD . "v-list-remote-dns-hosts json", $output, $return_var);
  88. $dns_cluster = json_decode(implode("", $output), true);
  89. unset($output);
  90. if (is_array($dns_cluster)) {
  91. foreach ($dns_cluster as $key => $value) {
  92. $v_dns_cluster = "yes";
  93. }
  94. }
  95. if (empty($v_dns_cluster)) {
  96. $v_dns_cluster = "";
  97. }
  98. $v_release_branch = $_SESSION["RELEASE_BRANCH"];
  99. // List smtp relay settings
  100. if (!empty($_SESSION["SMTP_RELAY"])) {
  101. $v_smtp_relay = $_SESSION["SMTP_RELAY"];
  102. } else {
  103. $v_smtp_relay = "";
  104. }
  105. if (!empty($_SESSION["SMTP_RELAY_HOST"])) {
  106. $v_smtp_relay_host = $_SESSION["SMTP_RELAY_HOST"];
  107. } else {
  108. $v_smtp_relay_host = "";
  109. }
  110. if (!empty($_SESSION["SMTP_RELAY_PORT"])) {
  111. $v_smtp_relay_port = $_SESSION["SMTP_RELAY_PORT"];
  112. } else {
  113. $v_smtp_relay_port = "";
  114. }
  115. if (!empty($_SESSION["SMTP_RELAY_USER"])) {
  116. $v_smtp_relay_user = $_SESSION["SMTP_RELAY_USER"];
  117. } else {
  118. $v_smtp_relay_user = "";
  119. }
  120. $v_smtp_relay_pass = "";
  121. if (empty($_POST["v_experimental_features"])) {
  122. $_POST["v_experimental_features"] = "false";
  123. }
  124. if (empty($_POST["v_policy_user_view_suspended"])) {
  125. $_POST["v_policy_user_view_suspended"] = "false";
  126. }
  127. // List Database hosts
  128. exec(HESTIA_CMD . "v-list-database-hosts json", $output, $return_var);
  129. $db_hosts = json_decode(implode("", $output), true);
  130. unset($output);
  131. $v_mysql_hosts = array_values(
  132. array_filter($db_hosts, function ($host) {
  133. return $host["TYPE"] === "mysql";
  134. }),
  135. );
  136. $v_mysql = count($v_mysql_hosts) ? "yes" : "no";
  137. $v_pgsql_hosts = array_values(
  138. array_filter($db_hosts, function ($host) {
  139. return $host["TYPE"] === "pgsql";
  140. }),
  141. );
  142. $v_pgsql = count($v_pgsql_hosts) ? "yes" : "no";
  143. unset($db_hosts);
  144. // List backup settings
  145. $v_backup_dir = "/backup";
  146. if (!empty($_SESSION["BACKUP"])) {
  147. $v_backup_dir = $_SESSION["BACKUP"];
  148. }
  149. $v_backup_gzip = "5";
  150. if (!empty($_SESSION["BACKUP_GZIP"])) {
  151. $v_backup_gzip = $_SESSION["BACKUP_GZIP"];
  152. }
  153. $v_backup_mode = "gzip";
  154. if (!empty($_SESSION["BACKUP_MODE"])) {
  155. $v_backup_mode = $_SESSION["BACKUP_MODE"];
  156. }
  157. $backup_types = explode(",", $_SESSION["BACKUP_SYSTEM"]);
  158. foreach ($backup_types as $backup_type) {
  159. if ($backup_type == "local") {
  160. $v_backup = "yes";
  161. } else {
  162. exec(
  163. HESTIA_CMD . "v-list-backup-host " . quoteshellarg($backup_type) . " json",
  164. $output,
  165. $return_var,
  166. );
  167. $v_remote_backup = json_decode(implode("", $output), true);
  168. unset($output);
  169. if (in_array($backup_type, ["ftp", "sftp"])) {
  170. $v_backup_host = $v_remote_backup[$backup_type]["HOST"];
  171. $v_backup_type = $v_remote_backup[$backup_type]["TYPE"];
  172. $v_backup_username = $v_remote_backup[$backup_type]["USERNAME"] ?? "";
  173. $v_backup_password = "";
  174. $v_backup_port = $v_remote_backup[$backup_type]["PORT"] ?? "";
  175. $v_backup_bpath = $v_remote_backup[$backup_type]["BPATH"];
  176. $v_backup_remote_adv = "yes";
  177. } elseif (in_array($backup_type, ["b2"])) {
  178. $v_backup_bucket = $v_remote_backup[$backup_type]["BUCKET"];
  179. $v_backup_type = $v_remote_backup[$backup_type]["TYPE"];
  180. $v_backup_application_id = $v_remote_backup[$backup_type]["B2_KEY_ID"];
  181. $v_backup_application_key = "";
  182. $v_backup_remote_adv = "yes";
  183. } elseif (in_array($backup_type, ["rclone"])) {
  184. $v_backup_type = $v_remote_backup[$backup_type]["TYPE"];
  185. $v_rclone_host = $v_remote_backup[$backup_type]["HOST"];
  186. $v_rclone_path = $v_remote_backup[$backup_type]["BPATH"];
  187. $v_backup_remote_adv = "yes";
  188. }
  189. }
  190. }
  191. if (empty($v_backup)) {
  192. $v_backup = "";
  193. }
  194. if (empty($v_backup_host)) {
  195. $v_backup_host = "";
  196. }
  197. if (empty($v_backup_type)) {
  198. $v_backup_type = "";
  199. }
  200. if (empty($v_backup_username)) {
  201. $v_backup_username = "";
  202. }
  203. if (empty($v_backup_password)) {
  204. $v_backup_password = "";
  205. }
  206. if (empty($v_backup_port)) {
  207. $v_backup_port = "";
  208. }
  209. if (empty($v_backup_bpath)) {
  210. $v_backup_bpath = "";
  211. }
  212. if (empty($v_backup_bucket)) {
  213. $v_backup_bucket = "";
  214. }
  215. if (empty($v_backup_application_id)) {
  216. $v_backup_application_id = "";
  217. }
  218. if (empty($v_backup_application_key)) {
  219. $v_backup_application_key = "";
  220. }
  221. if (empty($v_backup_remote_adv)) {
  222. $v_backup_remote_adv = "";
  223. }
  224. if (empty($v_rclone_host)) {
  225. $v_rclone_host = "";
  226. }
  227. if (empty($v_rclone_path)) {
  228. $v_rclone_path = "";
  229. }
  230. // List ssl certificate info
  231. exec(HESTIA_CMD . "v-list-sys-hestia-ssl json", $output, $return_var);
  232. $ssl_str = json_decode(implode("", $output), true);
  233. unset($output);
  234. $v_ssl_crt = $ssl_str["HESTIA"]["CRT"];
  235. $v_ssl_key = $ssl_str["HESTIA"]["KEY"];
  236. $v_ssl_ca = $ssl_str["HESTIA"]["CA"];
  237. $v_ssl_subject = $ssl_str["HESTIA"]["SUBJECT"];
  238. $v_ssl_aliases = $ssl_str["HESTIA"]["ALIASES"];
  239. $v_ssl_not_before = $ssl_str["HESTIA"]["NOT_BEFORE"];
  240. $v_ssl_not_after = $ssl_str["HESTIA"]["NOT_AFTER"];
  241. $v_ssl_signature = $ssl_str["HESTIA"]["SIGNATURE"];
  242. $v_ssl_pub_key = $ssl_str["HESTIA"]["PUB_KEY"];
  243. $v_ssl_issuer = $ssl_str["HESTIA"]["ISSUER"];
  244. // Check POST request
  245. if (!empty($_POST["save"])) {
  246. $require_refresh = false;
  247. // Check token
  248. verify_csrf($_POST);
  249. // Change hostname
  250. if (!empty($_POST["v_hostname"]) && $v_hostname != $_POST["v_hostname"]) {
  251. exec(
  252. HESTIA_CMD . "v-change-sys-hostname " . quoteshellarg($_POST["v_hostname"]),
  253. $output,
  254. $return_var,
  255. );
  256. check_return_code($return_var, $output);
  257. unset($output);
  258. $v_hostname = $_POST["v_hostname"];
  259. }
  260. if ($_SESSION["WEB_BACKEND"] == "php-fpm") {
  261. // Install/remove php versions
  262. if (empty($_SESSION["error_msg"])) {
  263. if (!empty($v_php_versions)) {
  264. $post_php = $_POST["v_php_versions"];
  265. if (empty($post_php)) {
  266. $post_php = [];
  267. }
  268. array_map(function ($php_version) use ($post_php) {
  269. if (array_key_exists($php_version->tpl, $post_php)) {
  270. if (!$php_version->installed) {
  271. exec(
  272. HESTIA_CMD .
  273. "v-add-web-php " .
  274. quoteshellarg($php_version->version),
  275. $output,
  276. $return_var,
  277. );
  278. check_return_code($return_var, $output);
  279. unset($output);
  280. if (empty($_SESSION["error_msg"])) {
  281. $php_version->installed = true;
  282. }
  283. }
  284. } else {
  285. if ($php_version->installed && !$php_version->protected) {
  286. exec(
  287. HESTIA_CMD .
  288. "v-delete-web-php " .
  289. quoteshellarg($php_version->version),
  290. $output,
  291. $return_var,
  292. );
  293. check_return_code($return_var, $output);
  294. unset($output);
  295. if (empty($_SESSION["error_msg"])) {
  296. $php_version->installed = false;
  297. }
  298. }
  299. }
  300. return $php_version;
  301. }, $v_php_versions);
  302. }
  303. }
  304. if (empty($_SESSION["error_msg"])) {
  305. if ("php-" . $_POST["v_php_default_version"] != DEFAULT_PHP_VERSION) {
  306. exec(
  307. HESTIA_CMD .
  308. "v-change-sys-php " .
  309. quoteshellarg($_POST["v_php_default_version"]),
  310. $output,
  311. $return_var,
  312. );
  313. check_return_code($return_var, $output);
  314. unset($output);
  315. //force reload
  316. $require_refresh = true;
  317. }
  318. }
  319. }
  320. // Change timezone
  321. if (empty($_SESSION["error_msg"])) {
  322. if (!empty($_POST["v_timezone"])) {
  323. if ($v_timezone != $_POST["v_timezone"]) {
  324. exec(
  325. HESTIA_CMD . "v-change-sys-timezone " . quoteshellarg($_POST["v_timezone"]),
  326. $output,
  327. $return_var,
  328. );
  329. check_return_code($return_var, $output);
  330. $v_timezone = $_POST["v_timezone"];
  331. unset($output);
  332. }
  333. }
  334. }
  335. // Change default language
  336. if (empty($_SESSION["error_msg"])) {
  337. if (!empty($_POST["v_language"]) && $_SESSION["LANGUAGE"] != $_POST["v_language"]) {
  338. if (isset($_POST["v_language_update"])) {
  339. exec(
  340. HESTIA_CMD .
  341. "v-change-sys-language " .
  342. quoteshellarg($_POST["v_language"]) .
  343. " yes",
  344. $output,
  345. $return_var,
  346. );
  347. if (empty($_SESSION["error_msg"])) {
  348. $_SESSION["LANGUAGE"] = $_POST["v_language"];
  349. }
  350. }
  351. exec(
  352. HESTIA_CMD . "v-change-sys-language " . quoteshellarg($_POST["v_language"]),
  353. $output,
  354. $return_var,
  355. );
  356. check_return_code($return_var, $output);
  357. unset($output);
  358. if (empty($_SESSION["error_msg"])) {
  359. $_SESSION["LANGUAGE"] = $_POST["v_language"];
  360. }
  361. }
  362. }
  363. // Update theme
  364. if (empty($_SESSION["error_msg"])) {
  365. if ($_POST["v_theme"] != $_SESSION["THEME"]) {
  366. exec(
  367. HESTIA_CMD . "v-change-sys-config-value THEME " . quoteshellarg($_POST["v_theme"]),
  368. $output,
  369. $return_var,
  370. );
  371. check_return_code($return_var, $output);
  372. unset($output);
  373. }
  374. }
  375. // Update debug mode status
  376. if (empty($_SESSION["error_msg"])) {
  377. if (!empty($_POST["v_debug_mode"])) {
  378. if ($_POST["v_debug_mode"] == "on") {
  379. $_POST["v_debug_mode"] = "true";
  380. } else {
  381. $_POST["v_debug_mode"] = "false";
  382. }
  383. } else {
  384. $_POST["v_debug_mode"] = "false";
  385. }
  386. if ($_POST["v_debug_mode"] != $_SESSION["DEBUG_MODE"]) {
  387. exec(
  388. HESTIA_CMD .
  389. "v-change-sys-config-value DEBUG_MODE " .
  390. quoteshellarg($_POST["v_debug_mode"]),
  391. $output,
  392. $return_var,
  393. );
  394. check_return_code($return_var, $output);
  395. unset($output);
  396. $v_debug_mode_adv = "yes";
  397. }
  398. }
  399. // Enable/Disable Quick App Installer
  400. if (empty($_SESSION["error_msg"])) {
  401. if ($_POST["v_plugin_app_installer"] != $_SESSION["PLUGIN_APP_INSTALLER"]) {
  402. if ($_POST["v_plugin_app_installer"] == "true") {
  403. $_POST["v_plugin_app_installer"] = "true";
  404. } else {
  405. $_POST["v_plugin_app_installer"] = "false";
  406. }
  407. exec(
  408. HESTIA_CMD .
  409. "v-change-sys-config-value PLUGIN_APP_INSTALLER " .
  410. quoteshellarg($_POST["v_plugin_app_installer"]),
  411. $output,
  412. $return_var,
  413. );
  414. check_return_code($return_var, $output);
  415. unset($output);
  416. }
  417. }
  418. // Update experimental features status
  419. if (
  420. empty($_SESSION["error_msg"]) &&
  421. $_POST["v_experimental_features"] != $_SESSION["POLICY_SYSTEM_ENABLE_BACON"]
  422. ) {
  423. if ($_POST["v_experimental_features"] == "on") {
  424. $_POST["v_experimental_features"] = "true";
  425. } else {
  426. $_POST["v_experimental_features"] = "false";
  427. }
  428. if ($_POST["v_experimental_features"] != $_SESSION["POLICY_SYSTEM_ENABLE_BACON"]) {
  429. exec(
  430. HESTIA_CMD .
  431. "v-change-sys-config-value POLICY_SYSTEM_ENABLE_BACON " .
  432. quoteshellarg($_POST["v_experimental_features"]),
  433. $output,
  434. $return_var,
  435. );
  436. check_return_code($return_var, $output);
  437. unset($output);
  438. $v_debug_mode_adv = "yes";
  439. }
  440. if (
  441. $_POST["v_policy_user_view_suspended"] != $_SESSION["POLICY_SYSTEM_ENABLE_BACON"] &&
  442. $_POST["v_experimental_features"] == "false"
  443. ) {
  444. //disable preview mode
  445. exec(
  446. HESTIA_CMD .
  447. "v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED " .
  448. quoteshellarg($_POST["v_policy_user_view_suspended"]),
  449. $output,
  450. $return_var,
  451. );
  452. check_return_code($return_var, $output);
  453. unset($output);
  454. }
  455. }
  456. // Set File Manager support
  457. if (empty($_SESSION["error_msg"])) {
  458. if (
  459. !empty($_POST["v_filemanager"]) &&
  460. $_SESSION["FILE_MANAGER"] != $_POST["v_filemanager"]
  461. ) {
  462. if ($_POST["v_filemanager"] == "true") {
  463. exec(HESTIA_CMD . "v-add-sys-filemanager", $output, $return_var);
  464. check_return_code($return_var, $output);
  465. unset($output);
  466. if (empty($_SESSION["error_msg"])) {
  467. $_SESSION["FILE_MANAGER"] = "true";
  468. }
  469. } else {
  470. exec(HESTIA_CMD . "v-delete-sys-filemanager", $output, $return_var);
  471. check_return_code($return_var, $output);
  472. unset($output);
  473. if (empty($_SESSION["error_msg"])) {
  474. $_SESSION["FILE_MANAGER"] = "false";
  475. }
  476. }
  477. }
  478. }
  479. // Set Web Terminal support
  480. if (empty($_SESSION["error_msg"])) {
  481. if (
  482. !empty($_POST["v_web_terminal"]) &&
  483. $_SESSION["WEB_TERMINAL"] != $_POST["v_web_terminal"]
  484. ) {
  485. if ($_POST["v_web_terminal"] == "true") {
  486. exec(HESTIA_CMD . "v-add-sys-web-terminal", $output, $return_var);
  487. check_return_code($return_var, $output);
  488. unset($output);
  489. if (empty($_SESSION["error_msg"])) {
  490. $_SESSION["WEB_TERMINAL"] = "true";
  491. }
  492. } else {
  493. exec(HESTIA_CMD . "v-delete-sys-web-terminal", $output, $return_var);
  494. check_return_code($return_var, $output);
  495. unset($output);
  496. if (empty($_SESSION["error_msg"])) {
  497. $_SESSION["WEB_TERMINAL"] = "false";
  498. }
  499. }
  500. }
  501. }
  502. // Set phpMyAdmin SSO key
  503. if (empty($_SESSION["error_msg"])) {
  504. if (!empty($_POST["v_phpmyadmin_key"])) {
  505. if ($_POST["v_phpmyadmin_key"] == "yes" && $_SESSION["PHPMYADMIN_KEY"] == "") {
  506. exec(HESTIA_CMD . "v-add-sys-pma-sso quiet", $output, $return_var);
  507. check_return_code($return_var, $output);
  508. unset($output);
  509. if (empty($_SESSION["error_msg"])) {
  510. $_SESSION["PHPMYADMIN_KEY"] != "";
  511. }
  512. } elseif ($_POST["v_phpmyadmin_key"] == "no" && $_SESSION["PHPMYADMIN_KEY"] != "") {
  513. exec(HESTIA_CMD . "v-delete-sys-pma-sso quiet", $output, $return_var);
  514. check_return_code($return_var, $output);
  515. unset($output);
  516. if (empty($_SESSION["error_msg"])) {
  517. $_SESSION["PHPMYADMIN_KEY"] = "";
  518. }
  519. }
  520. }
  521. }
  522. // Set disk_quota support
  523. if (empty($_SESSION["error_msg"])) {
  524. if (!empty($_POST["v_quota"]) && $_SESSION["DISK_QUOTA"] != $_POST["v_quota"]) {
  525. if ($_POST["v_quota"] == "yes") {
  526. exec(HESTIA_CMD . "v-add-sys-quota", $output, $return_var);
  527. check_return_code($return_var, $output);
  528. unset($output);
  529. if (empty($_SESSION["error_msg"])) {
  530. $_SESSION["DISK_QUOTA"] = "yes";
  531. }
  532. } else {
  533. exec(HESTIA_CMD . "v-delete-sys-quota", $output, $return_var);
  534. check_return_code($return_var, $output);
  535. unset($output);
  536. if (empty($_SESSION["error_msg"])) {
  537. $_SESSION["DISK_QUOTA"] = "no";
  538. }
  539. }
  540. }
  541. }
  542. // Set firewall support
  543. if (empty($_SESSION["error_msg"])) {
  544. if ($_SESSION["FIREWALL_SYSTEM"] == "iptables") {
  545. $v_firewall = "yes";
  546. }
  547. if ($_SESSION["FIREWALL_SYSTEM"] != "iptables") {
  548. $v_firewall = "no";
  549. }
  550. if (!empty($_POST["v_firewall"]) && $v_firewall != $_POST["v_firewall"]) {
  551. if ($_POST["v_firewall"] == "yes") {
  552. exec(HESTIA_CMD . "v-add-sys-firewall", $output, $return_var);
  553. check_return_code($return_var, $output);
  554. unset($output);
  555. if (empty($_SESSION["error_msg"])) {
  556. $_SESSION["FIREWALL_SYSTEM"] = "iptables";
  557. }
  558. } else {
  559. exec(HESTIA_CMD . "v-delete-sys-firewall", $output, $return_var);
  560. check_return_code($return_var, $output);
  561. unset($output);
  562. if (empty($_SESSION["error_msg"])) {
  563. $_SESSION["FIREWALL_SYSTEM"] = "";
  564. }
  565. }
  566. }
  567. }
  568. // Update mysql pasword
  569. if (empty($_SESSION["error_msg"])) {
  570. if (!empty($_POST["v_mysql_password"])) {
  571. exec(
  572. HESTIA_CMD .
  573. "v-change-database-host-password mysql localhost root " .
  574. quoteshellarg($_POST["v_mysql_password"]),
  575. $output,
  576. $return_var,
  577. );
  578. check_return_code($return_var, $output);
  579. unset($output);
  580. $v_db_adv = "yes";
  581. }
  582. }
  583. // Update webmail url
  584. if (empty($_SESSION["error_msg"])) {
  585. if ($_POST["v_webmail_alias"] != $_SESSION["WEBMAIL_ALIAS"]) {
  586. exec(
  587. HESTIA_CMD . "v-change-sys-webmail " . quoteshellarg($_POST["v_webmail_alias"]),
  588. $output,
  589. $return_var,
  590. );
  591. check_return_code($return_var, $output);
  592. unset($output);
  593. $v_mail_adv = "yes";
  594. }
  595. }
  596. // Update system wide smtp relay
  597. if (empty($_SESSION["error_msg"])) {
  598. if (isset($_POST["v_smtp_relay"]) && !empty($_POST["v_smtp_relay_host"])) {
  599. if (
  600. $_POST["v_smtp_relay_host"] != $v_smtp_relay_host ||
  601. $_POST["v_smtp_relay_user"] != $v_smtp_relay_user ||
  602. $_POST["v_smtp_relay_port"] != $v_smtp_relay_port ||
  603. !empty($_POST["v_smtp_relay_pass"])
  604. ) {
  605. $v_smtp_relay = true;
  606. $v_smtp_relay_host = quoteshellarg($_POST["v_smtp_relay_host"]);
  607. $v_smtp_relay_user = quoteshellarg($_POST["v_smtp_relay_user"]);
  608. $v_smtp_relay_pass = quoteshellarg($_POST["v_smtp_relay_pass"]);
  609. if (!empty($_POST["v_smtp_relay_port"])) {
  610. $v_smtp_relay_port = quoteshellarg($_POST["v_smtp_relay_port"]);
  611. } else {
  612. $v_smtp_relay_port = "587";
  613. }
  614. exec(
  615. HESTIA_CMD .
  616. "v-add-sys-smtp-relay " .
  617. $v_smtp_relay_host .
  618. " " .
  619. $v_smtp_relay_user .
  620. " " .
  621. $v_smtp_relay_pass .
  622. " " .
  623. $v_smtp_relay_port,
  624. $output,
  625. $return_var,
  626. );
  627. check_return_code($return_var, $output);
  628. unset($output);
  629. }
  630. }
  631. if (!isset($_POST["v_smtp_relay"]) && $v_smtp_relay == true) {
  632. $v_smtp_relay = false;
  633. $v_smtp_relay_host = $v_smtp_relay_user = $v_smtp_relay_pass = $v_smtp_relay_port = "";
  634. exec(HESTIA_CMD . "v-delete-sys-smtp-relay", $output, $return_var);
  635. check_return_code($return_var, $output);
  636. unset($output);
  637. }
  638. }
  639. // Update phpMyAdmin url
  640. if (empty($_SESSION["error_msg"])) {
  641. if ($_POST["v_mysql_url"] != $_SESSION["DB_PMA_ALIAS"]) {
  642. exec(
  643. HESTIA_CMD . "v-change-sys-db-alias pma " . quoteshellarg($_POST["v_mysql_url"]),
  644. $output,
  645. $return_var,
  646. );
  647. check_return_code($return_var, $output);
  648. unset($output);
  649. $v_db_adv = "yes";
  650. }
  651. }
  652. // Update phpPgAdmin url
  653. if (empty($_SESSION["error_msg"])) {
  654. if (empty($_POST["v_pgsql_url"])) {
  655. $_POST["v_pgsql_url"] = "";
  656. }
  657. if ($_POST["v_pgsql_url"] != $_SESSION["DB_PGA_ALIAS"]) {
  658. exec(
  659. HESTIA_CMD . "v-change-sys-db-alias pga " . quoteshellarg($_POST["v_pgsql_url"]),
  660. $output,
  661. $return_var,
  662. );
  663. check_return_code($return_var, $output);
  664. unset($output);
  665. $v_db_adv = "yes";
  666. }
  667. }
  668. // Update send notification setting
  669. if (empty($_SESSION["error_msg"])) {
  670. if ($_SESSION["UPGRADE_SEND_EMAIL"] == "true") {
  671. $ugrade_send_mail = "on";
  672. } else {
  673. $ugrade_send_mail = "";
  674. }
  675. if (empty($_POST["v_upgrade_send_notification_email"])) {
  676. $_POST["v_upgrade_send_notification_email"] = "";
  677. }
  678. if ($_POST["v_upgrade_send_notification_email"] != $ugrade_send_mail) {
  679. if ($_POST["v_upgrade_send_notification_email"] == "on") {
  680. $_POST["v_upgrade_send_notification_email"] = "true";
  681. } else {
  682. $_POST["v_upgrade_send_notification_email"] = "false";
  683. }
  684. exec(
  685. HESTIA_CMD .
  686. "v-change-sys-config-value UPGRADE_SEND_EMAIL " .
  687. quoteshellarg($_POST["v_upgrade_send_notification_email"]),
  688. $output,
  689. $return_var,
  690. );
  691. check_return_code($return_var, $output);
  692. unset($output);
  693. $v_upgrade_notification_adv = "yes";
  694. }
  695. }
  696. // Update send log by email setting
  697. if (empty($_SESSION["error_msg"])) {
  698. if ($_SESSION["UPGRADE_SEND_EMAIL_LOG"] == "true") {
  699. $send_email_log = "on";
  700. } else {
  701. $send_email_log = "";
  702. }
  703. if (empty($_POST["v_upgrade_send_email_log"])) {
  704. $_POST["v_upgrade_send_email_log"] = "";
  705. }
  706. if ($_POST["v_upgrade_send_email_log"] != $send_email_log) {
  707. if ($_POST["v_upgrade_send_email_log"] == "on") {
  708. $_POST["v_upgrade_send_email_log"] = "true";
  709. } else {
  710. $_POST["v_upgrade_send_email_log"] = "false";
  711. }
  712. exec(
  713. HESTIA_CMD .
  714. "v-change-sys-config-value UPGRADE_SEND_EMAIL_LOG " .
  715. quoteshellarg($_POST["v_upgrade_send_email_log"]),
  716. $output,
  717. $return_var,
  718. );
  719. check_return_code($return_var, $output);
  720. unset($output);
  721. $v_upgrade_send_log_adv = "yes";
  722. }
  723. }
  724. // Disable local backup
  725. if (empty($_SESSION["error_msg"])) {
  726. if ($_POST["v_backup"] == "no" && $v_backup == "yes") {
  727. exec(HESTIA_CMD . "v-delete-backup-host local", $output, $return_var);
  728. check_return_code($return_var, $output);
  729. unset($output);
  730. if (empty($_SESSION["error_msg"])) {
  731. $v_backup = "no";
  732. }
  733. $v_backup_adv = "yes";
  734. }
  735. }
  736. // Enable local backups
  737. if (empty($_SESSION["error_msg"])) {
  738. if ($_POST["v_backup"] == "yes" && $v_backup != "yes") {
  739. exec(HESTIA_CMD . "v-add-backup-host local", $output, $return_var);
  740. check_return_code($return_var, $output);
  741. unset($output);
  742. if (empty($_SESSION["error_msg"])) {
  743. $v_backup = "yes";
  744. }
  745. $v_backup_adv = "yes";
  746. }
  747. }
  748. // Change backup gzip level
  749. if (empty($_SESSION["error_msg"])) {
  750. if ($_POST["v_backup_gzip"] != $v_backup_gzip) {
  751. if ($_POST["v_backup_mode"] == "gzip") {
  752. $_POST["v_backup_gzip"] = 9;
  753. }
  754. exec(
  755. HESTIA_CMD .
  756. "v-change-sys-config-value BACKUP_GZIP " .
  757. quoteshellarg($_POST["v_backup_gzip"]),
  758. $output,
  759. $return_var,
  760. );
  761. check_return_code($return_var, $output);
  762. unset($output);
  763. if (empty($_SESSION["error_msg"])) {
  764. $v_backup_gzip = $_POST["v_backup_gzip"];
  765. }
  766. $v_backup_adv = "yes";
  767. }
  768. }
  769. // Change backup mode
  770. if (empty($_SESSION["error_msg"])) {
  771. if ($_POST["v_backup_mode"] != $v_backup_mode) {
  772. exec(
  773. HESTIA_CMD .
  774. "v-change-sys-config-value BACKUP_MODE " .
  775. quoteshellarg($_POST["v_backup_mode"]),
  776. $output,
  777. $return_var,
  778. );
  779. check_return_code($return_var, $output);
  780. unset($output);
  781. if (empty($_SESSION["error_msg"])) {
  782. $v_backup_mode = $_POST["v_backup_mode"];
  783. }
  784. $v_backup_adv = "yes";
  785. if ($_POST["v_backup_mode"] == "gzip") {
  786. $_POST["v_backup_gzip"] = 9;
  787. if (empty($_SESSION["error_msg"])) {
  788. $v_backup_gzip = $_POST["v_backup_gzip"];
  789. }
  790. exec(
  791. HESTIA_CMD .
  792. "v-change-sys-config-value BACKUP_GZIP " .
  793. quoteshellarg($_POST["v_backup_gzip"]),
  794. $output,
  795. $return_var,
  796. );
  797. }
  798. }
  799. }
  800. // Change backup path
  801. if (empty($_SESSION["error_msg"])) {
  802. if (empty($_POST["v_backup_dir"])) {
  803. $_POST["v_backup_dir"] = "";
  804. }
  805. if ($_POST["v_backup_dir"] != $v_backup_dir) {
  806. /*
  807. See #1655
  808. exec (HESTIA_CMD."v-change-sys-config-value BACKUP ".quoteshellarg($_POST['v_backup_dir']), $output, $return_var);
  809. check_return_code($return_var,$output);
  810. unset($output);
  811. */
  812. if (empty($_SESSION["error_msg"])) {
  813. $v_backup_dir = $_POST["v_backup_dir"];
  814. }
  815. #$v_backup_adv = 'yes';
  816. }
  817. }
  818. // Add remote backup host
  819. if (empty($_SESSION["error_msg"])) {
  820. if (
  821. $v_backup_host == "" &&
  822. $v_backup_bucket == "" &&
  823. (!empty($_POST["v_backup_host"]) || !empty($_POST["v_backup_bucket"]))
  824. ) {
  825. if (in_array($_POST["v_backup_type"], ["ftp", "sftp"])) {
  826. $v_backup_host = quoteshellarg($_POST["v_backup_host"]);
  827. $v_backup_port = quoteshellarg($_POST["v_backup_port"]);
  828. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  829. $v_backup_username = quoteshellarg($_POST["v_backup_username"]);
  830. $v_backup_password = quoteshellarg($_POST["v_backup_password"]);
  831. $v_backup_bpath = quoteshellarg($_POST["v_backup_bpath"]);
  832. exec(
  833. HESTIA_CMD .
  834. "v-add-backup-host " .
  835. $v_backup_type .
  836. " " .
  837. $v_backup_host .
  838. " " .
  839. $v_backup_username .
  840. " " .
  841. $v_backup_password .
  842. " " .
  843. $v_backup_bpath .
  844. " " .
  845. $v_backup_port,
  846. $output,
  847. $return_var,
  848. );
  849. check_return_code($return_var, $output);
  850. unset($output);
  851. if (empty($_SESSION["error_msg"])) {
  852. $v_backup_host = $_POST["v_backup_host"];
  853. }
  854. if (empty($_SESSION["error_msg"])) {
  855. $v_backup_type = $_POST["v_backup_type"];
  856. }
  857. if (empty($_SESSION["error_msg"])) {
  858. $v_backup_username = $_POST["v_backup_username"];
  859. }
  860. if (empty($_SESSION["error_msg"])) {
  861. $v_backup_password = $_POST["v_backup_password"];
  862. }
  863. if (empty($_SESSION["error_msg"])) {
  864. $v_backup_bpath = $_POST["v_backup_bpath"];
  865. }
  866. if (empty($_SESSION["error_msg"])) {
  867. $v_backup_port = $_POST["v_backup_port"];
  868. }
  869. $v_backup_new = "yes";
  870. $v_backup_adv = "yes";
  871. $v_backup_remote_adv = "yes";
  872. } elseif (in_array($_POST["v_backup_type"], ["b2"])) {
  873. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  874. $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
  875. $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
  876. $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
  877. exec(
  878. HESTIA_CMD .
  879. "v-add-backup-host " .
  880. $v_backup_type .
  881. " " .
  882. $v_backup_bucket .
  883. " " .
  884. $v_backup_application_id .
  885. " " .
  886. $v_backup_application_key,
  887. $output,
  888. $return_var,
  889. );
  890. check_return_code($return_var, $output);
  891. unset($output);
  892. if (empty($_SESSION["error_msg"])) {
  893. $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
  894. }
  895. if (empty($_SESSION["error_msg"])) {
  896. $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
  897. }
  898. if (empty($_SESSION["error_msg"])) {
  899. $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
  900. }
  901. $v_backup_new = "yes";
  902. $v_backup_adv = "yes";
  903. $v_backup_remote_adv = "yes";
  904. }
  905. }
  906. if (
  907. $v_rclone_host == "" &&
  908. !empty($_POST["v_rclone_host"]) &&
  909. $_POST["v_backup_type"] == "rclone"
  910. ) {
  911. $v_rclone_host = quoteshellarg($_POST["v_rclone_host"]);
  912. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  913. $v_rclone_path = quoteshellarg($_POST["v_rclone_path"]);
  914. exec(
  915. HESTIA_CMD .
  916. "v-add-backup-host " .
  917. $v_backup_type .
  918. " " .
  919. $v_rclone_host .
  920. " '' '' " .
  921. $v_rclone_path,
  922. $output,
  923. $return_var,
  924. );
  925. check_return_code($return_var, $output);
  926. unset($output);
  927. $v_backup_new = "yes";
  928. $v_backup_adv = "yes";
  929. $v_backup_remote_adv = "yes";
  930. }
  931. }
  932. // Change remote backup host type
  933. if (empty($_SESSION["error_msg"])) {
  934. if (
  935. !empty($_POST["v_backup_host"]) &&
  936. $_POST["v_backup_type"] != $v_backup_type &&
  937. $v_backup_type != ""
  938. ) {
  939. exec(
  940. HESTIA_CMD . "v-delete-backup-host " . quoteshellarg($v_backup_type),
  941. $output,
  942. $return_var,
  943. );
  944. unset($output);
  945. if (in_array($_POST["v_backup_type"], ["ftp", "sftp"])) {
  946. $v_backup_host = quoteshellarg($_POST["v_backup_host"]);
  947. $v_backup_port = quoteshellarg($_POST["v_backup_port"]);
  948. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  949. $v_backup_username = quoteshellarg($_POST["v_backup_username"]);
  950. $v_backup_password = quoteshellarg($_POST["v_backup_password"]);
  951. $v_backup_bpath = quoteshellarg($_POST["v_backup_bpath"]);
  952. exec(
  953. HESTIA_CMD .
  954. "v-add-backup-host " .
  955. $v_backup_type .
  956. " " .
  957. $v_backup_host .
  958. " " .
  959. $v_backup_username .
  960. " " .
  961. $v_backup_password .
  962. " " .
  963. $v_backup_bpath .
  964. " " .
  965. $v_backup_port,
  966. $output,
  967. $return_var,
  968. );
  969. check_return_code($return_var, $output);
  970. unset($output);
  971. if (empty($_SESSION["error_msg"])) {
  972. $v_backup_host = $_POST["v_backup_host"];
  973. }
  974. if (empty($_SESSION["error_msg"])) {
  975. $v_backup_type = $_POST["v_backup_type"];
  976. }
  977. if (empty($_SESSION["error_msg"])) {
  978. $v_backup_username = $_POST["v_backup_username"];
  979. }
  980. if (empty($_SESSION["error_msg"])) {
  981. $v_backup_password = $_POST["v_backup_password"];
  982. }
  983. if (empty($_SESSION["error_msg"])) {
  984. $v_backup_bpath = $_POST["v_backup_bpath"];
  985. }
  986. if (empty($_SESSION["error_msg"])) {
  987. $v_backup_port = $_POST["v_backup_port"];
  988. }
  989. $v_backup_adv = "yes";
  990. $v_backup_remote_adv = "yes";
  991. } elseif (in_array($_POST["v_backup_type"], ["b2"])) {
  992. $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
  993. $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
  994. $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
  995. exec(
  996. HESTIA_CMD .
  997. "v-add-backup-host " .
  998. $v_backup_type .
  999. " " .
  1000. $v_backup_bucket .
  1001. " " .
  1002. $v_backup_application_id .
  1003. " " .
  1004. $v_backup_application_key,
  1005. $output,
  1006. $return_var,
  1007. );
  1008. check_return_code($return_var, $output);
  1009. unset($output);
  1010. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  1011. if (empty($_SESSION["error_msg"])) {
  1012. $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
  1013. }
  1014. if (empty($_SESSION["error_msg"])) {
  1015. $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
  1016. }
  1017. if (empty($_SESSION["error_msg"])) {
  1018. $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
  1019. }
  1020. $v_backup_adv = "yes";
  1021. $v_backup_remote_adv = "yes";
  1022. }
  1023. }
  1024. }
  1025. // Change remote backup host
  1026. if (empty($_SESSION["error_msg"])) {
  1027. if ($_POST["v_backup_type"] == $v_backup_type && !isset($v_backup_new)) {
  1028. if (in_array($_POST["v_backup_type"], ["ftp", "sftp"])) {
  1029. if (
  1030. $_POST["v_backup_host"] != $v_backup_host ||
  1031. $_POST["v_backup_username"] != $v_backup_username ||
  1032. $_POST["v_backup_password"] != $v_backup_password ||
  1033. ($_POST["v_backup_bpath"] != $v_backup_bpath ||
  1034. $_POST["v_backup_port"] != $v_backup_port)
  1035. ) {
  1036. $v_backup_host = quoteshellarg($_POST["v_backup_host"]);
  1037. $v_backup_port = quoteshellarg($_POST["v_backup_port"]);
  1038. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  1039. $v_backup_username = quoteshellarg($_POST["v_backup_username"]);
  1040. $v_backup_password = quoteshellarg($_POST["v_backup_password"]);
  1041. $v_backup_bpath = quoteshellarg($_POST["v_backup_bpath"]);
  1042. exec(
  1043. HESTIA_CMD .
  1044. "v-add-backup-host " .
  1045. $v_backup_type .
  1046. " " .
  1047. $v_backup_host .
  1048. " " .
  1049. $v_backup_username .
  1050. " " .
  1051. $v_backup_password .
  1052. " " .
  1053. $v_backup_bpath .
  1054. " " .
  1055. $v_backup_port,
  1056. $output,
  1057. $return_var,
  1058. );
  1059. check_return_code($return_var, $output);
  1060. unset($output);
  1061. if (empty($_SESSION["error_msg"])) {
  1062. $v_backup_host = $_POST["v_backup_host"];
  1063. }
  1064. if (empty($_SESSION["error_msg"])) {
  1065. $v_backup_type = $_POST["v_backup_type"];
  1066. }
  1067. if (empty($_SESSION["error_msg"])) {
  1068. $v_backup_username = $_POST["v_backup_username"];
  1069. }
  1070. if (empty($_SESSION["error_msg"])) {
  1071. $v_backup_password = $_POST["v_backup_password"];
  1072. }
  1073. if (empty($_SESSION["error_msg"])) {
  1074. $v_backup_bpath = $_POST["v_backup_bpath"];
  1075. }
  1076. if (empty($_SESSION["error_msg"])) {
  1077. $v_backup_port = $_POST["v_backup_port"];
  1078. }
  1079. $v_backup_adv = "yes";
  1080. $v_backup_remote_adv = "yes";
  1081. }
  1082. } elseif (in_array($_POST["v_backup_type"], ["b2"])) {
  1083. if (
  1084. $_POST["v_backup_bucket"] != $v_backup_bucket ||
  1085. $_POST["v_backup_application_key"] != $v_backup_application_key ||
  1086. $_POST["v_backup_application_id"] != $v_backup_application_id
  1087. ) {
  1088. $v_backup_type = quoteshellarg($_POST["v_backup_type"]);
  1089. $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
  1090. $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
  1091. $v_backup_application_key = quoteshellarg($_POST["v_backup_application_key"]);
  1092. exec(
  1093. HESTIA_CMD .
  1094. "v-add-backup-host " .
  1095. $v_backup_type .
  1096. " " .
  1097. $v_backup_bucket .
  1098. " " .
  1099. $v_backup_application_id .
  1100. " " .
  1101. $v_backup_application_key,
  1102. $output,
  1103. $return_var,
  1104. );
  1105. check_return_code($return_var, $output);
  1106. unset($output);
  1107. if (empty($_SESSION["error_msg"])) {
  1108. $v_backup_bucket = quoteshellarg($_POST["v_backup_bucket"]);
  1109. }
  1110. if (empty($_SESSION["error_msg"])) {
  1111. $v_backup_application_id = quoteshellarg($_POST["v_backup_application_id"]);
  1112. }
  1113. if (empty($_SESSION["error_msg"])) {
  1114. $v_backup_application_key = quoteshellarg(
  1115. $_POST["v_backup_application_key"],
  1116. );
  1117. }
  1118. $v_backup_adv = "yes";
  1119. $v_backup_remote_adv = "yes";
  1120. }
  1121. }
  1122. }
  1123. }
  1124. // Delete remote backup host
  1125. if (empty($_SESSION["error_msg"])) {
  1126. if (empty($_POST["v_backup_remote_adv"]) && $v_backup_remote_adv != "") {
  1127. exec(
  1128. HESTIA_CMD . "v-delete-backup-host " . quoteshellarg($v_backup_type),
  1129. $output,
  1130. $return_var,
  1131. );
  1132. check_return_code($return_var, $output);
  1133. unset($output);
  1134. if (empty($_SESSION["error_msg"])) {
  1135. $v_backup_host = "";
  1136. }
  1137. if (empty($_SESSION["error_msg"])) {
  1138. $v_backup_type = "";
  1139. }
  1140. if (empty($_SESSION["error_msg"])) {
  1141. $v_backup_username = "";
  1142. }
  1143. if (empty($_SESSION["error_msg"])) {
  1144. $v_backup_password = "";
  1145. }
  1146. if (empty($_SESSION["error_msg"])) {
  1147. $v_backup_bpath = "";
  1148. }
  1149. if (empty($_SESSION["error_msg"])) {
  1150. $v_backup_bucket = "";
  1151. }
  1152. if (empty($_SESSION["error_msg"])) {
  1153. $v_backup_application_id = "";
  1154. }
  1155. if (empty($_SESSION["error_msg"])) {
  1156. $v_backup_application_key = "";
  1157. }
  1158. $v_backup_adv = "";
  1159. $v_backup_remote_adv = "";
  1160. }
  1161. }
  1162. // Change INACTIVE_SESSION_TIMEOUT
  1163. if (empty($_SESSION["error_msg"])) {
  1164. if ($_POST["v_inactive_session_timeout"] != $_SESSION["INACTIVE_SESSION_TIMEOUT"]) {
  1165. if ($_POST["v_inactive_session_timeout"] < 1) {
  1166. $_SESSION["error_msg"] = _("Inactive session timeout can not lower than 1 minute.");
  1167. } else {
  1168. exec(
  1169. HESTIA_CMD .
  1170. "v-change-sys-config-value INACTIVE_SESSION_TIMEOUT " .
  1171. quoteshellarg($_POST["v_inactive_session_timeout"]),
  1172. $output,
  1173. $return_var,
  1174. );
  1175. check_return_code($return_var, $output);
  1176. unset($output);
  1177. if (empty($_SESSION["error_msg"])) {
  1178. $v_inactive_session_timeout = $_POST["v_inactive_session_timeout"];
  1179. }
  1180. }
  1181. $v_security_adv = "yes";
  1182. }
  1183. }
  1184. // Change POLICY_CSRF_STRICTNESS
  1185. if (empty($_SESSION["error_msg"])) {
  1186. if ($_POST["v_policy_csrf_strictness"] != $_SESSION["POLICY_CSRF_STRICTNESS"]) {
  1187. exec(
  1188. HESTIA_CMD .
  1189. "v-change-sys-config-value POLICY_CSRF_STRICTNESS " .
  1190. quoteshellarg($_POST["v_policy_csrf_strictness"]),
  1191. $output,
  1192. $return_var,
  1193. );
  1194. check_return_code($return_var, $output);
  1195. unset($output);
  1196. if (empty($_SESSION["error_msg"])) {
  1197. $v_policy_csrf_strictness = $_POST["v_inactive_session_timeout"];
  1198. }
  1199. $v_security_adv = "yes";
  1200. }
  1201. }
  1202. // Change ENFORCE_SUBDOMAIN_OWNERSHIP
  1203. if (empty($_SESSION["error_msg"])) {
  1204. if ($_POST["v_enforce_subdomain_ownership"] != $_SESSION["ENFORCE_SUBDOMAIN_OWNERSHIP"]) {
  1205. exec(
  1206. HESTIA_CMD .
  1207. "v-change-sys-config-value ENFORCE_SUBDOMAIN_OWNERSHIP " .
  1208. quoteshellarg($_POST["v_enforce_subdomain_ownership"]),
  1209. $output,
  1210. $return_var,
  1211. );
  1212. check_return_code($return_var, $output);
  1213. unset($output);
  1214. if (empty($_SESSION["error_msg"])) {
  1215. $v_enforce_subdomain_ownership = $_POST["v_enforce_subdomain_ownership"];
  1216. }
  1217. $v_security_adv = "yes";
  1218. }
  1219. }
  1220. // Change POLICY_USER_EDIT_DETAILS
  1221. if (empty($_SESSION["error_msg"])) {
  1222. if ($_POST["v_policy_user_edit_details"] != $_SESSION["POLICY_USER_EDIT_DETAILS"]) {
  1223. exec(
  1224. HESTIA_CMD .
  1225. "v-change-sys-config-value POLICY_USER_EDIT_DETAILS " .
  1226. quoteshellarg($_POST["v_policy_user_edit_details"]),
  1227. $output,
  1228. $return_var,
  1229. );
  1230. check_return_code($return_var, $output);
  1231. unset($output);
  1232. if (empty($_SESSION["error_msg"])) {
  1233. $v_policy_user_edit_details = $_POST["v_policy_user_edit_details"];
  1234. }
  1235. $v_security_adv = "yes";
  1236. }
  1237. }
  1238. // Change POLICY_USER_EDIT_WEB_TEMPLATES
  1239. if (empty($_SESSION["error_msg"])) {
  1240. if (
  1241. $_POST["v_policy_user_edit_web_templates"] !=
  1242. $_SESSION["POLICY_USER_EDIT_WEB_TEMPLATES"]
  1243. ) {
  1244. exec(
  1245. HESTIA_CMD .
  1246. "v-change-sys-config-value POLICY_USER_EDIT_WEB_TEMPLATES " .
  1247. quoteshellarg($_POST["v_policy_user_edit_web_templates"]),
  1248. $output,
  1249. $return_var,
  1250. );
  1251. check_return_code($return_var, $output);
  1252. unset($output);
  1253. if (empty($_SESSION["error_msg"])) {
  1254. $v_policy_user_edit_details = $_POST["v_policy_user_edit_web_templates"];
  1255. }
  1256. $v_security_adv = "yes";
  1257. }
  1258. }
  1259. // Change POLICY_USER_EDIT_DNS_TEMPLATES
  1260. if (empty($_SESSION["error_msg"])) {
  1261. if (
  1262. $_POST["v_policy_user_edit_dns_templates"] !=
  1263. $_SESSION["POLICY_USER_EDIT_DNS_TEMPLATES"]
  1264. ) {
  1265. exec(
  1266. HESTIA_CMD .
  1267. "v-change-sys-config-value POLICY_USER_EDIT_DNS_TEMPLATES " .
  1268. quoteshellarg($_POST["v_policy_user_edit_dns_templates"]),
  1269. $output,
  1270. $return_var,
  1271. );
  1272. check_return_code($return_var, $output);
  1273. unset($output);
  1274. if (empty($_SESSION["error_msg"])) {
  1275. $v_policy_user_edit_details = $_POST["v_policy_user_edit_dns_templates"];
  1276. }
  1277. $v_security_adv = "yes";
  1278. }
  1279. }
  1280. if (
  1281. $_POST["v_api_system"] != $_SESSION["API_SYSTEM"] ||
  1282. $_POST["v_api"] != $_SESSION["API"] ||
  1283. $_POST["v_api_allowed_ip"] != $_SESSION["API_ALLOWED_IP"]
  1284. ) {
  1285. if (empty($_SESSION["error_msg"])) {
  1286. if ($_POST["v_api"] == "no" && $_POST["v_api_system"] === 0) {
  1287. exec(HESTIA_CMD . "v-change-sys-api 'disable'", $output, $return_var);
  1288. check_return_code($return_var, $output);
  1289. unset($output);
  1290. }
  1291. if (
  1292. $_POST["v_api"] == "yes" ||
  1293. ($_POST["v_api_system"] !== 0 &&
  1294. $_POST["v_api_system"] != $_SESSION["API_SYSTEM"]) ||
  1295. $_POST["v_api"] != $_SESSION["API"]
  1296. ) {
  1297. exec(HESTIA_CMD . "v-change-sys-api 'enable'", $output, $return_var);
  1298. check_return_code($return_var, $output);
  1299. unset($output);
  1300. }
  1301. }
  1302. if (empty($_SESSION["error_msg"])) {
  1303. if ($_POST["v_api_system"] != $_SESSION["API_SYSTEM"]) {
  1304. exec(
  1305. HESTIA_CMD .
  1306. "v-change-sys-config-value API_SYSTEM " .
  1307. quoteshellarg($_POST["v_api_system"]),
  1308. $output,
  1309. $return_var,
  1310. );
  1311. check_return_code($return_var, $output);
  1312. unset($output);
  1313. if (empty($_SESSION["error_msg"])) {
  1314. $v_policy_user_edit_details = $_POST["v_api_system"];
  1315. }
  1316. $v_security_adv = "yes";
  1317. }
  1318. }
  1319. // Change API access
  1320. if (empty($_SESSION["error_msg"])) {
  1321. if ($_POST["v_api"] != $_SESSION["API"]) {
  1322. $api_status = "no";
  1323. if ($_POST["v_api"] == "yes") {
  1324. $api_status = "yes";
  1325. }
  1326. exec(
  1327. HESTIA_CMD . "v-change-sys-config-value API " . quoteshellarg($api_status),
  1328. $output,
  1329. $return_var,
  1330. );
  1331. check_return_code($return_var, $output);
  1332. unset($output);
  1333. if (empty($_SESSION["error_msg"])) {
  1334. $v_api = $_POST["v_api"];
  1335. }
  1336. $v_security_adv = "yes";
  1337. }
  1338. }
  1339. // Change API allowed IPs
  1340. if (empty($_SESSION["error_msg"])) {
  1341. if ($_POST["v_api_allowed_ip"] != $_SESSION["API_ALLOWED_IP"]) {
  1342. $ips = [];
  1343. foreach (explode("\n", $_POST["v_api_allowed_ip"]) as $ip) {
  1344. if (trim($ip) != "allow-all") {
  1345. if (filter_var(trim($ip), FILTER_VALIDATE_IP)) {
  1346. $ips[] = trim($ip);
  1347. }
  1348. } else {
  1349. $ips[] = trim($ip);
  1350. }
  1351. }
  1352. if (implode(",", $ips) != $_SESSION["API_ALLOWED_IP"]) {
  1353. exec(
  1354. HESTIA_CMD .
  1355. "v-change-sys-config-value API_ALLOWED_IP " .
  1356. quoteshellarg(implode(",", $ips)),
  1357. $output,
  1358. $return_var,
  1359. );
  1360. check_return_code($return_var, $output);
  1361. unset($output);
  1362. if (empty($_SESSION["error_msg"])) {
  1363. $v_api_allowed_ip = $_POST["v_api_allowed_ip"];
  1364. }
  1365. $v_security_adv = "yes";
  1366. }
  1367. }
  1368. }
  1369. }
  1370. // Change POLICY_USER_VIEW_LOGS
  1371. if (empty($_SESSION["error_msg"])) {
  1372. if ($_POST["v_policy_user_view_logs"] != $_SESSION["POLICY_USER_VIEW_LOGS"]) {
  1373. exec(
  1374. HESTIA_CMD .
  1375. "v-change-sys-config-value POLICY_USER_VIEW_LOGS " .
  1376. quoteshellarg($_POST["v_policy_user_view_logs"]),
  1377. $output,
  1378. $return_var,
  1379. );
  1380. check_return_code($return_var, $output);
  1381. unset($output);
  1382. if (empty($_SESSION["error_msg"])) {
  1383. $v_policy_user_view_logs = $_POST["v_policy_user_view_logs"];
  1384. }
  1385. $v_security_adv = "yes";
  1386. }
  1387. }
  1388. // Change POLICY_USER_DELETE_LOGS
  1389. if (empty($_SESSION["error_msg"])) {
  1390. if ($_POST["v_policy_user_delete_logs"] != $_SESSION["POLICY_USER_DELETE_LOGS"]) {
  1391. exec(
  1392. HESTIA_CMD .
  1393. "v-change-sys-config-value POLICY_USER_DELETE_LOGS " .
  1394. quoteshellarg($_POST["v_policy_user_delete_logs"]),
  1395. $output,
  1396. $return_var,
  1397. );
  1398. check_return_code($return_var, $output);
  1399. unset($output);
  1400. if (empty($_SESSION["error_msg"])) {
  1401. $v_policy_user_delete_logs = $_POST["v_policy_user_delete_logs"];
  1402. }
  1403. $v_security_adv = "yes";
  1404. }
  1405. }
  1406. // Change POLICY_SYSTEM_PASSWORD_RESET
  1407. if (empty($_SESSION["error_msg"])) {
  1408. if ($_POST["v_policy_system_password_reset"] != $_SESSION["POLICY_SYSTEM_PASSWORD_RESET"]) {
  1409. exec(
  1410. HESTIA_CMD .
  1411. "v-change-sys-config-value POLICY_SYSTEM_PASSWORD_RESET " .
  1412. quoteshellarg($_POST["v_policy_system_password_reset"]),
  1413. $output,
  1414. $return_var,
  1415. );
  1416. check_return_code($return_var, $output);
  1417. unset($output);
  1418. if (empty($_SESSION["error_msg"])) {
  1419. $v_policy_system_password_reset = $_POST["v_policy_system_password_reset"];
  1420. }
  1421. $v_security_adv = "yes";
  1422. }
  1423. }
  1424. // Change POLICY_SYSTEM_PROTECTED_ADMIN
  1425. if (empty($_SESSION["error_msg"])) {
  1426. if (!empty($_POST["v_policy_system_protected_admin"])) {
  1427. if (
  1428. $_POST["v_policy_system_protected_admin"] !=
  1429. $_SESSION["POLICY_SYSTEM_PROTECTED_ADMIN"]
  1430. ) {
  1431. exec(
  1432. HESTIA_CMD .
  1433. "v-change-sys-config-value POLICY_SYSTEM_PROTECTED_ADMIN " .
  1434. quoteshellarg($_POST["v_policy_system_protected_admin"]),
  1435. $output,
  1436. $return_var,
  1437. );
  1438. check_return_code($return_var, $output);
  1439. unset($output);
  1440. if (empty($_SESSION["error_msg"])) {
  1441. $v_policy_system_protected_admin = $_POST["v_policy_system_protected_admin"];
  1442. }
  1443. $v_security_adv = "yes";
  1444. }
  1445. }
  1446. }
  1447. // Change POLICY_USER_VIEW_SUSPENDED
  1448. if (empty($_SESSION["error_msg"])) {
  1449. if (!empty($_POST["v_policy_user_view_suspended"])) {
  1450. if (
  1451. $_POST["v_policy_user_view_suspended"] != $_SESSION["POLICY_USER_VIEW_SUSPENDED"] &&
  1452. !empty($_SESSION["POLICY_USER_VIEW_SUSPENDED"])
  1453. ) {
  1454. exec(
  1455. HESTIA_CMD .
  1456. "v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED " .
  1457. quoteshellarg($_POST["v_policy_user_view_suspended"]),
  1458. $output,
  1459. $return_var,
  1460. );
  1461. check_return_code($return_var, $output);
  1462. unset($output);
  1463. if (empty($_SESSION["error_msg"])) {
  1464. $v_policy_user_view_suspended = $_POST["v_policy_user_view_suspended"];
  1465. }
  1466. $v_security_adv = "yes";
  1467. }
  1468. }
  1469. }
  1470. // Change POLICY_USER_CHANGE_THEME
  1471. if (empty($_SESSION["error_msg"])) {
  1472. if (empty($_POST["v_policy_user_change_theme"])) {
  1473. $_POST["v_policy_user_change_theme"] = "";
  1474. }
  1475. if ($_POST["v_policy_user_change_theme"] == "on") {
  1476. $_POST["v_policy_user_change_theme"] = "no";
  1477. } else {
  1478. $_POST["v_policy_user_change_theme"] = "yes";
  1479. }
  1480. if ($_POST["v_policy_user_change_theme"] != $_SESSION["POLICY_USER_CHANGE_THEME"]) {
  1481. exec(
  1482. HESTIA_CMD .
  1483. "v-change-sys-config-value POLICY_USER_CHANGE_THEME " .
  1484. quoteshellarg($_POST["v_policy_user_change_theme"]),
  1485. $output,
  1486. $return_var,
  1487. );
  1488. check_return_code($return_var, $output);
  1489. unset($output);
  1490. if ($_POST["v_policy_user_change_theme"]) {
  1491. unset($_SESSION["userTheme"]);
  1492. $require_refresh = true;
  1493. }
  1494. if (empty($_SESSION["error_msg"])) {
  1495. $v_policy_user_change_theme = $_POST["v_policy_user_change_theme"];
  1496. }
  1497. }
  1498. }
  1499. // Change POLICY_SYSTEM_HIDE_ADMIN
  1500. if (empty($_SESSION["error_msg"])) {
  1501. if (!empty($_POST["v_policy_system_hide_admin"])) {
  1502. if ($_POST["v_policy_system_hide_admin"] != $_SESSION["POLICY_SYSTEM_HIDE_ADMIN"]) {
  1503. exec(
  1504. HESTIA_CMD .
  1505. "v-change-sys-config-value POLICY_SYSTEM_HIDE_ADMIN " .
  1506. quoteshellarg($_POST["v_policy_system_hide_admin"]),
  1507. $output,
  1508. $return_var,
  1509. );
  1510. check_return_code($return_var, $output);
  1511. unset($output);
  1512. if (empty($_SESSION["error_msg"])) {
  1513. $v_policy_system_hide_admin = $_POST["v_policy_system_hide_admin"];
  1514. }
  1515. $v_security_adv = "yes";
  1516. }
  1517. }
  1518. }
  1519. // Change POLICY_SYSTEM_HIDE_SERVICES
  1520. if (empty($_SESSION["error_msg"])) {
  1521. if (!empty($_POST["v_policy_system_hide_services"])) {
  1522. if (
  1523. $_POST["v_policy_system_hide_services"] != $_SESSION["POLICY_SYSTEM_HIDE_SERVICES"]
  1524. ) {
  1525. exec(
  1526. HESTIA_CMD .
  1527. "v-change-sys-config-value POLICY_SYSTEM_HIDE_SERVICES " .
  1528. quoteshellarg($_POST["v_policy_system_hide_services"]),
  1529. $output,
  1530. $return_var,
  1531. );
  1532. check_return_code($return_var, $output);
  1533. unset($output);
  1534. if (empty($_SESSION["error_msg"])) {
  1535. $v_policy_system_hide_services = $_POST["v_policy_system_hide_services"];
  1536. }
  1537. $v_security_adv = "yes";
  1538. }
  1539. }
  1540. }
  1541. // Change POLICY_SYSTEM_HIDE_SERVICES
  1542. if (empty($_SESSION["error_msg"])) {
  1543. if (
  1544. $_POST["v_policy_backup_suspended_users"] != $_SESSION["POLICY_BACKUP_SUSPENDED_USERS"]
  1545. ) {
  1546. exec(
  1547. HESTIA_CMD .
  1548. "v-change-sys-config-value POLICY_BACKUP_SUSPENDED_USERS " .
  1549. quoteshellarg($_POST["v_policy_backup_suspended_users"]),
  1550. $output,
  1551. $return_var,
  1552. );
  1553. check_return_code($return_var, $output);
  1554. unset($output);
  1555. if (empty($_SESSION["error_msg"])) {
  1556. $v_policy_system_hide_services = $_POST["v_policy_backup_suspended_users"];
  1557. }
  1558. $v_security_adv = "yes";
  1559. }
  1560. }
  1561. if (empty($_SESSION["error_msg"])) {
  1562. if ($_POST["v_policy_sync_error_documents"] != $_SESSION["POLICY_SYNC_ERROR_DOCUMENTS"]) {
  1563. exec(
  1564. HESTIA_CMD .
  1565. "v-change-sys-config-value POLICY_SYNC_ERROR_DOCUMENTS " .
  1566. quoteshellarg($_POST["v_policy_sync_error_documents"]),
  1567. $output,
  1568. $return_var,
  1569. );
  1570. check_return_code($return_var, $output);
  1571. unset($output);
  1572. if (empty($_SESSION["error_msg"])) {
  1573. $v_policy_sync_error_documents = $_POST["v_policy_sync_error_documents"];
  1574. }
  1575. $v_security_adv = "yes";
  1576. }
  1577. }
  1578. if (empty($_SESSION["error_msg"])) {
  1579. if ($_POST["v_policy_sync_skeleton"] != $_SESSION["POLICY_SYNC_SKELETON"]) {
  1580. exec(
  1581. HESTIA_CMD .
  1582. "v-change-sys-config-value POLICY_SYNC_SKELETON " .
  1583. quoteshellarg($_POST["v_policy_sync_skeleton"]),
  1584. $output,
  1585. $return_var,
  1586. );
  1587. check_return_code($return_var, $output);
  1588. unset($output);
  1589. if (empty($_SESSION["error_msg"])) {
  1590. $v_policy_sync_skeleton = $_POST["v_policy_sync_skeleton"];
  1591. }
  1592. $v_security_adv = "yes";
  1593. }
  1594. }
  1595. // Change login style
  1596. if (empty($_SESSION["error_msg"])) {
  1597. if ($_POST["v_login_style"] != $_SESSION["LOGIN_STYLE"]) {
  1598. exec(
  1599. HESTIA_CMD .
  1600. "v-change-sys-config-value LOGIN_STYLE " .
  1601. quoteshellarg($_POST["v_login_style"]),
  1602. $output,
  1603. $return_var,
  1604. );
  1605. check_return_code($return_var, $output);
  1606. unset($output);
  1607. if (empty($_SESSION["error_msg"])) {
  1608. $v_login_style = $_POST["v_login_style"];
  1609. }
  1610. $v_security_adv = "yes";
  1611. }
  1612. }
  1613. // Update SSL certificate
  1614. if (!empty($_POST["v_ssl_crt"]) && empty($_SESSION["error_msg"])) {
  1615. if (
  1616. $v_ssl_crt != str_replace("\r\n", "\n", $_POST["v_ssl_crt"]) ||
  1617. $v_ssl_key != str_replace("\r\n", "\n", $_POST["v_ssl_key"])
  1618. ) {
  1619. exec("mktemp -d", $mktemp_output, $return_var);
  1620. $tmpdir = $mktemp_output[0];
  1621. // Certificate
  1622. if (!empty($_POST["v_ssl_crt"])) {
  1623. $fp = fopen($tmpdir . "/certificate.crt", "w");
  1624. fwrite($fp, str_replace("\r\n", "\n", $_POST["v_ssl_crt"]));
  1625. fwrite($fp, "\n");
  1626. fclose($fp);
  1627. }
  1628. // Key
  1629. if (!empty($_POST["v_ssl_key"])) {
  1630. $fp = fopen($tmpdir . "/certificate.key", "w");
  1631. fwrite($fp, str_replace("\r\n", "\n", $_POST["v_ssl_key"]));
  1632. fwrite($fp, "\n");
  1633. fclose($fp);
  1634. }
  1635. exec(HESTIA_CMD . "v-change-sys-hestia-ssl " . $tmpdir, $output, $return_var);
  1636. check_return_code($return_var, $output);
  1637. unset($output);
  1638. // List ssl certificate info
  1639. exec(HESTIA_CMD . "v-list-sys-hestia-ssl json", $output, $return_var);
  1640. $ssl_str = json_decode(implode("", $output), true);
  1641. unset($output);
  1642. $v_ssl_crt = $ssl_str["HESTIA"]["CRT"];
  1643. $v_ssl_key = $ssl_str["HESTIA"]["KEY"];
  1644. $v_ssl_ca = $ssl_str["HESTIA"]["CA"];
  1645. $v_ssl_subject = $ssl_str["HESTIA"]["SUBJECT"];
  1646. $v_ssl_aliases = $ssl_str["HESTIA"]["ALIASES"];
  1647. $v_ssl_not_before = $ssl_str["HESTIA"]["NOT_BEFORE"];
  1648. $v_ssl_not_after = $ssl_str["HESTIA"]["NOT_AFTER"];
  1649. $v_ssl_signature = $ssl_str["HESTIA"]["SIGNATURE"];
  1650. $v_ssl_pub_key = $ssl_str["HESTIA"]["PUB_KEY"];
  1651. $v_ssl_issuer = $ssl_str["HESTIA"]["ISSUER"];
  1652. // Cleanup certificate tempfiles
  1653. if (file_exists($tmpdir . "/certificate.crt")) {
  1654. unlink($tmpdir . "/certificate.crt");
  1655. }
  1656. if (file_exists($tmpdir . "/certificate.key")) {
  1657. unlink($tmpdir . "/certificate.key");
  1658. }
  1659. rmdir($tmpdir);
  1660. }
  1661. }
  1662. // Flush field values on success
  1663. if (empty($_SESSION["error_msg"])) {
  1664. $_SESSION["ok_msg"] = _("Changes have been saved.");
  1665. }
  1666. if ($require_refresh == true) {
  1667. $refresh = $_SERVER["REQUEST_URI"];
  1668. $_SESSION["ok_msg"] = _("Changes have been saved.");
  1669. header("Location: $refresh");
  1670. die();
  1671. }
  1672. }
  1673. // Check system configuration
  1674. exec(HESTIA_CMD . "v-list-sys-config json", $output, $return_var);
  1675. $data = json_decode(implode("", $output), true);
  1676. unset($output);
  1677. $sys_arr = $data["config"];
  1678. foreach ($sys_arr as $key => $value) {
  1679. $_SESSION[$key] = $value;
  1680. }
  1681. // Render page
  1682. render_page($user, $TAB, "edit_server");
  1683. // Flush session messages
  1684. unset($_SESSION["error_msg"]);
  1685. unset($_SESSION["ok_msg"]);