version 1.5, 2003/09/01 03:37:27
|
version 1.7, 2008/11/28 20:50:25
|
Line 25
|
Line 25
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
|
|
use strict; |
$|=1; |
$|=1; |
|
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA::Configuration; |
use Apache::lonnet; |
|
use LONCAPA::loncgi; |
use IO::File; |
|
use IO::Socket; |
|
|
|
my %perlvar; |
print("Content-type: text/plain\n\n"); |
|
|
# -------------------------------------------------- Non-critical communication |
&main(); |
sub reply { |
|
my ($cmd,$server)=@_; |
|
my $peerfile="$perlvar{'lonSockDir'}/$server"; |
|
my $client=IO::Socket::UNIX->new(Peer =>"$peerfile", |
|
Type => SOCK_STREAM, |
|
Timeout => 10) |
|
or return "con_lost"; |
|
print $client "$cmd\n"; |
|
my $answer=<$client>; |
|
chomp($answer); |
|
if (!$answer) { $answer="con_lost"; } |
|
return $answer; |
|
} |
|
|
|
|
sub main { |
|
if (!&LONCAPA::loncgi::check_ipbased_access('ping')) { |
|
if (!&LONCAPA::loncgi::check_cookie_and_load_env()) { |
|
return; |
|
} |
|
|
# --------------------- Read loncapa.conf (and by default loncapa_apache.conf). |
if (!&LONCAPA::loncgi::can_view('ping')) { |
my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf'); |
return; |
%perlvar=%{$perlvarref}; |
} |
undef $perlvarref; # remove since sensitive and not needed |
} |
delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed |
|
delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed |
|
|
|
$testhost=$ENV{'QUERY_STRING'}; |
my $testhost=$ENV{'QUERY_STRING'}; |
$testhost=~s/\W//g; |
$testhost=~s/\W//g; |
|
|
print "Content-type: text/plain\n\n". |
print &Apache::lonnet::reply('ping',$testhost)."\n"; |
&reply('ping',$testhost)."\n"; |
return; |
|
} |