File:  [LON-CAPA] / loncom / auth / lonlogout.pm
Revision 1.12: download - view: text, annotated - select for diffs
Tue Sep 23 00:26:10 2003 UTC (20 years, 7 months ago) by www
Branches: MAIN
CVS tags: version_1_2_X, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, HEAD
Internationalizing.

    1: # The LearningOnline Network
    2: # Logout Handler
    3: #
    4: # $Id: lonlogout.pm,v 1.12 2003/09/23 00:26:10 www 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: # (Cookie Based Access Handler
   29: # 5/21/99,5/22,5/29,5/31,6/15,16/11,22/11,
   30: # 01/06,01/13 Gerd Kortemeyer)
   31: # 05/31,11/29,12/29 Gerd Kortemeyer
   32: 
   33: package Apache::lonlogout;
   34: 
   35: use strict;
   36: use Apache::Constants qw(:common);
   37: use Apache::File;
   38: use Apache::lonnet;
   39: use Apache::lonmenu;
   40: use CGI::Cookie();
   41: use Apache::lonlocal;
   42: 
   43: sub handler {
   44:     my $r = shift;
   45: 
   46:     my $requrl=$r->uri;
   47:     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
   48:     my $lonid=$cookies{'lonID'};
   49:     my $cookie;
   50:     if ($lonid) {
   51: 	my $handle=$lonid->value;
   52:         $handle=~s/\W//g;
   53:         my $lonidsdir=$r->dir_config('lonIDsDir');
   54:         if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
   55:            my @profile;
   56:            my %sessionhash;
   57: 	    {
   58:              my $idf=Apache::File->new("$lonidsdir/$handle.id");
   59:              @profile=<$idf>;
   60: 	    }
   61:             my $envi;
   62:             for ($envi=0;$envi<=$#profile;$envi++) {
   63: 		chomp($profile[$envi]);
   64: 		my ($envname,$envvalue)=split(/=/,$profile[$envi]);
   65:                 $sessionhash{$envname}=$envvalue;
   66:             }
   67:             unlink("$lonidsdir/$handle.id");
   68: 	    my %temp=('logout' => time);
   69: 	    &Apache::lonnet::put('email_status',\%temp);
   70: 	    &Apache::lonnet::log($sessionhash{'user.domain'},
   71:                                  $sessionhash{'user.name'},
   72:                                  $sessionhash{'user.home'},
   73:                                  "Logout $ENV{'REMOTE_ADDR'}");
   74:             &Apache::loncommon::content_type($r,'text/html');
   75:             $r->send_http_header;
   76:             return OK if $r->header_only;
   77: # -------------------------------------------------------- Menu script and info
   78: 
   79:     my $windowinfo=&Apache::lonmenu::close();
   80: # ---------------------------------------------------------------- Get handover
   81:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['handover']);
   82:     my $switch='';
   83:     my $bodytag='';
   84:     my $relogmessage='';
   85:     if ($ENV{'form.handover'}) {
   86:        $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.
   87: 	   $ENV{'form.handover'}.'">';
   88:        $bodytag=&Apache::loncommon::bodytag('Switching Server ...');
   89:    } else {
   90:        $bodytag=&Apache::loncommon::bodytag('Logged Out');
   91:        my %lt=&Apache::lonlocal::texthash('gb' => 'Goodbye',
   92:                                           'cw' => 'close this window',
   93:                                           'li' => 'log in again',
   94:                                           'pe' => 'Please either',
   95:                                           'or' => 'or');
   96:        $relogmessage=(<<ENDRELOG);
   97: <h1>$lt{'gb'}!</h1>
   98:     $lt{'pe'} <a href="javascript:self.close();">$lt{'cw'}</a> $lt{'or'}
   99: <a href="/adm/login">$lt{'li'}</a>.
  100: ENDRELOG
  101:    }
  102: # --------------------------------------------------------------- Screen Output
  103:             $r->print(<<ENDDOCUMENT);
  104: <html>
  105: <head><title>The LearningOnline Network with CAPA Logout</title>
  106: $switch
  107: </head>
  108: $bodytag
  109: $windowinfo
  110: $relogmessage
  111: </body>
  112: </html>
  113: ENDDOCUMENT
  114:             &Apache::lonnet::flushcourselogs();
  115:             return OK; 
  116:         } else { 
  117:             $r->log_reason("Cookie $handle not valid", $r->filename); 
  118:         }
  119:     }
  120:     return FORBIDDEN;
  121: }
  122: 
  123: 1;
  124: __END__
  125: 
  126: 
  127: 
  128: 
  129: 
  130: 
  131: 
  132: 

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