#!/usr/bin/perl
# tta_alivehosts.cgi
# Alive Hosts from Services with Tarantella
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.31051043346- [2004_01_29_102036]

 require './stta-lib.pl';
 &ReadParse();
 $hostname = $in{hostname};
 if (!$hostname) { &redirect("tta_selhosts.cgi?form=alivehosts&multi=1"); }
 $postform = $in{postform};

 &headerstta($text{'index_alivehosts'}, "", "alivehosts",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" ); 
 print "<hr><p>\n"; 
 print "<table width=100% border>\n";

if ( !$hostname ) {&footHere; exit }  ;  

%h_hosts=&list_hosts();
%h_grphosts=&list_grphosts();
if ($hostname && $hostname ne "all" ) {
    $obj_name="";
    $ens_hosts="";
    $dns_hosts="";
    if ( $h_hosts{$hostname}->{'alias'} ne $hostname ) {
         $err_msg=$text{'list_err'};
         &footHere;
         exit;
    }
}
if ( $hostname eq "all" ) {
     $title=$text{edit_all};
} else {
     $title="";
}
print "<tr $tb> <td><font color='$revtext'><b>$text{'titidx_alivehosts'} $title </b></td> </tr>\n";
print "<tr $cb> <td><table align=left>\n";
$rv = { 'fh' => time().$$ };   

if ( $hostname eq "all" ) {
        foreach $item (keys (%h_hosts)) { 
            next if ( !$h_hosts{$item}->{'portalive'})  ;  
            print "<tr><td><b>".&check_host($item,"true")."</b></td></tr>\n";
        }
} else {
        $hostname =~ s/\r|\n/ /g;
        foreach $item (split(/ /, $hostname)) {
            next if ( $item eq "" );
            print "<tr><td><b>".&check_host($item,"true")."</b></td></tr>\n";
        }
}
 print "<tr><tr></table></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;
