index.php 50 KB

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