#!/usr/local/bin/perl # index.cgi # Display hosts on which users are being managed, and inputs for adding more require './cluster-useradmin-lib.pl'; &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1); # Display hosts on which users will be managed print &ui_subheading($text{'index_hosts'}); @servers = &list_servers(); @hosts = &list_useradmin_hosts(); if ($config{'sort_mode'} == 1) { @hosts = sort { my ($as) = grep { $_->{'id'} == $a->{'id'} } @servers; my ($bs) = grep { $_->{'id'} == $b->{'id'} } @servers; lc($as->{'host'}) cmp lc($bs->{'host'}) } @hosts; } elsif ($config{'sort_mode'} == 2) { @hosts = sort { my ($as) = grep { $_->{'id'} == $a->{'id'} } @servers; my ($bs) = grep { $_->{'id'} == $b->{'id'} } @servers; lc(&server_name($as)) cmp lc(&server_name($bs)) }@hosts; } $formno = 0; foreach $h (@hosts) { local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; next if (!$s); local ($link) = $config{'conf_host_links'} ? "edit_host.cgi?id=$h->{'id'}" : "#"; push(@titles, $s->{'desc'} ? $s->{'desc'} : "$s->{'host'}:$s->{'port'}"); push(@links, $link); push(@icons, $gconfig{'webprefix'} ? ($gconfig{'webprefix'}."/servers/images/".$s->{'type'}.".gif") : ("../servers/images/".$s->{'type'}.".gif")); push(@installed, @{$h->{'packages'}}); $gothost{$h->{'id'}}++; } if (@links) { if ($config{'table_mode'}) { # Show as table print &ui_columns_start([ $text{'index_thost'}, $text{'index_tdesc'}, $text{'index_tucount'}, $text{'index_tgcount'}, $text{'index_ttype'} ]); foreach $h (@hosts) { local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; next if (!$s); local ($type) = grep { $_->[0] eq $s->{'type'} } @servers::server_types; local ($link) = $config{'conf_host_links'} ? &ui_link("edit_host.cgi?id=$h->{'id'}",($s->{'host'} || &get_system_hostname())) : ($s->{'host'} || &get_system_hostname()); print &ui_columns_row([ $link, $s->{'desc'}, scalar(@{$h->{'users'}}), scalar(@{$h->{'groups'}}), $type->[1], ]); } print &ui_columns_end(); } else { # Show as icons &icons_table(\@links, \@titles, \@icons); } } else { print "$text{'index_nohosts'}

\n"; } $formno++; print "

\n"; print "\n"; @addservers = grep { !$gothost{$_->{'id'}} } @servers; if (@addservers) { print "\n"; } @groups = &servers::list_all_groups(\@servers); if (@groups) { print "\n"; } print "
\n"; print "\n"; print "
\n"; if ($config{'conf_add_user'} == 0 && $config{'conf_add_group'} == 0 && $config{'conf_allow_refresh'} == 0 && $config{'conf_allow_sync'} == 0 && $config{'conf_find_user'} == 0 && $config{'conf_find_group'} == 0) { # If we have configured EVERY possible 'host' action off, then don't show # the header/horizontal-rule/etc... @hosts = (); } if (@hosts) { # Display search and add forms print &ui_hr(); print &ui_subheading($text{'index_users'}); print ""; if ($config{'conf_find_user'} == 1 || $config{'conf_add_user'} == 1) { print "\n"; } if ($config{'conf_find_user'} == 1) { print "\n"; } if ($config{'conf_add_user'} == 1 && $config{'conf_find_user'} == 1) { print "\n"; } if ($config{'conf_find_user'} == 1 || $config{'conf_add_user'} == 1) { print "\n"; } if ($config{'conf_find_group'} == 1 || $config{'conf_add_group'} == 1) { print "\n"; } if ($config{'conf_find_group'} == 1) { print ""; } if ($config{'conf_add_group'} == 1 && $config{'conf_find_group'} == 1) { print "\n"; } if ($config{'conf_find_group'} == 1 || $config{'conf_add_group'} == 1) { print "\n"; } if ($config{'conf_allow_refresh'} == 1 || $config{'conf_allow_sync'} == 1) { print "\n"; } if ($config{'conf_allow_refresh'} == 1) { print "\n"; } if ($config{'conf_allow_refresh'} == 1 && $config{'conf_allow_sync'} == 1) { print "\n"; } if ($config{'conf_allow_refresh'} == 1 || $config{'conf_allow_sync'} == 1) { print "\n"; } print "
\n"; print "
\n"; print "$text{'index_finduser'}   \n"; print "
\n"; print "
\n"; } elsif ($config{'conf_add_user'} == 1) { print "\n"; } if ($config{'conf_add_user'} == 1) { print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "
"; print "$text{'index_findgroup'}   \n"; print ""; print "
\n"; print "
\n"; } elsif ($config{'conf_add_group'} == 1) { print "\n"; } if ($config{'conf_add_group'} == 1) { print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "\n"; &create_on_input(undef, 1); print "
\n"; print "
"; } else { print ""; } if ($config{'conf_allow_sync'} == 1) { print "
\n"; print "\n"; print "
\n"; print "
\n"; } &ui_print_footer("/", $text{'index'});