#!/usr/local/bin/perl require './user-lib.pl'; &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0, &help_search_link("passwd group shadow gshadow", "man")); $formno = 0; %access = &get_module_acl(); # Get the user and group lists @allulist = &list_users(); @ulist = &list_allowed_users(\%access, \@allulist); @allglist = &list_groups(); @glist = &list_allowed_groups(\%access, \@allglist); foreach $g (@allglist) { $usedgid{$g->{'gid'}} = $g; } # Show users list header if (@ulist || $access{'ucreate'}) { print "\n"; print "\n"; print "\n"; if (@glist || $access{'gcreate'}) { print "\n"; } print "
".&ui_subheading($text{'index_users'})."", "$text{'index_gjump'}
\n"; } if (@ulist > $config{'display_max'}) { # Display user search form print "$text{'index_toomany'}

\n"; print "

\n"; print &hlink("$text{'index_find'}","findform"), "   \n"; print "
\n"; $formno++; } elsif (@ulist) { # Display a table of all users @ulist = &sort_users(\@ulist, $config{'sort_mode'}); if ($access{'icons'}) { # Show an icon for each user &show_user_buttons(); local @icons = map { "images/user.gif" } @ulist; local @links = map { "edit_user.cgi?num=$_->{'num'}" } @ulist; local @titles = map { $_->{'user'} } @ulist; &icons_table(\@links, \@titles, \@icons, 5); } elsif ($config{'display_mode'} == 2) { # Show usernames under groups foreach $u (@ulist) { push(@{$ug{$u->{'gid'}}}, $u); } &show_user_buttons(); print "\n"; print " ", "\n"; foreach $g (keys %ug) { print "\n"; print "\n"; } print "
$text{'index_ugroup'}$text{'index_users'}
", &html_escape($usedgid{$g}->{'group'}), "\n"; $i = 0; foreach $u (@{$ug{$g}}) { if ($i%4 == 0) { print "\n"; } print "\n"; if ($i%4 == 3) { print "\n"; } $i++; } print "
",&user_link($u),"
\n"; } elsif ($config{'display_mode'} == 1) { # Show names, real names, home dirs and shells &users_table(\@ulist, $formno++, 0, 0, [ &get_user_buttons() ]); $no_user_buttons = 1; } else { # Just show names &show_user_buttons(); print "\n"; print "\n"; print "
$text{'index_users'}
\n"; for($i=0; $i<@ulist; $i++) { if ($i%4 == 0) { print "\n"; } print "\n"; if ($i%4 == 3) { print "\n"; } } print "
",&user_link($ulist[$i]),"
\n"; } } elsif ($access{'ucreate'}) { if (@allulist) { print "$text{'index_notusers'}.

\n"; } else { print "$text{'index_notusers2'}.

\n"; } } &show_user_buttons() if (!$no_user_buttons); print "

\n"; if (@glist || $access{'gcreate'}) { print "


\n"; print "\n"; print "\n"; print "\n"; if (@ulist || $access{'ucreate'}) { print "\n"; } print "
".&ui_subheading($text{'index_groups'})."", "$text{'index_ujump'}
\n"; } if (@glist > $config{'display_max'}) { # Display group search form print "$text{'index_gtoomany'}

\n"; print "

\n"; print &hlink("$text{'index_gfind'}","gfindform"), "   \n"; print "
\n"; $formno++; } elsif (@glist) { @glist = &sort_groups(\@glist, $config{'sort_mode'}); if ($access{'icons'}) { # Show an icon for each group &show_group_buttons(); local @icons = map { "images/group.gif" } @glist; local @links = map { "edit_group.cgi?num=$_->{'num'}" } @glist; local @titles = map { $_->{'group'} } @glist; &icons_table(\@links, \@titles, \@icons, 5); } elsif ($config{'display_mode'} == 1) { # Display group name, ID and members &groups_table(\@glist, $formno++, 0, [ &get_group_buttons() ]); $no_group_buttons = 1; } else { # Just display group names &show_group_buttons(); print "\n"; print "\n"; print "
$text{'index_groups'}
\n"; for($i=0; $i<@glist; $i++) { if ($i%4 == 0) { print "\n"; } print "\n"; if ($i%4 == 3) { print "\n"; } } print "
", &group_link($glist[$i]),"
\n"; } } elsif ($access{'gcreate'} == 1) { print "
\n"; if (@allglist) { print "$text{'index_notgroups'}.

\n"; } else { print "$text{'index_notgroups2'}.

\n"; } } &show_group_buttons() if (!$no_group_buttons); if ($access{'logins'}) { print "


\n"; print "\n"; print "\n"; print "\n"; if (defined(&logged_in_users)) { print "\n"; print "\n"; } print "
\n"; print " ", &user_chooser_button("username",0,$formno),"
\n"; } &ui_print_footer("/", $text{'index'}); sub get_user_buttons { local @rv; if ($access{'ucreate'}) { local $cancreate; if ($access{'hiuid'} && !$access{'umultiple'}) { foreach $u (@allulist) { $useduid{$u->{'uid'}}++; } for($i=int($access{'lowuid'}); $i<=$access{'hiuid'}; $i++) { if (!$useduid{$i}) { $cancreate = 1; last; } } } else { $cancreate = 1; } if ($cancreate) { push(@rv, "". "$text{'index_createuser'}"); } else { push(@rv, $text{'index_nomoreusers'}); } } push(@rv, "$text{'index_batch'}") if ($access{'batch'}); push(@rv, "$text{'index_export'}") if ($access{'export'}); return @rv; } sub show_user_buttons { local @b = &get_user_buttons(); print &ui_links_row(\@b); } sub get_group_buttons { local @rv; if ($access{'gcreate'} == 1) { local $cancreate; if ($access{'higid'} && !$access{'gmultiple'}) { for($i=int($access{'lowgid'}); $i<=$access{'higid'}; $i++) { if (!$usedgid{$i}) { $cancreate = 1; last; } } } else { $cancreate = 1; } if ($cancreate) { push(@rv, "$text{'index_creategroup'}"); } else { push(@rv, $text{'index_nomoregroups'}); } } return @rv; } sub show_group_buttons { local @b = &get_group_buttons(); print &ui_links_row(\@b); }