@@ -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