#!/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 = ('Set' => 'Set',
'Literacy Intervention' => 'Literacy Intervention',
'Group' => 'Group',
'Name' => 'Name',
'Dates' => 'Dates',
'New' => 'New',
'Teacher' => 'Teacher',
'Start Date' => 'Start Date',
'End Date' => 'End Date',
'Program Hours' => 'Program Hours',
'Main' => 'Main',
'Error' => 'Error',
'Students' => 'Students',
'Record(s) Stored' => 'Record(s) Stored',
'Save' => 'Save',
'No User Id' => 'No User Id',
'No Password' => 'No Password',
'Please Log In' => 'Please Log In',
'Description' => 'Description',
'Add' => 'Add',
'Edit' => 'Edit',
'Delete' => 'Delete',
'Period Length' => 'Period Length',
'No Blanks Allowed' => 'No Blanks Allowed',
'Not Found' => 'Not Found',
);
use DBI;
use CGI;
use CGI::Session;
my $self = 'lintProgSet.pl';
my $editscript = 'lintProgEdit.pl';
my $deletescript = 'lintProgDelete.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 $lex{Error}. " $self: $@
\n";
die $lex{Error}. "$self: $@\n";
}
eval require "../../lib/libsession.pl";
if ( $@ ) {
print $lex{Error}. " $self: $@
\n";
die $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{
\n}; print qq{\n}; print qq{ | ||||
$lex{Name} | $lex{Dates} | $lex{Group} | }; print qq{$lex{Students} | |
---|---|---|---|---|
$teachername | }; print qq{$ref->{startdate} | $ref->{enddate} | \n}; print qq{$ref->{groupdesc} | \n}; # Edit Button print qq{\n}; # Delete Button print qq{\n}; print qq{ | \n};
# Get Students
$sth2->execute( $ref->{id} );
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; }
while ( my ($lastname, $firstname) = $sth2->fetchrow ) {
print qq{$lastname, $firstname }; } print qq{ |