Commit 24625933 authored by Marius Cramer's avatar Marius Cramer
Browse files

Merge branch 'master' into 'master'

Master

See merge request !158
parents 1302aa50 610315b8
......@@ -108,6 +108,7 @@ class page_action extends tform_actions {
if (!empty($this->dataRecord['data'])) {
$this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data'];
$this->dataRecord['name']=$this->dataRecord['selector'].'._domainkey.'.$this->dataRecord['name'];
$this->dataRecord['ttl']=60;
}
// Update the serial number and timestamp of the RR record
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ?", $this->id);
......
......@@ -227,14 +227,14 @@ class page_action extends tform_actions {
$domain_name = rtrim($soa['origin'], '.');
// DMARC requieres at least one active dkim-record...
$sql = "SELECT * FROM dns_rr WHERE name LIKE ? AND type='TXT' AND data like 'v=DKIM1;%' AND active='Y'";
$temp = $app->db->queryAllRecords($sql, '%._domainkey.$domain_name'.'.');
if (!is_array($temp)) {
$temp = $app->db->queryAllRecords($sql, '%._domainkey.'.$domain_name.'.');
if (empty($temp)) {
if (isset($app->tform->errorMessage )) $app->tform->errorMessage = '<br/>' . $app->tform->errorMessage;
$app->tform->errorMessage .= $app->tform->wordbook['dmarc_no_dkim_txt'].$email;
}
// ... and an active spf-record (this breaks the current draft but DMARC is useless if you use DKIM or SPF
$sql = "SELECT * FROM dns_rr WHERE name LIKE ? AND type='TXT' AND (data LIKE 'v=spf1;%' AND active = 'y')";
$sql = "SELECT * FROM dns_rr WHERE name LIKE ? AND type='TXT' AND (data LIKE 'v=spf1%' AND active = 'y')";
$temp = $app->db->queryAllRecords($sql, $domain_name.'.');
// abort if more than 1 active spf-records (backward-compatibility)
if (is_array($temp[1])) {
......
......@@ -229,7 +229,7 @@ class page_action extends tform_actions {
$this->dataRecord["stamp"] = date('Y-m-d H:i:s');
// always update an existing entry
$check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND type = ? AND data LIKE 'v=spf1%' AND name = ?", $this->dataRecord["zone"], $this->dataRecord["type"], $this->dataRecord['name'].'.');
$check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND type = ? AND data LIKE 'v=spf1%' AND name = ?", $this->dataRecord["zone"], $this->dataRecord["type"], $this->dataRecord['name']);
$this->id = $check['id'];
if (!isset($this->dataRecord['active'])) $this->dataRecord['active'] = 'N';
......
......@@ -170,6 +170,10 @@ $form["tabs"]['dns'] = array (
)
);
if($_SESSION["s"]["user"]["typ"] == 'admin') {
unset($form["tabs"]['dns']['fields']['data']['validators']);
$form["tabs"]['dns']['fields']['data']['validators'][0]['type'] = 'NOTEMPTY';
$form["tabs"]['dns']['fields']['data']['validators'][0]['errmsg'] = 'data_error_empty';
$form["tabs"]['dns']['fields']['data']['maxlength'] = 512;
}
?>
<div class='page-header'>
<h1><tmpl_var name="list_head_txt"></h1>
</div>
<p><tmpl_var name="list_desc_txt"></p>
<div class="form-group">
<label for="data" class="col-sm-3 control-label">{tmpl_var name='data_txt'}</label>
<div class="col-sm-9"><input type="text" name="data" id="data" value="{tmpl_var name='data'}" readonly class="form-control" /></div></div>
<div class="form-group">
<label for="spf_mechanism" class="col-sm-3 control-label">{tmpl_var name='spf_mechanism_txt'}</label>
<div class="col-sm-9"><select name="spf_mechanism" id="spf_mechanism" class="form-control">
{tmpl_var name='spf_mechanism'}
</select></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='spf_mx_txt'}</label>
<div class="col-sm-9"><input class="form-control" type="checkbox" value="1" id="spf_mx" name="spf_mx" {tmpl_var name = 'spf_mx_active'} /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='spf_a_txt'}</label>
<div class="col-sm-9"><input class="form-control" type="checkbox" value="1" id="spf_a" name="spf_a" {tmpl_var name = 'spf_a_active'} /></div>
</div>
<div class="form-group">
<label for="spf_ip" class="col-sm-3 control-label">{tmpl_var name='spf_ip_txt'}</label>
<div class="col-sm-6"><input type="text" name="spf_ip" id="spf_ip" value="{tmpl_var name='spf_ip'}" class="form-control" /></div><div class="col-sm-3 input-sm">
{tmpl_var name='spf_ip_note_txt'}
</div></div>
<div class="form-group">
<label for="spf_hostname" class="col-sm-3 control-label">{tmpl_var name='spf_hostname_txt'}</label>
<div class="col-sm-6"><input type="text" name="spf_hostname" id="spf_hostname" value="{tmpl_var name='spf_hostname'}" class="form-control" /></div><div class="col-sm-3 input-sm">
{tmpl_var name='spf_hostname_note_txt'}
</div></div>
<div class="form-group">
<label for="spf_domain" class="col-sm-3 control-label">{tmpl_var name='spf_domain_txt'}</label>
<div class="col-sm-6"><input type="text" name="spf_domain" id="spf_domain" value="{tmpl_var name='spf_domain'}" class="form-control" /></div><div class="col-sm-3 input-sm">
{tmpl_var name='spf_domain_note_txt'}
</div></div>
<div class="form-group">
<label for="ttl" class="col-sm-3 control-label">{tmpl_var name='ttl_txt'}</label>
<div class="col-sm-9"><input type="text" name="ttl" id="ttl" value="{tmpl_var name='ttl'}" class="form-control" /></div></div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='active_txt'}</label>
<div class="col-sm-9"><input class="form-control" type="checkbox" value="1" id="active" name="active" {tmpl_var name='active'} /></div>
</div>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<input type="hidden" name="zone" value="{tmpl_var name='zone'}" id="zone">
<input type="hidden" name="type" value="{tmpl_var name='type'}">
<input type="hidden" name="name" value="{tmpl_var name='name'}">
</div>
<div class="clear"><div class="right">
<button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="dns/dns_spf_edit.php">{tmpl_var name='btn_save_txt'}</button>
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="dns/dns_soa_edit.php?id={tmpl_var name='zone'}">{tmpl_var name='btn_cancel_txt'}</button>
</div></div>
......@@ -296,6 +296,12 @@ class page_action extends tform_actions {
}
} // endif spamfilter policy
//* create dns-record with dkim-values if the zone exists
if ( $this->dataRecord['active'] == 'y' && $this->dataRecord['dkim'] == 'y' ) {
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $this->dataRecord['domain'].'.');
if ( isset($soa) && !empty($soa) ) $this->update_dns($this->dataRecord, $soa);
}
}
function onBeforeUpdate() {
......@@ -407,17 +413,17 @@ class page_action extends tform_actions {
$selector = @($this->dataRecord['dkim_selector'] != $this->oldDataRecord['dkim_selector']) ? true : false;
$dkim_private = @($this->dataRecord['dkim_private'] != $this->oldDataRecord['dkim_private']) ? true : false;
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $this->dataRecord['domain']);
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $this->dataRecord['domain'].'.');
if ( ($selector || $dkim_private || $dkim_active) && $dkim_active )
//* create a new record only if the dns-zone exists
if ( isset($soa) && !empty($soa) ) {
$this->update_dns($this->dataRecord, $soa);
}
elseif ( !isset($this->dataRecord['dkim']) ) {
if (! $dkim_active) {
// updated existing dmarc-record to policy 'none'
$sql = "SELECT * from dns_rr WHERE name ='_dmarc.?.' AND data LIKE 'v=DMARC1%' AND ?";
$rec = $app->db->queryOneRecord($sql, $this->dataRecord['domain'], $app->tform->getAuthSQL('r'));
$sql = "SELECT * from dns_rr WHERE name = ? AND data LIKE 'v=DMARC1%' AND ?";
$rec = $app->db->queryOneRecord($sql, '_dmarc.'.$this->dataRecord['domain'].'.', $app->tform->getAuthSQL('r'));
if (is_array($rec))
if (strpos($rec['data'], 'p=none=') === false) {
$rec['data'] = str_replace(array('quarantine', 'reject'), 'none', $rec['data']);
......@@ -435,15 +441,15 @@ class page_action extends tform_actions {
global $app, $conf;
// purge old rr-record(s)
$sql = "SELECT * FROM dns_rr WHERE name LIKE '%._domainkey.?.' AND data LIKE 'v=DKIM1%' AND ? ORDER BY serial DESC";
$rec = $app->db->queryAllRecords($sql, $dataRecord['domain'], $app->tform->getAuthSQL('r'));
$sql = "SELECT * FROM dns_rr WHERE name LIKE ? AND data LIKE 'v=DKIM1%' AND ? ORDER BY serial DESC";
$rec = $app->db->queryAllRecords($sql, '%._domainkey.'.$dataRecord['domain'].'.', $app->tform->getAuthSQL('r'));
if (is_array($rec[1])) {
for ($i=1; $i < count($rec); ++$i)
$app->db->datalogDelete('dns_rr', 'id', $rec[$i]['id']);
}
// also delete a dsn-records with same selector
$sql = "SELECT * from dns_rr WHERE name ='?._domainkey.?.' AND data LIKE 'v=DKIM1%' AND ?";
$rec = $app->db->queryAllRecords($sql, $dataRecord['dkim_selector'], $dataRecord['domain'], $app->tform->getAuthSQL('r'));
$sql = "SELECT * from dns_rr WHERE name ? AND data LIKE 'v=DKIM1%' AND ?";
$rec = $app->db->queryAllRecords($sql, '.._domainkey.'.$dataRecord['dkim_selector'].'.', $dataRecord['domain'], $app->tform->getAuthSQL('r'));
if (is_array($rec))
foreach ($rec as $del)
$app->db->datalogDelete('dns_rr', 'id', $del['id']);
......@@ -456,7 +462,7 @@ class page_action extends tform_actions {
$new_rr['stamp'] = date('Y-m-d H:i:s');
$new_rr['serial'] = $app->validate_dns->increase_serial($new_rr['serial']);
$app->db->datalogInsert('dns_rr', $new_rr, 'id', $new_rr['zone']);
$zone = $app->db->queryOneRecord("SELECT id, serial FROM dns_soa WHERE active = 'Y' AND id = ".$app->functions->intval($new_rr['zone']));
$zone = $app->db->queryOneRecord("SELECT id, serial FROM dns_soa WHERE active = 'Y' AND id = ?", $new_rr['zone']);
$new_serial = $app->validate_dns->increase_serial($zone['serial']);
$app->db->datalogUpdate('dns_soa', "serial = '".$new_serial."'", 'id', $zone['id']);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment