Handle hostnames with upper-case letters
[webmin.git] / proftpd / manual_form.cgi
1 #!/usr/local/bin/perl
2 # manual.cgi
3 # Display a text box for manually editing directives
4
5 require './proftpd-lib.pl';
6 &ReadParse();
7 if ($in{'global'}) {
8         $conf = &get_config();
9         $global = &find_directive_struct("Global", $conf);
10         $conf = $global->{'members'};
11         if (defined($in{'limit'})) {
12                 # limit within the global section
13                 if ($in{'idx'}) {
14                         $d = $conf->[$in{'idx'}];
15                         $l = $d->{'members'}->[$in{'limit'}];
16                         $title = &text('limit_header4', $l->{'value'},
17                                        $d->{'words'}->[0]);
18                         }
19                 else {
20                         $l = $conf->[$in{'limit'}];
21                         $title = &text('limit_header7', $l->{'value'});
22                         }
23                 $return = "limit_index.cgi"; $rmsg = $text{'limit_return'};
24                 $file = $l->{'file'};
25                 $start = $l->{'line'}+1; $end = $l->{'eline'}-1;
26                 }
27         else {
28                 # directory in the global section
29                 $d = $conf->[$in{'idx'}];
30                 $title = &text('dir_header5', $d->{'words'}->[0]);
31                 $return = "dir_index.cgi"; $rmsg = $text{'dir_return'};
32                 $file = $d->{'file'};
33                 $start = $d->{'line'}+1; $end = $d->{'eline'}-1;
34                 }
35         }
36 elsif (defined($in{'virt'})) {
37         if (defined($in{'limit'})) {
38                 # limit, maybe within a directory
39                 ($conf, $v) = &get_virtual_config($in{'virt'});
40                 if ($in{'anon'}) {
41                         $anon = &find_directive_struct("Anonymous", $conf);
42                         $conf = $anon->{'members'};
43                         }
44                 if ($in{'idx'} ne '') {
45                         $dir = $conf->[$in{'idx'}];
46                         $conf = $dir->{'members'};
47                         }
48                 $l = $conf->[$in{'limit'}];
49                 $ln = $l->{'value'};
50                 $title = $dir ?
51                         &text('limit_header4', $ln, $dir->{'words'}->[0]) :
52                         $in{'virt'} ?
53                         &text('limit_header1', $ln, $v->{'words'}->[0]) :
54                         &text('limit_header2', $ln);
55                 $return = "limit_index.cgi"; $rmsg = $text{'limit_return'};
56                 $file = $l->{'file'};
57                 $start = $l->{'line'}+1; $end = $l->{'eline'}-1;
58                 }
59         elsif (defined($in{'idx'})) {
60                 # directory within virtual server
61                 ($vconf, $v) = &get_virtual_config($in{'virt'});
62                 if ($in{'anon'}) {
63                         $anon = &find_directive_struct("Anonymous", $vconf);
64                         $vconf = $anon->{'members'};
65                         }
66                 $d = $vconf->[$in{'idx'}];
67                 $dn = $d->{'words'}->[0];
68                 $title = $in{'anon'} ? &text('dir_header4', $dn) : $in{'virt'} ?
69                         &text('dir_header1', $dn, $v->{'words'}->[0]) :
70                         &text('dir_header2', $dn);
71                 $return = "dir_index.cgi"; $rmsg = $text{'dir_return'};
72                 $file = $d->{'file'};
73                 $start = $d->{'line'}+1; $end = $d->{'eline'}-1;
74                 }
75         else {
76                 # virtual server
77                 ($conf, $v) = &get_virtual_config($in{'virt'});
78                 $title = $in{'virt'} eq '' ? $text{'virt_header2'} :
79                          &text('virt_header1', $v->{'value'});
80                 $return = "virt_index.cgi"; $rmsg = $text{'virt_return'};
81                 $file = $v->{'file'};
82                 $start = $v->{'line'}+1; $end = $v->{'eline'}-1;
83                 }
84         }
85 else {
86         # Something in a .ftpaccess file
87         if (defined($in{'limit'})) {
88                 # limit within .ftpaccess file
89                 $hconf = &get_ftpaccess_config($in{'file'});
90                 $l = $hconf->[$in{'limit'}];
91                 $file = $in{'file'};
92                 $start = $l->{'line'}+1; $end = $l->{'eline'}-1;
93                 $title = &text('limit_header6', $l->{'value'},
94                                "<tt>$in{'file'}</tt>");
95                 $return = "limit_index.cgi";
96                 $rmsg = $text{'limit_return'};
97                 }
98         else {
99                 # .ftpaccess file
100                 $file = $in{'file'};
101                 $title = &text('ftpindex_header', "<tt>$in{'file'}</tt>");
102                 $return = "ftpaccess_index.cgi";
103                 $rmsg = $text{'ftpindex_return'};
104                 }
105         }
106 &ui_print_header($title, $text{'manual_title'}, "",
107         undef, undef, undef, undef, &restart_button());
108
109 print &text('manual_header', "<tt>$file</tt>"),"<p>\n";
110 print "<form action=manual_save.cgi method=post enctype=multipart/form-data>\n";
111 foreach $h ('virt', 'idx', 'file', 'limit', 'anon', 'global') {
112         if (defined($in{$h})) {
113                 print "<input type=hidden name=$h value='$in{$h}'>\n";
114                 push(@args, "$h=$in{$h}");
115                 }
116         }
117 $args = join('&', @args);
118
119 print "<textarea rows=15 cols=80 name=directives>\n";
120 $lref = &read_file_lines($file);
121 if (!defined($start)) {
122         $start = 0;
123         $end = @$lref - 1;
124         }
125 for($i=$start; $i<=$end; $i++) {
126         print &html_escape($lref->[$i]),"\n";
127         }
128 print "</textarea><br><input type=submit value=\"$text{'save'}\"></form>\n";
129
130 &ui_print_footer("$return?$args", $rmsg);
131