Annotation of loncom/auth/lonlogout.pm, revision 1.1
1.1 ! www 1: # The LearningOnline Network
! 2: # Logout Handler
! 3: # (Cookie Based Access Handler
! 4: # 5/21/99,5/22,5/29,5/31,6/15,16/11,22/11,
! 5: # 01/06,01/13 Gerd Kortemeyer)
! 6: # 05/31 Gerd Kortemeyer
! 7:
! 8: package Apache::lonlogout;
! 9:
! 10: use strict;
! 11: use Apache::Constants qw(:common);
! 12: use Apache::File;
! 13: use Apache::lonnet;
! 14: use CGI::Cookie();
! 15:
! 16: sub handler {
! 17: my $r = shift;
! 18:
! 19: my $requrl=$r->uri;
! 20: my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
! 21: my $lonid=$cookies{'lonID'};
! 22: my $cookie;
! 23: if ($lonid) {
! 24: my $handle=$lonid->value;
! 25: $handle=~s/\W//g;
! 26: my $lonidsdir=$r->dir_config('lonIDsDir');
! 27: if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
! 28: my @profile;
! 29: my %sessionhash;
! 30: {
! 31: my $idf=Apache::File->new("$lonidsdir/$handle.id");
! 32: @profile=<$idf>;
! 33: }
! 34: my $envi;
! 35: for ($envi=0;$envi<=$#profile;$envi++) {
! 36: chomp($profile[$envi]);
! 37: my ($envname,$envvalue)=split(/=/,$profile[$envi]);
! 38: $sessionhash{$envname}=$envvalue;
! 39: }
! 40: unlink("$lonidsdir/$handle.id");
! 41: &Apache::lonnet::log($sessionhash{'user.domain'},
! 42: $sessionhash{'user.name'},
! 43: $sessionhash{'user.home'},
! 44: "Logout $ENV{'REMOTE_ADDR'}");
! 45: $r->content_type('text/html');
! 46: $r->send_http_header;
! 47: return OK if $r->header_only;
! 48: $r->print(<<ENDDOCUMENT);
! 49: <html>
! 50: <head><title>The LearningOnline Network with CAPA Logout</title></head>
! 51: <body bgcolor="#FFFFFF"><h1>Goodbye!</h1></body>
! 52: </html>
! 53: ENDDOCUMENT
! 54: return OK;
! 55: } else {
! 56: $r->log_reason("Cookie $handle not valid", $r->filename);
! 57: }
! 58: }
! 59: return FORBIDDEN;
! 60: }
! 61:
! 62: 1;
! 63: __END__
! 64:
! 65:
! 66:
! 67:
! 68:
! 69:
! 70:
! 71:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>