index.php 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  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. ];
  34. sort($v_php_versions);
  35. if (empty($backend_templates)) {
  36. $v_php_versions=[];
  37. }
  38. $backends_active = backendtpl_with_webdomains();
  39. $v_php_versions = array_map(function ($php_version) use ($backend_templates, $backends_active) {
  40. // Mark installed php versions
  41. if (stripos($php_version, 'php') !== 0) {
  42. return false;
  43. }
  44. $phpinfo = (object) [
  45. "name" => $php_version,
  46. "tpl" => strtoupper(str_replace('.', '_', $php_version)),
  47. "version" => str_ireplace('php-', '', $php_version),
  48. "usedby" => [],
  49. "installed" => false,
  50. "protected" => false,
  51. ];
  52. if (in_array($phpinfo->tpl, $backend_templates)) {
  53. $phpinfo->installed = true;
  54. }
  55. if (array_key_exists($phpinfo->tpl, $backends_active)) {
  56. // Prevent used php version to be removed
  57. if ($phpinfo->installed) {
  58. $phpinfo->protected = true;
  59. }
  60. $phpinfo->usedby = $backends_active[$phpinfo->tpl];
  61. }
  62. if ($phpinfo->name == DEFAULT_PHP_VERSION) {
  63. // Prevent default php version to be removed
  64. if ($phpinfo->installed) {
  65. $phpinfo->protected = true;
  66. }
  67. if (!empty($backends_active['default'])) {
  68. $phpinfo->usedby = array_merge_recursive($phpinfo->usedby, $backends_active['default']);
  69. }
  70. }
  71. return $phpinfo;
  72. }, $v_php_versions);
  73. // List languages
  74. exec(HESTIA_CMD."v-list-sys-languages json", $output, $return_var);
  75. $language = json_decode(implode('', $output), true);
  76. foreach ($language as $lang) {
  77. $languages[$lang] = translate_json($lang);
  78. }
  79. asort($languages);
  80. unset($output);
  81. // List themes
  82. exec(HESTIA_CMD."v-list-sys-themes json", $output, $return_var);
  83. $theme = json_decode(implode('', $output), true);
  84. unset($output);
  85. // List dns cluster hosts
  86. exec(HESTIA_CMD."v-list-remote-dns-hosts json", $output, $return_var);
  87. $dns_cluster = json_decode(implode('', $output), true);
  88. unset($output);
  89. if (is_array($dns_cluster)) {
  90. foreach ($dns_cluster as $key => $value) {
  91. $v_dns_cluster = 'yes';
  92. }
  93. }
  94. if (empty($v_dns_cluster)) {
  95. $v_dns_cluster = '';
  96. }
  97. $v_release_branch = $_SESSION['RELEASE_BRANCH'];
  98. // List smtp relay settings
  99. if (!empty($_SESSION['SMTP_RELAY'])) {
  100. $v_smtp_relay = $_SESSION['SMTP_RELAY'];
  101. } else {
  102. $v_smtp_relay = '';
  103. }
  104. if (!empty($_SESSION['SMTP_RELAY_HOST'])) {
  105. $v_smtp_relay_host = $_SESSION['SMTP_RELAY_HOST'];
  106. } else {
  107. $v_smtp_relay_host = '';
  108. }
  109. if (!empty($_SESSION['SMTP_RELAY_PORT'])) {
  110. $v_smtp_relay_port = $_SESSION['SMTP_RELAY_PORT'];
  111. } else {
  112. $v_smtp_relay_port = '';
  113. }
  114. if (!empty($_SESSION['SMTP_RELAY_USER'])) {
  115. $v_smtp_relay_user = $_SESSION['SMTP_RELAY_USER'];
  116. } else {
  117. $v_smtp_relay_user = '';
  118. }
  119. $v_smtp_relay_pass = '';
  120. if (empty($_POST['v_experimental_features'])){
  121. $_POST['v_experimental_features'] = 'false';
  122. }
  123. if (empty($_POST['v_policy_user_view_suspended'])){
  124. $_POST['v_policy_user_view_suspended'] = 'false';
  125. }
  126. // List Database hosts
  127. exec(HESTIA_CMD."v-list-database-hosts json", $output, $return_var);
  128. $db_hosts = json_decode(implode('', $output), true);
  129. unset($output);
  130. $v_mysql_hosts = array_values(array_filter($db_hosts, function ($host) {
  131. return $host['TYPE'] === 'mysql';
  132. }));
  133. $v_mysql = count($v_mysql_hosts) ? 'yes' : 'no';
  134. $v_pgsql_hosts = array_values(array_filter($db_hosts, function ($host) {
  135. return $host['TYPE'] === 'pgsql';
  136. }));
  137. $v_pgsql = count($v_pgsql_hosts) ? 'yes' : 'no';
  138. unset($db_hosts);
  139. // List backup settings
  140. $v_backup_dir = "/backup";
  141. if (!empty($_SESSION['BACKUP'])) {
  142. $v_backup_dir = $_SESSION['BACKUP'];
  143. }
  144. $v_backup_gzip = '5';
  145. if (!empty($_SESSION['BACKUP_GZIP'])) {
  146. $v_backup_gzip = $_SESSION['BACKUP_GZIP'];
  147. }
  148. $v_backup_mode = 'gzip';
  149. if (!empty($_SESSION['BACKUP_MODE'])) {
  150. $v_backup_mode = $_SESSION['BACKUP_MODE'];
  151. }
  152. $backup_types = explode(",", $_SESSION['BACKUP_SYSTEM']);
  153. foreach ($backup_types as $backup_type) {
  154. if ($backup_type == 'local') {
  155. $v_backup = 'yes';
  156. } else {
  157. exec(HESTIA_CMD."v-list-backup-host ".quoteshellarg($backup_type)." json", $output, $return_var);
  158. $v_remote_backup = json_decode(implode('', $output), true);
  159. unset($output);
  160. if (in_array($backup_type, array('ftp','sftp'))) {
  161. $v_backup_host = $v_remote_backup[$backup_type]['HOST'];
  162. $v_backup_type = $v_remote_backup[$backup_type]['TYPE'];
  163. $v_backup_username = $v_remote_backup[$backup_type]['USERNAME'] ?? '';
  164. $v_backup_password = "";
  165. $v_backup_port = $v_remote_backup[$backup_type]['PORT'] ?? '';
  166. $v_backup_bpath = $v_remote_backup[$backup_type]['BPATH'];
  167. $v_backup_remote_adv = "yes";
  168. } elseif (in_array($backup_type, array('b2'))) {
  169. $v_backup_bucket = $v_remote_backup[$backup_type]['BUCKET'];
  170. $v_backup_type = $v_remote_backup[$backup_type]['TYPE'];
  171. $v_backup_application_id = $v_remote_backup[$backup_type]['B2_KEY_ID'];
  172. $v_backup_application_key = '';
  173. $v_backup_remote_adv = "yes";
  174. } elseif (in_array($backup_type, array('rclone'))) {
  175. $v_backup_type = $v_remote_backup[$backup_type]['TYPE'];
  176. $v_rclone_host = $v_remote_backup[$backup_type]['HOST'];
  177. $v_rclone_path = $v_remote_backup[$backup_type]['BPATH'];
  178. $v_backup_remote_adv = "yes";
  179. }
  180. }
  181. }
  182. if (empty($v_backup)) {
  183. $v_backup = '';
  184. }
  185. if (empty($v_backup_host)) {
  186. $v_backup_host = '';
  187. }
  188. if (empty($v_backup_type)) {
  189. $v_backup_type = '';
  190. }
  191. if (empty($v_backup_username)) {
  192. $v_backup_username = '';
  193. }
  194. if (empty($v_backup_password)) {
  195. $v_backup_password = '';
  196. }
  197. if (empty($v_backup_port)) {
  198. $v_backup_port = '';
  199. }
  200. if (empty($v_backup_bpath)) {
  201. $v_backup_bpath = '';
  202. }
  203. if (empty($v_backup_bucket)) {
  204. $v_backup_bucket = '';
  205. }
  206. if (empty($v_backup_application_id)) {
  207. $v_backup_application_id = '';
  208. }
  209. if (empty($v_backup_application_key)) {
  210. $v_backup_application_key = '';
  211. }
  212. if (empty($v_backup_remote_adv)) {
  213. $v_backup_remote_adv = '';
  214. }
  215. if (empty($v_rclone_host)) {
  216. $v_rclone_host = '';
  217. }
  218. if (empty($v_rclone_path)) {
  219. $v_rclone_path = '';
  220. }
  221. // List ssl certificate info
  222. exec(HESTIA_CMD."v-list-sys-hestia-ssl json", $output, $return_var);
  223. $ssl_str = json_decode(implode('', $output), true);
  224. unset($output);
  225. $v_ssl_crt = $ssl_str['HESTIA']['CRT'];
  226. $v_ssl_key = $ssl_str['HESTIA']['KEY'];
  227. $v_ssl_ca = $ssl_str['HESTIA']['CA'];
  228. $v_ssl_subject = $ssl_str['HESTIA']['SUBJECT'];
  229. $v_ssl_aliases = $ssl_str['HESTIA']['ALIASES'];
  230. $v_ssl_not_before = $ssl_str['HESTIA']['NOT_BEFORE'];
  231. $v_ssl_not_after = $ssl_str['HESTIA']['NOT_AFTER'];
  232. $v_ssl_signature = $ssl_str['HESTIA']['SIGNATURE'];
  233. $v_ssl_pub_key = $ssl_str['HESTIA']['PUB_KEY'];
  234. $v_ssl_issuer = $ssl_str['HESTIA']['ISSUER'];
  235. // Check POST request
  236. if (!empty($_POST['save'])) {
  237. $require_refresh = false;
  238. // Check token
  239. verify_csrf($_POST);
  240. // Change hostname
  241. if ((!empty($_POST['v_hostname'])) && ($v_hostname != $_POST['v_hostname'])) {
  242. exec(HESTIA_CMD."v-change-sys-hostname ".quoteshellarg($_POST['v_hostname']), $output, $return_var);
  243. check_return_code($return_var, $output);
  244. unset($output);
  245. $v_hostname = $_POST['v_hostname'];
  246. }
  247. if ($_SESSION['WEB_BACKEND'] == "php-fpm") {
  248. // Install/remove php versions
  249. if (empty($_SESSION['error_msg'])) {
  250. if (!empty($v_php_versions)) {
  251. $post_php = $_POST['v_php_versions'];
  252. if (empty($post_php)) {
  253. $post_php = array();
  254. }
  255. array_map(function ($php_version) use ($post_php) {
  256. if (array_key_exists($php_version->tpl, $post_php)) {
  257. if (!$php_version->installed) {
  258. exec(HESTIA_CMD . "v-add-web-php " . quoteshellarg($php_version->version), $output, $return_var);
  259. check_return_code($return_var, $output);
  260. unset($output);
  261. if (empty($_SESSION['error_msg'])) {
  262. $php_version->installed = true;
  263. }
  264. }
  265. } else {
  266. if ($php_version->installed && !$php_version->protected) {
  267. exec(HESTIA_CMD . "v-delete-web-php " . quoteshellarg($php_version->version), $output, $return_var);
  268. check_return_code($return_var, $output);
  269. unset($output);
  270. if (empty($_SESSION['error_msg'])) {
  271. $php_version->installed = false;
  272. }
  273. }
  274. }
  275. return $php_version;
  276. }, $v_php_versions);
  277. }
  278. }
  279. if (empty($_SESSION['error_msg'])) {
  280. if ('php-'.$_POST['v_php_default_version'] != DEFAULT_PHP_VERSION) {
  281. exec(HESTIA_CMD . "v-change-sys-php " . quoteshellarg($_POST['v_php_default_version']), $output, $return_var);
  282. check_return_code($return_var, $output);
  283. unset($output);
  284. //force reload
  285. $require_refresh = true;
  286. }
  287. }
  288. }
  289. // Change timezone
  290. if (empty($_SESSION['error_msg'])) {
  291. if (!empty($_POST['v_timezone'])) {
  292. if ($v_timezone != $_POST['v_timezone']) {
  293. exec(HESTIA_CMD."v-change-sys-timezone ".quoteshellarg($_POST['v_timezone']), $output, $return_var);
  294. check_return_code($return_var, $output);
  295. $v_timezone = $_POST['v_timezone'];
  296. unset($output);
  297. }
  298. }
  299. }
  300. // Change default language
  301. if (empty($_SESSION['error_msg'])) {
  302. if ((!empty($_POST['v_language'])) && ($_SESSION['LANGUAGE'] != $_POST['v_language'])) {
  303. if (isset($_POST['v_language_update'])) {
  304. exec(HESTIA_CMD."v-change-sys-language ".quoteshellarg($_POST['v_language'])." yes", $output, $return_var);
  305. if (empty($_SESSION['error_msg'])) {
  306. $_SESSION['LANGUAGE'] = $_POST['v_language'];
  307. }
  308. }
  309. exec(HESTIA_CMD."v-change-sys-language ".quoteshellarg($_POST['v_language']), $output, $return_var);
  310. check_return_code($return_var, $output);
  311. unset($output);
  312. if (empty($_SESSION['error_msg'])) {
  313. $_SESSION['LANGUAGE'] = $_POST['v_language'];
  314. }
  315. }
  316. }
  317. // Update theme
  318. if (empty($_SESSION['error_msg'])) {
  319. if ($_POST['v_theme'] != $_SESSION['THEME']) {
  320. exec(HESTIA_CMD."v-change-sys-config-value THEME ".quoteshellarg($_POST['v_theme']), $output, $return_var);
  321. check_return_code($return_var, $output);
  322. unset($output);
  323. }
  324. }
  325. // Update debug mode status
  326. if (empty($_SESSION['error_msg'])) {
  327. if ($_POST['v_debug_mode'] == 'on') {
  328. $_POST['v_debug_mode'] = 'true';
  329. } else {
  330. $_POST['v_debug_mode'] = 'false';
  331. }
  332. if ($_POST['v_debug_mode'] != $_SESSION['DEBUG_MODE']) {
  333. exec(HESTIA_CMD."v-change-sys-config-value DEBUG_MODE ".quoteshellarg($_POST['v_debug_mode']), $output, $return_var);
  334. check_return_code($return_var, $output);
  335. unset($output);
  336. $v_debug_mode_adv = 'yes';
  337. }
  338. }
  339. // Enable/Disable Quick App Installer
  340. if (empty($_SESSION['error_msg'])) {
  341. if ($_POST['v_plugin_app_installer'] != $_SESSION['PLUGIN_APP_INSTALLER']) {
  342. if ($_POST['v_plugin_app_installer'] == 'true') {
  343. $_POST['v_plugin_app_installer'] = 'true';
  344. } else {
  345. $_POST['v_plugin_app_installer'] = 'false';
  346. }
  347. exec(HESTIA_CMD."v-change-sys-config-value PLUGIN_APP_INSTALLER ".quoteshellarg($_POST['v_plugin_app_installer']), $output, $return_var);
  348. check_return_code($return_var, $output);
  349. unset($output);
  350. }
  351. }
  352. // Update experimental features status
  353. if (empty($_SESSION['error_msg']) && $_POST['v_experimental_features'] != $_SESSION['POLICY_SYSTEM_ENABLE_BACON']) {
  354. if ($_POST['v_experimental_features'] == 'on') {
  355. $_POST['v_experimental_features'] = 'true';
  356. } else {
  357. $_POST['v_experimental_features'] = 'false';
  358. }
  359. if ($_POST['v_experimental_features'] != $_SESSION['POLICY_SYSTEM_ENABLE_BACON']) {
  360. exec(HESTIA_CMD."v-change-sys-config-value POLICY_SYSTEM_ENABLE_BACON ".quoteshellarg($_POST['v_experimental_features']), $output, $return_var);
  361. check_return_code($return_var, $output);
  362. unset($output);
  363. $v_debug_mode_adv = 'yes';
  364. }
  365. if (($_POST['v_policy_user_view_suspended'] != $_SESSION['POLICY_SYSTEM_ENABLE_BACON']) && $_POST['v_experimental_features'] == "false") {
  366. //disable preview mode
  367. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED ".quoteshellarg($_POST['v_policy_user_view_suspended']), $output, $return_var);
  368. check_return_code($return_var, $output);
  369. unset($output);
  370. }
  371. }
  372. // Set File Manager support
  373. if (empty($_SESSION['error_msg'])) {
  374. if ((!empty($_POST['v_filemanager'])) && ($_SESSION['FILE_MANAGER'] != $_POST['v_filemanager'])) {
  375. if ($_POST['v_filemanager'] == 'true') {
  376. exec(HESTIA_CMD."v-add-sys-filemanager", $output, $return_var);
  377. check_return_code($return_var, $output);
  378. unset($output);
  379. if (empty($_SESSION['error_msg'])) {
  380. $_SESSION['FILE_MANAGER'] = 'true';
  381. }
  382. } else {
  383. exec(HESTIA_CMD."v-delete-sys-filemanager", $output, $return_var);
  384. check_return_code($return_var, $output);
  385. unset($output);
  386. if (empty($_SESSION['error_msg'])) {
  387. $_SESSION['FILE_MANAGER'] = 'false';
  388. }
  389. }
  390. }
  391. }
  392. // Set phpMyAdmin SSO key
  393. if (empty($_SESSION['error_msg'])) {
  394. if (!empty($_POST['v_phpmyadmin_key'])) {
  395. if ($_POST['v_phpmyadmin_key'] == 'yes' && $_SESSION['PHPMYADMIN_KEY'] == '') {
  396. exec(HESTIA_CMD."v-add-sys-pma-sso quiet", $output, $return_var);
  397. check_return_code($return_var, $output);
  398. unset($output);
  399. if (empty($_SESSION['error_msg'])) {
  400. $_SESSION['PHPMYADMIN_KEY'] != "";
  401. }
  402. } elseif ($_POST['v_phpmyadmin_key'] == 'no' && $_SESSION['PHPMYADMIN_KEY'] != '') {
  403. exec(HESTIA_CMD."v-delete-sys-pma-sso quiet", $output, $return_var);
  404. check_return_code($return_var, $output);
  405. unset($output);
  406. if (empty($_SESSION['error_msg'])) {
  407. $_SESSION['PHPMYADMIN_KEY'] = '';
  408. }
  409. }
  410. }
  411. }
  412. // Set disk_quota support
  413. if (empty($_SESSION['error_msg'])) {
  414. if ((!empty($_POST['v_quota'])) && ($_SESSION['DISK_QUOTA'] != $_POST['v_quota'])) {
  415. if ($_POST['v_quota'] == 'yes') {
  416. exec(HESTIA_CMD."v-add-sys-quota", $output, $return_var);
  417. check_return_code($return_var, $output);
  418. unset($output);
  419. if (empty($_SESSION['error_msg'])) {
  420. $_SESSION['DISK_QUOTA'] = 'yes';
  421. }
  422. } else {
  423. exec(HESTIA_CMD."v-delete-sys-quota", $output, $return_var);
  424. check_return_code($return_var, $output);
  425. unset($output);
  426. if (empty($_SESSION['error_msg'])) {
  427. $_SESSION['DISK_QUOTA'] = 'no';
  428. }
  429. }
  430. }
  431. }
  432. // Set firewall support
  433. if (empty($_SESSION['error_msg'])) {
  434. if ($_SESSION['FIREWALL_SYSTEM'] == 'iptables') {
  435. $v_firewall = 'yes';
  436. }
  437. if ($_SESSION['FIREWALL_SYSTEM'] != 'iptables') {
  438. $v_firewall = 'no';
  439. }
  440. if ((!empty($_POST['v_firewall'])) && ($v_firewall != $_POST['v_firewall'])) {
  441. if ($_POST['v_firewall'] == 'yes') {
  442. exec(HESTIA_CMD."v-add-sys-firewall", $output, $return_var);
  443. check_return_code($return_var, $output);
  444. unset($output);
  445. if (empty($_SESSION['error_msg'])) {
  446. $_SESSION['FIREWALL_SYSTEM'] = 'iptables';
  447. }
  448. } else {
  449. exec(HESTIA_CMD."v-delete-sys-firewall", $output, $return_var);
  450. check_return_code($return_var, $output);
  451. unset($output);
  452. if (empty($_SESSION['error_msg'])) {
  453. $_SESSION['FIREWALL_SYSTEM'] = '';
  454. }
  455. }
  456. }
  457. }
  458. // Update mysql pasword
  459. if (empty($_SESSION['error_msg'])) {
  460. if (!empty($_POST['v_mysql_password'])) {
  461. exec(HESTIA_CMD."v-change-database-host-password mysql localhost root ".quoteshellarg($_POST['v_mysql_password']), $output, $return_var);
  462. check_return_code($return_var, $output);
  463. unset($output);
  464. $v_db_adv = 'yes';
  465. }
  466. }
  467. // Update webmail url
  468. if (empty($_SESSION['error_msg'])) {
  469. if ($_POST['v_webmail_alias'] != $_SESSION['WEBMAIL_ALIAS']) {
  470. exec(HESTIA_CMD."v-change-sys-webmail ".quoteshellarg($_POST['v_webmail_alias']), $output, $return_var);
  471. check_return_code($return_var, $output);
  472. unset($output);
  473. $v_mail_adv = 'yes';
  474. }
  475. }
  476. // Update system wide smtp relay
  477. if (empty($_SESSION['error_msg'])) {
  478. if (isset($_POST['v_smtp_relay']) && !empty($_POST['v_smtp_relay_host'])) {
  479. if (($_POST['v_smtp_relay_host'] != $v_smtp_relay_host) ||
  480. ($_POST['v_smtp_relay_user'] != $v_smtp_relay_user) ||
  481. ($_POST['v_smtp_relay_port'] != $v_smtp_relay_port)) {
  482. $v_smtp_relay = true;
  483. $v_smtp_relay_host = quoteshellarg($_POST['v_smtp_relay_host']);
  484. $v_smtp_relay_user = quoteshellarg($_POST['v_smtp_relay_user']);
  485. $v_smtp_relay_pass = quoteshellarg($_POST['v_smtp_relay_pass']);
  486. if (!empty($_POST['v_smtp_relay_port'])) {
  487. $v_smtp_relay_port = quoteshellarg($_POST['v_smtp_relay_port']);
  488. } else {
  489. $v_smtp_relay_port = '587';
  490. }
  491. exec(HESTIA_CMD."v-add-sys-smtp-relay ".$v_smtp_relay_host." ".$v_smtp_relay_user." ".$v_smtp_relay_pass." ".$v_smtp_relay_port, $output, $return_var);
  492. check_return_code($return_var, $output);
  493. unset($output);
  494. }
  495. }
  496. if ((!isset($_POST['v_smtp_relay'])) && ($v_smtp_relay == true)) {
  497. $v_smtp_relay = false;
  498. $v_smtp_relay_host = $v_smtp_relay_user = $v_smtp_relay_pass = $v_smtp_relay_port = '';
  499. exec(HESTIA_CMD."v-delete-sys-smtp-relay", $output, $return_var);
  500. check_return_code($return_var, $output);
  501. unset($output);
  502. }
  503. }
  504. // Update phpMyAdmin url
  505. if (empty($_SESSION['error_msg'])) {
  506. if ($_POST['v_mysql_url'] != $_SESSION['DB_PMA_ALIAS']) {
  507. exec(HESTIA_CMD."v-change-sys-db-alias pma ".quoteshellarg($_POST['v_mysql_url']), $output, $return_var);
  508. check_return_code($return_var, $output);
  509. unset($output);
  510. $v_db_adv = 'yes';
  511. }
  512. }
  513. // Update phpPgAdmin url
  514. if (empty($_SESSION['error_msg'])) {
  515. if ($_POST['v_pgsql_url'] != $_SESSION['DB_PGA_ALIAS']) {
  516. exec(HESTIA_CMD."v-change-sys-db-alias pga ".quoteshellarg($_POST['v_pgsql_url']), $output, $return_var);
  517. check_return_code($return_var, $output);
  518. unset($output);
  519. $v_db_adv = 'yes';
  520. }
  521. }
  522. // Update send notification setting
  523. if (empty($_SESSION['error_msg'])) {
  524. if ($_SESSION['UPGRADE_SEND_EMAIL'] == 'true') {
  525. $ugrade_send_mail = 'on';
  526. } else {
  527. $ugrade_send_mail = '';
  528. }
  529. if ($_POST['v_upgrade_send_notification_email'] != $ugrade_send_mail) {
  530. if ($_POST['v_upgrade_send_notification_email'] == 'on') {
  531. $_POST['v_upgrade_send_notification_email'] = 'true';
  532. } else {
  533. $_POST['v_upgrade_send_notification_email'] = 'false';
  534. }
  535. exec(HESTIA_CMD."v-change-sys-config-value UPGRADE_SEND_EMAIL ".quoteshellarg($_POST['v_upgrade_send_notification_email']), $output, $return_var);
  536. check_return_code($return_var, $output);
  537. unset($output);
  538. $v_upgrade_notification_adv = 'yes';
  539. }
  540. }
  541. // Update send log by email setting
  542. if (empty($_SESSION['error_msg'])) {
  543. if ($_SESSION['UPGRADE_SEND_EMAIL_LOG'] == 'true') {
  544. $send_email_log = 'on';
  545. } else {
  546. $send_email_log = '';
  547. }
  548. if (empty($_POST['v_upgrade_send_email_log'])) {
  549. $_POST['v_upgrade_send_email_log'] = '';
  550. }
  551. if ($_POST['v_upgrade_send_email_log'] != $send_email_log) {
  552. if ($_POST['v_upgrade_send_email_log'] == 'on') {
  553. $_POST['v_upgrade_send_email_log'] = 'true';
  554. } else {
  555. $_POST['v_upgrade_send_email_log'] = 'false';
  556. }
  557. exec(HESTIA_CMD."v-change-sys-config-value UPGRADE_SEND_EMAIL_LOG ".quoteshellarg($_POST['v_upgrade_send_email_log']), $output, $return_var);
  558. check_return_code($return_var, $output);
  559. unset($output);
  560. $v_upgrade_send_log_adv = 'yes';
  561. }
  562. }
  563. // Disable local backup
  564. if (empty($_SESSION['error_msg'])) {
  565. if (($_POST['v_backup'] == 'no') && ($v_backup == 'yes')) {
  566. exec(HESTIA_CMD."v-delete-backup-host local", $output, $return_var);
  567. check_return_code($return_var, $output);
  568. unset($output);
  569. if (empty($_SESSION['error_msg'])) {
  570. $v_backup = 'no';
  571. }
  572. $v_backup_adv = 'yes';
  573. }
  574. }
  575. // Enable local backups
  576. if (empty($_SESSION['error_msg'])) {
  577. if (($_POST['v_backup'] == 'yes') && ($v_backup != 'yes')) {
  578. exec(HESTIA_CMD."v-add-backup-host local", $output, $return_var);
  579. check_return_code($return_var, $output);
  580. unset($output);
  581. if (empty($_SESSION['error_msg'])) {
  582. $v_backup = 'yes';
  583. }
  584. $v_backup_adv = 'yes';
  585. }
  586. }
  587. // Change backup gzip level
  588. if (empty($_SESSION['error_msg'])) {
  589. if ($_POST['v_backup_gzip'] != $v_backup_gzip) {
  590. if ($_POST['v_backup_mode'] == 'gzip') {
  591. $_POST['v_backup_gzip'] = 9;
  592. }
  593. exec(HESTIA_CMD."v-change-sys-config-value BACKUP_GZIP ".quoteshellarg($_POST['v_backup_gzip']), $output, $return_var);
  594. check_return_code($return_var, $output);
  595. unset($output);
  596. if (empty($_SESSION['error_msg'])) {
  597. $v_backup_gzip = $_POST['v_backup_gzip'];
  598. }
  599. $v_backup_adv = 'yes';
  600. }
  601. }
  602. // Change backup mode
  603. if (empty($_SESSION['error_msg'])) {
  604. if ($_POST['v_backup_mode'] != $v_backup_mode) {
  605. exec(HESTIA_CMD."v-change-sys-config-value BACKUP_MODE ".quoteshellarg($_POST['v_backup_mode']), $output, $return_var);
  606. check_return_code($return_var, $output);
  607. unset($output);
  608. if (empty($_SESSION['error_msg'])) {
  609. $v_backup_mode = $_POST['v_backup_mode'];
  610. }
  611. $v_backup_adv = 'yes';
  612. if ($_POST['v_backup_mode'] == 'gzip') {
  613. $_POST['v_backup_gzip'] = 9;
  614. if (empty($_SESSION['error_msg'])) {
  615. $v_backup_gzip = $_POST['v_backup_gzip'];
  616. }
  617. exec(HESTIA_CMD."v-change-sys-config-value BACKUP_GZIP ".quoteshellarg($_POST['v_backup_gzip']), $output, $return_var);
  618. }
  619. }
  620. }
  621. // Change backup path
  622. if (empty($_SESSION['error_msg'])) {
  623. if (empty($_POST['v_backup_dir'])) {
  624. $_POST['v_backup_dir'] = '';
  625. }
  626. if ($_POST['v_backup_dir'] != $v_backup_dir) {
  627. /*
  628. See #1655
  629. exec (HESTIA_CMD."v-change-sys-config-value BACKUP ".quoteshellarg($_POST['v_backup_dir']), $output, $return_var);
  630. check_return_code($return_var,$output);
  631. unset($output);
  632. */
  633. if (empty($_SESSION['error_msg'])) {
  634. $v_backup_dir = $_POST['v_backup_dir'];
  635. }
  636. #$v_backup_adv = 'yes';
  637. }
  638. }
  639. // Add remote backup host
  640. if (empty($_SESSION['error_msg'])) {
  641. if (($v_backup_host == '' && $v_backup_bucket == '' && ((!empty($_POST['v_backup_host'])) || !empty($_POST['v_backup_bucket'])))) {
  642. if (in_array($_POST['v_backup_type'], array('ftp','sftp'))) {
  643. $v_backup_host = quoteshellarg($_POST['v_backup_host']);
  644. $v_backup_port = quoteshellarg($_POST['v_backup_port']);
  645. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  646. $v_backup_username = quoteshellarg($_POST['v_backup_username']);
  647. $v_backup_password = quoteshellarg($_POST['v_backup_password']);
  648. $v_backup_bpath = quoteshellarg($_POST['v_backup_bpath']);
  649. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_backup_host ." ". $v_backup_username ." ". $v_backup_password ." ". $v_backup_bpath." ".$v_backup_port, $output, $return_var);
  650. check_return_code($return_var, $output);
  651. unset($output);
  652. if (empty($_SESSION['error_msg'])) {
  653. $v_backup_host = $_POST['v_backup_host'];
  654. }
  655. if (empty($_SESSION['error_msg'])) {
  656. $v_backup_type = $_POST['v_backup_type'];
  657. }
  658. if (empty($_SESSION['error_msg'])) {
  659. $v_backup_username = $_POST['v_backup_username'];
  660. }
  661. if (empty($_SESSION['error_msg'])) {
  662. $v_backup_password = $_POST['v_backup_password'];
  663. }
  664. if (empty($_SESSION['error_msg'])) {
  665. $v_backup_bpath = $_POST['v_backup_bpath'];
  666. }
  667. if (empty($_SESSION['error_msg'])) {
  668. $v_backup_port = $_POST['v_backup_port'];
  669. }
  670. $v_backup_new = 'yes';
  671. $v_backup_adv = 'yes';
  672. $v_backup_remote_adv = 'yes';
  673. } elseif (in_array($_POST['v_backup_type'], array('b2'))) {
  674. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  675. $v_backup_bucket = quoteshellarg($_POST['v_backup_bucket']);
  676. $v_backup_application_id = quoteshellarg($_POST['v_backup_application_id']);
  677. $v_backup_application_key = quoteshellarg($_POST['v_backup_application_key']);
  678. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_backup_bucket ." ". $v_backup_application_id ." ". $v_backup_application_key, $output, $return_var);
  679. check_return_code($return_var, $output);
  680. unset($output);
  681. if (empty($_SESSION['error_msg'])) {
  682. $v_backup_bucket = quoteshellarg($_POST['v_backup_bucket']);
  683. }
  684. if (empty($_SESSION['error_msg'])) {
  685. $v_backup_application_id = quoteshellarg($_POST['v_backup_application_id']);
  686. }
  687. if (empty($_SESSION['error_msg'])) {
  688. $v_backup_application_key = quoteshellarg($_POST['v_backup_application_key']);
  689. }
  690. $v_backup_new = 'yes';
  691. $v_backup_adv = 'yes';
  692. $v_backup_remote_adv = 'yes';
  693. }
  694. }
  695. if ($v_rclone_host == '' && !empty($_POST['v_rclone_host']) && $_POST['v_backup_type'] =="rclone" ) {
  696. $v_rclone_host = quoteshellarg($_POST['v_rclone_host']);
  697. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  698. $v_rclone_path = quoteshellarg($_POST['v_rclone_path']);
  699. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_rclone_host ." '' '' ".$v_rclone_path, $output, $return_var);
  700. check_return_code($return_var, $output);
  701. unset($output);
  702. $v_backup_new = 'yes';
  703. $v_backup_adv = 'yes';
  704. $v_backup_remote_adv = 'yes';
  705. }
  706. }
  707. // Change remote backup host type
  708. if (empty($_SESSION['error_msg'])) {
  709. if ((!empty($_POST['v_backup_host'])) && ($_POST['v_backup_type'] != $v_backup_type) && $v_backup_type != '') {
  710. exec(HESTIA_CMD."v-delete-backup-host " . quoteshellarg($v_backup_type), $output, $return_var);
  711. unset($output);
  712. if (in_array($_POST['v_backup_type'], array('ftp','sftp'))) {
  713. $v_backup_host = quoteshellarg($_POST['v_backup_host']);
  714. $v_backup_port = quoteshellarg($_POST['v_backup_port']);
  715. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  716. $v_backup_username = quoteshellarg($_POST['v_backup_username']);
  717. $v_backup_password = quoteshellarg($_POST['v_backup_password']);
  718. $v_backup_bpath = quoteshellarg($_POST['v_backup_bpath']);
  719. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_backup_host ." ". $v_backup_username ." ". $v_backup_password ." ". $v_backup_bpath." ".$v_backup_port, $output, $return_var);
  720. check_return_code($return_var, $output);
  721. unset($output);
  722. if (empty($_SESSION['error_msg'])) {
  723. $v_backup_host = $_POST['v_backup_host'];
  724. }
  725. if (empty($_SESSION['error_msg'])) {
  726. $v_backup_type = $_POST['v_backup_type'];
  727. }
  728. if (empty($_SESSION['error_msg'])) {
  729. $v_backup_username = $_POST['v_backup_username'];
  730. }
  731. if (empty($_SESSION['error_msg'])) {
  732. $v_backup_password = $_POST['v_backup_password'];
  733. }
  734. if (empty($_SESSION['error_msg'])) {
  735. $v_backup_bpath = $_POST['v_backup_bpath'];
  736. }
  737. if (empty($_SESSION['error_msg'])) {
  738. $v_backup_port = $_POST['v_backup_port'];
  739. }
  740. $v_backup_adv = 'yes';
  741. $v_backup_remote_adv = 'yes';
  742. } elseif (in_array($_POST['v_backup_type'], array('b2'))) {
  743. $v_backup_bucket = quoteshellarg($_POST['v_backup_bucket']);
  744. $v_backup_application_id = quoteshellarg($_POST['v_backup_application_id']);
  745. $v_backup_application_key = quoteshellarg($_POST['v_backup_application_key']);
  746. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_backup_bucket ." ". $v_backup_application_id ." ". $v_backup_application_key, $output, $return_var);
  747. check_return_code($return_var, $output);
  748. unset($output);
  749. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  750. if (empty($_SESSION['error_msg'])) {
  751. $v_backup_bucket = quoteshellarg($_POST['v_backup_bucket']);
  752. }
  753. if (empty($_SESSION['error_msg'])) {
  754. $v_backup_application_id = quoteshellarg($_POST['v_backup_application_id']);
  755. }
  756. if (empty($_SESSION['error_msg'])) {
  757. $v_backup_application_key = quoteshellarg($_POST['v_backup_application_key']);
  758. }
  759. $v_backup_adv = 'yes';
  760. $v_backup_remote_adv = 'yes';
  761. }
  762. }
  763. }
  764. // Change remote backup host
  765. if (empty($_SESSION['error_msg'])) {
  766. if ((!empty($_POST['v_backup_host'])) && ($_POST['v_backup_type'] == $v_backup_type) && (!isset($v_backup_new))) {
  767. if (in_array($_POST['v_backup_type'], array('ftp','sftp'))) {
  768. if (($_POST['v_backup_host'] != $v_backup_host) || ($_POST['v_backup_username'] != $v_backup_username) || ($_POST['v_backup_password'] != $v_backup_password) || ($_POST['v_backup_bpath'] != $v_backup_bpath || $_POST['v_backup_port'] != $v_backup_port)) {
  769. $v_backup_host = quoteshellarg($_POST['v_backup_host']);
  770. $v_backup_port = quoteshellarg($_POST['v_backup_port']);
  771. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  772. $v_backup_username = quoteshellarg($_POST['v_backup_username']);
  773. $v_backup_password = quoteshellarg($_POST['v_backup_password']);
  774. $v_backup_bpath = quoteshellarg($_POST['v_backup_bpath']);
  775. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_backup_host ." ". $v_backup_username ." ". $v_backup_password ." ". $v_backup_bpath." ".$v_backup_port, $output, $return_var);
  776. check_return_code($return_var, $output);
  777. unset($output);
  778. if (empty($_SESSION['error_msg'])) {
  779. $v_backup_host = $_POST['v_backup_host'];
  780. }
  781. if (empty($_SESSION['error_msg'])) {
  782. $v_backup_type = $_POST['v_backup_type'];
  783. }
  784. if (empty($_SESSION['error_msg'])) {
  785. $v_backup_username = $_POST['v_backup_username'];
  786. }
  787. if (empty($_SESSION['error_msg'])) {
  788. $v_backup_password = $_POST['v_backup_password'];
  789. }
  790. if (empty($_SESSION['error_msg'])) {
  791. $v_backup_bpath = $_POST['v_backup_bpath'];
  792. }
  793. if (empty($_SESSION['error_msg'])) {
  794. $v_backup_port = $_POST['v_backup_port'];
  795. }
  796. $v_backup_adv = 'yes';
  797. $v_backup_remote_adv = 'yes';
  798. }
  799. } elseif (in_array($_POST['v_backup_type'], array('b2'))) {
  800. if (($_POST['v_backup_bucket'] != $v_backup_bucket) || ($_POST['v_backup_application_key'] != $v_backup_application_key) || ($_POST['v_backup_application_id'] != $v_backup_application_id)) {
  801. $v_backup_type = quoteshellarg($_POST['v_backup_type']);
  802. $v_backup_bucket = quoteshellarg($_POST['v_backup_bucket']);
  803. $v_backup_application_id = quoteshellarg($_POST['v_backup_application_id']);
  804. $v_backup_application_key = quoteshellarg($_POST['v_backup_application_key']);
  805. exec(HESTIA_CMD."v-add-backup-host ". $v_backup_type ." ". $v_backup_bucket ." ". $v_backup_application_id ." ". $v_backup_application_key, $output, $return_var);
  806. check_return_code($return_var, $output);
  807. unset($output);
  808. if (empty($_SESSION['error_msg'])) {
  809. $v_backup_bucket = quoteshellarg($_POST['v_backup_bucket']);
  810. }
  811. if (empty($_SESSION['error_msg'])) {
  812. $v_backup_application_id = quoteshellarg($_POST['v_backup_application_id']);
  813. }
  814. if (empty($_SESSION['error_msg'])) {
  815. $v_backup_application_key = quoteshellarg($_POST['v_backup_application_key']);
  816. }
  817. $v_backup_adv = 'yes';
  818. $v_backup_remote_adv = 'yes';
  819. }
  820. }
  821. }
  822. }
  823. // Delete remote backup host
  824. if (empty($_SESSION['error_msg'])) {
  825. if (empty($_POST['v_backup_remote_adv']) && $v_backup_remote_adv != '') {
  826. exec(HESTIA_CMD."v-delete-backup-host ".quoteshellarg($v_backup_type), $output, $return_var);
  827. check_return_code($return_var, $output);
  828. unset($output);
  829. if (empty($_SESSION['error_msg'])) {
  830. $v_backup_host = '';
  831. }
  832. if (empty($_SESSION['error_msg'])) {
  833. $v_backup_type = '';
  834. }
  835. if (empty($_SESSION['error_msg'])) {
  836. $v_backup_username = '';
  837. }
  838. if (empty($_SESSION['error_msg'])) {
  839. $v_backup_password = '';
  840. }
  841. if (empty($_SESSION['error_msg'])) {
  842. $v_backup_bpath = '';
  843. }
  844. if (empty($_SESSION['error_msg'])) {
  845. $v_backup_bucket = '';
  846. }
  847. if (empty($_SESSION['error_msg'])) {
  848. $v_backup_application_id = '';
  849. }
  850. if (empty($_SESSION['error_msg'])) {
  851. $v_backup_application_key = '';
  852. }
  853. $v_backup_adv = '';
  854. $v_backup_remote_adv = '';
  855. }
  856. }
  857. // Change INACTIVE_SESSION_TIMEOUT
  858. if (empty($_SESSION['error_msg'])) {
  859. if ($_POST['v_inactive_session_timeout'] != $_SESSION['INACTIVE_SESSION_TIMEOUT']) {
  860. if ($_POST['v_inactive_session_timeout'] < 1) {
  861. $_SESSION['error_msg'] = _('Inactive session timeout can not lower than 1 minute');
  862. } else {
  863. exec(HESTIA_CMD."v-change-sys-config-value INACTIVE_SESSION_TIMEOUT ".quoteshellarg($_POST['v_inactive_session_timeout']), $output, $return_var);
  864. check_return_code($return_var, $output);
  865. unset($output);
  866. if (empty($_SESSION['error_msg'])) {
  867. $v_inactive_session_timeout = $_POST['v_inactive_session_timeout'];
  868. }
  869. }
  870. $v_security_adv = 'yes';
  871. }
  872. }
  873. // Change POLICY_CSRF_STRICTNESS
  874. if (empty($_SESSION['error_msg'])) {
  875. if ($_POST['v_policy_csrf_strictness'] != $_SESSION['POLICY_CSRF_STRICTNESS']) {
  876. exec(HESTIA_CMD."v-change-sys-config-value POLICY_CSRF_STRICTNESS ".quoteshellarg($_POST['v_policy_csrf_strictness']), $output, $return_var);
  877. check_return_code($return_var, $output);
  878. unset($output);
  879. if (empty($_SESSION['error_msg'])) {
  880. $v_policy_csrf_strictness = $_POST['v_inactive_session_timeout'];
  881. }
  882. $v_security_adv = 'yes';
  883. }
  884. }
  885. // Change ENFORCE_SUBDOMAIN_OWNERSHIP
  886. if (empty($_SESSION['error_msg'])) {
  887. if ($_POST['v_enforce_subdomain_ownership'] != $_SESSION['ENFORCE_SUBDOMAIN_OWNERSHIP']) {
  888. exec(HESTIA_CMD."v-change-sys-config-value ENFORCE_SUBDOMAIN_OWNERSHIP ".quoteshellarg($_POST['v_enforce_subdomain_ownership']), $output, $return_var);
  889. check_return_code($return_var, $output);
  890. unset($output);
  891. if (empty($_SESSION['error_msg'])) {
  892. $v_enforce_subdomain_ownership = $_POST['v_enforce_subdomain_ownership'];
  893. }
  894. $v_security_adv = 'yes';
  895. }
  896. }
  897. // Change POLICY_USER_EDIT_DETAILS
  898. if (empty($_SESSION['error_msg'])) {
  899. if ($_POST['v_policy_user_edit_details'] != $_SESSION['POLICY_USER_EDIT_DETAILS']) {
  900. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_EDIT_DETAILS ".quoteshellarg($_POST['v_policy_user_edit_details']), $output, $return_var);
  901. check_return_code($return_var, $output);
  902. unset($output);
  903. if (empty($_SESSION['error_msg'])) {
  904. $v_policy_user_edit_details = $_POST['v_policy_user_edit_details'];
  905. }
  906. $v_security_adv = 'yes';
  907. }
  908. }
  909. // Change POLICY_USER_EDIT_WEB_TEMPLATES
  910. if (empty($_SESSION['error_msg'])) {
  911. if ($_POST['v_policy_user_edit_web_templates'] != $_SESSION['POLICY_USER_EDIT_WEB_TEMPLATES']) {
  912. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_EDIT_WEB_TEMPLATES ".quoteshellarg($_POST['v_policy_user_edit_web_templates']), $output, $return_var);
  913. check_return_code($return_var, $output);
  914. unset($output);
  915. if (empty($_SESSION['error_msg'])) {
  916. $v_policy_user_edit_details = $_POST['v_policy_user_edit_web_templates'];
  917. }
  918. $v_security_adv = 'yes';
  919. }
  920. }
  921. // Change POLICY_USER_EDIT_DNS_TEMPLATES
  922. if (empty($_SESSION['error_msg'])) {
  923. if ($_POST['v_policy_user_edit_dns_templates'] != $_SESSION['POLICY_USER_EDIT_DNS_TEMPLATES']) {
  924. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_EDIT_DNS_TEMPLATES ".quoteshellarg($_POST['v_policy_user_edit_dns_templates']), $output, $return_var);
  925. check_return_code($return_var, $output);
  926. unset($output);
  927. if (empty($_SESSION['error_msg'])) {
  928. $v_policy_user_edit_details = $_POST['v_policy_user_edit_dns_templates'];
  929. }
  930. $v_security_adv = 'yes';
  931. }
  932. }
  933. if ($_POST['v_api_system'] != $_SESSION['API_SYSTEM'] || $_POST['v_api'] != $_SESSION['API'] || $_POST['v_api_allowed_ip'] != $_SESSION['API_ALLOWED_IP']){
  934. if (empty($_SESSION['error_msg'])) {
  935. if($_POST['v_api'] == "no" && $_POST['v_api_system'] === 0 ){
  936. exec(HESTIA_CMD."v-change-sys-api 'disable'", $output, $return_var);
  937. check_return_code($return_var, $output);
  938. unset($output);
  939. }
  940. if($_POST['v_api'] == "yes" || $_POST['v_api_system'] !== 0 && $_POST['v_api_system'] != $_SESSION['API_SYSTEM'] || $_POST['v_api'] != $_SESSION['API']){
  941. exec(HESTIA_CMD."v-change-sys-api 'enable'", $output, $return_var);
  942. check_return_code($return_var, $output);
  943. unset($output);
  944. }
  945. }
  946. if (empty($_SESSION['error_msg'])) {
  947. if ($_POST['v_api_system'] != $_SESSION['API_SYSTEM']) {
  948. exec(HESTIA_CMD."v-change-sys-config-value API_SYSTEM ".quoteshellarg($_POST['v_api_system']), $output, $return_var);
  949. check_return_code($return_var, $output);
  950. unset($output);
  951. if (empty($_SESSION['error_msg'])) {
  952. $v_policy_user_edit_details = $_POST['v_api_system'];
  953. }
  954. $v_security_adv = 'yes';
  955. }
  956. }
  957. // Change API access
  958. if (empty($_SESSION['error_msg'])) {
  959. if ($_POST['v_api'] != $_SESSION['API']) {
  960. $api_status = 'no';
  961. if ($_POST['v_api'] == 'yes') {
  962. $api_status = 'yes';
  963. }
  964. exec(HESTIA_CMD."v-change-sys-config-value API ".quoteshellarg($api_status), $output, $return_var);
  965. check_return_code($return_var, $output);
  966. unset($output);
  967. if (empty($_SESSION['error_msg'])) {
  968. $v_api = $_POST['v_api'];
  969. }
  970. $v_security_adv = 'yes';
  971. }
  972. }
  973. // Change API allowed IPs
  974. if (empty($_SESSION['error_msg'])) {
  975. if ($_POST['v_api_allowed_ip'] != $_SESSION['API_ALLOWED_IP']) {
  976. $ips = array();
  977. foreach (explode("\n", $_POST['v_api_allowed_ip']) as $ip) {
  978. if (trim($ip) != "allow-all") {
  979. if (filter_var(trim($ip), FILTER_VALIDATE_IP)) {
  980. $ips[] = trim($ip);
  981. }
  982. } else {
  983. $ips[] = trim($ip);
  984. }
  985. }
  986. if (implode(',', $ips) != $_SESSION['API_ALLOWED_IP']) {
  987. exec(HESTIA_CMD."v-change-sys-config-value API_ALLOWED_IP ".quoteshellarg(implode(',', $ips)), $output, $return_var);
  988. check_return_code($return_var, $output);
  989. unset($output);
  990. if (empty($_SESSION['error_msg'])) {
  991. $v_api_allowed_ip = $_POST['v_api_allowed_ip'];
  992. }
  993. $v_security_adv = 'yes';
  994. }
  995. }
  996. }
  997. }
  998. // Change POLICY_USER_VIEW_LOGS
  999. if (empty($_SESSION['error_msg'])) {
  1000. if ($_POST['v_policy_user_view_logs'] != $_SESSION['POLICY_USER_VIEW_LOGS']) {
  1001. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_VIEW_LOGS ".quoteshellarg($_POST['v_policy_user_view_logs']), $output, $return_var);
  1002. check_return_code($return_var, $output);
  1003. unset($output);
  1004. if (empty($_SESSION['error_msg'])) {
  1005. $v_policy_user_view_logs = $_POST['v_policy_user_view_logs'];
  1006. }
  1007. $v_security_adv = 'yes';
  1008. }
  1009. }
  1010. // Change POLICY_USER_DELETE_LOGS
  1011. if (empty($_SESSION['error_msg'])) {
  1012. if ($_POST['v_policy_user_delete_logs'] != $_SESSION['POLICY_USER_DELETE_LOGS']) {
  1013. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_DELETE_LOGS ".quoteshellarg($_POST['v_policy_user_delete_logs']), $output, $return_var);
  1014. check_return_code($return_var, $output);
  1015. unset($output);
  1016. if (empty($_SESSION['error_msg'])) {
  1017. $v_policy_user_delete_logs = $_POST['v_policy_user_delete_logs'];
  1018. }
  1019. $v_security_adv = 'yes';
  1020. }
  1021. }
  1022. // Change POLICY_SYSTEM_PASSWORD_RESET
  1023. if (empty($_SESSION['error_msg'])) {
  1024. if ($_POST['v_policy_system_password_reset'] != $_SESSION['POLICY_SYSTEM_PASSWORD_RESET']) {
  1025. exec(HESTIA_CMD."v-change-sys-config-value POLICY_SYSTEM_PASSWORD_RESET ".quoteshellarg($_POST['v_policy_system_password_reset']), $output, $return_var);
  1026. check_return_code($return_var, $output);
  1027. unset($output);
  1028. if (empty($_SESSION['error_msg'])) {
  1029. $v_policy_system_password_reset = $_POST['v_policy_system_password_reset'];
  1030. }
  1031. $v_security_adv = 'yes';
  1032. }
  1033. }
  1034. // Change POLICY_SYSTEM_PROTECTED_ADMIN
  1035. if (empty($_SESSION['error_msg'])) {
  1036. if ($_POST['v_policy_system_protected_admin'] != $_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN']) {
  1037. exec(HESTIA_CMD."v-change-sys-config-value POLICY_SYSTEM_PROTECTED_ADMIN ".quoteshellarg($_POST['v_policy_system_protected_admin']), $output, $return_var);
  1038. check_return_code($return_var, $output);
  1039. unset($output);
  1040. if (empty($_SESSION['error_msg'])) {
  1041. $v_policy_system_protected_admin = $_POST['v_policy_system_protected_admin'];
  1042. }
  1043. $v_security_adv = 'yes';
  1044. }
  1045. }
  1046. // Change POLICY_USER_VIEW_SUSPENDED
  1047. if (empty($_SESSION['error_msg'])) {
  1048. if ($_POST['v_policy_user_view_suspended'] != $_SESSION['POLICY_USER_VIEW_SUSPENDED'] && !empty($_SESSION['POLICY_USER_VIEW_SUSPENDED'])) {
  1049. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED ".quoteshellarg($_POST['v_policy_user_view_suspended']), $output, $return_var);
  1050. check_return_code($return_var, $output);
  1051. unset($output);
  1052. if (empty($_SESSION['error_msg'])) {
  1053. $v_policy_system_hide_admin = $_POST['v_policy_user_view_suspended'];
  1054. }
  1055. $v_security_adv = 'yes';
  1056. }
  1057. }
  1058. // Change POLICY_USER_CHANGE_THEME
  1059. if (empty($_SESSION['error_msg'])) {
  1060. if (empty($_POST['v_policy_user_change_theme'])) {
  1061. $_POST['v_policy_user_change_theme'] = '';
  1062. }
  1063. if ($_POST['v_policy_user_change_theme'] == 'on') {
  1064. $_POST['v_policy_user_change_theme'] = 'no';
  1065. } else {
  1066. $_POST['v_policy_user_change_theme'] = 'yes';
  1067. }
  1068. {
  1069. if ($_POST['v_policy_user_change_theme'] != $_SESSION['POLICY_USER_CHANGE_THEME']) {
  1070. exec(HESTIA_CMD."v-change-sys-config-value POLICY_USER_CHANGE_THEME ".quoteshellarg($_POST['v_policy_user_change_theme']), $output, $return_var);
  1071. check_return_code($return_var, $output);
  1072. unset($output);
  1073. if ($_POST['v_policy_user_change_theme']) {
  1074. unset($_SESSION['userTheme']);
  1075. $require_refresh = true;
  1076. }
  1077. if (empty($_SESSION['error_msg'])) {
  1078. $v_policy_user_change_theme = $_POST['v_policy_user_change_theme'];
  1079. }
  1080. }
  1081. }
  1082. }
  1083. // Change POLICY_SYSTEM_HIDE_ADMIN
  1084. if (empty($_SESSION['error_msg'])) {
  1085. if ($_POST['v_policy_system_hide_admin'] != $_SESSION['POLICY_SYSTEM_HIDE_ADMIN']) {
  1086. exec(HESTIA_CMD."v-change-sys-config-value POLICY_SYSTEM_HIDE_ADMIN ".quoteshellarg($_POST['v_policy_system_hide_admin']), $output, $return_var);
  1087. check_return_code($return_var, $output);
  1088. unset($output);
  1089. if (empty($_SESSION['error_msg'])) {
  1090. $v_policy_system_hide_admin = $_POST['v_policy_system_hide_admin'];
  1091. }
  1092. $v_security_adv = 'yes';
  1093. }
  1094. }
  1095. // Change POLICY_SYSTEM_HIDE_SERVICES
  1096. if (empty($_SESSION['error_msg'])) {
  1097. if ($_POST['v_policy_system_hide_services'] != $_SESSION['POLICY_SYSTEM_HIDE_SERVICES']) {
  1098. exec(HESTIA_CMD."v-change-sys-config-value POLICY_SYSTEM_HIDE_SERVICES ".quoteshellarg($_POST['v_policy_system_hide_services']), $output, $return_var);
  1099. check_return_code($return_var, $output);
  1100. unset($output);
  1101. if (empty($_SESSION['error_msg'])) {
  1102. $v_policy_system_hide_services = $_POST['v_policy_system_hide_services'];
  1103. }
  1104. $v_security_adv = 'yes';
  1105. }
  1106. }
  1107. // Change login style
  1108. if (empty($_SESSION['error_msg'])) {
  1109. if ($_POST['v_login_style'] != $_SESSION['LOGIN_STYLE']) {
  1110. exec(HESTIA_CMD."v-change-sys-config-value LOGIN_STYLE ".quoteshellarg($_POST['v_login_style']), $output, $return_var);
  1111. check_return_code($return_var, $output);
  1112. unset($output);
  1113. if (empty($_SESSION['error_msg'])) {
  1114. $v_login_style = $_POST['v_login_style'];
  1115. }
  1116. $v_security_adv = 'yes';
  1117. }
  1118. }
  1119. // Update SSL certificate
  1120. if ((!empty($_POST['v_ssl_crt'])) && (empty($_SESSION['error_msg']))) {
  1121. if (($v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ($v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key']))) {
  1122. exec('mktemp -d', $mktemp_output, $return_var);
  1123. $tmpdir = $mktemp_output[0];
  1124. // Certificate
  1125. if (!empty($_POST['v_ssl_crt'])) {
  1126. $fp = fopen($tmpdir."/certificate.crt", 'w');
  1127. fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt']));
  1128. fwrite($fp, "\n");
  1129. fclose($fp);
  1130. }
  1131. // Key
  1132. if (!empty($_POST['v_ssl_key'])) {
  1133. $fp = fopen($tmpdir."/certificate.key", 'w');
  1134. fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key']));
  1135. fwrite($fp, "\n");
  1136. fclose($fp);
  1137. }
  1138. exec(HESTIA_CMD."v-change-sys-hestia-ssl ".$tmpdir, $output, $return_var);
  1139. check_return_code($return_var, $output);
  1140. unset($output);
  1141. // List ssl certificate info
  1142. exec(HESTIA_CMD."v-list-sys-hestia-ssl json", $output, $return_var);
  1143. $ssl_str = json_decode(implode('', $output), true);
  1144. unset($output);
  1145. $v_ssl_crt = $ssl_str['HESTIA']['CRT'];
  1146. $v_ssl_key = $ssl_str['HESTIA']['KEY'];
  1147. $v_ssl_ca = $ssl_str['HESTIA']['CA'];
  1148. $v_ssl_subject = $ssl_str['HESTIA']['SUBJECT'];
  1149. $v_ssl_aliases = $ssl_str['HESTIA']['ALIASES'];
  1150. $v_ssl_not_before = $ssl_str['HESTIA']['NOT_BEFORE'];
  1151. $v_ssl_not_after = $ssl_str['HESTIA']['NOT_AFTER'];
  1152. $v_ssl_signature = $ssl_str['HESTIA']['SIGNATURE'];
  1153. $v_ssl_pub_key = $ssl_str['HESTIA']['PUB_KEY'];
  1154. $v_ssl_issuer = $ssl_str['HESTIA']['ISSUER'];
  1155. // Cleanup certificate tempfiles
  1156. if (file_exists($tmpdir . '/certificate.crt')) {
  1157. unlink($tmpdir . '/certificate.crt');
  1158. }
  1159. if (file_exists($tmpdir . '/certificate.key')) {
  1160. unlink($tmpdir . '/certificate.key');
  1161. }
  1162. rmdir($tmpdir);
  1163. }
  1164. }
  1165. // Flush field values on success
  1166. if (empty($_SESSION['error_msg'])) {
  1167. $_SESSION['ok_msg'] = _('Changes has been saved.');
  1168. }
  1169. if ($require_refresh == true) {
  1170. $refresh = $_SERVER['REQUEST_URI'];
  1171. $_SESSION['ok_msg'] = _('Changes has been saved.');
  1172. header("Location: $refresh");
  1173. die();
  1174. }
  1175. }
  1176. // Check system configuration
  1177. exec(HESTIA_CMD . "v-list-sys-config json", $output, $return_var);
  1178. $data = json_decode(implode('', $output), true);
  1179. unset($output);
  1180. $sys_arr = $data['config'];
  1181. foreach ($sys_arr as $key => $value) {
  1182. $_SESSION[$key] = $value;
  1183. }
  1184. // Render page
  1185. render_page($user, $TAB, 'edit_server');
  1186. // Flush session messages
  1187. unset($_SESSION['error_msg']);
  1188. unset($_SESSION['ok_msg']);