Handle hostnames with upper-case letters
[webmin.git] / dfsadmin / edit_share.cgi
1 #!/usr/local/bin/perl
2 # edit_share.cgi
3 # Display a form for editing a shared directory
4
5 require './dfs-lib.pl';
6 $access{'view'} && &error($text{'ecannot'});
7 $s = $ARGV[0];
8
9 if (defined($s)) {
10         &ui_print_header(undef, $text{'edit_title1'}, "", "edit_share");
11         }
12 else {
13         &ui_print_header(undef, $text{'edit_title2'}, "", "create_share");
14         }
15
16 print &ui_form_start("save_share.cgi", "post");
17 if (defined($s)) {
18         print &ui_hidden("idx", $s),"\n";
19         @shlist = &list_shares();
20         $share = $shlist[$s];
21         }
22
23 # Directory and description section
24 print &ui_table_start($text{'edit_header1'}, "width=100%", 2);
25
26 print &ui_table_row(&hlink($text{'edit_dir'}, "dir"),
27                     &ui_textbox("directory", $share->{'dir'}, 60)." ".
28                     &file_chooser_button("directory", 1));
29
30 print &ui_table_row(&hlink($text{'edit_desc'}, "desc"),
31                     &ui_textbox("desc", $share->{'desc'}, 60));
32
33 print &ui_table_end(),"<p>\n";
34
35 print "<table width=100% border>\n";
36 &parse_options($share->{'opts'});
37 print "<tr $tb>\n";
38 print "<td>",&hlink("<b>$text{'edit_ro'}</b>","ro"),"</td>\n";
39 print "<td>",&hlink("<b>$text{'edit_rw'}</b>","rw"),"</td>\n";
40 print "<td>",&hlink("<b>$text{'edit_root'}</b>","root"),"</td> </tr>\n";
41
42 # $fn = "<font size=-2>"; $efn = "</font>";
43 print "<tr $cb>\n";
44 print "<td valign=top>",
45       &ui_radio("readonly", !defined($options{"ro"}) ? 0 :
46                             $options{"ro"} ? 2 : 1,
47                 [ [ 0, $text{'edit_none'}."<br>" ],
48                   [ 1, $text{'edit_all'}."<br>" ],
49                   [ 2, $text{'edit_listed'}."<br>" ] ])."\n".
50       &ui_textarea("rolist", join("\n", split(/:/, $options{"ro"})), 8, 25),
51       "</td>\n";
52
53 print "<td valign=top>",
54       &ui_radio("readwrite", !defined($options{"rw"}) ? 0 :
55                             $options{"rw"} ? 2 : 1,
56                 [ [ 0, $text{'edit_none'}."<br>" ],
57                   [ 1, $text{'edit_all'}."<br>" ],
58                   [ 2, $text{'edit_listed'}."<br>" ] ])."\n".
59       &ui_textarea("rwlist", join("\n", split(/:/, $options{"rw"})), 8, 25),
60       "</td>\n";
61
62 print "<td valign=top>",
63       &ui_radio("root", !defined($options{"root"}) ? 0 :
64                         $options{"root"} ? 2 : 1,
65                 [ [ 0, $text{'edit_none'}."<br>&nbsp;<br>" ],
66                   [ 2, $text{'edit_listed'}."<br>" ] ])."\n".
67       &ui_textarea("rtlist", join("\n", split(/:/, $options{"root"})), 8, 25),
68       "</td>\n";
69 print "</tr></table><p>\n";
70
71 if (!$access{'simple'}) {
72         print &ui_table_start($text{'edit_header2'}, "width=100%", 4);
73
74         print &ui_table_row(&hlink($text{'edit_nosub'}, "sub"),
75                     &ui_radio("nosub", defined($options{"nosub"}) ? 1 : 0,
76                               [ [ 0, $text{'yes'} ],
77                                 [ 1, $text{'no'} ] ]));
78
79         print &ui_table_row(&hlink($text{'edit_nosuid'}, "suid"),
80                     &ui_radio("nosuid", defined($options{"nosuid"}) ? 1 : 0,
81                               [ [ 0, $text{'yes'} ],
82                                 [ 1, $text{'no'} ] ]));
83
84         print &ui_table_row(&hlink($text{'edit_des'}, "des"),
85                     &ui_radio("secure", defined($options{"secure"}) ? 1 : 0,
86                               [ [ 1, $text{'yes'} ],
87                                 [ 0, $text{'no'} ] ]));
88
89         print &ui_table_row(&hlink($text{'edit_kerberos'}, "kerberos"),
90                     &ui_radio("kerberos", defined($options{"kerberos"}) ? 1 : 0,
91                               [ [ 1, $text{'yes'} ],
92                                 [ 0, $text{'no'} ] ]));
93
94         $user = defined($options{"anon"}) && $options{"anon"} != -1 ?
95                         getpwuid($options{'anon'}) : undef;
96         print &ui_table_row(&hlink($text{'edit_anon'}, "anon"),
97                     &ui_radio("anon_m", !defined($options{"anon"}) ? 0 :
98                                         $options{"anon"} == -1 ? 1 : 2,
99                               [ [ 0, $text{'edit_anon0'} ],
100                                 [ 1, $text{'edit_anon1'} ],
101                                 [ 2, &ui_user_textbox("anon", $user) ] ]));
102
103         print &ui_table_row(&hlink($text{'edit_aclok'}, "aclok"),
104                     &ui_radio("aclok", defined($options{"aclok"}) ? 1 : 0,
105                               [ [ 1, $text{'yes'} ],
106                                 [ 0, $text{'no'} ] ]));
107
108         if ($gconfig{'os_version'} >= 7) {
109                 print &ui_table_row(&hlink($text{'edit_public'}, "public"),
110                     &ui_radio("public", defined($options{"public"}) ? 1 : 0,
111                               [ [ 1, $text{'yes'} ],
112                                 [ 0, $text{'no'} ] ]));
113
114                 print &ui_table_row(&hlink($text{'edit_index'}, "index"),
115                     &ui_opt_textbox("index", $options{"index"}, 15,
116                                     $text{'edit_none'}));
117                 }
118
119         print &ui_table_end();
120         }
121
122 if ($s ne "") {
123         print &ui_form_end([ [ "save", $text{'save'} ],
124                              [ "delete", $text{'delete'} ] ]);
125         }
126 else {
127         print &ui_form_end([ [ "create", $text{'create'} ] ]);
128         }
129 &ui_print_footer("", $text{'index_return'});
130
131