--- loncom/cgi/ping.pl 2007/04/17 23:18:42 1.6 +++ loncom/cgi/ping.pl 2008/11/28 20:50:25 1.7 @@ -1,6 +1,6 @@ #!/usr/bin/perl # ping cgi-script -# $Id: ping.pl,v 1.6 2007/04/17 23:18:42 albertel Exp $ +# $Id: ping.pl,v 1.7 2008/11/28 20:50:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,9 +30,26 @@ $|=1; use lib '/home/httpd/lib/perl/'; use Apache::lonnet; +use LONCAPA::loncgi; -my $testhost=$ENV{'QUERY_STRING'}; -$testhost=~s/\W//g; +print("Content-type: text/plain\n\n"); -print("Content-type: text/plain\n\n". - &Apache::lonnet::reply('ping',$testhost)."\n"); +&main(); + +sub main { + if (!&LONCAPA::loncgi::check_ipbased_access('ping')) { + if (!&LONCAPA::loncgi::check_cookie_and_load_env()) { + return; + } + + if (!&LONCAPA::loncgi::can_view('ping')) { + return; + } + } + + my $testhost=$ENV{'QUERY_STRING'}; + $testhost=~s/\W//g; + + print &Apache::lonnet::reply('ping',$testhost)."\n"; + return; +}