44 $this->shouldreload=
false;
45 $this->shouldreconfig=
false;
57 global $L_FQDN,$L_NS1_HOSTNAME,$L_NS2_HOSTNAME,$L_DEFAULT_MX,$L_DEFAULT_SECONDARY_MX,$L_PUBLIC_IP,$L_PUBLIC_IPV6;
59 $domain = $dominfo[
"domaine"];
60 $ttl = $dominfo[
"zonettl"];
63 if (file_exists($this->zone_file_directory.
"/".$domain)) {
64 list($islocked,$serial,$more)=$this->
read_zone($domain);
68 $serial=date(
"Ymd").
"00";
71 if ($islocked)
return 1;
74 $zone = file_get_contents($this->ZONE_TEMPLATE);
80 $zone = strtr($zone, array(
81 "%%fqdn%%" =>
"$L_FQDN",
82 "%%ns1%%" =>
"$L_NS1_HOSTNAME",
83 "%%ns2%%" =>
"$L_NS2_HOSTNAME",
84 "%%DEFAULT_MX%%" =>
"$L_DEFAULT_MX",
85 "%%DEFAULT_SECONDARY_MX%%" =>
"$L_DEFAULT_SECONDARY_MX",
86 "@@fqdn@@" =>
"$L_FQDN",
87 "@@ns1@@" =>
"$L_NS1_HOSTNAME",
88 "@@ns2@@" =>
"$L_NS2_HOSTNAME",
89 "@@DEFAULT_MX@@" =>
"$L_DEFAULT_MX",
90 "@@DEFAULT_SECONDARY_MX@@" =>
"$L_DEFAULT_SECONDARY_MX",
91 "@@DOMAINE@@" => $domain,
92 "@@SERIAL@@" => $serial,
93 "@@PUBLIC_IP@@" =>
"$L_PUBLIC_IP",
94 "@@PUBLIC_IPV6@@" =>
"$L_PUBLIC_IPV6",
95 "@@ZONETTL@@" => $ttl,
99 $zone .=
";;; END ALTERNC AUTOGENERATE CONFIGURATION\n";
103 file_put_contents($this->zone_file_directory.
"/".$domain,$zone);
106 if (add_line_to_file(
109 file_get_contents($this->NAMED_TEMPLATE),
111 "@@DOMAIN@@" => $domain,
112 "@@ZONE_FILE@@" => $this->zone_file_directory.
"/".$domain
116 $this->shouldreconfig=
true;
118 $this->shouldreload=
true;
132 $domain = $dominfo[
"domaine"];
133 if (del_line_from_file(
136 file_get_contents($this->NAMED_TEMPLATE),
138 "@@DOMAIN@@" => $domain,
139 "@@ZONE_FILE@@" => $this->zone_file_directory.
"/".$domain
143 $this->shouldreconfig=
true;
147 @unlink($this->zone_file_directory.
"/".$domain);
161 if ($this->shouldreload) {
163 exec($this->RNDC.
" reload 2>&1",$out,$ret);
165 $msg->raise(
"ERROR",
"bind",
"Error while reloading bind, error code is $ret\n".implode(
"\n",$out));
167 $msg->raise(
"INFO",
"bind",
"Bind reloaded");
170 if ($this->shouldreconfig) {
172 exec($this->RNDC.
" reconfig 2>&1",$out,$ret);
174 $msg->raise(
"ERROR",
"bind",
"Error while reconfiguring bind, error code is $ret\n".implode(
"\n",$out));
176 $msg->raise(
"INFO",
"bind",
"Bind reconfigured");
190 $f=fopen($this->zone_file_directory.
"/".$domain,
"rb");
193 $serial=date(
"Ymd").
"00";
194 while ($s=fgets($f,4096)) {
195 if (preg_match(
"#\;\s*LOCKED:YES#i",$s)) {
198 if (preg_match(
"/\s*(\d{10})\s+\;\sserial\s?/", $s,$mat)) {
201 if (preg_match(
'/\;\s*END\sALTERNC\sAUTOGENERATE\sCONFIGURATION(.*)/s', $s)) {
205 while ($s=fgets($f,4096)) {
208 return array($islocked,$serial,$more);
223 REPLACE(REPLACE(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) AS ENTRY
229 AND sd.enable IN ('ENABLE', 'ENABLED')
230 AND sd.web_action NOT IN ('DELETE')
232 ORDER BY ENTRY ;", array($domain));
234 while ($db->next_record()) {
235 $t.= $db->f(
'ENTRY').
"\n";
Manages BIND 9+ zone management templates in AlternC 3.5+.
hook_updatedomains_dns_pre()
Hook launched before any action by updatedomains initialize the reload/reconfig flags used by POST @N...
read_zone($domain)
read a zone file for $domain,
hook_updatedomains_dns_del($dominfo)
Hook launched for each ZONE for which we want a zone DELETE remove the zone and its file,...
hook_updatedomains_dns_add($dominfo)
Hook launched for each ZONE for which we want a zone update (or create) update the zone,...
conf_from_db($domain)
Return the part of the conf we got from the sub_domaines table.
hook_updatedomains_dns_post()
Hook function launched at the very end of updatedomains here, we just reload OR reconfig (or both) bi...