Handle hostnames with upper-case letters
[webmin.git] / htpasswd-file / index.cgi
1 #!/usr/local/bin/perl
2 # Display users in the .htpasswd file
3
4 require './htpasswd-file-lib.pl';
5 if ($access{'single'}) {
6         &redirect("edit.cgi");
7         exit;
8         }
9
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
11
12 # Check if file is set in config
13 if (!$config{'file'}) {
14         print &text('index_econfig',
15                           "../config.cgi?$module_name"),"<p>\n";
16         &ui_print_footer("/", $text{'index'});
17         exit;
18         }
19
20 if ($config{'md5'}) {
21         # Check if MD5 perl module is installed, and offer to install
22         &foreign_require("useradmin", "user-lib.pl");
23         if (!defined(&useradmin::check_md5)) {
24                 print &text('index_eversion',
25                                   "../config.cgi?$module_name"),"<p>\n";
26                 &ui_print_footer("/", $text{'index'});
27                 exit;
28                 }
29         elsif ($err = &useradmin::check_md5()) {
30                 print &text('index_emd5',
31                                   "../config.cgi?$module_name",
32                                   "<tt>$err</tt>",
33                                   "../cpan/download.cgi?source=3&cpan=Digest::MD5&mode=2&return=/$module_name/&returndesc=".&urlize($text{'index_return'})),"<p>\n";
34                 &ui_print_footer("/", $text{'index'});
35                 exit;
36                 }
37         }
38
39 # Display list of users
40 print &ui_subheading(&text('index_file', "<tt>$config{'file'}</tt>"));
41 $users = &list_users();
42 if (@$users) {
43         print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><br>\n"
44                 if ($access{'create'});
45         print "<table border width=100%>\n";
46         print "<tr $tb> <td><b>$text{'index_header'}</b></td> </tr>\n";
47         print "<tr $cb> <td><table width=100%>\n";
48         for($i=0; $i<@$users; $i++) {
49                 $u = $users->[$i];
50                 $link = "<a href='edit.cgi?idx=$u->{'index'}'>".
51                         "$u->{'user'}</a>";
52                 print "<tr>\n" if ($i%4 == 0);
53                 if ($u->{'enabled'}) {
54                         print "<td width=25%>$link</td>\n";
55                         }
56                 else {
57                         print "<td width=25%><i>$link</i></td>\n";
58                         }
59                 print "</tr>\n" if ($i%4 == 3);
60                 }
61         if ($i%4) {
62                 while($i++%4) { print "<td width=25%></td>\n"; }
63                 print "</tr>\n";
64                 }
65         print "</table></td></tr></table>\n";
66         }
67 else {
68         print "<b>$text{'index_none'}</b><p>\n";
69         }
70 print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><p>\n"
71         if ($access{'create'});
72
73 if ($access{'sync'}) {
74         # Show sync options
75         print "<hr>\n";
76         print &ui_subheading($text{'index_sync'});
77         print "<form action=save_sync.cgi>\n";
78         printf "<input type=checkbox name=create value=1 %s> %s<p>\n",
79                 $config{'sync_create'} ? "checked" : "",
80                 $text{'index_synccreate'};
81         printf "<input type=checkbox name=modify value=1 %s> %s<p>\n",
82                 $config{'sync_modify'} ? "checked" : "",
83                 $text{'index_syncmodify'};
84         printf "<input type=checkbox name=delete value=1 %s> %s<p>\n",
85                 $config{'sync_delete'} ? "checked" : "",
86                 $text{'index_syncdelete'};
87         print "<input type=submit value='$text{'index_ssave'}'></form>\n";
88         }
89
90 &ui_print_footer("/", $text{'index'});
91