diff --git a/C4/Auth.pm b/C4/Auth.pm index 6fd530df6f..da70939d10 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -22,6 +22,8 @@ package C4::Auth; use strict; use Digest::MD5 qw(md5_base64); +use CGI::Session; + require Exporter; use C4::Context; @@ -387,34 +389,32 @@ sub checkauth { # Using Basic Authentication, no cookies required $cookie = $query->cookie( - -name => 'sessionID', + -name => 'CGISESSID', -value => '', -expires => '' ); $loggedin = 1; } - elsif ( $sessionID = $query->cookie('sessionID') ) { + elsif ( $sessionID = $query->cookie("CGISESSID")) { + my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh}); + C4::Context->_new_userenv($sessionID); - if ( my %hash = $query->cookie('userenv') ) { - C4::Context::set_userenv( - $hash{number}, $hash{id}, - $hash{cardnumber}, $hash{firstname}, - $hash{surname}, $hash{branch}, - $hash{branchname}, $hash{flags}, - $hash{emailaddress}, $hash{branchprinter} + if ($session){ + C4::Context::set_userenv( + $session->param('number'), $session->param('id'), + $session->param('cardnumber'), $session->param('firstname'), + $session->param('surname'), $session->param('branch'), + $session->param('branchname'), $session->param('flags'), + $session->param('emailaddress'), $session->param('branchprinter') ); } - my ( $ip, $lasttime ); - - ( $userid, $ip, $lasttime ) = - $dbh->selectrow_array( - "SELECT userid,ip,lasttime FROM sessions WHERE sessionid=?", - undef, $sessionID ); + my $ip=$session->param('ip'); + $userid = $session->param('id'); + my $lasttime = $session->param('lasttime'); if ($logout) { # voluntary logout the user - $dbh->do( "DELETE FROM sessions WHERE sessionID=?", - undef, $sessionID ); + $session->delete; C4::Context->_unset_userenv($sessionID); $sessionID = undef; $userid = undef; @@ -425,12 +425,12 @@ sub checkauth { close L; } if ($userid) { + warn "here $userid"; if ( $lasttime < time() - $timeout ) { # timed logout $info{'timed_out'} = 1; - $dbh->do( "DELETE FROM sessions WHERE sessionID=?", - undef, $sessionID ); + $session->delete(); C4::Context->_unset_userenv($sessionID); $userid = undef; $sessionID = undef; @@ -446,8 +446,7 @@ sub checkauth { $info{'oldip'} = $ip; $info{'newip'} = $ENV{'REMOTE_ADDR'}; $info{'different_ip'} = 1; - $dbh->do( "DELETE FROM sessions WHERE sessionID=?", - undef, $sessionID ); + $session->delete(); C4::Context->_unset_userenv($sessionID); $sessionID = undef; $userid = undef; @@ -459,13 +458,9 @@ sub checkauth { close L; } else { - $cookie = $query->cookie( - -name => 'sessionID', - -value => $sessionID, - -expires => '' + $cookie = $query->cookie(CGISESSID => $session->id ); - $dbh->do( "UPDATE sessions SET lasttime=? WHERE sessionID=?", - undef, ( time(), $sessionID ) ); + $session->param('lasttime',time()); $flags = haspermission( $dbh, $userid, $flagsrequired ); if ($flags) { $loggedin = 1; @@ -477,30 +472,20 @@ sub checkauth { } } unless ($userid) { - $sessionID = int( rand() * 100000 ) . '-' . time(); + my $session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh}); + my $sessionID = $session->id; $userid = $query->param('userid'); C4::Context->_new_userenv($sessionID); my $password = $query->param('password'); C4::Context->_new_userenv($sessionID); my ( $return, $cardnumber ) = checkpw( $dbh, $userid, $password ); if ($return) { - $dbh->do( "DELETE FROM sessions WHERE sessionID=? AND userid=?", - undef, ( $sessionID, $userid ) ); - $dbh->do( -"INSERT INTO sessions (sessionID, userid, ip,lasttime) VALUES (?, ?, ?, ?)", - undef, - ( $sessionID, $userid, $ENV{'REMOTE_ADDR'}, time() ) - ); open L, ">>/tmp/sessionlog"; my $time = localtime( time() ); printf L "%20s from %16s logged in at %30s.\n", $userid, $ENV{'REMOTE_ADDR'}, $time; close L; - $cookie = $query->cookie( - -name => 'sessionID', - -value => $sessionID, - -expires => '' - ); + $cookie = $query->cookie(CGISESSID => $sessionID); if ( $flags = haspermission( $dbh, $userid, $flagsrequired ) ) { $loggedin = 1; } @@ -574,39 +559,34 @@ sub checkauth { $branchname = $branches->{$br}->{'branchname'}; } } - my $hash = C4::Context::set_userenv( - $borrowernumber, $userid, $cardnumber, - $firstname, $surname, $branchcode, - $branchname, $userflags, $emailaddress, - $branchprinter, - ); - - $envcookie = $query->cookie( - -name => 'userenv', - -value => $hash, - -expires => '' - ); + + $session->param('number',$borrowernumber); + $session->param('id',$userid); + $session->param('cardnumber',$cardnumber); + $session->param('firstname',$firstname); + $session->param('surname',$surname); + $session->param('branch',$branchcode); + $session->param('branchname',$branchname); + $session->param('flags',$userflags); + $session->param('emailaddress',$emailaddress); + $session->param('ip',$session->remote_addr()); + $session->param('lasttime',time()); } elsif ( $return == 2 ) { #We suppose the user is the superlibrarian - my $hash = C4::Context::set_userenv( - 0, - 0, - C4::Context->config('user'), - C4::Context->config('user'), - C4::Context->config('user'), - "", - "NO_LIBRARY_SET", - 1, - C4::Context->preference('KohaAdminEmailAddress') - ); - $envcookie = $query->cookie( - -name => 'userenv', - -value => $hash, - -expires => '' - ); - } + $session->param('number',0); + $session->param('id',C4::Context->config('user')); + $session->param('cardnumber',C4::Context->config('user')); + $session->param('firstname',C4::Context->config('user')); + $session->param('surname',C4::Context->config('user'),); + $session->param('branch','NO_LIBRARY_SET'); + $session->param('branchname','NO_LIBRARY_SET'); + $session->param('flags',1); + $session->param('emailaddress', C4::Context->preference('KohaAdminEmailAddress')); + $session->param('ip',$session->remote_addr()); + $session->param('lasttime',time()); + } } else { if ($userid) { @@ -620,21 +600,13 @@ sub checkauth { # finished authentification, now respond if ( $loggedin || $authnotrequired || ( defined($insecure) && $insecure ) ) { - # successful login unless ($cookie) { - $cookie = $query->cookie( - -name => 'sessionID', - -value => '', - -expires => '' + $cookie = $query->cookie( CGISESSID => '' ); } - if ($envcookie) { - return ( $userid, [ $cookie, $envcookie ], $sessionID, $flags ); - } - else { - return ( $userid, $cookie, $sessionID, $flags ); - } + return ( $userid, $cookie, $sessionID, $flags ); + } # else we have a problem... @@ -678,11 +650,8 @@ sub checkauth { LibraryName => => C4::Context->preference("LibraryName"), ); $template->param( \%info ); - $cookie = $query->cookie( - -name => 'sessionID', - -value => $sessionID, - -expires => '' - ); +# $cookie = $query->cookie(CGISESSID => $session->id +# ); print $query->header( -type => 'utf-8', -cookie => $cookie diff --git a/about.pl b/about.pl index 641451e1b4..99b9fd55d5 100755 --- a/about.pl +++ b/about.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +ö#!/usr/bin/perl # This file is part of Koha. # diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl old mode 100755 new mode 100644 diff --git a/acqui/parcel.pl b/acqui/parcel.pl old mode 100755 new mode 100644 diff --git a/acqui/parcels.pl b/acqui/parcels.pl old mode 100755 new mode 100644 diff --git a/admin/categoryitem.pl b/admin/categoryitem.pl old mode 100755 new mode 100644 diff --git a/admin/itemtypecategory.pl b/admin/itemtypecategory.pl old mode 100755 new mode 100644 diff --git a/admin/itemtypesubcategory.pl b/admin/itemtypesubcategory.pl old mode 100755 new mode 100644 diff --git a/admin/mediatype.pl b/admin/mediatype.pl old mode 100755 new mode 100644 diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl old mode 100755 new mode 100644 diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl old mode 100755 new mode 100644 diff --git a/installer/InstallAuth.pm b/installer/InstallAuth.pm old mode 100755 new mode 100644 diff --git a/installer/externalmodules.pl b/installer/externalmodules.pl old mode 100755 new mode 100644 diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index a22b0649f4..fd47e19063 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -1374,13 +1374,11 @@ CREATE TABLE `sessionqueries` ( -- Table structure for table `sessions` -- -DROP TABLE IF EXISTS `sessions`; -CREATE TABLE `sessions` ( - `sessionID` varchar(255) NOT NULL default '', - `userid` varchar(255) default NULL, - `ip` varchar(16) default NULL, - `lasttime` int(11) default NULL, - PRIMARY KEY (`sessionID`) +DROP TABLE IF EXISTS sessions; +CREATE TABLE sessions ( + `id` char(32) NOT NULL, + `a_session` text NOT NULL, + UNIQUE KEY id (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1632,6 +1630,20 @@ CREATE TABLE `users` ( `level` smallint(6) default NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `websites` +-- + +DROP TABLE IF EXISTS `websites`; +CREATE TABLE `websites` ( + `websitenumber` int(11) NOT NULL auto_increment, + `biblionumber` int(11) NOT NULL default '0', + `title` mediumtext, + `description` mediumtext, + `url` varchar(255) default NULL, + PRIMARY KEY (`websitenumber`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- -- Table structure for table `z3950queue` -- diff --git a/koha-tmpl/intranet-tmpl/prog/en/catalogue/subject.tmpl b/koha-tmpl/intranet-tmpl/prog/en/catalogue/subject.tmpl old mode 100644 new mode 100755 diff --git a/koha-tmpl/intranet-tmpl/prog/en/circ/branchoverdues.tmpl b/koha-tmpl/intranet-tmpl/prog/en/circ/branchoverdues.tmpl old mode 100644 new mode 100755 diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/guarantor_search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/guarantor_search.tmpl old mode 100644 new mode 100755 diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl old mode 100644 new mode 100755 diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl old mode 100644 new mode 100755 diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl old mode 100644 new mode 100755 diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl old mode 100644 new mode 100755 diff --git a/members/borrowers_details.pl b/members/borrowers_details.pl old mode 100755 new mode 100644 diff --git a/members/member-picupload.pl b/members/member-picupload.pl old mode 100755 new mode 100644 diff --git a/members/setdebar.pl b/members/setdebar.pl old mode 100755 new mode 100644 diff --git a/opac/opac-ics.pl b/opac/opac-ics.pl new file mode 100755 index 0000000000..ec03b70b04 --- /dev/null +++ b/opac/opac-ics.pl @@ -0,0 +1,93 @@ +#!/usr/bin/perl + +# Copyright 2007 Liblime Ltd + +# This file is part of Koha. +# +# Koha 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. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +# This script builds an ICalendar file (rfc 2445) for use in programs such as Ical + +use strict; +use CGI; +use Data::ICal; +use Data::ICal::Entry::Event; +use Date::ICal; +use Date::Calc qw (Parse_Date); + +use C4::Auth; +use C4::Koha; +use C4::Circulation::Circ2; +use C4::Date; + +my $query = new CGI; +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-user.tmpl", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => { borrow => 1 }, + debug => 1, + } +); + +# get borrower information .... +my ( $borr, $flags ) = getpatroninformation( undef, $borrowernumber ); + +# Create Calendar +my $calendar = Data::ICal->new(); + +# get issued items .... +my $issues = getissues($borr); + +foreach my $key ( keys %$issues ) { + my $issue = $issues->{$key}; + my $vevent = Data::ICal::Entry::Event->new(); + my ($year,$month,$day)=Parse_Date($issue->{'date_due'}); + ($year,$month,$day)=split /-|\/|\.|:/,$issue->{'date_due'} unless ($year && $month); +# Decode_Date_EU2($string)) + my $datestart = Date::ICal->new( + day => $day, + month => $month, + year => $year, + hour => 9, + min => 0, + sec => 0 + )->ical; + my $dateend = Date::ICal->new( + day => $day, + month => $month, + year => $year, + hour => 10, + min => 0, + sec => 0 + )->ical; + $vevent->add_properties( + summary => "$issue->{'title'} Due", + description => +"Your copy of $issue->{'title'} barcode $issue->{'barcode'} is due back at the library today", + dtstart => $datestart, + dtend => $dateend, + ); + $calendar->add_entry($vevent); +} + +print $query->header( + -type => 'application/octet-stream', + -attachment => 'koha.ics' +); + + +print $calendar->as_string; diff --git a/reports/reports-home.pl b/reports/reports-home.pl old mode 100755 new mode 100644 diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl old mode 100755 new mode 100644