|
| 1 | +<?php |
| 2 | +// Init |
| 3 | +//error_reporting(NULL); |
| 4 | +ob_start(); |
| 5 | +session_start(); |
| 6 | + |
| 7 | +$TAB = 'DNS'; |
| 8 | +include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); |
| 9 | + |
| 10 | +// Header |
| 11 | +include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); |
| 12 | + |
| 13 | +// Panel |
| 14 | +top_panel($user,$TAB); |
| 15 | + |
| 16 | +// Are you admin? |
| 17 | +if ($_SESSION['user'] == 'admin') { |
| 18 | + |
| 19 | + // Check user argument? |
| 20 | + if (empty($_GET['domain'])) { |
| 21 | + header("Location: /list/dns/"); |
| 22 | + } |
| 23 | + |
| 24 | + if (!empty($_POST['cancel'])) { |
| 25 | + header("Location: /list/dns/"); |
| 26 | + } |
| 27 | + |
| 28 | + // Check domain |
| 29 | + $v_domain = escapeshellarg($_GET['domain']); |
| 30 | + exec (VESTA_CMD."v_list_dns_domain ".$user." ".$v_domain." json", $output, $return_var); |
| 31 | + if ($return_var != 0) { |
| 32 | + $error = implode('<br>', $output); |
| 33 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 34 | + $_SESSION['error_msg'] = $error; |
| 35 | + } else { |
| 36 | + $data = json_decode(implode('', $output), true); |
| 37 | + unset($output); |
| 38 | + |
| 39 | + $v_username = $user; |
| 40 | + $v_domain = $_GET['domain']; |
| 41 | + $v_ip = $data[$v_domain]['IP']; |
| 42 | + $v_template = $data[$v_domain]['TPL']; |
| 43 | + $v_ttl = $data[$v_domain]['TTL']; |
| 44 | + $v_exp = $data[$v_domain]['EXP']; |
| 45 | + $v_soa = $data[$v_domain]['SOA']; |
| 46 | + $v_date = $data[$v_domain]['DATE']; |
| 47 | + $v_time = $data[$v_domain]['TIME']; |
| 48 | + |
| 49 | + exec (VESTA_CMD."v_list_dns_templates json", $output, $return_var); |
| 50 | + $templates = json_decode(implode('', $output), true); |
| 51 | + unset($output); |
| 52 | + } |
| 53 | + |
| 54 | + // Action |
| 55 | + if (!empty($_POST['save'])) { |
| 56 | + $v_domain = escapeshellarg($_POST['v_domain']); |
| 57 | + |
| 58 | + // IP |
| 59 | + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { |
| 60 | + $v_ip = escapeshellarg($_POST['v_ip']); |
| 61 | + exec (VESTA_CMD."v_change_dns_domain_ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); |
| 62 | + if ($return_var != 0) { |
| 63 | + $error = implode('<br>', $output); |
| 64 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 65 | + $_SESSION['error_msg'] = $error; |
| 66 | + } |
| 67 | + $restart_dns = 'yes'; |
| 68 | + unset($output); |
| 69 | + } |
| 70 | + |
| 71 | + // Template |
| 72 | + if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { |
| 73 | + $v_template = escapeshellarg($_POST['v_template']); |
| 74 | + exec (VESTA_CMD."v_change_dns_domain_tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); |
| 75 | + if ($return_var != 0) { |
| 76 | + $error = implode('<br>', $output); |
| 77 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 78 | + $_SESSION['error_msg'] = $error; |
| 79 | + } |
| 80 | + unset($output); |
| 81 | + $restart_dns = 'yes'; |
| 82 | + } |
| 83 | + |
| 84 | + // SOA |
| 85 | + if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) { |
| 86 | + $v_soa = escapeshellarg($_POST['v_soa']); |
| 87 | + exec (VESTA_CMD."v_change_dns_domain_soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var); |
| 88 | + if ($return_var != 0) { |
| 89 | + $error = implode('<br>', $output); |
| 90 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 91 | + $_SESSION['error_msg'] = $error; |
| 92 | + } |
| 93 | + unset($output); |
| 94 | + $restart_dns = 'yes'; |
| 95 | + } |
| 96 | + |
| 97 | + // EXP |
| 98 | + if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) { |
| 99 | + $v_exp = escapeshellarg($_POST['v_exp']); |
| 100 | + exec (VESTA_CMD."v_change_dns_domain_exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var); |
| 101 | + if ($return_var != 0) { |
| 102 | + $error = implode('<br>', $output); |
| 103 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 104 | + $_SESSION['error_msg'] = $error; |
| 105 | + } |
| 106 | + unset($output); |
| 107 | + $restart_dns = 'yes'; |
| 108 | + } |
| 109 | + |
| 110 | + // TTL |
| 111 | + if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) { |
| 112 | + $v_ttl = escapeshellarg($_POST['v_ttl']); |
| 113 | + exec (VESTA_CMD."v_change_dns_domain_ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var); |
| 114 | + if ($return_var != 0) { |
| 115 | + $error = implode('<br>', $output); |
| 116 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 117 | + $_SESSION['error_msg'] = $error; |
| 118 | + } |
| 119 | + unset($output); |
| 120 | + $restart_dns = 'yes'; |
| 121 | + } |
| 122 | + |
| 123 | + // Restart dns |
| 124 | + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { |
| 125 | + exec (VESTA_CMD."v_restart_dns", $output, $return_var); |
| 126 | + if ($return_var != 0) { |
| 127 | + $error = implode('<br>', $output); |
| 128 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 129 | + $_SESSION['error_msg'] = $error; |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + if (empty($_SESSION['error_msg'])) { |
| 134 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 135 | + } |
| 136 | + |
| 137 | + } |
| 138 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns.html'); |
| 139 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html'); |
| 140 | + unset($_SESSION['error_msg']); |
| 141 | + unset($_SESSION['ok_msg']); |
| 142 | +} |
| 143 | + |
| 144 | +// Footer |
| 145 | +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); |
0 commit comments