Skip to content

Commit dd1a335

Browse files
committed
allow dkim-records if there is no maildomain (#4626)
1 parent fcc522b commit dd1a335

27 files changed

+112
-45
lines changed

interface/web/dns/dns_dkim_edit.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,26 @@ function onShowNew() {
7272
parent::onShowNew();
7373

7474
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $app->tform->getAuthSQL('r'), $_GET['zone']);
75-
$sql=$app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND " . $app->tform->getAuthSQL('r'), substr_replace($soa['origin'],'',-1));
76-
$public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$sql['dkim_public']);
77-
$app->tpl->setVar('public_key', $public_key);
78-
$app->tpl->setVar('selector', $sql['dkim_selector']);
75+
$sql=$app->db->queryOneRecord("SELECT domain, dkim_public, dkim_selector, dkim FROM mail_domain WHERE domain = ? AND " . $app->tform->getAuthSQL('r'), substr_replace($soa['origin'],'',-1));
76+
if(isset($sql['domain']) && $sql['domain'] != '') {
77+
if($sql['dkim'] == 'y') {
78+
$public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$sql['dkim_public']);
79+
$app->tpl->setVar('public_key', $public_key);
80+
$app->tpl->setVar('selector', $sql['dkim_selector']);
81+
} else {
82+
//TODO: show warning - use mail_domain for dkim and enabled dkim
83+
}
84+
$app->tpl->setVar('edit_disabled', 1);
85+
} else {
86+
$app->tpl->setVar('edit_disabled', 0);
87+
}
7988
$app->tpl->setVar('name', $soa['origin']);
8089

8190
}
8291

8392
function onSubmit() {
8493
global $app, $conf;
94+
8595
// Get the parent soa record of the domain
8696
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $app->tform->getAuthSQL('r'), $_POST["zone"]);
8797
// Check if Domain belongs to user
@@ -110,15 +120,20 @@ function onSubmit() {
110120
$this->dataRecord['name']=$this->dataRecord['selector'].'._domainkey.'.$this->dataRecord['name'];
111121
$this->dataRecord['ttl']=60;
112122
}
113-
// Update the serial number and timestamp of the RR record
114-
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ?", $this->id);
115-
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
116-
$this->dataRecord["stamp"] = date('Y-m-d H:i:s');
117-
118-
// check for duplicate entry
119-
$check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND type = ? AND data = ? AND name = ?", $this->dataRecord["zone"], $this->dataRecord["type"], $this->dataRecord["data"], $this->dataRecord['name']);
120-
if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"];
121-
if (empty($this->dataRecord['data'])) $app->tform->errorMessage .= $app->tform->wordbook["dkim_disabled_txt"];
123+
// Update the serial number and timestamp of the RR record
124+
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ?", $this->id);
125+
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
126+
$this->dataRecord["stamp"] = date('Y-m-d H:i:s');
127+
128+
// check for duplicate entry
129+
$check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND type = ? AND data = ? AND name = ?", $this->dataRecord["zone"], $this->dataRecord["type"], $this->dataRecord["data"], $this->dataRecord['name']);
130+
if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"];
131+
if (empty($this->dataRecord['data'])) $app->tform->errorMessage /= $app->tform->wordbook["dkim_disabled_txt"];
132+
133+
// validate selector and public-key
134+
if (empty($this->dataRecord['selector'])) $app->tform->errorMessage .= '<br/>'.$app->tform->wordbook["dkim_selector_empty_txt"].'<br/>';
135+
$this->dataRecord['data']=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$this->dataRecord['data']); // if the users entered his own key
136+
122137
parent::onSubmit();
123138
}
124139

interface/web/dns/lib/lang/ar_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account i
88
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/bg_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account i
88
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/br_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'O limite de registros dns para esta conta foi alc
88
$wb['no_zone_perm'] = 'Você não tem permissão para adicionar registros a esta zona dns.';
99
$wb['ttl_range_error'] = 'O ttl mínimo são 60 segundos.';
1010
$wb['selector_txt'] = 'Seletor DKIM';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/ca_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account i
88
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/cz_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'Byl dosažen max. počet DNS záznamů pro váš
88
$wb['no_zone_perm'] = 'Nemáte povolení k přidat záznam do této zóny DNS.';
99
$wb['ttl_range_error'] = 'Min. TTL doba je 60 sekund.';
1010
$wb['selector_txt'] = 'DKIM selektor';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/de_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'Die max. Anzahl von DNS Eintraegen für den Accou
88
$wb['no_zone_perm'] = 'Fehlende Berechtigung zum Hinzufuegen eines Eintrags zur DNS-Zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time ist 60 Sekunden.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'öffentlicher Schlüssel fehlt';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector darf nicht leer sein';
1113
?>

interface/web/dns/lib/lang/dk_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account i
88
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/el_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account i
88
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

interface/web/dns/lib/lang/en_dns_dkim.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ $wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account i
88
$wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.';
99
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
1010
$wb['selector_txt'] = 'DKIM-Selector';
11+
$wb['data_error_empty'] = 'Public-Key missing';
12+
$wb['dkim_selector_empty_txt'] = 'DKIM-Selector is empty';
1113
?>

0 commit comments

Comments
 (0)