index.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. error_reporting(NULL);
  3. $TAB = 'SERVER';
  4. // Main include
  5. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  6. // Check user
  7. if ($_SESSION['user'] != 'admin') {
  8. header("Location: /list/user");
  9. exit;
  10. }
  11. // Check POST request
  12. if (!empty($_POST['save'])) {
  13. // Check token
  14. if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
  15. header('location: /login/');
  16. exit();
  17. }
  18. // Set restart flag
  19. $v_restart = 'yes';
  20. if (empty($_POST['v_restart'])) $v_restart = 'no';
  21. // Update options
  22. if (!empty($_POST['v_options'])) {
  23. exec ('mktemp', $mktemp_output, $return_var);
  24. $new_conf = $mktemp_output[0];
  25. $fp = fopen($new_conf, 'w');
  26. fwrite($fp, str_replace("\r\n", "\n", $_POST['v_options']));
  27. fclose($new_conf);
  28. exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." bind9-opt ".$v_restart, $output, $return_var);
  29. check_return_code($return_var,$output);
  30. unset($output);
  31. unlink($new_conf);
  32. }
  33. // Update config
  34. if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config']))) {
  35. exec ('mktemp', $mktemp_output, $return_var);
  36. $new_conf = $mktemp_output[0];
  37. $fp = fopen($new_conf, 'w');
  38. fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config']));
  39. fclose($new_conf);
  40. exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." bind9 ".$v_restart, $output, $return_var);
  41. check_return_code($return_var,$output);
  42. unset($output);
  43. unlink($new_conf);
  44. }
  45. // Set success message
  46. if (empty($_SESSION['error_msg'])) {
  47. $_SESSION['ok_msg'] = __('Changes has been saved.');
  48. }
  49. }
  50. $v_options_path = '/etc/bind/named.conf.options';
  51. $v_config_path = '/etc/bind/named.conf';
  52. $v_service_name = strtoupper('bind9');
  53. // Read config
  54. $v_options = shell_exec(VESTA_CMD."v-open-fs-config ".$v_options_path);
  55. $v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
  56. // Render page
  57. render_page($user, $TAB, 'edit_server_bind9');
  58. // Flush session messages
  59. unset($_SESSION['error_msg']);
  60. unset($_SESSION['ok_msg']);