Handle hostnames with upper-case letters
[webmin.git] / samba / edit_fshare.cgi
1 #!/usr/local/bin/perl
2 # edit_fshare.cgi
3 # Display a form for editing or creating a new directory share
4
5 require './samba-lib.pl';
6 &ReadParse();
7 $s = $in{'share'};
8 # check acls
9
10 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
11 if(!$s) {
12     &error("$text{'eacl_np'} $text{'eacl_pcfs'}")
13             unless $access{'c_fs'};
14         }
15 else {
16         &error("$text{'eacl_np'} $text{'eacl_pafs'}")
17         unless &can('r', \%access, $in{'share'});
18     }
19 # display
20 if ($s) {
21         &ui_print_header(undef, $s eq 'global' ? $text{'share_title1'} : $text{'share_title2'}, "");
22         &get_share($s);
23         }
24 else {
25         &ui_print_header(undef, $text{'share_title3'}, "");
26         }
27
28 print "<form action=save_fshare.cgi>\n";
29 if ($s) { print "<input type=hidden name=old_name value=\"$s\">\n"; }
30
31 # Vital share options..
32 print "<table border width=100%>\n";
33 print "<tr $tb> <td><b>$text{'share_info'}</b></td> </tr>\n";
34 print "<tr $cb> <td><table cellpadding=2>\n";
35 if ($s ne "global") {
36         if ($copy = &getval("copy")) {
37                 print "<tr> <td colspan=4><b>",&text('share_copy', $copy),
38                       "</b></td> </tr>\n";
39                 }
40         print "<tr> <td align=right><b>$text{'share_name'}</b></td>\n";
41         printf "<td colspan=3><input type=radio name=homes value=0 %s>\n",
42                 $s eq "homes" ? "" : "checked";
43         printf "<input size=10 name=share value=\"%s\">&nbsp;&nbsp;&nbsp;\n",
44                 $s eq "homes" ? "" : $s;
45         printf "<input type=radio name=homes value=1 %s> $text{'share_home'}\n",
46                 $s eq "homes" ? "checked" : "";
47         print "</td> </tr>\n";
48         }
49
50 print "<tr> <td align=right><b>$text{'share_dir'}</b></td>\n";
51 printf "<td colspan=3><input name=path size=40 value=\"%s\">\n",
52         &getval("path");
53 print &file_chooser_button("path", 1);
54 print "</td> </tr>\n";
55
56 if (!$s) {
57         print "<tr> <td align=right><b>$text{'share_create'}</b></td>\n";
58         print "<td>",&yesno_input("create"),"</td>\n";
59
60         print "<td align=right><b>$text{'share_owner'}</b></td>\n";
61         print "<td>",&ui_user_textbox("createowner", "root"),"</td> </tr>\n";
62
63         print "<tr> <td align=right><b>$text{'share_createperms'}</b></td>\n";
64         print "<td>",&ui_textbox("createperms", "755", 5),"</td>\n";
65
66         print "<td align=right><b>$text{'share_group'}</b></td>\n";
67         print "<td>",&ui_group_textbox("creategroup", "root"),"</td> </tr>\n";
68 }
69
70 print "<tr> <td align=right><b>$text{'share_available'}</b></td>\n";
71 print "<td>",&yesno_input("available"),"</td>\n";
72
73 print "<td align=right><b>$text{'share_browseable'}</b></td>\n";
74 print "<td>",&yesno_input("browseable"),"</td> </tr>\n";
75
76 print "<td align=right><b>$text{'share_comment'}</b></td>\n";
77 printf "<td colspan=3><input size=40 name=comment value=\"%s\"></td> </tr>\n",
78         &getval("comment");
79
80 print "<tr> <td colspan=4 align=center>$text{'share_samedesc2'}</td> </tr>\n"
81         if ($s eq "global");
82
83 print "</table> </td></tr></table><p>\n";
84 if ($s eq "global") {
85         print "<input type=submit value=$text{'save'}> </form>\n";
86         }
87 elsif ($s) {
88         print "<table width=100%> <tr>\n";
89         print "<td align=left><input type=submit value=$text{'save'}></td>\n"
90                 if &can('rw', \%access, $s);
91         print "</form><form action=view_users.cgi>\n";
92         print "<input type=hidden name=share value=\"$s\">\n";
93         print "<td align=center><input type=submit value=\"$text{'share_view'}\"></td>\n"
94                 if &can('rv', \%access, $s);
95         print "</form><form action=delete_share.cgi>\n";
96         print "<input type=hidden name=share value=\"$s\">\n";
97         print "<input type=hidden name=type value=fshare>\n";
98         print "<td align=right><input type=submit value=$text{'delete'}></td>\n"
99                 if &can('rw', \%access, $s);
100         print "</form> </tr> </table>\n";
101         }
102 else {
103         print "<input type=submit value=$text{'create'}> </form>\n";
104         }
105
106 if ($s) {
107         # Icons for other share options
108         $us = "share=".&urlize($s);
109         local (@url, @text, @icon, $disp);
110         if (&can('rs',\%access, $s)) {
111                 push(@url,  "edit_sec.cgi?$us");
112                 push(@text, $text{'share_security'});
113                 push(@icon, "images/icon_2.gif");
114                 $disp++;
115                 }
116         if (&can('rp',\%access, $s)) {
117                 push(@url,  "edit_fperm.cgi?$us");
118                 push(@text, $text{'share_permission'});
119                 push(@icon, "images/icon_7.gif");
120                 $disp++;
121                 }
122         if (&can('rn',\%access, $s)) {
123                 push(@url,  "edit_fname.cgi?$us");
124                 push(@text, $text{'share_naming'});
125                 push(@icon, "images/icon_8.gif");
126                 $disp++;
127                 }
128         if (&can('ro',\%access, $s)) {
129                 push(@url,  "edit_fmisc.cgi?$us");
130                 push(@text, $text{'share_misc'});
131                 push(@icon, "images/icon_4.gif");
132                 $disp++;
133                 }
134         if ($disp) {
135                 print &ui_hr();
136                 print &ui_subheading($text{'share_option'});
137                 &icons_table(\@url, \@text, \@icon);
138                 }
139         }
140
141 &ui_print_footer("", $text{'index_sharelist'});
142