|
26 | 26 | } |
27 | 27 |
|
28 | 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 | | - } |
| 29 | + if ((!empty($_GET['domain'])) && (empty($_GET['record_id']))) { |
| 30 | + $v_domain = escapeshellarg($_GET['domain']); |
| 31 | + exec (VESTA_CMD."v_list_dns_domain ".$user." ".$v_domain." json", $output, $return_var); |
| 32 | + if ($return_var != 0) { |
| 33 | + $error = implode('<br>', $output); |
| 34 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 35 | + $_SESSION['error_msg'] = $error; |
| 36 | + } else { |
| 37 | + $data = json_decode(implode('', $output), true); |
| 38 | + unset($output); |
53 | 39 |
|
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; |
| 40 | + $v_username = $user; |
| 41 | + $v_domain = $_GET['domain']; |
| 42 | + $v_ip = $data[$v_domain]['IP']; |
| 43 | + $v_template = $data[$v_domain]['TPL']; |
| 44 | + $v_ttl = $data[$v_domain]['TTL']; |
| 45 | + $v_exp = $data[$v_domain]['EXP']; |
| 46 | + $v_soa = $data[$v_domain]['SOA']; |
| 47 | + $v_date = $data[$v_domain]['DATE']; |
| 48 | + $v_time = $data[$v_domain]['TIME']; |
| 49 | + $v_suspended = $data[$v_domain]['SUSPENDED']; |
| 50 | + if ( $v_suspended == 'yes' ) { |
| 51 | + $v_status = 'suspended'; |
| 52 | + } else { |
| 53 | + $v_status = 'active'; |
66 | 54 | } |
67 | | - $restart_dns = 'yes'; |
| 55 | + |
| 56 | + exec (VESTA_CMD."v_list_dns_templates json", $output, $return_var); |
| 57 | + $templates = json_decode(implode('', $output), true); |
68 | 58 | unset($output); |
69 | 59 | } |
70 | 60 |
|
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; |
| 61 | + // Action |
| 62 | + if (!empty($_POST['save'])) { |
| 63 | + $v_domain = escapeshellarg($_POST['v_domain']); |
| 64 | + |
| 65 | + // IP |
| 66 | + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { |
| 67 | + $v_ip = escapeshellarg($_POST['v_ip']); |
| 68 | + exec (VESTA_CMD."v_change_dns_domain_ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); |
| 69 | + if ($return_var != 0) { |
| 70 | + $error = implode('<br>', $output); |
| 71 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 72 | + $_SESSION['error_msg'] = $error; |
| 73 | + } |
| 74 | + $restart_dns = 'yes'; |
| 75 | + unset($output); |
79 | 76 | } |
80 | | - unset($output); |
81 | | - $restart_dns = 'yes'; |
82 | | - } |
83 | 77 |
|
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; |
| 78 | + // Template |
| 79 | + if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { |
| 80 | + $v_template = escapeshellarg($_POST['v_template']); |
| 81 | + exec (VESTA_CMD."v_change_dns_domain_tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); |
| 82 | + if ($return_var != 0) { |
| 83 | + $error = implode('<br>', $output); |
| 84 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 85 | + $_SESSION['error_msg'] = $error; |
| 86 | + } |
| 87 | + unset($output); |
| 88 | + $restart_dns = 'yes'; |
92 | 89 | } |
93 | | - unset($output); |
94 | | - $restart_dns = 'yes'; |
95 | | - } |
96 | 90 |
|
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; |
| 91 | + // SOA |
| 92 | + if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) { |
| 93 | + $v_soa = escapeshellarg($_POST['v_soa']); |
| 94 | + exec (VESTA_CMD."v_change_dns_domain_soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var); |
| 95 | + if ($return_var != 0) { |
| 96 | + $error = implode('<br>', $output); |
| 97 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 98 | + $_SESSION['error_msg'] = $error; |
| 99 | + } |
| 100 | + unset($output); |
| 101 | + $restart_dns = 'yes'; |
105 | 102 | } |
106 | | - unset($output); |
107 | | - $restart_dns = 'yes'; |
108 | | - } |
109 | 103 |
|
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; |
| 104 | + // EXP |
| 105 | + if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) { |
| 106 | + $v_exp = escapeshellarg($_POST['v_exp']); |
| 107 | + exec (VESTA_CMD."v_change_dns_domain_exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var); |
| 108 | + if ($return_var != 0) { |
| 109 | + $error = implode('<br>', $output); |
| 110 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 111 | + $_SESSION['error_msg'] = $error; |
| 112 | + } |
| 113 | + unset($output); |
| 114 | + $restart_dns = 'yes'; |
118 | 115 | } |
| 116 | + |
| 117 | + // TTL |
| 118 | + if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) { |
| 119 | + $v_ttl = escapeshellarg($_POST['v_ttl']); |
| 120 | + exec (VESTA_CMD."v_change_dns_domain_ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var); |
| 121 | + if ($return_var != 0) { |
| 122 | + $error = implode('<br>', $output); |
| 123 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 124 | + $_SESSION['error_msg'] = $error; |
| 125 | + } |
| 126 | + unset($output); |
| 127 | + $restart_dns = 'yes'; |
| 128 | + } |
| 129 | + |
| 130 | + // Restart dns |
| 131 | + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { |
| 132 | + exec (VESTA_CMD."v_restart_dns", $output, $return_var); |
| 133 | + if ($return_var != 0) { |
| 134 | + $error = implode('<br>', $output); |
| 135 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 136 | + $_SESSION['error_msg'] = $error; |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + if (empty($_SESSION['error_msg'])) { |
| 141 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
| 142 | + } |
| 143 | + |
| 144 | + } |
| 145 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns.html'); |
| 146 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html'); |
| 147 | + unset($_SESSION['error_msg']); |
| 148 | + unset($_SESSION['ok_msg']); |
| 149 | + } else { |
| 150 | + $v_domain = escapeshellarg($_GET['domain']); |
| 151 | + $v_record_id = escapeshellarg($_GET['record_id']); |
| 152 | + exec (VESTA_CMD."v_list_dns_domain_records ".$user." ".$v_domain." 'json'", $output, $return_var); |
| 153 | + if ($return_var != 0) { |
| 154 | + $error = implode('<br>', $output); |
| 155 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 156 | + $_SESSION['error_msg'] = $error; |
| 157 | + } else { |
| 158 | + $data = json_decode(implode('', $output), true); |
119 | 159 | unset($output); |
120 | | - $restart_dns = 'yes'; |
| 160 | + $v_username = $user; |
| 161 | + $v_domain = $_GET['domain']; |
| 162 | + $v_record_id = $_GET['record_id']; |
| 163 | + $v_rec = $data[$v_record_id]['RECORD']; |
| 164 | + $v_type = $data[$v_record_id]['TYPE']; |
| 165 | + $v_val = $data[$v_record_id]['VALUE']; |
| 166 | + $v_priority = $data[$v_record_id]['PRIORITY']; |
| 167 | + $v_suspended = $data[$v_record_id]['SUSPENDED']; |
| 168 | + if ( $v_suspended == 'yes' ) { |
| 169 | + $v_status = 'suspended'; |
| 170 | + } else { |
| 171 | + $v_status = 'active'; |
| 172 | + } |
| 173 | + $v_date = $data[$v_record_id]['DATE']; |
| 174 | + $v_time = $data[$v_record_id]['TIME']; |
121 | 175 | } |
122 | 176 |
|
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; |
| 177 | + // Action |
| 178 | + if (!empty($_POST['save'])) { |
| 179 | + $v_domain = escapeshellarg($_POST['v_domain']); |
| 180 | + $v_record_id = escapeshellarg($_POST['v_record_id']); |
| 181 | + |
| 182 | + if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { |
| 183 | + $v_val = escapeshellarg($_POST['v_val']); |
| 184 | + $v_priority = escapeshellarg($_POST['v_priority']); |
| 185 | + exec (VESTA_CMD."v_change_dns_domain_record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); |
| 186 | + if ($return_var != 0) { |
| 187 | + $error = implode('<br>', $output); |
| 188 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 189 | + $_SESSION['error_msg'] = $error; |
| 190 | + } |
| 191 | + $restart_dns = 'yes'; |
| 192 | + unset($output); |
| 193 | + } |
| 194 | + |
| 195 | + if (empty($_SESSION['error_msg'])) { |
| 196 | + $_SESSION['ok_msg'] = "OK: changes has been saved."; |
130 | 197 | } |
131 | | - } |
132 | 198 |
|
133 | | - if (empty($_SESSION['error_msg'])) { |
134 | | - $_SESSION['ok_msg'] = "OK: changes has been saved."; |
135 | 199 | } |
136 | | - |
| 200 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_dns_rec.html'); |
| 201 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); |
| 202 | + unset($_SESSION['error_msg']); |
| 203 | + unset($_SESSION['ok_msg']); |
137 | 204 | } |
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 | 205 | } |
143 | 206 |
|
144 | 207 | // Footer |
|
0 commit comments