#!/usr/bin/perl
# Copyright 2001-2021 Leslie Richardson
# This file is part of Open Admin for Schools.
# Open Admin for Schools is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
my %lex = ('User Id' => 'User Id',
'Password' => 'Password',
'Duration' => 'Duration',
'Login' => 'Login',
'Log In' => 'Log In',
'Log Out' => 'Log Out',
'min' => 'min',
'No Userid Found' => 'No Userid Found',
'Incorrect Password' => 'Incorrect Password',
'Logged In' => 'Logged In',
'Error' => 'Error',
'Continue' => 'Continue',
'User' => 'User',
'Main' => 'Main',
);
my $self = 'tlogin.pl';
my $defaulttime = 90; # minutes; should be loaded from config
use DBI;
use CGI;
use CGI::Session;
my $q = CGI->new;
my %arr = $q->Vars;
eval require "../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. ": $@
\n";
die $lex{Error}. ": $@\n";
}
eval require "../lib/libsession.pl"; # contains login/ checkPassword/ checkCookieTime functions
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@
\n";
}
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
$dbh->{mysql_enable_utf8} = 1;
# foreach my $key ( sort keys %arr ) { print qq{K:$key V:$arr{$key}
\n}; }
if ( not $arr{page} or $arr{page} == -1 ) {
print $q->header( -charset, $charset );
printHTMLHeader();
showStartPage();
} elsif ( $arr{page} == 1 ) {
delete $arr{page};
doLogin();
} elsif ( $arr{page} == 2 ) {
delete $arr{page};
doLogout();
}
#----------------
sub showStartPage {
#----------------
my $userid_env = $ENV{'REMOTE_USER'};
print qq{