| | |
| | | $options_dns_servers = ""; |
| | | |
| | | foreach ($dns_servers as $dns_server) { |
| | | $options_dns_servers .= "<option value='$dns_server[server_id]'>$dns_server[server_name]</option>"; |
| | | $options_dns_servers .= '<option value="'.$dns_server['server_id'].'"'.($_POST['server_id'] == $dns_server['server_id'] ? ' selected="selected"' : '').'>'.$dns_server['server_name'].'</option>'; |
| | | } |
| | | |
| | | $app->tpl->setVar("server_id", $options_dns_servers); |
| | |
| | | } |
| | | |
| | | if($_POST['create'] == 1) { |
| | | |
| | | |
| | | //* CSRF Check |
| | | $app->auth->csrf_token_check(); |
| | | |
| | | $error = ''; |
| | | |
| | | if ($post_server_id) |
| | |
| | | elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />'; |
| | | |
| | | if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />'; |
| | | 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 />'; |
| | | elseif(isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) $error .= $app->lng('error_email_regex').'<br />'; |
| | | |
| | | // make sure that the record belongs to the client group and not the admin group when admin inserts it |
| | | if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($_POST['client_group_id'])) { |
| | |
| | | if($_POST['ns1'] != '') $tpl_content = str_replace('{NS1}', $_POST['ns1'], $tpl_content); |
| | | if($_POST['ns2'] != '') $tpl_content = str_replace('{NS2}', $_POST['ns2'], $tpl_content); |
| | | if($_POST['email'] != '') $tpl_content = str_replace('{EMAIL}', $_POST['email'], $tpl_content); |
| | | $enable_dnssec = (($_POST['dnssec'] == 'Y') ? 'Y' : 'N'); |
| | | if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/', $_POST['domain'])) { |
| | | $sql = $app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $_POST['domain']); |
| | | $public_key = $sql['dkim_public']; |
| | |
| | | $tpl_rows = explode("\n", $tpl_content); |
| | | $section = ''; |
| | | $vars = array(); |
| | | $vars['xfer']=''; |
| | | $dns_rr = array(); |
| | | foreach($tpl_rows as $row) { |
| | | $row = trim($row); |
| | |
| | | if($section == 'dns_records') { |
| | | $parts = explode('|', $row); |
| | | $dns_rr[] = array( |
| | | 'name' => $app->db->quote($parts[1]), |
| | | 'type' => $app->db->quote($parts[0]), |
| | | 'data' => $app->db->quote($parts[2]), |
| | | 'aux' => $app->db->quote($parts[3]), |
| | | 'ttl' => $app->db->quote($parts[4]) |
| | | 'name' => $parts[1], |
| | | 'type' => $parts[0], |
| | | 'data' => $parts[2], |
| | | 'aux' => $parts[3], |
| | | 'ttl' => $parts[4] |
| | | ); |
| | | } |
| | | } |
| | |
| | | if($error == '') { |
| | | // Insert the soa record |
| | | $sys_userid = $_SESSION['s']['user']['userid']; |
| | | $origin = $app->db->quote($vars['origin']); |
| | | $ns = $app->db->quote($vars['ns']); |
| | | $mbox = $app->db->quote(str_replace('@', '.', $vars['mbox'])); |
| | | $refresh = $app->db->quote($vars['refresh']); |
| | | $retry = $app->db->quote($vars['retry']); |
| | | $expire = $app->db->quote($vars['expire']); |
| | | $minimum = $app->db->quote($vars['minimum']); |
| | | $ttl = $app->db->quote($vars['ttl']); |
| | | $xfer = $app->db->quote($vars['xfer']); |
| | | $also_notify = $app->db->quote($vars['also_notify']); |
| | | $update_acl = $app->db->quote($vars['update_acl']); |
| | | $origin = $vars['origin']; |
| | | $ns = $vars['ns']; |
| | | $mbox = str_replace('@', '.', $vars['mbox']); |
| | | $refresh = $vars['refresh']; |
| | | $retry = $vars['retry']; |
| | | $expire = $vars['expire']; |
| | | $minimum = $vars['minimum']; |
| | | $ttl = $vars['ttl']; |
| | | $xfer = $vars['xfer']; |
| | | $also_notify = $vars['also_notify']; |
| | | $update_acl = $vars['update_acl']; |
| | | $serial = $app->validate_dns->increase_serial(0); |
| | | |
| | | $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`, `also_notify`, `update_acl`) VALUES |
| | | ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$origin', '$ns', '$mbox', '$serial', '$refresh', '$retry', '$expire', '$minimum', '$ttl', 'Y', '$xfer', '$also_notify', '$update_acl')"; |
| | | $insert_data = array( |
| | | "sys_userid" => $sys_userid, |
| | | "sys_groupid" => $sys_groupid, |
| | | "sys_perm_user" => 'riud', |
| | | "sys_perm_group" => 'riud', |
| | | "sys_perm_other" => '', |
| | | "server_id" => $server_id, |
| | | "origin" => $origin, |
| | | "ns" => $ns, |
| | | "mbox" => $mbox, |
| | | "serial" => $serial, |
| | | "refresh" => $refresh, |
| | | "retry" => $retry, |
| | | "expire" => $expire, |
| | | "minimum" => $minimum, |
| | | "ttl" => $ttl, |
| | | "active" => 'Y', |
| | | "xfer" => $xfer, |
| | | "also_notify" => $also_notify, |
| | | "update_acl" => $update_acl, |
| | | "dnssec_wanted" => $enable_dnssec |
| | | ); |
| | | $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); |
| | | |
| | | // Insert the dns_rr records |
| | | if(is_array($dns_rr) && $dns_soa_id > 0) { |
| | | foreach($dns_rr as $rr) { |
| | | $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES |
| | | ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$rr[name]', '$rr[type]', '$rr[data]', '$rr[aux]', '$rr[ttl]', 'Y')"; |
| | | $insert_data = array( |
| | | "sys_userid" => $sys_userid, |
| | | "sys_groupid" => $sys_groupid, |
| | | "sys_perm_user" => 'riud', |
| | | "sys_perm_group" => 'riud', |
| | | "sys_perm_other" => '', |
| | | "server_id" => $server_id, |
| | | "zone" => $dns_soa_id, |
| | | "name" => $rr['name'], |
| | | "type" => $rr['type'], |
| | | "data" => $rr['data'], |
| | | "aux" => $rr['aux'], |
| | | "ttl" => $rr['ttl'], |
| | | "active" => 'Y' |
| | | ); |
| | | $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); |
| | | } |
| | | } |
| | |
| | | |
| | | $app->tpl->setVar("title", 'DNS Wizard'); |
| | | |
| | | //* SET csrf token |
| | | $csrf_token = $app->auth->csrf_token_get('dns_wizard'); |
| | | $app->tpl->setVar('_csrf_id',$csrf_token['csrf_id']); |
| | | $app->tpl->setVar('_csrf_key',$csrf_token['csrf_key']); |
| | | |
| | | $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng'; |
| | | include $lng_file; |
| | | $app->tpl->setVar($wb); |