commit | author | age
|
3dbcc3
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2008, Till Brehm, projektfarm Gmbh |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
b1a6a5
|
31 |
require_once '../../lib/config.inc.php'; |
MC |
32 |
require_once '../../lib/app.inc.php'; |
3dbcc3
|
33 |
|
T |
34 |
//* Check permissions for module |
|
35 |
$app->auth->check_module_permissions('dns'); |
|
36 |
|
|
37 |
|
|
38 |
// Loading the template |
|
39 |
$app->uses('tpl,validate_dns'); |
|
40 |
$app->tpl->newTemplate("form.tpl.htm"); |
b1a6a5
|
41 |
$app->tpl->setInclude('content_tpl', 'templates/dns_wizard.htm'); |
44d2a7
|
42 |
$app->load_language_file('/web/dns/lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng'); |
3dbcc3
|
43 |
|
T |
44 |
// import variables |
65ea2e
|
45 |
$template_id = (isset($_POST['template_id']))?$app->functions->intval($_POST['template_id']):0; |
M |
46 |
$sys_groupid = (isset($_POST['client_group_id']))?$app->functions->intval($_POST['client_group_id']):0; |
3dbcc3
|
47 |
|
T |
48 |
// get the correct server_id |
bd6659
|
49 |
if (isset($_POST['server_id'])) { |
SJ |
50 |
$server_id = $app->functions->intval($_POST['server_id']); |
|
51 |
$post_server_id = true; |
1a2cbf
|
52 |
} elseif (isset($_POST['server_id_value'])) { |
MC |
53 |
$server_id = $app->functions->intval($_POST['server_id_value']); |
|
54 |
$post_server_id = true; |
3dbcc3
|
55 |
} else { |
41d7d1
|
56 |
$settings = $app->getconf->get_global_config('dns'); |
SC |
57 |
$server_id = $app->functions->intval($settings['default_dnsserver']); |
bd6659
|
58 |
$post_server_id = false; |
SJ |
59 |
} |
3dbcc3
|
60 |
|
T |
61 |
// Load the templates |
222ea2
|
62 |
$records = $app->db->queryAllRecords("SELECT * FROM dns_template WHERE visible = 'Y' ORDER BY name ASC"); |
3dbcc3
|
63 |
$template_id_option = ''; |
T |
64 |
$n = 0; |
|
65 |
foreach($records as $rec){ |
|
66 |
$checked = ($rec['template_id'] == $template_id)?' SELECTED':''; |
|
67 |
$template_id_option .= '<option value="'.$rec['template_id'].'"'.$checked.'>'.$rec['name'].'</option>'; |
|
68 |
if($n == 0 && $template_id == 0) $template_id = $rec['template_id']; |
|
69 |
$n++; |
|
70 |
} |
|
71 |
unset($n); |
b1a6a5
|
72 |
$app->tpl->setVar("template_id_option", $template_id_option); |
3dbcc3
|
73 |
|
3e94c8
|
74 |
$app->uses('ini_parser,getconf'); |
SC |
75 |
$domains_settings = $app->getconf->get_global_config('domains'); |
|
76 |
|
3dbcc3
|
77 |
// If the user is administrator |
T |
78 |
if($_SESSION['s']['user']['typ'] == 'admin') { |
b1a6a5
|
79 |
|
3dbcc3
|
80 |
// Load the list of servers |
0da7c5
|
81 |
$records = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 ORDER BY server_name"); |
3dbcc3
|
82 |
$server_id_option = ''; |
T |
83 |
foreach($records as $rec){ |
|
84 |
$checked = ($rec['server_id'] == $server_id)?' SELECTED':''; |
|
85 |
$server_id_option .= '<option value="'.$rec['server_id'].'"'.$checked.'>'.$rec['server_name'].'</option>'; |
|
86 |
} |
b1a6a5
|
87 |
$app->tpl->setVar("server_id", $server_id_option); |
MC |
88 |
|
3e94c8
|
89 |
if ($domains_settings['use_domain_module'] != 'y') { |
SC |
90 |
// load the list of clients |
|
91 |
$sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; |
|
92 |
$clients = $app->db->queryAllRecords($sql); |
|
93 |
$client_select = ''; |
|
94 |
if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>"; |
|
95 |
if(is_array($clients)) { |
|
96 |
foreach( $clients as $client) { |
|
97 |
$selected = ($client["groupid"] == $sys_groupid)?'SELECTED':''; |
|
98 |
$client_select .= "<option value='$client[groupid]' $selected>$client[contactname]</option>\r\n"; |
|
99 |
} |
3dbcc3
|
100 |
} |
T |
101 |
|
3e94c8
|
102 |
$app->tpl->setVar("client_group_id", $client_select); |
SC |
103 |
} |
3dbcc3
|
104 |
} |
T |
105 |
|
0fd51f
|
106 |
if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
b1a6a5
|
107 |
|
0fd51f
|
108 |
// Get the limits of the client |
604c0c
|
109 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
cc7a82
|
110 |
$client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); |
0fd51f
|
111 |
|
b1a6a5
|
112 |
|
3e94c8
|
113 |
if ($domains_settings['use_domain_module'] != 'y') { |
SC |
114 |
// load the list of clients |
cc7a82
|
115 |
$sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; |
MC |
116 |
$clients = $app->db->queryAllRecords($sql, $client['client_id']); |
|
117 |
$tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); |
3e94c8
|
118 |
$client_select = '<option value="'.$tmp['groupid'].'">'.$client['contactname'].'</option>'; |
SC |
119 |
if(is_array($clients)) { |
|
120 |
foreach( $clients as $client) { |
|
121 |
$selected = ($client["groupid"] == $sys_groupid)?'SELECTED':''; |
|
122 |
$client_select .= "<option value='$client[groupid]' $selected>$client[contactname]</option>\r\n"; |
|
123 |
} |
0fd51f
|
124 |
} |
T |
125 |
|
3e94c8
|
126 |
$app->tpl->setVar("client_group_id", $client_select); |
SC |
127 |
} |
0fd51f
|
128 |
} |
T |
129 |
|
bd6659
|
130 |
if($_SESSION["s"]["user"]["typ"] != 'admin') |
775c05
|
131 |
{ |
MC |
132 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
cc7a82
|
133 |
$client_dns = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); |
bd6659
|
134 |
|
SJ |
135 |
$client_dns['dns_servers_ids'] = explode(',', $client_dns['dns_servers']); |
|
136 |
|
|
137 |
$only_one_server = count($client_dns['dns_servers_ids']) === 1; |
|
138 |
$app->tpl->setVar('only_one_server', $only_one_server); |
|
139 |
|
|
140 |
if ($only_one_server) { |
|
141 |
$app->tpl->setVar('server_id_value', $client_dns['dns_servers_ids'][0]); |
|
142 |
} |
|
143 |
|
cc7a82
|
144 |
$sql = "SELECT server_id, server_name FROM server WHERE server_id IN ?"; |
MC |
145 |
$dns_servers = $app->db->queryAllRecords($sql, $client_dns['dns_servers_ids']); |
bd6659
|
146 |
|
SJ |
147 |
$options_dns_servers = ""; |
|
148 |
|
|
149 |
foreach ($dns_servers as $dns_server) { |
|
150 |
$options_dns_servers .= "<option value='$dns_server[server_id]'>$dns_server[server_name]</option>"; |
|
151 |
} |
|
152 |
|
|
153 |
$app->tpl->setVar("server_id", $options_dns_servers); |
|
154 |
unset($options_dns_servers); |
|
155 |
|
|
156 |
} |
0fd51f
|
157 |
|
cc7a82
|
158 |
$template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $template_id); |
b1a6a5
|
159 |
$fields = explode(',', $template_record['fields']); |
3dbcc3
|
160 |
if(is_array($fields)) { |
T |
161 |
foreach($fields as $field) { |
b1a6a5
|
162 |
$app->tpl->setVar($field."_VISIBLE", 1); |
3dbcc3
|
163 |
$field = strtolower($field); |
b1a6a5
|
164 |
$app->tpl->setVar($field, $_POST[$field]); |
3dbcc3
|
165 |
} |
T |
166 |
} |
|
167 |
|
021ef6
|
168 |
/* |
SC |
169 |
* Now we have to check, if we should use the domain-module to select the domain |
|
170 |
* or not |
|
171 |
*/ |
3e94c8
|
172 |
if ($domains_settings['use_domain_module'] == 'y') { |
021ef6
|
173 |
/* |
SC |
174 |
* The domain-module is in use. |
|
175 |
*/ |
9ec304
|
176 |
$domains = $app->tools_sites->getDomainModuleDomains("dns_soa"); |
021ef6
|
177 |
$domain_select = ''; |
SC |
178 |
if(is_array($domains) && sizeof($domains) > 0) { |
|
179 |
/* We have domains in the list, so create the drop-down-list */ |
|
180 |
foreach( $domains as $domain) { |
|
181 |
$domain_select .= "<option value=" . $domain['domain_id'] ; |
|
182 |
if ($domain['domain'] == $_POST['domain']) { |
|
183 |
$domain_select .= " selected"; |
|
184 |
} |
|
185 |
$domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . ".</option>\r\n"; |
|
186 |
} |
|
187 |
} |
|
188 |
else { |
|
189 |
/* |
|
190 |
* We have no domains in the domain-list. This means, we can not add ANY new domain. |
|
191 |
* To avoid, that the variable "domain_option" is empty and so the user can |
|
192 |
* free enter a domain, we have to create a empty option! |
|
193 |
*/ |
|
194 |
$domain_select .= "<option value=''></option>\r\n"; |
|
195 |
} |
|
196 |
$app->tpl->setVar("domain_option", $domain_select); |
|
197 |
} |
|
198 |
|
3dbcc3
|
199 |
if($_POST['create'] == 1) { |
b1a6a5
|
200 |
|
3dbcc3
|
201 |
$error = ''; |
b1a6a5
|
202 |
|
015dff
|
203 |
if ($post_server_id) |
bd6659
|
204 |
{ |
c6d29c
|
205 |
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); |
cc7a82
|
206 |
$client = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); |
bd6659
|
207 |
|
SJ |
208 |
$client['dns_servers_ids'] = explode(',', $client['dns_servers']); |
|
209 |
|
|
210 |
// Check if chosen server is in authorized servers for this client |
|
211 |
if (!(is_array($client['dns_servers_ids']) && in_array($server_id, $client['dns_servers_ids'])) && $_SESSION["s"]["user"]["typ"] != 'admin') { |
|
212 |
$error .= $app->lng('error_not_allowed_server_id').'<br />'; |
|
213 |
} |
|
214 |
} |
|
215 |
else |
|
216 |
{ |
|
217 |
$error .= $app->lng('error_no_server_id').'<br />'; |
|
218 |
} |
015dff
|
219 |
|
992797
|
220 |
// apply filters |
MC |
221 |
if(isset($_POST['domain']) && $_POST['domain'] != ''){ |
021ef6
|
222 |
/* check if the domain module is used - and check if the selected domain can be used! */ |
3e94c8
|
223 |
if ($domains_settings['use_domain_module'] == 'y') { |
SC |
224 |
if ($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) { |
|
225 |
$_POST['client_group_id'] = $app->tools_sites->getClientIdForDomain($_POST['domain']); |
|
226 |
} |
021ef6
|
227 |
$domain_check = $app->tools_sites->checkDomainModuleDomain($_POST['domain']); |
SC |
228 |
if(!$domain_check) { |
|
229 |
// invalid domain selected |
|
230 |
$_POST['domain'] = ''; |
|
231 |
} else { |
|
232 |
$_POST['domain'] = $domain_check; |
|
233 |
} |
|
234 |
} else { |
|
235 |
$_POST['domain'] = $app->functions->idn_encode($_POST['domain']); |
|
236 |
$_POST['domain'] = strtolower($_POST['domain']); |
|
237 |
} |
992797
|
238 |
} |
MC |
239 |
if(isset($_POST['ns1']) && $_POST['ns1'] != ''){ |
|
240 |
$_POST['ns1'] = $app->functions->idn_encode($_POST['ns1']); |
|
241 |
$_POST['ns1'] = strtolower($_POST['ns1']); |
|
242 |
} |
|
243 |
if(isset($_POST['ns2']) && $_POST['ns2'] != ''){ |
|
244 |
$_POST['ns2'] = $app->functions->idn_encode($_POST['ns2']); |
|
245 |
$_POST['ns2'] = strtolower($_POST['ns2']); |
|
246 |
} |
|
247 |
if(isset($_POST['email']) && $_POST['email'] != ''){ |
|
248 |
$_POST['email'] = $app->functions->idn_encode($_POST['email']); |
|
249 |
$_POST['email'] = strtolower($_POST['email']); |
|
250 |
} |
b1a6a5
|
251 |
|
MC |
252 |
|
44d2a7
|
253 |
if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty').'<br />'; |
b1a6a5
|
254 |
elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,30}$/', $_POST['domain'])) $error .= $app->lng('error_domain_regex').'<br />'; |
72695f
|
255 |
|
44d2a7
|
256 |
if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty').'<br />'; |
72695f
|
257 |
|
604d25
|
258 |
if(isset($_POST['ipv6']) && $_POST['ipv6'] == '') $error .= $app->lng('error_ipv6_empty').'<br />'; |
CS |
259 |
|
44d2a7
|
260 |
if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty').'<br />'; |
b1a6a5
|
261 |
elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />'; |
72695f
|
262 |
|
44d2a7
|
263 |
if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty').'<br />'; |
b1a6a5
|
264 |
elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />'; |
72695f
|
265 |
|
44d2a7
|
266 |
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />'; |
b1a6a5
|
267 |
elseif(isset($_POST['email']) && !preg_match('/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z0-9\-]{2,30}$/i', $_POST['email'])) $error .= $app->lng('error_email_regex').'<br />'; |
MC |
268 |
|
10b4c8
|
269 |
// make sure that the record belongs to the client group and not the admin group when admin inserts it |
721fb2
|
270 |
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($_POST['client_group_id'])) { |
65ea2e
|
271 |
$sys_groupid = $app->functions->intval($_POST['client_group_id']); |
721fb2
|
272 |
} elseif($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($_POST['client_group_id'])) { |
65ea2e
|
273 |
$sys_groupid = $app->functions->intval($_POST['client_group_id']); |
721fb2
|
274 |
} else { |
T |
275 |
$sys_groupid = $_SESSION["s"]["user"]["default_group"]; |
|
276 |
} |
b1a6a5
|
277 |
|
8fb58f
|
278 |
$tform_def_file = "form/dns_soa.tform.php"; |
T |
279 |
$app->uses('tform'); |
|
280 |
$app->tform->loadFormDef($tform_def_file); |
b1a6a5
|
281 |
|
616d34
|
282 |
if($_SESSION['s']['user']['typ'] != 'admin') { |
T |
283 |
if(!$app->tform->checkClientLimit('limit_dns_zone')) { |
|
284 |
$error .= $app->tform->wordbook["limit_dns_zone_txt"]; |
|
285 |
} |
|
286 |
if(!$app->tform->checkResellerLimit('limit_dns_zone')) { |
|
287 |
$error .= $app->tform->wordbook["limit_dns_zone_txt"]; |
|
288 |
} |
3cebc3
|
289 |
} |
b1a6a5
|
290 |
|
MC |
291 |
|
3dbcc3
|
292 |
// replace template placeholders |
T |
293 |
$tpl_content = $template_record['template']; |
b1a6a5
|
294 |
if($_POST['domain'] != '') $tpl_content = str_replace('{DOMAIN}', $_POST['domain'], $tpl_content); |
MC |
295 |
if($_POST['ip'] != '') $tpl_content = str_replace('{IP}', $_POST['ip'], $tpl_content); |
604d25
|
296 |
if($_POST['ipv6'] != '') $tpl_content = str_replace('{IPV6}',$_POST['ipv6'],$tpl_content); |
b1a6a5
|
297 |
if($_POST['ns1'] != '') $tpl_content = str_replace('{NS1}', $_POST['ns1'], $tpl_content); |
MC |
298 |
if($_POST['ns2'] != '') $tpl_content = str_replace('{NS2}', $_POST['ns2'], $tpl_content); |
|
299 |
if($_POST['email'] != '') $tpl_content = str_replace('{EMAIL}', $_POST['email'], $tpl_content); |
|
300 |
if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/', $_POST['domain'])) { |
5588af
|
301 |
$sql = $app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $_POST['domain']); |
76be2b
|
302 |
$public_key = $sql['dkim_public']; |
b1a6a5
|
303 |
if ($public_key!='') { |
76be2b
|
304 |
if (empty($sql['dkim_selector'])) $sql['dkim_selector'] = 'default'; |
FS |
305 |
$dns_record=str_replace(array("\r\n", "\n", "\r", "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"), '', $public_key); |
|
306 |
$tpl_content .= "\n".'TXT|'.$sql['dkim_selector'].'._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record; |
b1a6a5
|
307 |
} |
MC |
308 |
} |
|
309 |
|
992797
|
310 |
// Parse the template |
b1a6a5
|
311 |
$tpl_rows = explode("\n", $tpl_content); |
3dbcc3
|
312 |
$section = ''; |
T |
313 |
$vars = array(); |
|
314 |
$dns_rr = array(); |
|
315 |
foreach($tpl_rows as $row) { |
|
316 |
$row = trim($row); |
b1a6a5
|
317 |
if(substr($row, 0, 1) == '[') { |
3dbcc3
|
318 |
if($row == '[ZONE]') { |
T |
319 |
$section = 'zone'; |
|
320 |
} elseif($row == '[DNS_RECORDS]') { |
|
321 |
$section = 'dns_records'; |
|
322 |
} else { |
|
323 |
die('Unknown section type'); |
|
324 |
} |
|
325 |
} else { |
|
326 |
if($row != '') { |
|
327 |
// Handle zone section |
|
328 |
if($section == 'zone') { |
b1a6a5
|
329 |
$parts = explode('=', $row); |
3dbcc3
|
330 |
$key = trim($parts[0]); |
T |
331 |
$val = trim($parts[1]); |
|
332 |
if($key != '') $vars[$key] = $val; |
|
333 |
} |
|
334 |
// Handle DNS Record rows |
|
335 |
if($section == 'dns_records') { |
b1a6a5
|
336 |
$parts = explode('|', $row); |
3dbcc3
|
337 |
$dns_rr[] = array( |
3a11d2
|
338 |
'name' => $parts[1], |
MC |
339 |
'type' => $parts[0], |
|
340 |
'data' => $parts[2], |
|
341 |
'aux' => $parts[3], |
|
342 |
'ttl' => $parts[4] |
3dbcc3
|
343 |
); |
T |
344 |
} |
|
345 |
} |
|
346 |
} |
b1a6a5
|
347 |
|
3dbcc3
|
348 |
} // end foreach |
b1a6a5
|
349 |
|
44d2a7
|
350 |
if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'<br />'; |
T |
351 |
if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'<br />'; |
|
352 |
if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'<br />'; |
|
353 |
if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty').'<br />'; |
|
354 |
if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'<br />'; |
|
355 |
if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'<br />'; |
|
356 |
if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'<br />'; |
|
357 |
if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'<br />'; |
b1a6a5
|
358 |
|
3dbcc3
|
359 |
if($error == '') { |
T |
360 |
// Insert the soa record |
|
361 |
$sys_userid = $_SESSION['s']['user']['userid']; |
3a11d2
|
362 |
$origin = $vars['origin']; |
MC |
363 |
$ns = $vars['ns']; |
|
364 |
$mbox = str_replace('@', '.', $vars['mbox']); |
|
365 |
$refresh = $vars['refresh']; |
|
366 |
$retry = $vars['retry']; |
|
367 |
$expire = $vars['expire']; |
|
368 |
$minimum = $vars['minimum']; |
|
369 |
$ttl = $vars['ttl']; |
|
370 |
$xfer = $vars['xfer']; |
|
371 |
$also_notify = $vars['also_notify']; |
|
372 |
$update_acl = $vars['update_acl']; |
3dbcc3
|
373 |
$serial = $app->validate_dns->increase_serial(0); |
b1a6a5
|
374 |
|
3a11d2
|
375 |
$insert_data = array( |
MC |
376 |
"sys_userid" => $sys_userid, |
|
377 |
"sys_groupid" => $sys_groupid, |
|
378 |
"sys_perm_user" => 'riud', |
|
379 |
"sys_perm_group" => 'riud', |
|
380 |
"sys_perm_other" => '', |
|
381 |
"server_id" => $server_id, |
|
382 |
"origin" => $origin, |
|
383 |
"ns" => $ns, |
|
384 |
"mbox" => $mbox, |
|
385 |
"serial" => $serial, |
|
386 |
"refresh" => $refresh, |
|
387 |
"retry" => $retry, |
|
388 |
"expire" => $expire, |
|
389 |
"minimum" => $minimum, |
|
390 |
"ttl" => $ttl, |
|
391 |
"active" => 'Y', |
|
392 |
"xfer" => $xfer, |
|
393 |
"also_notify" => $also_notify, |
|
394 |
"update_acl" => $update_acl |
|
395 |
); |
3dbcc3
|
396 |
$dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); |
b1a6a5
|
397 |
|
3dbcc3
|
398 |
// Insert the dns_rr records |
T |
399 |
if(is_array($dns_rr) && $dns_soa_id > 0) { |
|
400 |
foreach($dns_rr as $rr) { |
3a11d2
|
401 |
$insert_data = array( |
MC |
402 |
"sys_userid" => $sys_userid, |
|
403 |
"sys_groupid" => $sys_groupid, |
|
404 |
"sys_perm_user" => 'riud', |
|
405 |
"sys_perm_group" => 'riud', |
|
406 |
"sys_perm_other" => '', |
|
407 |
"server_id" => $server_id, |
|
408 |
"zone" => $dns_soa_id, |
|
409 |
"name" => $rr['name'], |
|
410 |
"type" => $rr['type'], |
|
411 |
"data" => $rr['data'], |
|
412 |
"aux" => $rr['aux'], |
|
413 |
"ttl" => $rr['ttl'], |
|
414 |
"active" => 'Y' |
|
415 |
); |
3dbcc3
|
416 |
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); |
T |
417 |
} |
|
418 |
} |
b1a6a5
|
419 |
|
3dbcc3
|
420 |
header("Location: dns_soa_list.php"); |
T |
421 |
exit; |
b1a6a5
|
422 |
|
3dbcc3
|
423 |
} else { |
b1a6a5
|
424 |
$app->tpl->setVar("error", $error); |
3dbcc3
|
425 |
} |
b1a6a5
|
426 |
|
3dbcc3
|
427 |
} |
T |
428 |
|
|
429 |
|
|
430 |
|
b1a6a5
|
431 |
$app->tpl->setVar("title", 'DNS Wizard'); |
3dbcc3
|
432 |
|
T |
433 |
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng'; |
b1a6a5
|
434 |
include $lng_file; |
3dbcc3
|
435 |
$app->tpl->setVar($wb); |
T |
436 |
|
|
437 |
$app->tpl_defaults(); |
992797
|
438 |
$app->tpl->pparse(); |
MC |
439 |
|
|
440 |
|
e95eee
|
441 |
?> |