index.php 49 KB

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