forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.cgi
executable file
·55 lines (48 loc) · 1.66 KB
/
index.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/local/bin/perl
# index.cgi
# Show a list of all users whose passwords can be changed
require './cluster-passwd-lib.pl';
# Check if cluster-useradmin is set up
@hosts = &cluster_useradmin::list_useradmin_hosts();
if (!@hosts) {
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
&ui_print_endpage(&text('index_noservers', "../cluster-useradmin/"));
}
@ulist = grep { &can_edit_passwd($_) } &get_all_users(\@hosts);
if (@ulist == 1) {
# Can only edit one user, so re-direct to editing form
&redirect("edit_passwd.cgi?user=$ulist[0]->{'user'}&one=1");
}
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
if ($config{'sort_mode'}) {
@ulist = sort { lc($a->{'user'}) cmp lc($b->{'user'}) } @ulist;
}
print &text('index_hosts', scalar(@hosts)),"<p>\n";
if ($config{'max_users'} && @ulist > $config{'max_users'}) {
# Show as form for entering a username
print "$passwd::text{'index_toomany'}<br>\n";
print &ui_form_start("edit_passwd.cgi");
print &ui_submit($passwd::text{'index_user'});
if ($config{'input_type'}) {
print &ui_select("user", undef,
[ map { [ $_->{'user'} ] } @ulist ]);
}
else {
print &ui_user_textbox("user");
}
print &ui_form_end();
}
else {
# Show as table of users
print &ui_table_start($passwd::text{'index_header'}, "width=100%");
for($i=0; $i<@ulist; $i++) {
if ($i%4 == 0) { print "<tr>\n"; }
print "<td width=25%><a href=\"edit_passwd.cgi?",
"user=$ulist[$i]->{'user'}\">",
&html_escape($ulist[$i]->{'user'})."</a></td>\n";
if ($i%4 == 3) { print "</tr>\n"; }
}
while($i++ % 4) { print "<td width=25%></td>\n"; }
print &ui_table_end();
}
&ui_print_footer("/", $text{'index'});