Index: /branches/stable/cgi-bin/IPDB.pm
===================================================================
--- /branches/stable/cgi-bin/IPDB.pm	(revision 167)
+++ /branches/stable/cgi-bin/IPDB.pm	(revision 168)
@@ -22,5 +22,5 @@
 @ISA		= qw(Exporter);
 @EXPORT_OK    = qw(
-	%disp_alloctypes %list_alloctypes @citylist @poplist @masterblocks
+	%disp_alloctypes %list_alloctypes %def_custids @citylist @poplist @masterblocks
 	%allocated %free %routed %bigfree
 	&initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock &deleteBlock
@@ -30,6 +30,6 @@
 @EXPORT		= (); # Export nothing by default.
 %EXPORT_TAGS	= ( ALL => [qw(
-		%disp_alloctypes %list_alloctypes @citylist @poplist @masterblocks
-		%allocated %free %routed %bigfree
+		%disp_alloctypes %list_alloctypes %def_custids @citylist @poplist
+		@masterblocks %allocated %free %routed %bigfree
 		&initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock
 		&deleteBlock &mailNotify
@@ -42,4 +42,5 @@
 our %disp_alloctypes;
 our %list_alloctypes;
+our %def_custids;
 our @citylist;
 our @poplist;
@@ -58,8 +59,9 @@
 
   # Initialize alloctypes hashes
-  $sth = $dbh->prepare("select type,listname,dispname,listorder from alloctypes order by listorder");
+  $sth = $dbh->prepare("select type,listname,dispname,listorder,def_custid from alloctypes order by listorder");
   $sth->execute;
   while (my @data = $sth->fetchrow_array) {
     $disp_alloctypes{$data[0]} = $data[2];
+    $def_custids{$data[0]} = $data[4];
     if ($data[3] < 900) {
       $list_alloctypes{$data[0]} = $data[1];
Index: /branches/stable/cgi-bin/consistency-check.pl
===================================================================
--- /branches/stable/cgi-bin/consistency-check.pl	(revision 167)
+++ /branches/stable/cgi-bin/consistency-check.pl	(revision 168)
@@ -14,11 +14,6 @@
 
 ($dbh,$errstr) = connectDB_My;
-
-# Schlep up the masters
-$sth = $dbh->prepare("select * from masterblocks order by cidr");
-$sth->execute;
-for ($i=0; @data = $sth->fetchrow_array; $i++) {
-  $masterblocks[$i] = new NetAddr::IP $data[0];
-}
+# May as well.  We need a number of globals.
+initIPDBGlobals($dbh);
 
 print "First check:  All blocks must be within one of the master blocks\n";
@@ -54,5 +49,5 @@
 # Next:  free blocks
 print "Checking freeblocks: ";
-$sth = $dbh->prepare("select cidr from freeblocks");
+$sth = $dbh->prepare("select cidr from freeblocks order by cidr");
 $sth->execute;
 FREEBLOCK: while (@data = $sth->fetchrow_array) {
@@ -138,2 +133,13 @@
   print "done $master.\n";
 }
+
+print "Done checking block alignment.\n\nChecking for correctness on 'defined' CustIDs:\n";
+# New check:  Make sure "defined" CustIDs are correct.
+$sth = $dbh->prepare("select cidr,type,custid from allocations where not type='cn' order by cidr");
+$sth->execute;
+while (@data = $sth->fetchrow_array) {
+  print "$data[0] ($disp_alloctypes{$data[1]}) has incorrect CustID $data[2]\n"
+	if $data[2] ne $def_custids{$data[1]};
+}
+
+print "Done CustID correctness check.\n";
Index: /branches/stable/cgi-bin/main.cgi
===================================================================
--- /branches/stable/cgi-bin/main.cgi	(revision 167)
+++ /branches/stable/cgi-bin/main.cgi	(revision 168)
@@ -1013,9 +1013,7 @@
 #    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
   } else {
-    # All non-customer allocations MUST be entered with "our" customer ID.
-    # I have Defined this as 6750400 for consistency.
-    # STAFF is also acceptable.
+    # New!  Improved!  And now Loaded From The Database!!
     if ((!$webvar{custid}) || ($webvar{custid} ne 'STAFF')) {
-      $webvar{custid} = "6750400";
+      $webvar{custid} = $def_custids{$webvar{alloctype}};
     }
   }
