--- loncom/cgi/takeonline.pl 2003/09/11 20:54:11 1.2 +++ loncom/cgi/takeonline.pl 2008/11/28 20:50:25 1.3 @@ -1,7 +1,8 @@ #!/usr/bin/perl +$|=1; # Take machine online # -# $Id: takeonline.pl,v 1.2 2003/09/11 20:54:11 www Exp $ +# $Id: takeonline.pl,v 1.3 2008/11/28 20:50:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,8 +27,34 @@ # http://www.lon-capa.org/ # -print "Content-type: text/html\n\n". - "

Take Online

"; -system('cp /home/httpd/html/origindex.html /home/httpd/html/index.html'); -system('rm /home/httpd/html/lon-status/reroute.txt'); -print ""; +use strict; +use lib '/home/httpd/lib/perl/'; +use Apache::lonlocal; +use LONCAPA::loncgi; + +print "Content-type: text/html\n\n"; + +&main(); + +sub main { + if (!&LONCAPA::loncgi::check_ipbased_access('takeonline')) { + if (!&LONCAPA::loncgi::check_cookie_and_load_env()) { + &Apache::lonlocal::get_language_handle(); + print &LONCAPA::loncgi::missing_cookie_msg(); + return; + } + + if (!&LONCAPA::loncgi::can_view('takeonline')) { + &Apache::lonlocal::get_language_handle(); + print &LONCAPA::loncgi::unauthorized_msg('takeonline'); + return; + } + } + + &Apache::lonlocal::get_language_handle(); + + print '

'.&Apache::lonlocal::mt('Take Online').'

'; + system('cp /home/httpd/html/origindex.html /home/httpd/html/index.html'); + system('rm /home/httpd/html/lon-status/reroute.txt'); + print ''; +}