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