);
}
else {
- warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]"
- unless ( $in->{'type'} eq 'opac' );
+ warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
my $LibraryNameTitle = C4::Context->preference("LibraryName");
$LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
$LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
my $timeout = C4::Context->preference('timeout');
$timeout = 600 unless $timeout;
+
+ # If Version syspref is unavailable, it means Koha is beeing installed,
+ # and so we must redirect to OPAC maintenance page or to the WebInstaller
+ unless (C4::Context->preference('Version')) {
+ if ($type ne 'opac') {
+ warn "Install required, redirecting to Installer";
+ print $query->redirect("/cgi-bin/koha/installer/install.pl");
+ }
+ else {
+ warn "OPAC Install required, redirecting to maintenance";
+ print $query->redirect("/cgi-bin/koha/maintenance.pl");
+ }
+ exit;
+ }
+
+
# state variables
my $loggedin = 0;
my %info;
$loggedin = 1;
}
elsif ( $sessionID = $query->cookie("CGISESSID")) {
-# my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
- my $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'});
+ my $storage_method = C4::Context->preference('SessionStorage');
+ my $session;
+ if ($storage_method eq 'mysql'){
+ $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+ }
+ else {
+ # catch all defaults to tmp should work on all systems
+ $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'});
+ }
C4::Context->_new_userenv($sessionID);
if ($session){
C4::Context::set_userenv(
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter')
);
- warn "".$session->param('cardnumber').", ".$session->param('firstname').",
- ".$session->param('surname').", ".$session->param('branch');
+# warn "".$session->param('cardnumber').", ".$session->param('firstname').",
+# ".$session->param('surname').", ".$session->param('branch');
}
my $ip;
my $lasttime;
if ($logout) {
# voluntary logout the user
-# $session->delete;
+
$session->flush;
+ $session->delete();
C4::Context->_unset_userenv($sessionID);
$sessionID = undef;
$userid = undef;
}
}
unless ($userid) {
-# my $session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh});
- my $session = new CGI::Session("driver:File", undef, {Directory=>'/tmp'});
+ my $storage_method = C4::Context->preference('SessionStorage');
+ my $session;
+ if ($storage_method eq 'mysql'){
+ $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+ }
+ else {
+ # catch all defaults to tmp should work on all systems
+ $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'});
+ }
+
my $sessionID;
- if ($session) {
- $sessionID = $session->id;
- }
+ if ($session) {
+ $sessionID = $session->id;
+ }
$userid = $query->param('userid');
C4::Context->_new_userenv($sessionID);
my $password = $query->param('password');
# check that database and koha version are the same
# there is no DB version, it's a fresh install,
# go to web installer
- warn "about to check version";
- unless (C4::Context->preference('Version')){
- if ($type ne 'opac'){
- warn "Install required, redirecting to Installer";
- print $query->redirect("/cgi-bin/koha/installer/install.pl");
- } else {
- warn "OPAC Install required, redirecting to maintenance";
- print $query->redirect("/cgi-bin/koha/maintenance.pl");
- }
- exit;
- }
# there is a DB version, compare it to the code version
my $kohaversion=C4::Context::KOHAVERSION;
# remove the 3 last . to have a Perl number