Annotation of loncom/auth/lonlogout.pm, revision 1.2
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;
1.2 ! www 14: use Apache::lonmenu;
1.1 www 15: use CGI::Cookie();
16:
17: sub handler {
18: my $r = shift;
19:
20: my $requrl=$r->uri;
21: my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
22: my $lonid=$cookies{'lonID'};
23: my $cookie;
24: if ($lonid) {
25: my $handle=$lonid->value;
26: $handle=~s/\W//g;
27: my $lonidsdir=$r->dir_config('lonIDsDir');
28: if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
29: my @profile;
30: my %sessionhash;
31: {
32: my $idf=Apache::File->new("$lonidsdir/$handle.id");
33: @profile=<$idf>;
34: }
35: my $envi;
36: for ($envi=0;$envi<=$#profile;$envi++) {
37: chomp($profile[$envi]);
38: my ($envname,$envvalue)=split(/=/,$profile[$envi]);
39: $sessionhash{$envname}=$envvalue;
40: }
41: unlink("$lonidsdir/$handle.id");
42: &Apache::lonnet::log($sessionhash{'user.domain'},
43: $sessionhash{'user.name'},
44: $sessionhash{'user.home'},
45: "Logout $ENV{'REMOTE_ADDR'}");
46: $r->content_type('text/html');
47: $r->send_http_header;
48: return OK if $r->header_only;
1.2 ! www 49: # -------------------------------------------------------- Menu script and info
! 50:
! 51: my $windowinfo=&Apache::lonmenu::close();
! 52:
! 53: # --------------------------------------------------------------- Screen Output
1.1 www 54: $r->print(<<ENDDOCUMENT);
55: <html>
56: <head><title>The LearningOnline Network with CAPA Logout</title></head>
1.2 ! www 57: <body bgcolor="#FFFFFF">
! 58: $windowinfo
! 59: <h1>Goodbye!</h1></body>
1.1 www 60: </html>
61: ENDDOCUMENT
62: return OK;
63: } else {
64: $r->log_reason("Cookie $handle not valid", $r->filename);
65: }
66: }
67: return FORBIDDEN;
68: }
69:
70: 1;
71: __END__
72:
73:
74:
75:
76:
77:
78:
79:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>