# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.31051043346- [2004_01_29_102036]
# servers.pl for STTA 
 
if ($access{'global'}) {
        if ($access{'admin'} == 1) {
            if ($out_titles eq 1 ) {  
                print "<td align=center>\n";
	        print "<h3>$text{'index_servers'}</h3>\n";
            }
            $synclists_icon = { "icon" => "images/synclists.gif",
                             "name" => $text{'synclist_title'},
                             "link" => "stta_synclist.cgi" };
            if ($interface eq "tabs" ) {
                     &outconfig_icons("supervision", "index.cgi",
                         $logstta_icon, $deflists_icon, $defstta_icon );
                } else {
                     &config_icons("supervision", "index.cgi",
                         $logstta_icon, $deflists_icon, $defstta_icon );
            }
            %srv=();
            $i=0;
            $srvCfgPath="$config_directory/servers";
            opendir(DIR, "$srvCfgPath");
            foreach $f (readdir(DIR)) {
                # read the help file
                next if ( -d "$srvCfgPath/$f" );
                %srvcfg=();
                if ( $f =~ /\.serv$/ ) { &read_file("$srvCfgPath/$f", \%srvcfg); }
                next if ( !$srvcfg{id} || $srvcfg{id} eq "" );
                next if ( $config{stta_hosts} =~ $servcfg{host} );
	        $srv_icon = { "icon" => "images/iconsrv.gif",
		     	     "name" => $srvcfg{'host'},
			     "link" => "/servers/link.cgi/$srvcfg{'id'}/" };
                $srv{$i}=$srv_icon;
                $i++;
            }
            closedir(DIR);
            if ($interface eq "tabs" ) {
	        &outconfig_icons("servers", "index.cgi", $synclists_icon,
                           $srv{0}, $srv{1}, $srv{2}, $srv{3}, $srv{4}, $srv{5}, $srv{6},
                           $srv{7}, $srv{8}, $srv{9}, $srv{10}, $srv{11}, $srv{12} );
            } else {
                &config_icons("servers", "index.cgi", $synclists_icon,
                           $srv{0}, $srv{1}, $srv{2}, $srv{3}, $srv{4}, $srv{5}, $srv{6},
                           $srv{7}, $srv{8}, $srv{9}, $srv{10}, $srv{11}, $srv{12} );
                     }
           if ( $i > 12 ) {
                foreach $item (keys (%srv)) {
                    next if ( $item < 12 ); 
                    if ($interface eq "tabs" ) {
	                 &outconfig_icons("servers", "index.cgi",
                           $srv{$item})
                    } else {
                         &config_icons("servers", "index.cgi",
                           $srv{$item})
                    }
                }
           }
	}
}
