Handle hostnames with upper-case letters
[webmin.git] / proftpd / save_lserv.cgi
1 #!/usr/local/bin/perl
2 # save_dserv.cgi
3 # Save limit section options
4
5 require './proftpd-lib.pl';
6 &error_setup($text{'lserv_err'});
7 &ReadParse();
8 if ($in{'file'}) {
9         $conf = &get_ftpaccess_config($in{'file'});
10         }
11 else {
12         if ($in{'global'}) {
13                 $conf = &get_config();
14                 $conf = &get_or_create_global($conf);
15                 }
16         else {
17                 ($conf, $v) = &get_virtual_config($in{'virt'});
18                 }
19         if ($in{'anon'}) {
20                 $anon = &find_directive_struct("Anonymous", $conf);
21                 $conf = $anon->{'members'};
22                 }
23         if ($in{'idx'} ne '') {
24                 $conf = $conf->[$in{'idx'}]->{'members'};
25                 }
26         }
27 $l = $conf->[$in{'limit'}];
28 $ln = $l->{'value'};
29
30 if ($in{'delete'}) {
31         # Delete the directory
32         &lock_file($l->{'file'});
33         &before_changing();
34         $lref = &read_file_lines($l->{'file'});
35         splice(@$lref, $l->{'line'}, $l->{'eline'} - $l->{'line'} + 1);
36         &flush_file_lines();
37         &after_changing();
38         &unlock_file($l->{'file'});
39         if ($in{'file'}) {
40                 &redirect("ftpaccess_index.cgi?file=$in{'file'}");
41                 }
42         elsif ($in{'idx'} eq '') {
43                 if ($in{'global'}) {
44                         &redirect("");
45                         }
46                 elsif ($in{'anon'}) {
47                         &redirect("anon_index.cgi?virt=$in{'virt'}");
48                         }
49                 else {
50                         &redirect("virt_index.cgi?virt=$in{'virt'}");
51                         }
52                 }
53         else {
54                 &redirect("dir_index.cgi?virt=$in{'virt'}&idx=$in{'idx'}&anon=$in{'anon'}&global=$in{'global'}");
55                 }
56         &webmin_log("limit", "delete", $l->{'value'});
57         }
58 else {
59         # Update the limit
60         local @c = split(/\0/, $in{'cmd'});
61         @c || &error($text{'lserv_ecmd'});
62         &lock_file($l->{'file'});
63         &before_changing();
64         $lref = &read_file_lines($l->{'file'});
65         $lref->[$l->{'line'}] = "<Limit ".join(" ", @c).">";
66         &flush_file_lines();
67         &after_changing();
68         &unlock_file($l->{'file'});
69         &redirect("limit_index.cgi?virt=$in{'virt'}&idx=$in{'idx'}&limit=$in{'limit'}&anon=$in{'anon'}&file=$in{'file'}&global=$in{'global'}");
70         &webmin_log("limit", "save", $l->{'value'}, \%in);
71         }
72
73