Index: branches/stable/cgi-bin/extras/db2rwhois.pl
===================================================================
--- branches/stable/cgi-bin/extras/db2rwhois.pl	(revision 252)
+++ branches/stable/cgi-bin/extras/db2rwhois.pl	(revision 253)
@@ -41,18 +41,20 @@
 # Note that this ASS-U-MEs that we do not add master IP blocks-
 # there should probably be a separate system for doing that.
-my $sth = $dbh->prepare("select * from masterblocks;");
+my $sth = $dbh->prepare("select cidr,ctime from masterblocks;");
 $sth->execute;
 my $i=0;
 GETMASTERS: while (my @data = $sth->fetchrow_array()) {
 
-  if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0)/) {
+# Techically, we only need to exclude 204.138.172.0/24, as we "own" all of the other blocks.
+  if ($data[0] =~ /^(192.168.0.0|172.16.0.0|10.0.0.0|20[456])/) {
     next GETMASTERS;
   }
   $masterblocks[$i] = new NetAddr::IP $data[0];
+  my ($ctime,undef) = split /\s/, $data[1];
 
-print "$masterblocks[$i]\n";
+print "$masterblocks[$i] $data[1]\n";
 
   my $date;
-  chomp ($date = `/bin/date +"%Y%m%d"`);
+  chomp ($date = `/bin/date +"%Y-%m-%d"`);
 
 # Whew!  Ugly little varmint.
@@ -73,5 +75,5 @@
 	"Admin-Contact: ISP-ARIN-HANDLE\n".
 	"Abuse-Contact: abuse\@example.com\n".
-	"Created: 20040308\n".
+	"Created: $ctime\n".
 	"Updated: $date\n".
 	"Updated-By: noc\@example.com\n";
@@ -87,8 +89,15 @@
 # Make sure to remove the private netblocks from this.
 # No use or point in broadcasting our use of them.
-$sth = $dbh->prepare("select * from allocations where not (cidr <<= '192.168.0.0/16') and not (cidr <<= '172.16.0.0/12') and not (cidr <<= '10.0.0.0/8') and custid='6750400'");
+$sth = $dbh->prepare("select cidr,custid,type,city,description,createstamp,modifystamp ".
+	"from allocations where ".
+	"not (cidr <<= '192.168.0.0/16') and ".
+	"not (cidr <<= '172.16.0.0/12') and ".
+	"not (cidr <<= '10.0.0.0/8') and ".
+	"masklen(cidr) <=30");
+#" and (custid='6750400' or custid like '%-RES' or custid like '%-BUS')");
 $sth->execute;
 
-while (my @data = $sth->fetchrow_array()) {
+$i=0;
+while (my ($cidr, $custid, $type, $city, $desc, $ctime, $mtime) = $sth->fetchrow_array) {
 
 # We get master block info from @masterblocks.
@@ -106,5 +115,5 @@
 
   # Get the "full" network number
-  my $net = new NetAddr::IP $data[0];
+  my $net = new NetAddr::IP $cidr;
 
 # Assumptions:  All data in ipdb is public
@@ -127,5 +136,7 @@
 my $date;
       chomp ($date = `/bin/date +"%Y%m%d"`);
-if ($data[4] =~ /^\s*$/) { $data[4] = 'Friendly ISP'; }
+if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; }
+#print "$i:\t$net in $master\n";
+
       print MASTERFILE "---\nID: NETBLK-ISP.$master\n".
   	"Auth-Area: $master\n".
@@ -133,10 +144,10 @@
 	"IP-Network: $net\n".
 	"IP-Network-Block: ".$net->range."\n".
-	"Organization: $data[4]\n".
+	"Organization: $desc\n".
 #	"Tech-Contact: $data[9]\n".
 	"Tech-Contact: abuse\@example.com\n".
 	"Admin-Contact: ISP-ARIN-HANDLE\n".
-	"Created: $date\n".
-	"Updated: $date\n".
+	"Created: $ctime\n".
+	"Updated: $mtime\n".
 	"Updated-By: noc\@example.com\n";
     }
@@ -149,5 +160,5 @@
   #  print "$data[0]\t| $data[1]\t| $data[2]\t| $data[3]\t| $data[4]\t| ".
   #	"$data[5]\t| $data[6]\t| $data[7]\t| $data[8]\n";
-
+  $i++;
 } # while fetchrow_array()
 
