index.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. ob_start();
  5. session_start();
  6. header('Content-Type: application/json');
  7. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  8. // Check token
  9. if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
  10. header('location: /login/');
  11. exit();
  12. }
  13. // Check user
  14. if ($_SESSION['user'] != 'admin') {
  15. exit;
  16. }
  17. if (!empty($_GET['user'])) {
  18. $user=$_GET['user'];
  19. }
  20. // DNS domain
  21. if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) {
  22. $v_username = escapeshellarg($user);
  23. $v_domain = escapeshellarg($_GET['domain']);
  24. exec (VESTA_CMD."v-unsuspend-dns-domain ".$v_username." ".$v_domain, $output, $return_var);
  25. if ($return_var != 0) {
  26. $error = implode('<br>', $output);
  27. if (empty($error)) $error = __('Error: vesta did not return any output.');
  28. $_SESSION['error_msg'] = $error;
  29. }
  30. unset($output);
  31. }
  32. // DNS record
  33. if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) {
  34. $v_username = escapeshellarg($user);
  35. $v_domain = escapeshellarg($_GET['domain']);
  36. $v_record_id = escapeshellarg($_GET['record_id']);
  37. exec (VESTA_CMD."v-unsuspend-dns-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var);
  38. if ($return_var != 0) {
  39. $error = implode('<br>', $output);
  40. if (empty($error)) $error = __('Error: vesta did not return any output.');
  41. $_SESSION['error_msg'] = $error;
  42. }
  43. unset($output);
  44. }
  45. echo json_encode(array('error' => $_SESSION['error_msg']));
  46. unset($_SESSION['error_msg']);