index.php 50 KB

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