index.php 50 KB

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