#!/usr/local/bin/perl # Display a list of other webmin servers use strict; use warnings; require './servers-lib.pl'; our (%text, %config, %access, %in); &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1); &ReadParse(); # Get servers and apply search my @servers = &list_servers_sorted(1); if ($in{'search'}) { @servers = grep { $_->{'host'} =~ /\Q$in{'search'}\E/i || $_->{'desc'} =~ /\Q$in{'search'}\E/i } @servers; } # Show search form my $form = 0; if (@servers > $config{'max_servers'} || $in{'search'}) { print &ui_form_start("index.cgi"); print "$text{'index_search'} ", &ui_textbox("search", $in{'search'}, 40)," ", &ui_submit($text{'index_ok'}),"
\n"; print &ui_form_end(); $form++; } # Work out links my @linksrow; if ($access{'edit'}) { if (@servers) { print &ui_form_start("delete_servs.cgi"); push(@linksrow, &select_all_link("d", $form), &select_invert_link("d", $form)); } if ($access{'add'}) { push(@linksrow, &ui_link("edit_serv.cgi?new=1", $text{'index_add'}) ); } } if (@servers && $config{'display_mode'}) { # Show table of servers print &ui_links_row(\@linksrow); print &ui_columns_start([ $access{'edit'} ? ( "" ) : ( ), $text{'index_host'}, $text{'index_desc'}, $text{'index_group'}, $text{'index_os'} ], 100); foreach my $s (@servers) { my @cols; my $table = "
\n"; $table .= ($s->{'realhost'} || $s->{'host'}); $table .= ":$s->{'port'}" if ($s->{'port'}); $table .= " | \n"; } else { my $link = ""; if ($s->{'user'} || $s->{'autouser'}) { $link = "link.cgi/".$s->{'id'}."/"; } else { $link = &make_url($s); } $table .= "\n"; $table .= &ui_link($link, ($s->{'realhost'} || $s->{'host'} ). ":".$s->{'port'}, undef, "target=_top"); $table .= " | \n"; } $table .= ""; if ($s->{'autouser'} && &logged_in($s)) { $table .= &ui_link("logout.cgi?id=".$s->{'id'}, "(".$text{'index_logout'}.")"); } if ($access{'edit'}) { $table .= &ui_link("edit_serv.cgi?id=".$s->{'id'}, "(".$text{'index_edit'}.")"); } $table .= " |
\n"; } else { # No servers exist print "$text{'index_noservers'}
\n";
}
if ($access{'edit'}) {
print &ui_links_row(\@linksrow);
if (@servers) {
print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
}
}
my $myip = &get_my_address();
my $myscan = &address_to_broadcast($myip, 1) if ($myip);
if ($access{'find'} || $access{'auto'}) {
print &ui_hr();
print &ui_buttons_start();
if ($access{'find'}) {
# Buttons to scan and broadcast for servers
my %miniserv;
&get_miniserv_config(\%miniserv);
my $port = $config{'listen'} || $miniserv{'listen'} || 10000;
print &ui_buttons_row("find.cgi", $text{'index_broad'},
$text{'index_findmsg'});
my $t = &ui_buttons_row("find.cgi", $text{'index_scan'},
&text('index_scanmsg', &ui_textbox("scan", $myscan, 15)).
"
$text{'index_defuser'} | \n". "".&ui_textbox("defuser", undef, 20)." |
$text{'index_defpass'} | \n". "".&ui_password("defpass", undef, 20)." |
$text{'index_defport'} | \n". "".&ui_textbox("port", $port, 20)." |