source: branches/stable/cgi-bin/CustIDCK.pm@ 98

Last change on this file since 98 was 94, checked in by Kris Deugau, 20 years ago

/branches/stable

Corrected svn:* properties on several files

  • Property svn:keywords set to Date Rev Author
File size: 1.3 KB
Line 
1# ipdb/cgi-bin/CustIDCK.pm
2# External Customer ID checker stub
3###
4# SVN revision info
5# $Date: 2004-12-01 20:42:57 +0000 (Wed, 01 Dec 2004) $
6# SVN revision $Rev: 94 $
7# Last update by $Author: kdeugau $
8###
9
10package CustIDCK;
11
12use strict;
13use warnings;
14use Exporter;
15use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
16use DBI;
17
18$VERSION = 1.00;
19@ISA = qw(Exporter);
20@EXPORT = ();
21@EXPORT_OK = qw ( &custid_exist );
22
23# this is really an example stub, and should be replaced by
24# the local admin on installation
25sub custid_exist {
26 my $custid = shift;
27
28 return 1 if $custid =~ /^STAFF$/;
29 return 1 if $custid =~ /^6750400$/; # just in case some later change might block this
30 return 1 if $custid =~ /^\d{7}$/;
31 return 1 if $custid =~ /^\d{10}$/;
32
33# some example code for a database check
34 my $dbh = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck");
35 my $sth = $dbh->prepare("SELECT custid FROM custid WHERE custid = '$custid';");
36 $sth->execute;
37 if ($dbh->err) {
38 $CustIDCK::Error = 1;
39 $CustIDCK::ErrMsg = $dbh->errstr();
40 $sth->finish;
41 $dbh->disconnect;
42 return 0;
43 }
44 my $hr = $sth->fetchrow_hashref();
45 my $status = 0;
46 $status = 1 if ( $hr->{custid} );
47 $sth->finish;
48 $dbh->disconnect;
49 return $status;
50
51 return 0;
52 # Stubs for error messages
53 $CustIDCK::Error = 1 if 1 == 0;
54 $CustIDCK::ErrMsg = "bad foo-frob: 1 == 0";
55}
Note: See TracBrowser for help on using the repository browser.