Handle hostnames with upper-case letters
[webmin.git] / proftpd / save_dserv.cgi
1 #!/usr/local/bin/perl
2 # save_dserv.cgi
3 # Save directory section options
4
5 require './proftpd-lib.pl';
6 &ReadParse();
7 if ($in{'global'}) {
8         $conf = &get_config();
9         $conf = &get_or_create_global($conf);
10         }
11 else {
12         ($conf, $v) = &get_virtual_config($in{'virt'});
13         }
14 if ($in{'anon'}) {
15         $anon = &find_directive_struct("Anonymous", $conf);
16         $conf = $anon->{'members'};
17         }
18 $d = $conf->[$in{'idx'}];
19 &error_setup($text{'dserv_err'});
20
21 if ($in{'delete'}) {
22         # Delete the directory
23         &lock_file($d->{'file'});
24         &before_changing();
25         $lref = &read_file_lines($d->{'file'});
26         splice(@$lref, $d->{'line'}, $d->{'eline'} - $d->{'line'} + 1);
27         &flush_file_lines();
28         &after_changing();
29         &unlock_file($d->{'file'});
30         &webmin_log("dir", "delete", "$v->{'value'}:$d->{'words'}->[0]");
31         if ($in{'global'}) {
32                 &redirect("");
33                 }
34         elsif ($in{'anon'}) {
35                 &redirect("anon_index.cgi?virt=$in{'virt'}");
36                 }
37         else {
38                 &redirect("virt_index.cgi?virt=$in{'virt'}");
39                 }
40         }
41 else {
42         # Update the directory
43         $in{'dir'} =~ /^\S+$/ || &error($text{'dserv_edir'});
44         &lock_file($d->{'file'});
45         &before_changing();
46         $lref = &read_file_lines($d->{'file'});
47         $lref->[$d->{'line'}] = "<Directory $in{'dir'}>";
48         &flush_file_lines();
49         &after_changing();
50         &unlock_file($d->{'file'});
51         &webmin_log("dir", "save", "$v->{'value'}:$d->{'words'}->[0]");
52         &redirect("dir_index.cgi?virt=$in{'virt'}&idx=$in{'idx'}&anon=$in{'anon'}&global=$in{'global'}");
53         }
54
55