3 # Save manually entered directives
5 require './proftpd-lib.pl';
9 $global = &find_directive_struct("Global", $conf);
10 $conf = $global->{'members'};
11 if (defined($in{'limit'})) {
12 # limit within the global section
14 $d = $conf->[$in{'idx'}];
15 $l = $d->{'members'}->[$in{'limit'}];
18 $l = $conf->[$in{'limit'}];
21 $return = "limit_index.cgi";
22 $start = $l->{'line'}+1; $end = $l->{'eline'}-1;
25 # directory in the global section
26 $d = $conf->[$in{'idx'}];
28 $return = "dir_index.cgi";
29 $start = $d->{'line'}+1; $end = $d->{'eline'}-1;
31 $logname = $d->{'value'};
34 elsif (defined($in{'virt'})) {
35 if (defined($in{'limit'})) {
36 # limit, maybe within a directory
37 ($conf, $v) = &get_virtual_config($in{'virt'});
39 $anon = &find_directive_struct("Anonymous", $conf);
40 $conf = $anon->{'members'};
42 if ($in{'idx'} ne '') {
43 $conf = $conf->[$in{'idx'}]->{'members'};
45 $l = $conf->[$in{'limit'}];
47 $return = "limit_index.cgi";
48 $start = $l->{'line'}+1; $end = $l->{'eline'}-1;
50 $logname = $l->{'value'};
52 elsif (defined($in{'idx'})) {
53 # directory within virtual server
54 ($vconf, $v) = &get_virtual_config($in{'virt'});
56 $anon = &find_directive_struct("Anonymous", $vconf);
57 $vconf = $anon->{'members'};
59 $d = $vconf->[$in{'idx'}];
61 $return = "dir_index.cgi";
62 $start = $d->{'line'}+1; $end = $d->{'eline'}-1;
64 $logname = "$v->{'value'}:$d->{'words'}->[0]";
68 ($conf, $v) = &get_virtual_config($in{'virt'});
69 $return = "virt_index.cgi";
71 $start = $v->{'line'}+1; $end = $v->{'eline'}-1;
72 $logtype = 'virt'; $logname = $v->{'words'}->[0];
76 if (defined($in{'limit'})) {
77 # files within .htaccess file
78 $hconf = &get_ftpaccess_config($in{'file'});
79 $l = $hconf->[$in{'limit'}];
81 $return = "limit_index.cgi";
82 $start = $l->{'line'}+1; $end = $l->{'eline'}-1;
84 $logname = $l->{'value'};
89 $return = "ftpaccess_index.cgi";
90 $logtype = 'ftpaccess'; $logname = $in{'file'};
97 system("cp ".quotemeta($file)." $temp");
98 $in{'directives'} =~ s/\r//g;
99 $in{'directives'} =~ s/\s+$//;
100 @dirs = split(/\n/, $in{'directives'});
101 $lref = &read_file_lines($file);
102 if (!defined($start)) {
106 splice(@$lref, $start, $end-$start+1, @dirs);
108 if ($config{'test_manual'}) {
109 $err = &test_config();
111 system("mv $temp ".quotemeta($file));
112 &error(&text('manual_etest', "<pre>$err</pre>"));
117 &webmin_log($logtype, "manual", $logname, \%in);
119 foreach $h ('virt', 'idx', 'file', 'limit', 'anon', 'global') {
120 push(@args, "$h=$in{$h}") if (defined($in{$h}));
122 &redirect("$return?".join("&", @args));