index.php 49 KB

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