index.php 49 KB

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