File:  [LON-CAPA] / loncom / auth / blockedaccess.pm
Revision 1.2: download - view: text, annotated - select for diffs
Mon Dec 11 18:59:21 2006 UTC (17 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: version_2_8_X, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_99_1, version_2_2_99_0, HEAD, GCI_1
- style

    1: # The LearningOnline Network
    2: # Information about blocking status for Portfolio files
    3: #
    4: # Copyright Michigan State University Board of Trustees
    5: #
    6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    7: #
    8: # LON-CAPA is free software; you can redistribute it and/or modify
    9: # it under the terms of the GNU General Public License as published by
   10: # the Free Software Foundation; either version 2 of the License, or
   11: # (at your option) any later version.
   12: #
   13: # LON-CAPA is distributed in the hope that it will be useful,
   14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16: # GNU General Public License for more details.
   17: #
   18: # You should have received a copy of the GNU General Public License
   19: # along with LON-CAPA; if not, write to the Free Software
   20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21: #
   22: # /home/httpd/html/adm/gpl.txt
   23: #
   24: # http://www.lon-capa.org/
   25: #
   26: 
   27: package Apache::blockedaccess;
   28: 
   29: use strict;
   30: use Apache::Constants qw(:common :http REDIRECT);
   31: use Apache::lonnet;
   32: use Apache::loncommon();
   33: use Apache::lonlocal;
   34: 
   35: sub handler {
   36:     my $r = shift;
   37:     my $origurl = $r->uri;
   38:     my ($type,$udom,$uname,$file_name,$group) = 
   39: 	&Apache::lonnet::parse_portfolio_url($origurl);
   40:     &Apache::loncommon::content_type($r,'text/html');
   41:     $r->send_http_header;
   42:     return OK if $r->header_only;
   43: 
   44:     &Apache::lonlocal::get_language_handle($r);
   45:     my ($blocked,$blocktext) = 
   46:         &Apache::loncommon::blocking_status('port',$uname,$udom);
   47:     if ($blocked) {
   48:         $r->print(&Apache::loncommon::start_page('Access Temporarily Blocked'));
   49:         $r->print($blocktext);
   50:     } else {
   51:         my $server = &Apache::lonnet::absolute_url();
   52:         $r->header_out(Location => $server.$origurl);
   53:         return REDIRECT;
   54:     }
   55:     $r->print(&Apache::loncommon::end_page());
   56:     return OK;
   57: }
   58: 
   59: sub setup_handler {
   60:     my ($r) = @_;
   61:     $r->set_handlers('PerlHandler'=>
   62:                      [\&Apache::blockedaccess::handler]);
   63:     $r->handler('perl-script');
   64: }
   65: 
   66: 1;

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