index.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 config
  22. if (!empty($_POST['v_config'])) {
  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_config']));
  27. fclose($fp);
  28. exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." spamd ".$v_restart, $output, $return_var);
  29. check_return_code($return_var,$output);
  30. unset($output);
  31. unlink($new_conf);
  32. }
  33. // Set success message
  34. if (empty($_SESSION['error_msg'])) {
  35. $_SESSION['ok_msg'] = __('Changes has been saved.');
  36. }
  37. }
  38. $v_config_path = shell_exec(VESTA_CMD.'v-list-sys-spamd-config plain');
  39. $v_service_name = strtoupper('spamassassin');
  40. // Read config
  41. $v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
  42. // Render page
  43. render_page($user, $TAB, 'edit_server_service');
  44. // Flush session messages
  45. unset($_SESSION['error_msg']);
  46. unset($_SESSION['ok_msg']);