File:
[LON-CAPA] /
loncom /
auth /
lonlogout.pm
Revision
1.14:
download - view:
text,
annotated -
select for diffs
Thu Apr 7 06:56:21 2005 UTC (19 years, 4 months ago) by
albertel
Branches:
MAIN
CVS tags:
version_2_0_1,
version_2_0_0,
version_1_99_3,
version_1_99_2,
version_1_99_1_tmcc,
version_1_99_1,
version_1_99_0_tmcc,
version_1_99_0,
HEAD
- ENV -> env
1: # The LearningOnline Network
2: # Logout Handler
3: #
4: # $Id: lonlogout.pm,v 1.14 2005/04/07 06:56:21 albertel Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::lonlogout;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::File;
34: use Apache::lonnet;
35: use Apache::lonmenu;
36: use CGI::Cookie();
37: use Apache::lonlocal;
38:
39: sub handler {
40: my $r = shift;
41:
42: my $requrl=$r->uri;
43: my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
44: my $lonid=$cookies{'lonID'};
45: my $cookie;
46: if ($lonid) {
47: my $handle=$lonid->value;
48: $handle=~s/\W//g;
49: my $lonidsdir=$r->dir_config('lonIDsDir');
50: if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
51: my @profile;
52: my %sessionhash;
53: {
54: my $idf=Apache::File->new("$lonidsdir/$handle.id");
55: @profile=<$idf>;
56: }
57: my $envi;
58: for ($envi=0;$envi<=$#profile;$envi++) {
59: chomp($profile[$envi]);
60: my ($envname,$envvalue)=split(/=/,$profile[$envi]);
61: $sessionhash{$envname}=$envvalue;
62: }
63: unlink("$lonidsdir/$handle.id");
64: my %temp=('logout' => time);
65: &Apache::lonnet::put('email_status',\%temp);
66: &Apache::lonnet::log($sessionhash{'user.domain'},
67: $sessionhash{'user.name'},
68: $sessionhash{'user.home'},
69: "Logout $ENV{'REMOTE_ADDR'}");
70: &Apache::loncommon::content_type($r,'text/html');
71: $r->send_http_header;
72: return OK if $r->header_only;
73: # -------------------------------------------------------- Menu script and info
74:
75: my $windowinfo=&Apache::lonmenu::close();
76: $windowinfo.=&Apache::lonnavmaps::close();
77: # ---------------------------------------------------------------- Get handover
78: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['handover']);
79: my $switch='';
80: my $bodytag='';
81: my $relogmessage='';
82: if ($env{'form.handover'}) {
83: $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.
84: $env{'form.handover'}.'">';
85: $bodytag=&Apache::loncommon::bodytag('Switching Server ...');
86: } else {
87: $bodytag=&Apache::loncommon::bodytag('Logged Out');
88: my %lt=&Apache::lonlocal::texthash('gb' => 'Goodbye',
89: 'cw' => 'close this window',
90: 'li' => 'log in again',
91: 'pe' => 'Please either',
92: 'or' => 'or');
93: $relogmessage=(<<ENDRELOG);
94: <h1>$lt{'gb'}!</h1>
95: $lt{'pe'} <a href="javascript:self.close();">$lt{'cw'}</a> $lt{'or'}
96: <a href="/adm/login">$lt{'li'}</a>.
97: ENDRELOG
98: }
99: # --------------------------------------------------------------- Screen Output
100: $r->print(<<ENDDOCUMENT);
101: <html>
102: <head><title>The LearningOnline Network with CAPA Logout</title>
103: $switch
104: </head>
105: $bodytag
106: $windowinfo
107: $relogmessage
108: </body>
109: </html>
110: ENDDOCUMENT
111: &Apache::lonnet::flushcourselogs();
112: return OK;
113: } else {
114: $r->log_reason("Cookie $handle not valid", $r->filename);
115: }
116: }
117: return FORBIDDEN;
118: }
119:
120: 1;
121: __END__
122:
123:
124:
125:
126:
127:
128:
129:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>