Skip to content

Commit c03252d

Browse files
committed
Fixed a problem with serials in the powerdns plugin.
1 parent 430309f commit c03252d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

server/plugins-available/powerdns_plugin.inc.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ function soa_insert($event_name,$data) {
127127

128128
$origin = substr($data["new"]["origin"], 0, -1);
129129
$ispconfig_id = $data["new"]["id"];
130-
$app->db->query("INSERT INTO powerdns.domains (name, type, ispconfig_id) VALUES ('$origin', 'NATIVE', $ispconfig_id)");
130+
$serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id);
131+
$serial_id = $serial["serial"];
132+
$app->db->query("INSERT INTO powerdns.domains (name, type, notified_serial, ispconfig_id) VALUES ('$origin', 'MASTER', $serial_id, $ispconfig_id)");
133+
//$app->db->query("INSERT INTO powerdns.domains (name, type, ispconfig_id) VALUES ('$origin', 'NATIVE', $ispconfig_id)");
131134
$zone_id = mysql_insert_id();
132135
if(substr($data["new"]["ns"], -1) == '.'){
133136
$ns = substr($data["new"]["ns"], 0, -1);
@@ -137,7 +140,8 @@ function soa_insert($event_name,$data) {
137140
if($ns == '') $ns = $origin;
138141

139142
$hostmaster = substr($data["new"]["mbox"], 0, -1);
140-
$content = $ns.' '.$hostmaster.' 0';
143+
//$content = $ns.' '.$hostmaster.' 0';
144+
$content = $ns.' '.$hostmaster.' '.$serial_id.'';
141145
$ttl = $data["new"]["ttl"];
142146

143147
$app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES ($zone_id, '$origin', 'SOA', '$content', $ttl, 0, ".time().", $ispconfig_id)");
@@ -154,7 +158,10 @@ function soa_update($event_name,$data) {
154158
if($data["old"]["active"] == 'Y'){
155159
$origin = substr($data["new"]["origin"], 0, -1);
156160
$ispconfig_id = $data["new"]["id"];
157-
$app->db->query("UPDATE powerdns.domains SET name = '$origin' WHERE ispconfig_id = $ispconfig_id");
161+
$serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id);
162+
$serial_id = $serial["serial"];
163+
$app->db->query("UPDATE powerdns.domains SET name = '$origin', notified_serial = $serial_id WHERE ispconfig_id = $ispconfig_id");
164+
//$app->db->query("UPDATE powerdns.domains SET name = '$origin' WHERE ispconfig_id = $ispconfig_id");
158165

159166
if(substr($data["new"]["ns"], -1) == '.'){
160167
$ns = substr($data["new"]["ns"], 0, -1);
@@ -164,7 +171,8 @@ function soa_update($event_name,$data) {
164171
if($ns == '') $ns = $origin;
165172

166173
$hostmaster = substr($data["new"]["mbox"], 0, -1);
167-
$content = $ns.' '.$hostmaster.' 0';
174+
//$content = $ns.' '.$hostmaster.' 0';
175+
$content = $ns.' '.$hostmaster.' '.$serial_id.'';
168176
$ttl = $data["new"]["ttl"];
169177
$app->db->query("UPDATE powerdns.records SET name = '$origin', content = '$content', ttl = $ttl, change_date = ".time()." WHERE ispconfig_id = ".$data["new"]["id"]." AND type = 'SOA'");
170178
} else {

0 commit comments

Comments
 (0)