Index: /branches/stable/cgi-bin/CustIDCK.pm
===================================================================
--- /branches/stable/cgi-bin/CustIDCK.pm	(revision 56)
+++ /branches/stable/cgi-bin/CustIDCK.pm	(revision 56)
@@ -0,0 +1,55 @@
+# ipdb/cgi-bin/CustIDCK.pm
+# External Customer ID checker stub
+###
+# SVN revision info
+# $Date$
+# SVN revision $Rev$
+# Last update by $Author$
+###
+
+package CustIDCK;
+
+use strict;
+use warnings;
+use Exporter;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use DBI;
+
+$VERSION        = 1.00;
+@ISA            = qw(Exporter);
+@EXPORT         = ();
+@EXPORT_OK      = qw ( &custid_exist );
+
+# this is really an example stub, and should be replaced by
+# the local admin on installation
+sub custid_exist {
+  my $custid = shift;
+
+  return 1 if $custid =~ /^STAFF$/;
+  return 1 if $custid =~ /^6750400$/;  # just in case some later change might block this
+  return 1 if $custid =~ /^\d{7}$/;
+  return 1 if $custid =~ /^\d{10}$/;
+
+# some example code for a database check
+  my $dbh = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck");
+  my $sth = $dbh->prepare("SELECT custid FROM custid WHERE custid = '$custid';");
+  $sth->execute;
+  if ($dbh->err) {
+    $CustIDCK::Error = 1;
+    $CustIDCK::ErrMsg = $dbh->errstr();
+    $sth->finish;
+    $dbh->disconnect;
+    return 0;
+  }
+  my $hr = $sth->fetchrow_hashref();
+  my $status = 0;
+  $status = 1 if ( $hr->{custid} );
+  $sth->finish;
+  $dbh->disconnect;
+  return $status;
+
+  return 0;
+  # Stubs for error messages
+  $CustIDCK::Error = 1 if 1 == 0;
+  $CustIDCK::ErrMsg = "bad foo-frob: 1 == 0";
+}
Index: /branches/stable/cgi-bin/main.cgi
===================================================================
--- /branches/stable/cgi-bin/main.cgi	(revision 55)
+++ /branches/stable/cgi-bin/main.cgi	(revision 56)
@@ -15,4 +15,5 @@
 use CommonWeb qw(:ALL);
 use IPDB qw(:ALL);
+use CustIDCK;
 use POSIX qw(ceil);
 use NetAddr::IP;
@@ -1159,11 +1160,25 @@
     }
     if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) {
-      printAndExit("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff.");
-    }
-    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
+      # Force uppercase for now...
+      $webvar{custid} =~ tr/a-z/A-Z/;
+      # Crosscheck with ... er...  something.
+      my $status = CustIDCK->custid_exist($webvar{custid});
+      printAndExit("Error verifying customer ID: ".$CustIDCK::ErrMsg)
+	if $CustIDCK::Error;
+      printAndExit("Customer ID not valid.  Make sure the Customer ID ".
+	"is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
+	"non-customer assignments.")
+	if !$status;
+#"Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for
+#static IPs for staff.");
+    }
+#    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
   } elsif ($webvar{alloctype} =~ /^([sdcmw]p|si|dn|dy|dc|ee|rr|ii)$/){
     # All non-customer allocations MUST be entered with "our" customer ID.
     # I have Defined this as 6750400 for consistency.
-    $webvar{custid} = "6750400";
+    # STAFF is also acceptable.
+    if ((!$webvar{custid}) || ($webvar{custid} ne 'STAFF')) {
+      $webvar{custid} = "6750400";
+    }
     if ($webvar{alloctype} eq 'rr') {
       if ($webvar{city} !~ /^(?:Huntsville|North Bay|Ottawa|Pembroke|Sault Ste. Marie|Sudbury|Timmins|Thunder Bay|Toronto)$/) {
