index.php 50 KB

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