Handle hostnames with upper-case letters
[webmin.git] / pptp-server / list_secrets.cgi
1 #!/usr/local/bin/perl
2 # list_secrets.cgi
3 # Displays a list of all PAP secrets
4
5 require './pptp-server-lib.pl';
6 $access{'secrets'} || &error($text{'secrets_ecannot'});
7 &ui_print_header(undef, $text{'secrets_title'}, "", "secrets");
8
9 if (!-r $config{'pap_file'}) {
10         print "<p>", &text('secrets_enopfile', $config{'pap_file'},
11                            "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
12         &ui_print_footer("/", $text{'secrets_return'});
13         exit;
14         }
15
16 @links = ( &select_all_link("d"),
17            &select_invert_link("d"),
18           "<a href=edit_secret.cgi>$text{'secrets_create'}</a>" );
19
20 # Get the system's hostname for selecting PPP accounts
21 $host = &get_ppp_hostname();
22
23 print &text('secrets_desc', "<tt>$config{'pap_file'}</tt>", "<tt>$host</tt>",
24            $config{'pap_file'} =~ /pap-secrets/ ? "PAP" : "CHAP"),"<p>\n";
25
26 @sec = grep { $_->{'server'} eq $host } &list_secrets();
27 if (@sec) {
28         print &ui_form_start("delete_secrets.cgi", "post");
29         @tds = ( "width=5", "nowrap", "nowrap" );
30         print &ui_links_row(\@links);
31         print &ui_columns_start(
32                 [ "", $text{'secrets_user'}, $text{'secrets_ips'} ],
33                 undef, 0, \@tds);
34         for($i=0; $i<@sec; $i++) {
35                 $s = $sec[$i];
36                 local @cols;
37                 push(@cols, "<a href=\"edit_secret.cgi?$i\">".
38                         ($s->{'client'} ? &html_escape($s->{'client'})
39                                         : $text{'index_uany'})."</a>");
40                 @i = @{$s->{'ips'}};
41                 push(@cols, $i[0] eq "*" || $i[0] eq "" ?
42                                 $text{'edit_secret_aany'} :
43                             $i[0] eq "-" ? $text{'edit_secret_anone'} :
44                                 html_escape(join(" ", @i)));
45                 print &ui_checked_columns_row(\@cols, \@tds, "d", $i);
46                 }
47         print &ui_columns_end();
48         print &ui_links_row(\@links);
49         print &ui_form_end([ [ "delete", $text{'secrets_delete'} ] ]);
50         }
51 else {
52         print "<b>$text{'secrets_none'}</b><p>\n";
53         print &ui_links_row([ $links[2] ]);
54         }
55
56 &ui_print_footer("", $text{'secrets_return'});
57