#!/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 = ('Main' => 'Main',
'Error' => 'Error',
'Student' => 'Student',
'No User Id' => 'No User Id',
'No Password' => 'No Password',
'Please Log In' => 'Please Log In',
'Select' => 'Select',
'Select' => 'Select',
'Students' => 'Students',
'No Students Found' => 'No Students Found',
'Group' => 'Group',
'Students' => 'Students',
'Edit' => 'Edit',
'Delete' => 'Delete',
'Yes' => 'Yes',
'Confirm' => 'Confirm',
'Start Date' => 'Start Date',
'End Date' => 'End Date',
'Hours' => 'Hours',
'Record(s) Deleted' => 'Record(s) Deleted',
'More' => 'More',
'Record(s) Updated' => 'Record(s) Updated',
'Update' => 'Update',
'Program' => 'Program',
'Comment' => 'Comment',
'Dropped' => 'Dropped',
'Kit' => 'Kit',
'Lesson' => 'Lesson',
'Number' => 'Number',
'Initial' => 'Initial',
'Attended' => 'Attended',
'Not Found' => 'Not Found',
);
use DBI;
use CGI;
use CGI::Session;
my $self = 'lintStudDelEd.pl';
my $q = new CGI;
my %arr = $q->Vars;
my @tim = localtime(time);
my $year = $tim[5] + 1900;
my $month = $tim[4] + 1;
my $day = $tim[3];
if ( length( $month) == 1 ) { $month = '0'. $month; }
if ( length( $day) == 1 ) { $day = '0'. $day; }
my $currdate = "$year-$month-$day";
eval require "../../etc/admin.conf";
if ( $@ ) {
print qq{$lex{Error} $self: $@
\n};
die qq{$lex{Error} $self: $@\n};
}
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
# Session Setup Here
my $session = new CGI::Session("driver:mysql;serializer:FreezeThaw",
undef,{Handle => $dbh}) or die CGI::Session->errstr;
my ( $userid, $duration);
# Get/Set Session Values (a defined userid means it was passed)
if ( $arr{userid} ){ # we want to login, passed userid/password pair.
# Check password/userid against database (-1 no user, -2 wrong password);
my $error = checkPassword($arr{userid}, $arr{password}, $dbh);
if ($error == -1){ print $q->header( -charset, $charset ); login($lex{'No User Id'}); }
if ($error == -2){ print $q->header( -charset, $charset ); login($lex{'No Password'}); }
$cookietime = checkCookieTime( $arr{duration} );
# Set values for userid and logged_in in session
$session->param( 'logged_in','1');
$session->expire( 'logged_in', $cookietime );
$session->param( 'userid',$arr{userid} );
$session->param( 'duration',$cookietime );
$userid = $arr{userid};
} else { # check logged_in value in session
if ( not $session->param('logged_in') ){
$userid = $session->param('userid');
print $q->header( -charset, $charset );
print qq{
[ $lex{Main} ]
\n}; print qq{