1 package C4::Security; #asummes C4/Security
3 #requires DBI.pm to be installed
11 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
13 # set the version for version checking
17 @EXPORT = qw(&Login &CheckAccess);
18 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
20 # your exported package globals go here,
21 # as well as any optionally exported functions
23 @EXPORT_OK = qw($Var1 %Hashit);
26 # non-exported package globals go here
27 use vars qw(@more $stuff);
29 # initalize package globals, first exported ones
35 # then the others (which are still accessible as $Some::Module::stuff)
39 # all file-scoped lexicals must be created before
40 # the functions below that use them.
42 # file-private lexicals go here
46 # here's a file-private function as a closure,
47 # callable as &$priv_func; it cannot be prototyped.
52 # make all your functions, whether exported or not;
58 my $query = "select * from branches order by branchname";
59 my $sth=$dbh->prepare($query);
61 while (my $branchrec=$sth->fetchrow_hashref) {
63 fmtstr($env,$branchrec->{'branchcode'},"L2")." ".$branchrec->{'branchname'};
64 push @branches,$branchdet;
68 &startint($env,"Logging In");
69 until ($valid eq "t") {
70 my ($reason,$username,$password,$branch) = logondialog ($env,"Logon to System",\@branches);
71 $username = uc $username;
72 $password = uc $password;
73 my $query = "select * from users where usercode = '$username' and password ='$password'";
74 $sth=$dbh->prepare($query);
76 # debug_msg("",$query);
77 if (my $userrec = $sth->fetchrow_hashref) {
78 if ($userrec->{'usercode'} ne ''){
81 my @dummy = split ' ', $branch;
83 $env->{'usercode'} = $username;
84 $env->{'branchcode'} = $branch;
88 debug_msg("","not found");
101 END { } # module clean-up code here (global destructor)