|
20 | 20 | header("Location: /list/dns/"); |
21 | 21 | } |
22 | 22 |
|
23 | | - // Action |
| 23 | + // DNS Domain |
24 | 24 | if (!empty($_POST['ok'])) { |
25 | 25 | // Check input |
26 | 26 | if (empty($_POST['v_domain'])) $errors[] = 'domain'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 |
|
70 | | - exec (VESTA_CMD."v_list_dns_templates json", $output, $return_var); |
71 | | - $templates = json_decode(implode('', $output), true); |
72 | | - unset($output); |
73 | 70 |
|
74 | | - exec (VESTA_CMD."v_list_user_ns ".$user." json", $output, $return_var); |
75 | | - $soa = json_decode(implode('', $output), true); |
76 | | - $v_soa = $soa[0]; |
77 | | - unset($output); |
| 71 | + // DNS Record |
| 72 | + if (!empty($_POST['ok_rec'])) { |
| 73 | + // Check input |
| 74 | + if (empty($_POST['v_domain'])) $errors[] = 'domain'; |
| 75 | + if (empty($_POST['v_rec'])) $errors[] = 'record'; |
| 76 | + if (empty($_POST['v_type'])) $errors[] = 'type'; |
| 77 | + if (empty($_POST['v_val'])) $errors[] = 'value'; |
| 78 | + |
| 79 | + // Protect input |
| 80 | + $v_domain = escapeshellarg($_POST['v_domain']); |
| 81 | + $v_rec = escapeshellarg($_POST['v_rec']); |
| 82 | + $v_type = escapeshellarg($_POST['v_type']); |
| 83 | + $v_val = escapeshellarg($_POST['v_val']); |
| 84 | + $v_priority = escapeshellarg($_POST['v_priority']); |
| 85 | + |
| 86 | + // Check for errors |
| 87 | + if (!empty($errors[0])) { |
| 88 | + foreach ($errors as $i => $error) { |
| 89 | + if ( $i == 0 ) { |
| 90 | + $error_msg = $error; |
| 91 | + } else { |
| 92 | + $error_msg = $error_msg.", ".$error; |
| 93 | + } |
| 94 | + } |
| 95 | + $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; |
| 96 | + } else { |
| 97 | + // Add DNS Record |
| 98 | + exec (VESTA_CMD."v_add_dns_domain_record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var); |
| 99 | + $v_type = $_POST['v_type']; |
| 100 | + if ($return_var != 0) { |
| 101 | + $error = implode('<br>', $output); |
| 102 | + if (empty($error)) $error = 'Error: vesta did not return any output.'; |
| 103 | + $_SESSION['error_msg'] = $error; |
| 104 | + } |
| 105 | + unset($output); |
| 106 | + if (empty($_SESSION['error_msg'])) { |
| 107 | + $_SESSION['ok_msg'] = "OK: record <b>".$_POST[v_rec]."</b> has been created successfully."; |
| 108 | + unset($v_domain); |
| 109 | + unset($v_rec); |
| 110 | + unset($v_val); |
| 111 | + unset($v_priority); |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + |
78 | 116 |
|
79 | | - $v_ttl = 14400; |
80 | | - $v_exp = date('Y-m-d', strtotime('+1 year')); |
| 117 | + if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { |
| 118 | + exec (VESTA_CMD."v_list_dns_templates json", $output, $return_var); |
| 119 | + $templates = json_decode(implode('', $output), true); |
| 120 | + unset($output); |
81 | 121 |
|
82 | | - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns.html'); |
83 | | - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html'); |
84 | | - unset($_SESSION['error_msg']); |
85 | | - unset($_SESSION['ok_msg']); |
| 122 | + exec (VESTA_CMD."v_list_user_ns ".$user." json", $output, $return_var); |
| 123 | + $soa = json_decode(implode('', $output), true); |
| 124 | + $v_soa = $soa[0]; |
| 125 | + unset($output); |
| 126 | + |
| 127 | + $v_ttl = 14400; |
| 128 | + $v_exp = date('Y-m-d', strtotime('+1 year')); |
| 129 | + |
| 130 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns.html'); |
| 131 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html'); |
| 132 | + unset($_SESSION['error_msg']); |
| 133 | + unset($_SESSION['ok_msg']); |
| 134 | + } else { |
| 135 | + $v_domain = $_GET['domain']; |
| 136 | + |
| 137 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_dns_rec.html'); |
| 138 | + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns_rec.html'); |
| 139 | + unset($_SESSION['error_msg']); |
| 140 | + unset($_SESSION['ok_msg']); |
| 141 | + } |
86 | 142 | } |
87 | 143 |
|
88 | 144 | // Footer |
|
0 commit comments