index.php 49 KB

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