|
13 | 13 | // Check token |
14 | 14 | if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) { |
15 | 15 | header('location: /login/'); |
16 | | - exit(); |
| 16 | + exit; |
17 | 17 | } |
18 | 18 |
|
19 | 19 | // Check empty fields |
|
32 | 32 |
|
33 | 33 | // Protect input |
34 | 34 | $v_domain = preg_replace("/^www./i", "", $_POST['v_domain']); |
35 | | - $v_domain = escapeshellarg($v_domain); |
36 | 35 | $v_domain = strtolower($v_domain); |
37 | | - $v_ip = escapeshellarg($_POST['v_ip']); |
38 | | - if (!empty($_POST['v_ns1'])) $v_ns1 = escapeshellarg($_POST['v_ns1']); |
39 | | - if (!empty($_POST['v_ns2'])) $v_ns2 = escapeshellarg($_POST['v_ns2']); |
40 | | - if (!empty($_POST['v_ns3'])) $v_ns3 = escapeshellarg($_POST['v_ns3']); |
41 | | - if (!empty($_POST['v_ns4'])) $v_ns4 = escapeshellarg($_POST['v_ns4']); |
42 | | - if (!empty($_POST['v_ns5'])) $v_ns5 = escapeshellarg($_POST['v_ns5']); |
43 | | - if (!empty($_POST['v_ns6'])) $v_ns6 = escapeshellarg($_POST['v_ns6']); |
44 | | - if (!empty($_POST['v_ns7'])) $v_ns7 = escapeshellarg($_POST['v_ns7']); |
45 | | - if (!empty($_POST['v_ns8'])) $v_ns8 = escapeshellarg($_POST['v_ns8']); |
| 36 | + $v_ip = $_POST['v_ip']; |
| 37 | + if (!empty($_POST['v_ns1'])) $v_ns1 = $_POST['v_ns1']; |
| 38 | + if (!empty($_POST['v_ns2'])) $v_ns2 = $_POST['v_ns2']; |
| 39 | + if (!empty($_POST['v_ns3'])) $v_ns3 = $_POST['v_ns3']; |
| 40 | + if (!empty($_POST['v_ns4'])) $v_ns4 = $_POST['v_ns4']; |
| 41 | + if (!empty($_POST['v_ns5'])) $v_ns5 = $_POST['v_ns5']; |
| 42 | + if (!empty($_POST['v_ns6'])) $v_ns6 = $_POST['v_ns6']; |
| 43 | + if (!empty($_POST['v_ns7'])) $v_ns7 = $_POST['v_ns7']; |
| 44 | + if (!empty($_POST['v_ns8'])) $v_ns8 = $_POST['v_ns8']; |
46 | 45 |
|
47 | 46 | // Add dns domain |
48 | 47 | if (empty($_SESSION['error_msg'])) { |
49 | | - exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$v_ns4." ".$v_ns5." ".$v_ns6." ".$v_ns7." ".$v_ns8." no", $output, $return_var); |
50 | | - check_return_code($return_var,$output); |
51 | | - unset($output); |
| 48 | + v_exec('v-add-dns-domain', [$user, $v_domain, $v_ip, $v_ns1, $v_ns2, $v_ns3, $v_ns4, $v_ns5, $v_ns6, $v_ns7, $v_ns8, 'no']); |
52 | 49 | } |
53 | 50 |
|
54 | 51 |
|
55 | 52 | // Set expiriation date |
56 | 53 | if (empty($_SESSION['error_msg'])) { |
57 | 54 | if ((!empty($_POST['v_exp'])) && ($_POST['v_exp'] != date('Y-m-d', strtotime('+1 year')))) { |
58 | | - $v_exp = escapeshellarg($_POST['v_exp']); |
59 | | - exec (VESTA_CMD."v-change-dns-domain-exp ".$user." ".$v_domain." ".$v_exp." no", $output, $return_var); |
60 | | - check_return_code($return_var,$output); |
61 | | - unset($output); |
| 55 | + $v_exp = $_POST['v_exp']; |
| 56 | + v_exec('v-change-dns-domain-exp', [$user, $v_domain, $v_exp, 'no']); |
62 | 57 | } |
63 | 58 | } |
64 | 59 |
|
65 | 60 | // Set ttl |
66 | 61 | if (empty($_SESSION['error_msg'])) { |
67 | 62 | if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400') && (empty($_SESSION['error_msg']))) { |
68 | | - $v_ttl = escapeshellarg($_POST['v_ttl']); |
69 | | - exec (VESTA_CMD."v-change-dns-domain-ttl ".$user." ".$v_domain." ".$v_ttl." no", $output, $return_var); |
70 | | - check_return_code($return_var,$output); |
71 | | - unset($output); |
| 63 | + $v_ttl = $_POST['v_ttl']; |
| 64 | + v_exec('v-change-dns-domain-ttl', [$user, $v_domain, $v_ttl, 'no']); |
72 | 65 | } |
73 | 66 | } |
74 | 67 |
|
75 | 68 | // Restart dns server |
76 | 69 | if (empty($_SESSION['error_msg'])) { |
77 | | - exec (VESTA_CMD."v-restart-dns", $output, $return_var); |
78 | | - check_return_code($return_var,$output); |
79 | | - unset($output); |
| 70 | + v_exec('v-restart-dns'); |
80 | 71 | } |
81 | 72 |
|
82 | 73 | // Flush field values on success |
83 | 74 | if (empty($_SESSION['error_msg'])) { |
84 | | - $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain])); |
| 75 | + $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK', htmlentities($_POST[v_domain]), htmlentities($_POST[v_domain])); |
85 | 76 | unset($v_domain); |
86 | 77 | } |
87 | 78 | } |
|
93 | 84 | // Check token |
94 | 85 | if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) { |
95 | 86 | header('location: /login/'); |
96 | | - exit(); |
| 87 | + exit; |
97 | 88 | } |
98 | 89 |
|
99 | 90 | // Check empty fields |
|
113 | 104 | } |
114 | 105 |
|
115 | 106 | // Protect input |
116 | | - $v_domain = escapeshellarg($_POST['v_domain']); |
117 | | - $v_rec = escapeshellarg($_POST['v_rec']); |
118 | | - $v_type = escapeshellarg($_POST['v_type']); |
119 | | - $v_val = escapeshellarg($_POST['v_val']); |
120 | | - $v_priority = escapeshellarg($_POST['v_priority']); |
| 107 | + $v_domain = $_POST['v_domain']; |
| 108 | + $v_rec = $_POST['v_rec']; |
| 109 | + $v_type = $_POST['v_type']; |
| 110 | + $v_val = $_POST['v_val']; |
| 111 | + $v_priority = $_POST['v_priority']; |
121 | 112 |
|
122 | 113 | // Add dns record |
123 | 114 | if (empty($_SESSION['error_msg'])) { |
124 | | - exec (VESTA_CMD."v-add-dns-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var); |
125 | | - check_return_code($return_var,$output); |
126 | | - unset($output); |
127 | | - $v_type = $_POST['v_type']; |
| 115 | + v_exec('v-add-dns-record', [$user, $v_domain, $v_rec, $v_type, $v_val, $v_priority]); |
128 | 116 | } |
129 | 117 |
|
130 | 118 | // Flush field values on success |
|
159 | 147 | if (empty($v_ttl)) $v_ttl = 14400; |
160 | 148 | if (empty($v_exp)) $v_exp = date('Y-m-d', strtotime('+1 year')); |
161 | 149 | if (empty($v_ns1)) { |
162 | | - exec (VESTA_CMD."v-list-user-ns ".$user." json", $output, $return_var); |
163 | | - $nameservers = json_decode(implode('', $output), true); |
| 150 | + v_exec('v-list-user-ns', [$user, 'json'], false, $output); |
| 151 | + $nameservers = json_decode($output, true); |
164 | 152 | $v_ns1 = str_replace("'", "", $nameservers[0]); |
165 | 153 | $v_ns2 = str_replace("'", "", $nameservers[1]); |
166 | 154 | $v_ns3 = str_replace("'", "", $nameservers[2]); |
|
169 | 157 | $v_ns6 = str_replace("'", "", $nameservers[5]); |
170 | 158 | $v_ns7 = str_replace("'", "", $nameservers[6]); |
171 | 159 | $v_ns8 = str_replace("'", "", $nameservers[7]); |
172 | | - unset($output); |
173 | 160 | } |
174 | 161 | include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html'); |
175 | 162 | } |
|
0 commit comments