Skip to content

Commit 76be2b7

Browse files
author
Florian Schaal
committed
fixed mail_plugin_dkim.inc.php and add dkim-selector to dns
1 parent 69f5c9a commit 76be2b7

25 files changed

+41
-26
lines changed

interface/web/dns/dns_dkim_edit.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ function onSubmit() {
9797
$this->dataRecord["server_id"] = $soa["server_id"];
9898

9999
// add dkim-settings to the public-key in the txt-record
100-
if (!empty($this->dataRecord['data'])) $this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data'];
101-
$this->dataRecord['name']='default._domainkey.'.$this->dataRecord['name'];
102-
100+
if (!empty($this->dataRecord['data'])) {
101+
$this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data'];
102+
$this->dataRecord['name']=$this->dataRecord['selector'].'._domainkey.'.$this->dataRecord['name'];
103+
}
103104
// Update the serial number and timestamp of the RR record
104105
$soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ?", $this->id);
105106
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
@@ -109,6 +110,7 @@ function onSubmit() {
109110
$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']);
110111
if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"];
111112
if (empty($this->dataRecord['data'])) $app->tform->errorMessage .= $app->tform->wordbook["dkim_disabled_txt"];
113+
112114
parent::onSubmit();
113115
}
114116

interface/web/dns/dns_dkim_get.php

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,20 @@ function getRealPOST() {
6767
return $vars;
6868
}
6969

70-
/**
71-
* This function formats the public-key
72-
* @param array $pubkey
73-
* @return string public-key
74-
*/
75-
function pub_key($pubkey) {
76-
$public_key='';
77-
foreach($pubkey as $values) $public_key=$public_key.$values;
78-
return $public_key;
79-
}
80-
8170
$_POST=getRealPost();
8271

8372
if (ctype_digit($_POST['zone'])) {
8473
// Get the parent soa record of the domain
85-
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND ".$app->tform->getAuthSQL('r'), $_POST['zone']);
86-
87-
$public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = ? AND dkim = 'Y' AND ".$app->tform->getAuthSQL('r'), substr_replace($soa['origin'],'',-1));
88-
89-
$public_key=pub_key($public_key);
74+
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? and ?'", $app->db->quote($_POST['zone']), $app->tform->getAuthSQL('r'));
9075

91-
$public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$public_key);
76+
$sql=$app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'Y' AND ?", substr_replace($soa['origin'],'',-1), $app->tform->getAuthSQL('r'));
77+
$public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$sql['dkim_public']);
9278

9379
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
9480
echo "<formatname>\n";
9581
echo "<data>".$public_key."</data>\n";
9682
echo "<name>".$soa['origin']."</name>\n";
83+
echo "<selector>".$sql['dkim_selector']."</selector>\n";
9784
echo "</formatname>\n";
9885
}
9986
?>

interface/web/dns/dns_wizard.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,12 @@
245245
if($_POST['ns2'] != '') $tpl_content = str_replace('{NS2}', $_POST['ns2'], $tpl_content);
246246
if($_POST['email'] != '') $tpl_content = str_replace('{EMAIL}', $_POST['email'], $tpl_content);
247247
if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/', $_POST['domain'])) {
248-
$public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $_POST['domain']);
248+
$sql = $app->db->queryOneRecord("SELECT dkim_public, dkim_selecotr FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $_POST['domain']);
249+
$public_key = $sql['dkim_public'];
249250
if ($public_key!='') {
250-
$dns_record=str_replace(array("\r\n", "\n", "\r", "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"), '', $public_key['dkim_public']);
251-
$tpl_content .= "\n".'TXT|default._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record;
251+
if (empty($sql['dkim_selector'])) $sql['dkim_selector'] = 'default';
252+
$dns_record=str_replace(array("\r\n", "\n", "\r", "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"), '', $public_key);
253+
$tpl_content .= "\n".'TXT|'.$sql['dkim_selector'].'._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record;
252254
}
253255
}
254256

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain';
77
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain';
77
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain';
77
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain';
77
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb["dkim_disabled_txt"] = 'DKIM st fuer diese Domain nicht aktiv.';
77
$wb["limit_dns_record_txt"] = 'Die max. Anzahl von DNS Eintraegen fuer den Account ist erreicht.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb["dkim_disabled_txt"] = 'DKIM disabled for this mail-domain';
77
$wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain';
77
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
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.';
10+
$wb['selector_txt'] = 'DKIM-Selector';
1011
?>

0 commit comments

Comments
 (0)