@@ -99,13 +99,15 @@ function soa_update($event_name,$data) {
9999
100100 $ records = $ app ->db ->queryAllRecords ("SELECT * FROM dns_rr WHERE zone = " .$ zone ['id ' ]." AND active = 'Y' " );
101101 $ tpl ->setLoop ('zones ' ,$ records );
102+
102103
103104 $ filename = escapeshellcmd ($ dns_config ['bind_zonefiles_dir ' ].'/pri. ' .substr ($ zone ['origin ' ],0 ,-1 ));
104105 $ app ->log ("Writing BIND domain file: " .$ filename ,LOGLEVEL_DEBUG );
105106 file_put_contents ($ filename ,$ tpl ->grab ());
106107 exec ('chown ' .escapeshellcmd ($ dns_config ['bind_user ' ]).': ' .escapeshellcmd ($ dns_config ['bind_group ' ]).' ' .$ filename );
107108 unset($ tpl );
108109 unset($ records );
110+ unset($ records_out );
109111 unset($ zone );
110112 }
111113
@@ -136,9 +138,9 @@ function soa_delete($event_name,$data) {
136138 $ this ->write_named_conf ($ data ,$ dns_config );
137139
138140 //* Delete the domain file
139- $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/pri. ' .substr ($ data ['old ' ]['origin ' ],0 ,-1 );
140- if (is_file ($ filename )) unset( $ filename );
141- $ app ->log ("Deleting BIND domain file: " .$ filename ,LOGLEVEL_DEBUG );
141+ $ zone_file_name = $ dns_config ['bind_zonefiles_dir ' ].'/pri. ' .substr ($ data ['old ' ]['origin ' ],0 ,-1 );
142+ if (is_file ($ zone_file_name )) unlink ( $ zone_file_name );
143+ $ app ->log ("Deleting BIND domain file: " .$ zone_file_name ,LOGLEVEL_DEBUG );
142144
143145 //* Reload bind nameserver
144146 $ app ->services ->restartServiceDelayed ('bind ' ,'reload ' );
@@ -186,11 +188,18 @@ function rr_delete($event_name,$data) {
186188 function write_named_conf ($ data , $ dns_config ) {
187189 global $ app , $ conf ;
188190
189- $ tmps = $ app ->db ->queryAllRecords ("SELECT origin FROM dns_soa WHERE active = 'Y' " );
191+ $ tmps = $ app ->db ->queryAllRecords ("SELECT origin, xfer, also_notify FROM dns_soa WHERE active = 'Y' " );
190192 $ zones = array ();
193+
191194 foreach ($ tmps as $ tmp ) {
195+
196+ $ options = '' ;
197+ if (trim ($ tmp ['xfer ' ]) != '' ) $ options .= ' allow-transfer { ' .str_replace (', ' ,'; ' ,$ tmp ['xfer ' ]).";}; \n" ;
198+ if (trim ($ tmp ['also_notify ' ]) != '' ) $ options .= ' also-notify { ' .str_replace (', ' ,'; ' ,$ tmp ['also_notify ' ]).";}; \n" ;
199+
192200 $ zones [] = array ( 'zone ' => substr ($ tmp ['origin ' ],0 ,-1 ),
193- 'zonefile_path ' => $ dns_config ['bind_zonefiles_dir ' ].'/pri. ' .substr ($ tmp ['origin ' ],0 ,-1 )
201+ 'zonefile_path ' => $ dns_config ['bind_zonefiles_dir ' ].'/pri. ' .substr ($ tmp ['origin ' ],0 ,-1 ),
202+ 'options ' => $ options
194203 );
195204 }
196205
0 commit comments