1 package C4::Security; #assumes C4/Security
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
26 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
28 # set the version for version checking
32 @EXPORT = qw(&Login &CheckAccess);
38 my $query = "select * from branches order by branchname";
39 my $sth=$dbh->prepare($query);
41 while (my $branchrec=$sth->fetchrow_hashref) {
43 fmtstr($env,$branchrec->{'branchcode'},"L2")." ".$branchrec->{'branchname'};
44 push @branches,$branchdet;
48 &startint($env,"Logging In");
49 until ($valid eq "t") {
50 my ($reason,$username,$password,$branch) = logondialog ($env,"Logon to System",\@branches);
51 $username = uc $username;
52 $password = uc $password;
53 my $query = "select * from users where usercode = '$username' and password ='$password'";
54 $sth=$dbh->prepare($query);
56 # debug_msg("",$query);
57 if (my $userrec = $sth->fetchrow_hashref) {
58 if ($userrec->{'usercode'} ne ''){
61 my @dummy = split ' ', $branch;
63 $env->{'usercode'} = $username;
64 $env->{'branchcode'} = $branch;
68 debug_msg("","not found");
81 END { } # module clean-up code here (global destructor)