Skip to content

Commit 8ee1807

Browse files
committed
1 parent cb38082 commit 8ee1807

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

server/plugins-available/bind_plugin.inc.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,28 @@ function soa_update($event_name,$data) {
9090
$dns_config = $app->getconf->get_server_config($conf["server_id"], 'dns');
9191

9292
//* Write the domain file
93-
$tpl = new tpl();
94-
$tpl->newTemplate("bind_pri.domain.master");
95-
96-
$zone = $data['new'];
97-
$tpl->setVar($zone);
98-
99-
$records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
100-
$tpl->setLoop('zones',$records);
101-
102-
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
103-
$app->log("Writing BIND domain file: ".$filename,LOGLEVEL_DEBUG);
104-
file_put_contents($filename,$tpl->grab());
105-
exec('chown '.escapeshellcmd($dns_config['bind_user']).':'.escapeshellcmd($dns_config['bind_group']).' '.$filename);
106-
unset($tpl);
107-
unset($records);
108-
unset($zone);
93+
if(!empty($zone['id'])) {
94+
$tpl = new tpl();
95+
$tpl->newTemplate("bind_pri.domain.master");
96+
97+
$zone = $data['new'];
98+
$tpl->setVar($zone);
99+
100+
$records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
101+
$tpl->setLoop('zones',$records);
102+
103+
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
104+
$app->log("Writing BIND domain file: ".$filename,LOGLEVEL_DEBUG);
105+
file_put_contents($filename,$tpl->grab());
106+
exec('chown '.escapeshellcmd($dns_config['bind_user']).':'.escapeshellcmd($dns_config['bind_group']).' '.$filename);
107+
unset($tpl);
108+
unset($records);
109+
unset($zone);
110+
}
109111

110112
//* rebuild the named.conf file if the origin has changed or when the origin is inserted.
111113
//if($this->action == 'insert' || $data['old']['origin'] != $data['new']['origin']) {
112-
$this->write_named_conf($data,$dns_config);
114+
$this->write_named_conf($data,$dns_config);
113115
//}
114116

115117
//* Delete old domain file, if domain name has been changed

0 commit comments

Comments
 (0)