Handle hostnames with upper-case letters
[webmin.git] / proftpd / create_limit.cgi
1 #!/usr/local/bin/perl
2 # create_limit.cgi
3 # Create a new <Limit> section
4
5 require './proftpd-lib.pl';
6 &ReadParse();
7 if ($in{'file'}) {
8         $conf = &get_ftpaccess_config($in{'file'});
9         }
10 else {
11         if ($in{'global'}) {
12                 $conf = &get_config();
13                 $conf = &get_or_create_global($conf);
14                 }
15         else {
16                 ($conf, $v) = &get_virtual_config($in{'virt'});
17                 }
18         if ($in{'anon'}) {
19                 $anon = &find_directive_struct("Anonymous", $conf);
20                 $conf = $anon->{'members'};
21                 }
22         if ($in{'idx'} ne '') {
23                 $conf = $conf->[$in{'idx'}]->{'members'};
24                 }
25         }
26 &error_setup($text{'lserv_err'});
27
28 # Validate inputs
29 $in{'cmd'} =~ /\S/ || &error($text{'lserv_ecmd'});
30
31 # Add the limit
32 $l = $conf->[@$conf - 1];
33 &lock_file($l->{'file'});
34 &before_changing();
35 $lref = &read_file_lines($l->{'file'});
36 @lines = ( "<Limit $in{'cmd'}>", "</Limit>" );
37 splice(@$lref, $l->{'eline'}+1, 0, @lines);
38 &flush_file_lines();
39 &after_changing();
40 &unlock_file($l->{'file'});
41 &webmin_log("limit", "create", $in{'cmd'}, \%in);
42 if ($in{'file'}) {
43         &redirect("limit_index.cgi?file=$in{'file'}&limit=".scalar(@$conf));
44         }
45 else {
46         &redirect("limit_index.cgi?virt=$in{'virt'}&idx=$in{'idx'}&anon=$in{'anon'}&global=$in{'global'}&limit=".scalar(@$conf));
47         }
48