index.php 49 KB

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