File:  [LON-CAPA] / loncom / auth / londatecheck.pm
Revision 1.1: download - view: text, annotated - select for diffs
Mon May 31 20:24:11 2004 UTC (19 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
-n adding in functionality so that contentopne/close date settings are respected for html ish pages.

use strict;
package Apache::londatecheck;
use Apache::lonnet();
use Apache::Constants qw(:common :http :methods);

sub content_date_check {
    my $symb=$ENV{'request.symb'};
    my $open=&Apache::lonnet::EXT('resource.0.contentopen',$symb);
    &Apache::lonnet::logthis("Hrrm got an open of $open");
    my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb);
    if ( (defined($open)  && time < $open) ||
	 (defined($close) && time > $close)) {
	return ('CLOSED',$open,$close);
    }
    return ('OPEN',$open,$close);
}

sub handler {
    my ($r)=@_;
    my ($status)=&content_date_check();
    if ($status ne 'OPEN') {
	$r->set_handlers('PerlHandler'=>undef);
	&Apache::loncommon::content_type($r,'text/html');
	$r->send_http_header;
	return OK if $r->header_only;
	$r->print('<html><head><title>Go Away!</title>');
	my $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
	    '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
	$r->print(&Apache::lonmenu::registerurl(1));
	$r->print('</head>'.
		  &Apache::loncommon::bodytag('Go Away!','',$addentries,'','',
					      undef));
	$r->print('</body></html>');
	$r->print("Go Away!");
    }
    return OK;
}
1;

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