Skip to content

Commit 7011347

Browse files
committed
Merge branch 'stable-3.1' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.1
2 parents 925b12d + 5a5dc30 commit 7011347

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+205
-20
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ stages:
88

99
syntax:lint:
1010
stage: syntax
11-
image: bobey/docker-gitlab-ci-runner-php7
11+
image: edbizarro/gitlab-ci-pipeline-php:7.2
1212
allow_failure: false
1313
only:
1414
- schedules

interface/web/dns/dns_spf_edit.php

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,16 @@ function onShowNew() {
7272
}
7373

7474
function onShowEnd() {
75-
global $app, $conf;
75+
global $app;
76+
77+
$id = $app->functions->intval($_GET['id']);
7678

77-
$zone = $app->functions->intval($_GET['zone']);
79+
// if there is no existing SPF record, assume we want a new active record
80+
$app->tpl->setVar('active', 'CHECKED');
7881

7982
//* check for an existing spf-record
80-
$sql = "SELECT data, active FROM dns_rr WHERE data LIKE 'v=spf1%' AND zone = ? AND " . $app->tform->getAuthSQL('r');
81-
$rec = $app->db->queryOneRecord($sql, $zone);
83+
$sql = "SELECT data, active FROM dns_rr WHERE id = ? AND " . $app->tform->getAuthSQL('r');
84+
$rec = $app->db->queryOneRecord($sql, $id);
8285
if ( isset($rec) && !empty($rec) ) {
8386
$this->id = 1;
8487
$old_data = strtolower($rec['data']);
@@ -132,7 +135,6 @@ function onShowEnd() {
132135
function onSubmit() {
133136
global $app, $conf;
134137

135-
136138
// Get the parent soa record of the domain
137139
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $app->tform->getAuthSQL('r'), $app->functions->intval($_POST["zone"]));
138140

@@ -153,8 +155,27 @@ function onSubmit() {
153155
}
154156
}
155157
} // end if user is not admin
158+
159+
// Check that the record does not yet exist
160+
$existing_records = $app->db->queryAllRecords("SELECT id FROM dns_rr WHERE id != ? AND zone = ? AND name = ? AND type = 'TXT'", $this->dataRecord['id'], $_POST['zone'], $_POST['name']);
161+
if (!empty($existing_records)) {
162+
if (count($existing_records) > 1) {
163+
$multiple_existing_records_error_txt = $app->tform->wordbook['spf_record_exists_multiple_txt'];
164+
$multiple_existing_records_error_txt = str_replace('{hostname}', $_POST['name'], $multiple_existing_records_error_txt);
165+
166+
$app->error($multiple_existing_records_error_txt);
167+
}
156168

157-
//create spf-record
169+
$existing_record = array_pop($existing_records);
170+
171+
$existing_record_error_txt = $app->tform->wordbook['spf_record_exists_txt'];
172+
$existing_record_error_txt = str_replace('{hostname}', $_POST['name'], $existing_record_error_txt);
173+
$existing_record_error_txt = str_replace('{existing_record_id}', $existing_record['id'], $existing_record_error_txt);
174+
175+
$app->error($existing_record_error_txt);
176+
}
177+
178+
// Create spf-record
158179
if (!empty($this->dataRecord['spf_mx'])) {
159180
$spf_record[] = 'mx';
160181
}
@@ -217,7 +238,6 @@ function onSubmit() {
217238
else $this->dataRecord['data'] = 'v=spf1 ' . $this->dataRecord['spf_mechanism'] . 'all';
218239
unset($temp);
219240

220-
$this->dataRecord['name'] = $soa['origin'];
221241
if (isset($this->dataRecord['active'])) $this->dataRecord['active'] = 'Y';
222242

223243
// Set the server ID of the rr record to the same server ID as the parent record.
@@ -228,10 +248,6 @@ function onSubmit() {
228248
$this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]);
229249
$this->dataRecord["stamp"] = date('Y-m-d H:i:s');
230250

231-
// always update an existing entry
232-
$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']);
233-
$this->id = $check['id'];
234-
235251
if (!isset($this->dataRecord['active'])) $this->dataRecord['active'] = 'N';
236252

237253
parent::onSubmit();

interface/web/dns/dns_txt_edit.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,22 @@
4444

4545
// Loading classes
4646
class page_action extends dns_page_action {
47+
function onLoad() {
48+
parent::onLoad();
49+
50+
// The SPF wizard has a button to edit a record as TXT. We need this to prevent a redirect loop.
51+
if (!empty($_GET['edit_raw'])) {
52+
return;
53+
}
4754

55+
// Redirect to SPF wizard if we detect a SPF record
56+
if (!empty($this->dataRecord['data'])) {
57+
if ('v=spf1' === mb_substr($this->dataRecord['data'], 0, 6)) {
58+
header(sprintf('Location: dns_spf_edit.php?id=%d', $this->dataRecord['id']));
59+
exit;
60+
}
61+
}
62+
}
4863
}
4964

5065
$page = new page_action;

interface/web/dns/form/dns_spf.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
'type' => 'TOLOWER')
8787
),
8888
'validators' => array ( 0 => array ( 'type' => 'REGEX',
89-
'regex' => '/^[a-zA-Z0-9\.\-\_]{0,255}$/',
89+
'regex' => '/^(\*\.|[a-zA-Z0-9\.\-\_]){0,255}$/',
9090
'errmsg'=> 'name_error_regex'),
9191
),
9292
'default' => '',

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
$wb['data_txt'] = 'SPF-Record';
3+
$wb['name_txt'] = 'Hostname';
34
$wb['spf_mechanism_txt'] = 'SPF Mechanism';
45
$wb['spf_mechanism_pass_txt'] = 'Pass - allow mail from other senders';
56
$wb['spf_mechanism_fail_txt'] = 'Fail - reject mail from other senders';
@@ -19,7 +20,10 @@ $wb['spf_invalid_domain_txt'] = 'Invalid domainname';
1920
$wb['ttl_txt'] = 'TTL';
2021
$wb['active_txt'] = 'Active';
2122
$wb['record_exists_txt'] = 'DNS-Record already exists';
23+
$wb['spf_record_exists_txt'] = 'SPF-Record already exists for hostname "{hostname}". Do you want to <a href="#" data-load-content="dns/dns_spf_edit.php?id={existing_record_id}">edit the existing record</a>?';
24+
$wb['spf_record_exists_multiple_txt'] = 'Multiple SPF-Records exist for hostname "{hostname}". This will cause recipients to reject your mail! Delete or merge duplicate existing records and try again.';
2225
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
2326
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
2427
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
28+
$wb['btn_edit_as_txt_record_txt'] = 'Edit as TXT record';
2529
?>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
$wb['data_txt'] = 'SPF-Record';
3+
$wb['name_txt'] = 'Hostname';
34
$wb['spf_mechanism_txt'] = 'SPF Mechanism';
45
$wb['spf_mechanism_pass_txt'] = 'Pass - allow mail from other senders';
56
$wb['spf_mechanism_fail_txt'] = 'Fail - reject mail from other senders';
@@ -19,7 +20,10 @@ $wb['spf_invalid_domain_txt'] = 'Invalid domainname';
1920
$wb['ttl_txt'] = 'TTL';
2021
$wb['active_txt'] = 'Active';
2122
$wb['record_exists_txt'] = 'DNS-Record already exists';
23+
$wb['spf_record_exists_txt'] = 'SPF-Record already exists for hostname "{hostname}". Do you want to <a href="#" data-load-content="dns/dns_spf_edit.php?id={existing_record_id}">edit the existing record</a>?';
24+
$wb['spf_record_exists_multiple_txt'] = 'Multiple SPF-Records exist for hostname "{hostname}". This will cause recipients to reject your mail! Delete or merge duplicate existing records and try again.';
2225
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
2326
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
2427
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
28+
$wb['btn_edit_as_txt_record_txt'] = 'Edit as TXT record';
2529
?>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
$wb['data_txt'] = 'Registro SPF';
3+
$wb['name_txt'] = 'Hostname';
34
$wb['spf_mechanism_txt'] = 'Mecanismo SPF';
45
$wb['spf_mechanism_pass_txt'] = 'Pass - permitir e-mails de outros remetentes';
56
$wb['spf_mechanism_fail_txt'] = 'Fail - rejeitar e-mails de outros remetentes';
@@ -19,7 +20,10 @@ $wb['spf_invalid_domain_txt'] = 'O domínio é inválido.';
1920
$wb['ttl_txt'] = 'TTL';
2021
$wb['active_txt'] = 'Ativo';
2122
$wb['record_exists_txt'] = 'Registro dns já existe.';
23+
$wb['spf_record_exists_txt'] = 'SPF-Record already exists for hostname "{hostname}". Do you want to <a href="#" data-load-content="dns/dns_spf_edit.php?id={existing_record_id}">edit the existing record</a>?';
24+
$wb['spf_record_exists_multiple_txt'] = 'Multiple SPF-Records exist for hostname "{hostname}". This will cause recipients to reject your mail! Delete or merge duplicate existing records and try again.';
2225
$wb['limit_dns_record_txt'] = 'O limite de registros dns para esta conta foi alcançado.';
2326
$wb['no_zone_perm'] = 'Você não tem permissão para adicionar registros dns nesta zona.';
2427
$wb['ttl_range_error'] = 'O TTL mínimo são 60 segundos.';
28+
$wb['btn_edit_as_txt_record_txt'] = 'Edit as TXT record';
2529
?>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
$wb['data_txt'] = 'SPF-Record';
3+
$wb['name_txt'] = 'Hostname';
34
$wb['spf_mechanism_txt'] = 'SPF Mechanism';
45
$wb['spf_mechanism_pass_txt'] = 'Pass - allow mail from other senders';
56
$wb['spf_mechanism_fail_txt'] = 'Fail - reject mail from other senders';
@@ -19,7 +20,10 @@ $wb['spf_invalid_domain_txt'] = 'Invalid domainname';
1920
$wb['ttl_txt'] = 'TTL';
2021
$wb['active_txt'] = 'Active';
2122
$wb['record_exists_txt'] = 'DNS-Record already exists';
23+
$wb['spf_record_exists_txt'] = 'SPF-Record already exists for hostname "{hostname}". Do you want to <a href="#" data-load-content="dns/dns_spf_edit.php?id={existing_record_id}">edit the existing record</a>?';
24+
$wb['spf_record_exists_multiple_txt'] = 'Multiple SPF-Records exist for hostname "{hostname}". This will cause recipients to reject your mail! Delete or merge duplicate existing records and try again.';
2225
$wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.';
2326
$wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.';
2427
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
28+
$wb['btn_edit_as_txt_record_txt'] = 'Edit as TXT record';
2529
?>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
$wb['data_txt'] = 'SPF Záznam';
3+
$wb['name_txt'] = 'Hostname';
34
$wb['spf_mechanism_txt'] = 'SPF Mechanismus';
45
$wb['spf_mechanism_pass_txt'] = 'Přijmout - přijímat e-mail od ostatních odesílatelů';
56
$wb['spf_mechanism_fail_txt'] = 'Odmítat - odmítnout e-mail od ostatních odesílatelů';
@@ -19,7 +20,10 @@ $wb['spf_invalid_domain_txt'] = 'Neplatné doménové jméno';
1920
$wb['ttl_txt'] = 'TTL';
2021
$wb['active_txt'] = 'Aktivní';
2122
$wb['record_exists_txt'] = 'DNS záznam již existuje';
23+
$wb['spf_record_exists_txt'] = 'SPF-Record already exists for hostname "{hostname}". Do you want to <a href="#" data-load-content="dns/dns_spf_edit.php?id={existing_record_id}">edit the existing record</a>?';
24+
$wb['spf_record_exists_multiple_txt'] = 'Multiple SPF-Records exist for hostname "{hostname}". This will cause recipients to reject your mail! Delete or merge duplicate existing records and try again.';
2225
$wb['limit_dns_record_txt'] = 'Byl dosažen max. počet DNS záznamů pro váš účet.';
2326
$wb['no_zone_perm'] = 'Nemáte oprávnění přidat záznam do této zóny DNS.';
2427
$wb['ttl_range_error'] = 'Min. TTL doba je 60 sekund.';
28+
$wb['btn_edit_as_txt_record_txt'] = 'Edit as TXT record';
2529
?>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
$wb['data_txt'] = 'SPF Record';
3+
$wb['name_txt'] = 'Hostname';
34
$wb['spf_mechanism_txt'] = 'SPF Mechanismus';
45
$wb['spf_mechanism_pass_txt'] = 'Pass - Mails von anderen Sendern zulassen';
56
$wb['spf_mechanism_fail_txt'] = 'Fail - Mails von anderen Sendern abweisen';
@@ -19,7 +20,10 @@ $wb['spf_invalid_domain_txt'] = 'Ungültiger Domainname';
1920
$wb['ttl_txt'] = 'TTL';
2021
$wb['active_txt'] = 'Aktiv';
2122
$wb['record_exists_txt'] = 'DNS-Eintrag existiert bereits';
23+
$wb['spf_record_exists_txt'] = 'SPF-Record already exists for hostname "{hostname}". Do you want to <a href="#" data-load-content="dns/dns_spf_edit.php?id={existing_record_id}">edit the existing record</a>?';
24+
$wb['spf_record_exists_multiple_txt'] = 'Multiple SPF-Records exist for hostname "{hostname}". This will cause recipients to reject your mail! Delete or merge duplicate existing records and try again.';
2225
$wb['ttl_range_error'] = 'Min. TTL time ist 60 Sekunden.';
2326
$wb['limit_dns_record_txt'] = 'Die maximale Anzahl an DNS Einträgen für Ihr Konto wurde erreicht.';
2427
$wb['no_zone_perm'] = 'Sie haben nicht die Berechtigung, einen Eintrag zu dieser DNS Zone hinzuzufügen.';
28+
$wb['btn_edit_as_txt_record_txt'] = 'Edit as TXT record';
2529
?>

0 commit comments

Comments
 (0)