fix zonefile nameserver-entries when there are no nameservers given (use A/AAAA entries then)

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-05-03 10:45:27 +02:00
parent e0db240a3f
commit 55312a6df4

View File

@@ -186,10 +186,10 @@ class bind
while ($ip = $this->db->fetch_array($result_ip)) { while ($ip = $this->db->fetch_array($result_ip)) {
if (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { if (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$ip_a_records[] = "A $ip[ip]"; $ip_a_records[] = "A\t\t" . $ip['ip'];
} }
elseif (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { elseif (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$ip_a_records[] = "AAAA $ip[ip]"; $ip_a_records[] = "AAAA\t\t" . $ip['ip'];
} }
else { else {
return ";Error in at least one IP Adress (".$ip['ip']."), could not create zonefile!"; return ";Error in at least one IP Adress (".$ip['ip']."), could not create zonefile!";
@@ -198,7 +198,7 @@ class bind
$date = date('Ymd'); $date = date('Ymd');
$bindserial = (preg_match('/^' . $date . '/', $domain['bindserial']) ? $domain['bindserial'] + 1 : $date . '00'); $bindserial = (preg_match('/^' . $date . '/', $domain['bindserial']) ? $domain['bindserial'] + 1 : $date . '00');
$this->db->query('UPDATE `' . TABLE_PANEL_DOMAINS . '` SET `bindserial`=\'' . $bindserial . '\' WHERE `id`=\'' . $domain['id'] . '\''); $this->db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `bindserial`='" . $bindserial . "' WHERE `id`='" . $domain['id'] . "'");
$zonefile = '$TTL ' . (int)$this->settings['system']['defaultttl'] . "\n"; $zonefile = '$TTL ' . (int)$this->settings['system']['defaultttl'] . "\n";
if(count($this->nameservers) == 0) if(count($this->nameservers) == 0)
@@ -212,44 +212,34 @@ class bind
$zonefile.= ' ' . $bindserial . ' ; serial' . "\n" . ' 8H ; refresh' . "\n" . ' 2H ; retry' . "\n" . ' 1W ; expiry' . "\n" . ' 11h) ; minimum' . "\n"; $zonefile.= ' ' . $bindserial . ' ; serial' . "\n" . ' 8H ; refresh' . "\n" . ' 2H ; retry' . "\n" . ' 1W ; expiry' . "\n" . ' 11h) ; minimum' . "\n";
// FIXME What is this? there is no $ip_a_record at this stage // no nameservers given, use all if the A/AAAA entries
/* if (count($this->nameservers) == 0) {
if(count($this->nameservers) == 0) $zonefile .= '@ IN NS ns' . "\n";
{ foreach ($ip_a_records as $ip_a_record) {
$zonefile.= '@ IN NS ns' . "\n" . 'ns IN ' . $ip_a_record . "\n"; $zonefile .= 'ns IN ' . $ip_a_record . "\n";
}
else
{
*/
foreach($this->nameservers as $nameserver)
{
$zonefile.= '@ IN NS ' . trim($nameserver['hostname']) . "\n";
} }
//} } else {
foreach ($this->nameservers as $nameserver) {
$zonefile.= '@ IN NS ' . trim($nameserver['hostname']) . "\n";
}
}
if(count($this->mxservers) == 0) if (count($this->mxservers) == 0) {
{
$zonefile.= '@ IN MX 10 mail' . "\n"; $zonefile.= '@ IN MX 10 mail' . "\n";
$records[] = 'mail'; $records[] = 'mail';
if($domain['iswildcarddomain'] != '1') if ($domain['iswildcarddomain'] != '1') {
{
$records[] = 'imap'; $records[] = 'imap';
$records[] = 'smtp'; $records[] = 'smtp';
$records[] = 'pop3'; $records[] = 'pop3';
} }
} } else {
else foreach ($this->mxservers as $mxserver) {
{ $zonefile.= '@ IN MX ' . trim($mxserver) . "\n";
foreach($this->mxservers as $mxserver)
{
$zonefile.= '@ IN MX ' . trim($mxserver) . "\n";
} }
if($this->settings['system']['dns_createmailentry'] == '1') if ($this->settings['system']['dns_createmailentry'] == '1') {
{
$records[] = 'mail'; $records[] = 'mail';
if($domain['iswildcarddomain'] != '1') if ($domain['iswildcarddomain'] != '1') {
{
$records[] = 'imap'; $records[] = 'imap';
$records[] = 'smtp'; $records[] = 'smtp';
$records[] = 'pop3'; $records[] = 'pop3';
@@ -260,9 +250,9 @@ class bind
/* /*
* @TODO domain-based spf-settings * @TODO domain-based spf-settings
*/ */
if($this->settings['spf']['use_spf'] == '1' if ($this->settings['spf']['use_spf'] == '1'
/*&& $domain['spf'] == '1' */) /*&& $domain['spf'] == '1' */
{ ) {
$zonefile.= $this->settings['spf']['spf_entry'] . "\n"; $zonefile.= $this->settings['spf']['spf_entry'] . "\n";
} }