#!/usr/bin/perl
# fixhosts.cgi
# ...  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';
&headerstta("$text{'index_fixlists'}->host", "", "modhosts",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" );
print "<hr><p>\n"; 

 print "<table width=100% border>\n";
 print "<tr $tb> <td><font color='$revtext'><b>$text{'titidx_modhosts'}</b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<center>\n";

 %h_hosts=&list_hosts();
 %h_grphosts=&list_grphosts();
 foreach $item (keys (%h_hosts)) { push (@listhosts, $h_hosts{$item}); }
 @list__hosts = sort {$a->{'name'} cmp $b->{'name'}} @listhosts;
 &lock_file($config{'hosts_list'});
 open(FILEHOSTS, ">$config{'hosts_list'}");
     foreach $hosts (@list__hosts) {
         $ensObj=$host->{'ens'};
         $dnObj=$host->{'obj'};
         $grpObj=$hosts->{'grpalias'};
         $portAlive=$hosts->{'portalive'};
         if ( $ensObj eq "" ) {
              $ensObj=$h_grphosts{$grpObj}->{'ens'}."/cn=".$hosts->{'name'};
         } 
         if ( $dnObj eq "" ) {
              $dnObj="ou=".$hosts->{'name'}.",".$h_grphosts{$grpObj}->{'obj'};
         } 
#         if ( $portAlive eq "" ) {
              $portAlive="21";
#         }
         if ( $hosts->{'descrip'} eq "" ) {
                     $hosts->{'descrip'} = $hosts->{'name'};
         }
         $lin_hosts=$hosts->{'alias'}."::".$hosts->{'name'}."::".
                        $hosts->{'grpalias'}."::".$dnObj."::".
                        $ensObj."::".$hosts->{'ipname'}."::".
                        $hosts->{'maxsess'}."::".$portAlive."::".
                        $hosts->{'descrip'}."::\n";
         print FILEHOSTS "$lin_hosts";
     }
  close (FILEHOSTS);
  &unlock_file($config{'hosts_list'});
  print "<tr><p><b>".$text{'user_update'}."  </b></tr>\n";
  print "<tr></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;

