Handle hostnames with upper-case letters
[webmin.git] / cpan / uninstall_mods.cgi
1 #!/usr/local/bin/perl
2 # Uninstall a bunch of perl module groups, after asking for confirmation 
3
4 require './cpan-lib.pl';
5 &ReadParse();
6 &error_setup($text{'uninstalls_err'});
7 @d = split(/\0/, $in{'d'});
8 @d || &error($text{'uninstalls_enone'});
9
10 if ($in{'upgrade'}) {
11         # Just redirect to the install page from CPAN
12         &redirect("download.cgi?missingok=1&source=3&cpan=".
13                   &urlize(join(" ", @d)));
14         exit;
15         }
16
17 # Get the modules
18 @allmods = &list_perl_modules();
19 foreach $d (@d) {
20         ($mod) = grep { $_->{'name'} eq $d } @allmods;
21         if ($mod) {
22                 push(@mods, $mod);
23                 }
24         }
25
26 if ($in{'confirm'}) {
27         # Go ahead and do it
28         foreach $mod (@mods) {
29                 $err = &remove_module($mod);
30                 &error(&text('uninstalls_emod', "<tt>$mod</tt>", $err))
31                         if ($err);
32                 }
33         &redirect("");
34         }
35 else {
36         # Ask the user if he is sure
37         &ui_print_header(undef, $text{'uninstalls_title'}, "");
38
39         print &ui_form_start("uninstall_mods.cgi", "post");
40         print "<center>\n";
41         foreach $d (@d) {
42                 print &ui_hidden("d", $d),"\n";
43                 }
44         $mcount = 0;
45         $fcount = 0;
46         foreach $mod (@mods) {
47                 $mcount += scalar(@{$mod->{'mods'}})-1;
48                 $fcount += scalar(@{$mod->{'packlist'}})+1;
49                 }
50         print &text('uninstalls_rusure', scalar(@mods), $mcount, $fcount),
51               "<p>\n";
52         print "<input type=submit name=confirm ",
53               "value='$text{'uninstall_ok'}'></center></form>\n";
54
55         &ui_print_footer("", $text{'index_return'});
56         }
57