Annotation of loncom/auth/blockedaccess.pm, revision 1.1

1.1     ! raeburn     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 lib '/home/httpd/lib/perl/';
        !            31: use Apache::Constants qw(:common :http REDIRECT);
        !            32: use Apache::lonnet;
        !            33: use Apache::loncommon();
        !            34: use Apache::lonlocal;
        !            35: 
        !            36: sub handler {
        !            37:     my $r = shift;
        !            38:     my $origurl = $r->uri;
        !            39:     my ($type,$udom,$uname,$file_name,$group) = 
        !            40:              &Apache::lonnet::parse_portfolio_url($origurl);
        !            41:     &Apache::loncommon::content_type($r,'text/html');
        !            42:     $r->send_http_header;
        !            43:     return OK if $r->header_only;
        !            44: 
        !            45:     &Apache::lonlocal::get_language_handle($r);
        !            46:     my ($blocked,$blocktext) = 
        !            47:         &Apache::loncommon::blocking_status('port',$uname,$udom);
        !            48:     if ($blocked) {
        !            49:         $r->print(&Apache::loncommon::start_page('Access Temporarily Blocked'));
        !            50:         $r->print($blocktext);
        !            51:     } else {
        !            52:         my $server = &Apache::lonnet::absolute_url();
        !            53:         $r->header_out(Location => $server.$origurl);
        !            54:         return REDIRECT;
        !            55:     }
        !            56:     $r->print(&Apache::loncommon::end_page());
        !            57:     return OK;
        !            58: }
        !            59: 
        !            60: sub setup_handler {
        !            61:     my ($r) = @_;
        !            62:     $r->set_handlers('PerlHandler'=>
        !            63:                      [\&Apache::blockedaccess::handler]);
        !            64:     $r->handler('perl-script');
        !            65: }
        !            66: 
        !            67: 1;

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