Handle hostnames with upper-case letters
[webmin.git] / pap / list_secrets.cgi
1 #!/usr/local/bin/perl
2 # list_secrets.cgi
3 # Displays a list of all PAP secrets
4
5 require './pap-lib.pl';
6 $access{'secrets'} || &error($text{'secrets_ecannot'});
7 &ui_print_header(undef, $text{'secrets_title'}, "");
8
9 if (!-r $config{'pap_file'}) {
10         print "<b>", &text('index_enopfile', $config{'pap_file'}), "</b>.<p>\n";
11         &ui_print_footer("/", $text{'index_return'});
12         exit;
13         }
14
15 @links = ( &select_all_link("d"),
16            &select_invert_link("d"),
17           "<a href=edit_secret.cgi>$text{'index_create'}</a>" );
18
19 # Show table of users
20 @sec = &list_secrets();
21 @links = ( &select_all_link("d"),
22            &select_invert_link("d"),
23            "<a href=edit_secret.cgi>$text{'index_create'}</a>" );
24 if (@sec) {
25         print &ui_form_start("delete_secrets.cgi", "post");
26         @tds = ( "width=5" );
27         print &ui_links_row(\@links);
28         print &ui_columns_start(
29                 [ "", $text{'index_user'}, $text{'index_server'} ],
30                 undef, 0, \@tds);
31         for($i=0; $i<@sec; $i++) {
32                 $s = $sec[$i];
33                 local @cols;
34                 push(@cols, "<a href=\"edit_secret.cgi?$i\">".
35                         ($s->{'client'} ? &html_escape($s->{'client'})
36                                         : $text{'index_uany'})."</a>");
37                 push(@cols, $s->{'server'} eq "*" ? $text{'index_sany'}
38                                               : &html_escape($s->{'server'}));
39                 print &ui_checked_columns_row(\@cols, \@tds, "d", $i);
40                 }
41         print &ui_columns_end();
42         print &ui_links_row(\@links);
43         print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
44         }
45 else {
46         print "<b>$text{'secrets_none'}</b><p>\n";
47         print &ui_links_row([ $links[2] ]);
48         }
49
50 if ($access{'sync'}) {
51         print &ui_hr(), $text{'index_info'}, " <p>\n";
52
53         print "<form action=save_sync.cgi>\n";
54         printf "<input type=checkbox name=add value=1 %s>\n",
55                 $config{'sync_add'} ? "checked" : "";
56         print $text{'index_onadd'}, "\n";
57         print "<input name=server size=20 value='$config{'sync_server'}'><p>\n";
58
59         printf "<input type=checkbox name=change value=1 %s>\n",
60                 $config{'sync_change'} ? "checked" : "";
61         print $text{'index_onchange'}, "<p>\n";
62
63         printf "<input type=checkbox name=delete value=1 %s>\n",
64                 $config{'sync_delete'} ? "checked" : "";
65         print $text{'index_ondelete'}, "<p>\n";
66         print "<input type=submit value=", $text{'save'}, "></form>\n";
67         }
68
69 &ui_print_footer("", $text{'index_return'});
70