Handle hostnames with upper-case letters
[webmin.git] / webmin / edit_mods.cgi
1 #!/usr/local/bin/perl
2 # edit_mods.cgi
3 # Form for installing and removing modules
4
5 require './webmin-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'mods_title'}, "");
8 @mlist = sort { $a->{'desc'} cmp $b->{'desc'} }
9               grep { &check_os_support($_) } &get_all_module_infos();
10 $version = &get_webmin_version();
11
12 if (&shared_root_directory()) {
13         &ui_print_endpage($text{'mods_eroot'});
14         }
15
16 # Show tabs
17 @tabs = ( [ "install", $text{'mods_tabinstall'}, "edit_mods.cgi?mode=install" ],
18           [ "clone", $text{'mods_tabclone'}, "edit_mods.cgi?mode=clone" ],
19           [ "delete", $text{'mods_tabdelete'}, "edit_mods.cgi?mode=delete" ],
20           [ "export", $text{'mods_tabexport'}, "edit_mods.cgi?mode=export" ],
21         );
22 print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || "install", 1);
23
24 # Display installation form
25 print &ui_tabs_start_tab("mode", "install");
26 print "$text{'mods_desc1'}<p>\n";
27
28 print &ui_form_start("install_mod.cgi", "form-data");
29 print &ui_table_start($text{'mods_install'}, undef, 2);
30
31 print &ui_table_row($text{'mods_installsource'},
32         &ui_radio_table("source", 0,
33                 [ [ 0, $text{'mods_local'},
34                     &ui_textbox("file", undef, 40)." ".
35                     &file_chooser_button("file", 0) ],
36                   [ 1, $text{'mods_uploaded'},
37                     &ui_upload("upload", 40) ],
38                   [ 2, $text{'mods_ftp'},
39                     &ui_textbox("url", undef, 40) ],
40                   [ 3, $config{'standard_url'} ? $text{'mods_standard2'} :
41                          &text('mods_standard',
42                                "http://www.webmin.com/standard.html"),
43                     &ui_textbox("standard", undef, 20)." ".
44                     &standard_chooser_button("standard") ],
45                   [ 4, $text{'mods_third'},
46                     &ui_textbox("third", undef, 40)." ".
47                     &third_chooser_button("third") ] ]));
48
49 print &ui_table_row($text{'mods_nodeps'},
50         &ui_yesno_radio("nodeps", 0));
51
52 print &ui_table_row($text{'mods_grantto'},
53         &ui_radio("grant", 0,
54                   [ [ 0, $text{'mods_grant2'}." ".
55                          &ui_textbox("grantto", $base_remote_user, 30)."<br>" ],
56                     [ 1, $text{'mods_grant1'} ] ]));
57
58 print &ui_table_end();
59 print &ui_form_end([ [ "", $text{'mods_installok'} ] ]);
60 print &ui_tabs_end_tab();
61
62 # Display cloning form
63 print &ui_tabs_start_tab("mode", "clone");
64 print "$text{'mods_desc2'}<p>";
65
66 print &ui_form_start("clone_mod.cgi", "post");
67 print &ui_table_start($text{'mods_clone'}, undef, 2);
68
69 # Source module
70 print &ui_table_row($text{'mods_cname'},
71         &ui_select("mod", undef,
72                 [ map { [ $_->{'dir'}, $_->{'desc'} ] }
73                       grep { $_->{'dir'} ne 'webmin' && !$_->{'clone'} }
74                            @mlist ]));
75
76 # New description
77 print &ui_table_row($text{'mods_cnew'},
78         &ui_textbox("desc", undef, 40));
79
80 # New category
81 %cats = &list_categories(\@mlist, 1);
82 print &ui_table_row($text{'mods_ccat'},
83         &ui_select("cat", "*",
84                 [ [ "*", $text{'mods_csame'} ],
85                   map { [ $_, $cats{$_} ] }
86                       sort { lc($a) cmp lc($b) } (keys %cats) ]));
87
88 print &ui_table_row($text{'mods_creset'},
89         &ui_yesno_radio("creset", 0));
90
91 print &ui_table_end();
92 print &ui_form_end([ [ "", $text{'mods_cloneok'} ] ]);
93 print &ui_tabs_end_tab();
94
95 # Display deletion form
96 print &ui_tabs_start_tab("mode", "delete");
97 print "$text{'mods_desc3'}<p>\n";
98
99 print &ui_form_start("delete_mod.cgi", "post");
100 print &ui_table_start($text{'mods_delete'}, undef, 2);
101
102 my $home = $root_directory eq '/usr/local/webadmin';
103 @opts = ( );
104 foreach $m (@mlist) {
105         if ($m->{'dir'} ne 'webmin' && &check_os_support($m)) {
106                 my @st = stat(&module_root_directory($m->{'dir'}));
107                 my @tm = localtime($st[9]);
108                 my $vstr = $m->{'version'} == $version ? "" :
109                               $m->{'version'} ? "(v. $m->{'version'})" :
110                               $home ? "" :
111                               sprintf "(%d/%d/%d)",
112                                       $tm[3], $tm[4]+1, $tm[5]+1900;
113                 push(@opts, [ $m->{'dir'}, $m->{'desc'}." ".$vstr ]);
114                 }
115         }
116 print &ui_table_row(undef,
117         &ui_select("mod", undef, \@opts, 10, 1)."<br>\n".
118         &ui_checkbox("nodeps", 1, $text{'mods_nodeps2'}, 0), 2);
119 print &ui_table_end();
120 print &ui_form_end([ [ "", $text{'mods_deleteok'} ] ]);
121 print &ui_tabs_end_tab();
122
123 # Display export form
124 print &ui_tabs_start_tab("mode", "export");
125 print "$text{'mods_desc4'}<p>\n";
126
127 print &ui_form_start("export_mod.cgi/module.wbm.gz");
128 print &ui_table_start($text{'mods_header4'}, undef, 2);
129
130 print &ui_table_row($text{'mods_exportmods'},
131           &ui_select("mod", undef,
132                 [ map { [ $_->{'dir'},
133                           $_->{'desc'}.($_->{'version'} == $version ? "" :
134                                 $_->{'version'} ? "(v. $_->{'version'})" : "")
135                         ] } @mlist ], 10, 1));
136
137 print &ui_table_row($text{'mods_exportto'},
138           &ui_radio("to", 0,
139                 [ [ 0, $text{'mods_exportshow'}."<br>" ],
140                   [ 1, &text('mods_exportfile',
141                              &ui_textbox("file", undef, 40)) ] ]));
142
143 print &ui_table_end();
144 print &ui_form_end([ [ "ok", $text{'mods_exportok'} ] ]);
145 print &ui_tabs_end_tab();
146
147 print &ui_tabs_end(1);
148
149 &ui_print_footer("", $text{'index_return'});
150