Ignore:
Timestamp:
11/07/12 17:45:28 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak custid check in both main.cgi and admin.cgi; move the
general hardcoded checks into CustIDCK.pm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/CustIDCK.pm

    r517 r546  
    3434  my $custid = shift;
    3535
    36   return 1 if $custid =~ /^STAFF$/;
    37   return 1 if $custid =~ /^5554242$/;  # just in case some later change might block this
    38   return 1 if $custid =~ /^\d{7}$/;
    39   return 1 if $custid =~ /^\d{10}$/;
     36  # hardcoded "OK" custids.
     37  return 1 if $custid =~ /^STAFF(?:-\d\d?)?$/;
     38  return 1 if $custid =~ /^5554242(?:-\d\d?)?$/;  # just in case some later change might block this
     39  return 1 if $custid =~ /^\d{7}(?:-\d\d?)?$/;
     40  return 1 if $custid =~ /^\d{10}(?:-\d\d?)?$/;
     41
     42  # Force uppercase for now...
     43  $custid =~ tr/a-z/A-Z/;
    4044
    4145# some example code for a database check
     
    6670
    6771  # We should have a valid DB connection by now.
    68   my $sth = $dbh->prepare("SELECT custid FROM custid WHERE custid = '$custid'");
    69   $sth->execute;
     72 
     73  my $hr = $dbh->selectrow_hashref("SELECT custid FROM custid WHERE custid = ?", undef, ($custid) );
     74  my $status = 0;
    7075  if ($dbh->err) {
    7176    $CustIDCK::Error = 1;
    7277    $CustIDCK::ErrMsg = $dbh->errstr();
    73     $sth->finish;
    74     $dbh->disconnect;
    75     return 0;
     78  } else {
     79    $status = 1 if ( $hr->{custid} );
    7680  }
    77   my $hr = $sth->fetchrow_hashref();
    78   my $status = 0;
    79   $status = 1 if ( $hr->{custid} );
    80   $sth->finish;
    8181  $dbh->disconnect;
    8282  return $status;
Note: See TracChangeset for help on using the changeset viewer.