+sub checkpw {
+
+# This should be modified to allow a select of authentication schemes (ie LDAP)
+# as well as local authentication through the borrowers tables passwd field
+#
+ my ($dbh, $userid, $password) = @_;
+ my $sth=$dbh->prepare("select password from borrowers where userid=?");
+ $sth->execute($userid);
+ if ($sth->rows) {
+ my ($cryptpassword) = $sth->fetchrow;
+ if (crypt($password, $cryptpassword) eq $cryptpassword) {
+ return 1;
+ }
+ }
+ my $sth=$dbh->prepare("select password from borrowers where cardnumber=?");
+ $sth->execute($userid);
+ if ($sth->rows) {
+ my ($cryptpassword) = $sth->fetchrow;
+ if (crypt($password, $cryptpassword) eq $cryptpassword) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+