Index: /trunk/DNSDB.pm
===================================================================
--- /trunk/DNSDB.pm	(revision 643)
+++ /trunk/DNSDB.pm	(revision 644)
@@ -219,4 +219,7 @@
 		# 'all' (all IP values in any reverse zone view)
 		showrev_arpa	=> 'none',
+		# Two options for template record expansion:
+		template_skip_0	=> 0,	# publish .0 by default
+		template_skip_255	=> 0,	# publish .255 by default
 	);
 
@@ -248,5 +251,6 @@
 
   # Several settings are booleans.  Handle multiple possible ways of setting them.
-  for my $boolopt ('log_failures', 'force_refresh', 'lowercase', 'usecache') {
+  for my $boolopt ('log_failures', 'force_refresh', 'lowercase', 'usecache',
+	'template_skip_0', 'template_skip_255') {
     if ($self->{$boolopt} ne '1' && $self->{$boolopt} ne '0') {
       # true/false, on/off, yes/no all valid.
@@ -1700,4 +1704,6 @@
       $cfg->{lowercase}		= $1 if /^lowercase\s*=\s*([a-z01]+)/i;
       $cfg->{showrev_arpa}	= $1 if /^showrev_arpa\s*=\s*([a-z]+)/i;
+      $cfg->{template_skip_0}	= $1 if /^template_skip_0\s*=\s*([a-z01]+)/i;
+      $cfg->{template_skip_255}	= $1 if /^template_skip_255\s*=\s*([a-z01]+)/i;
 # not supported in dns.cgi yet
 #      $cfg->{templatedir}	= $1 if m{^templatedir\s*=\s*([a-z0-9/_.-]+)}i;
@@ -5554,5 +5560,5 @@
         $soasth->execute($revid);
         my (@zsoa) = $soasth->fetchrow_array();
-        _printrec_tiny($zonefilehandle, $zsoa[7], 'y',\%recflags,$revzone,
+        $self->_printrec_tiny($zonefilehandle, $zsoa[7], 'y',\%recflags,$revzone,
           $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
 
@@ -5588,5 +5594,5 @@
 	  }
 
-          _printrec_tiny($zonefilehandle, $recid, 'y', \%recflags, $revzone,
+          $self->_printrec_tiny($zonefilehandle, $recid, 'y', \%recflags, $revzone,
             $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive);
 
@@ -5665,5 +5671,5 @@
         $soasth->execute($domid);
         my (@zsoa) = $soasth->fetchrow_array();
-        _printrec_tiny($zonefilehandle, $zsoa[7], 'n',\%recflags,$dom,
+        $self->_printrec_tiny($zonefilehandle, $zsoa[7], 'n',\%recflags,$dom,
           $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
 
@@ -5687,5 +5693,5 @@
 	  }
 
-	  _printrec_tiny($zonefilehandle, $recid, 'n', \%recflags,
+	  $self->_printrec_tiny($zonefilehandle, $recid, 'n', \%recflags,
 		$dom, $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive);
 
@@ -5736,4 +5742,5 @@
 # Utility sub for __export_tiny above
 sub _printrec_tiny {
+  my $self = shift;
   my ($datafile, $recid, $revrec, $recflags, $zone, $host, $type, $val, $dist, $weight, $port, $ttl,
 	$loc, $stamp, $expires, $stampactive) = @_;
@@ -5840,4 +5847,5 @@
 ##  forked process
   sub __publish_subnet {
+    my $obj = shift;	# *sigh*  need to pass in the DNSDB object so we can read a couple of options
     my $sub = shift;
     my $recflags = shift;
@@ -5858,5 +5866,6 @@
       # make as if we split the non-octet-aligned block into octet-aligned blocks as with SOA
       my $lastoct = (split /\./, $ip)[3];
-      next if $ip =~ /\.(0|255)$/; # && $self->{skip_net_0}
+      next if $ip =~ /\.0$/ && $obj->{template_skip_0};
+      next if $ip =~ /\.255$/ && $obj->{template_skip_255};
       next if $$recflags{$ip}; # && $self->{skip_bcast_255}
       $$recflags{$ip}++;
@@ -6076,6 +6085,6 @@
     # print both;  a dangling record is harmless, and impossible via web
     # UI anyway
-    _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,28,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
-    _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,12,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
+    $self->_printrec_tiny($datafile,$revrec,$recflags,$zone,$host,28,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
+    $self->_printrec_tiny($datafile,$revrec,$recflags,$zone,$host,12,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
 ##fixme: add a config flag to indicate use of the patch from http://www.fefe.de/dns/
 # type 6 is for AAAA+PTR, type 3 is for AAAA
@@ -6090,8 +6099,8 @@
     if ($val->masklen <= 16) {
       foreach my $sub ($val->split(16)) {
-        __publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
+        $self->__publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
       }
     } else {
-      __publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
+      $self->__publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
     }
 
@@ -6104,8 +6113,8 @@
     if ($val->masklen <= 16) {
       foreach my $sub ($val->split(16)) {
-        __publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
+        $self->__publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
       }
     } else {
-      __publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
+      $self->__publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
     }
 
@@ -6119,5 +6128,5 @@
 
     # All delegations need to create one or more NS records.  The NS record handler knows what to do.
-    _printrec_tiny($datafile,$recid,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'},
+    $self->_printrec_tiny($datafile,$recid,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'},
       $val,$dist,$weight,$port,$ttl,$loc,$stamp);
     if ($revrec eq 'y') {
Index: /trunk/dnsdb.conf
===================================================================
--- /trunk/dnsdb.conf	(revision 643)
+++ /trunk/dnsdb.conf	(revision 644)
@@ -41,4 +41,10 @@
 #showrev_arpa = 0
 
+# publish .0 IP when expanding a template pattern
+#template_skip_0 = 0
+
+# publish .255 IP when expanding a template pattern
+#template_skip_255 = 0
+
 ## General RPC options
 # may already be obsolete.  how do we want to run RPC requests?
