File:  [LON-CAPA] / loncom / auth / lonlogout.pm
Revision 1.19: download - view: text, annotated - select for diffs
Mon May 1 21:04:31 2006 UTC (18 years ago) by albertel
Branches: MAIN
CVS tags: version_2_2_0, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, HEAD
- don't show th inline toggle link on the login/out screens

    1: # The LearningOnline Network
    2: # Logout Handler
    3: #
    4: # $Id: lonlogout.pm,v 1.19 2006/05/01 21:04:31 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:     #Check for cookie
   43:     my $requrl=$r->uri;
   44:     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
   45:     my $lonid=$cookies{'lonID'};
   46:     my $cookie;
   47:     if (!$lonid) {
   48: 	return FORBIDDEN;
   49:     }
   50: 
   51:     #check if cookie still valid
   52:     my $handle=$lonid->value;
   53:     $handle=~s/\W//g;
   54:     my $lonidsdir=$r->dir_config('lonIDsDir');
   55:     if ((!-e "$lonidsdir/$handle.id") || ($handle eq '')) {
   56: 	$r->log_reason("Cookie $handle not valid", $r->filename); 
   57: 	return FORBIDDEN;
   58:     }
   59: 
   60:     #we've got a valid user
   61:     my @profile;
   62:     my %sessionhash;
   63:     {
   64: 	my $idf=Apache::File->new("$lonidsdir/$handle.id");
   65: 	@profile=<$idf>;
   66:     }
   67:     my $envi;
   68:     for ($envi=0;$envi<=$#profile;$envi++) {
   69: 	chomp($profile[$envi]);
   70: 	my ($envname,$envvalue)=split(/=/,$profile[$envi]);
   71: 	$sessionhash{$envname}=$envvalue;
   72:     }
   73:     unlink("$lonidsdir/$handle.id");
   74:     my %temp=('logout' => time);
   75:     &Apache::lonnet::put('email_status',\%temp);
   76:     &Apache::lonnet::log($sessionhash{'user.domain'},
   77: 			 $sessionhash{'user.name'},
   78: 			 $sessionhash{'user.home'},
   79: 			 "Logout $ENV{'REMOTE_ADDR'}");
   80:     &Apache::loncommon::content_type($r,'text/html');
   81:     $r->send_http_header;
   82:     return OK if $r->header_only;
   83: # -------------------------------------------------------- Menu script and info
   84: 
   85:     my $windowinfo=&Apache::lonmenu::close();
   86:     $windowinfo.=&Apache::lonnavmaps::close();
   87: # ---------------------------------------------------------------- Get handover
   88:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['handover']);
   89:     my $switch='';
   90:     my $start_page='';
   91:     my $relogmessage='';
   92:     if ($env{'form.handover'}) {
   93: 	$switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.
   94: 	    $env{'form.handover'}.'">';
   95: 	$start_page=&Apache::loncommon::start_page('Switching Server ...',
   96: 						   $switch);
   97:     } else {
   98: 	$start_page=&Apache::loncommon::start_page('Logged Out',undef,
   99: 						   {'no_inline_link' => 1,});
  100: 	my %lt=&Apache::lonlocal::texthash('gb' => 'Goodbye',
  101: 					   'cw' => 'close this window',
  102: 					   'li' => 'log in again',
  103: 					   'pe' => 'Please either',
  104: 					   'or' => 'or');
  105: 	$relogmessage=(<<ENDRELOG);
  106: 	<h1>$lt{'gb'}!</h1>
  107: 	    $lt{'pe'} <a href="javascript:self.close();">$lt{'cw'}</a> $lt{'or'}
  108: 	<a href="/adm/login?domain=$sessionhash{'user.domain'}">$lt{'li'}</a>.
  109: ENDRELOG
  110:     }
  111:     my $end_page=&Apache::loncommon::end_page();
  112: # --------------------------------------------------------------- Screen Output
  113:     $r->print(<<ENDDOCUMENT);
  114: $start_page
  115: $windowinfo
  116: $relogmessage
  117: $end_page
  118: ENDDOCUMENT
  119:     &Apache::lonnet::flushcourselogs();
  120:     return OK; 
  121: }
  122: 
  123: 1;
  124: __END__
  125: 
  126: 
  127: 
  128: 
  129: 
  130: 
  131: 
  132: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>