3 # Display the icons for various types of proftpd config options
5 require './proftpd-lib.pl';
7 # Check if proftpd is installed
8 @st = stat($config{'proftpd_path'});
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
11 &help_search_link("proftpd", "man", "doc", "google"));
12 print &text('index_eproftpd', "<tt>$config{'proftpd_path'}</tt>",
13 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
15 &foreign_require("software", "software-lib.pl");
16 $lnk = &software::missing_install_link("proftpd",$text{'index_proftpd'},
17 "../$module_name/", $text{'index_title'});
18 print $lnk,"<p>\n" if ($lnk);
20 &ui_print_footer("/", $text{'index'});
24 # Check if the config file exists
25 $conf = &get_config();
27 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
28 &help_search_link("proftpd", "man", "doc", "google"));
29 print &text('index_econf', "<tt>$config{'proftpd_conf'}</tt>",
30 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
31 &ui_print_footer("/", $text{'index'});
35 # Check if the executable has changed ..
36 if ($site{'size'} != $st[7]) {
37 # Check if it really is proftpd and the right version
38 $site{'size'} = $st[7];
39 $ver = &get_proftpd_version(\$out);
41 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
42 &help_search_link("proftpd", "man", "doc", "google"));
43 print &text('index_eproftpd2',
44 "<tt>$config{'proftpd_path'}</tt>",
45 "$gconfig{'webprefix'}/config.cgi?$module_name",
46 "<tt>$config{'proftpd_path'} -v</tt>",
47 "<pre>$out</pre>"),"<p>\n";
48 &ui_print_footer("/", $text{'index'});
51 $site{'version'} = $ver;
52 if ($site{'version'} < 0.99) {
53 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
54 &help_search_link("proftpd", "man", "doc", "google"));
55 print &text('index_eversion',
56 "<tt>$config{'proftpd_path'}</tt>",
57 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
58 &ui_print_footer("/", $text{'index'});
62 # Get the list of modules
64 open(MODS, "$config{'proftpd_path'} -l |");
67 if (/^\s*(\S+)\.c$/) {
72 $site{'modules'} = join(" ", @mods);
73 &write_file("$module_config_directory/site", \%site);
76 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
77 &help_search_link("proftpd", "man", "doc", "google"),
78 undef, undef, &text('index_version', $site{'version'}));
79 $conf = &get_config();
81 # Display global category icons
82 print &ui_subheading($text{'index_global'});
83 $ft_icon = { "icon" => "images/dir.gif",
84 "name" => $text{'ftpaccess_title'},
85 "link" => "ftpaccess.cgi" };
86 $us_icon = { "icon" => "images/ftpusers.gif",
87 "name" => $text{'ftpusers_title'},
88 "link" => "edit_ftpusers.cgi" };
89 $ed_icon = { "icon" => "images/edit.gif",
90 "name" => $text{'manual_configs'},
91 "link" => "allmanual_form.cgi" };
92 &config_icons("root global", "edit_global.cgi?", $ft_icon, $us_icon, $ed_icon);
94 # Display global per-directory/limit options
95 $global = &find_directive_struct("Global", $conf);
96 $gconf = $global->{'members'} if ($global);
97 @dir = ( &find_directive_struct("Directory", $gconf) ,
98 &find_directive_struct("Limit", $gconf) );
101 print &ui_subheading($text{'virt_header'});
103 if ($d->{'name'} eq 'Limit') {
104 push(@links, "limit_index.cgi?limit=".
105 &indexof($d, @$gconf)."&global=1");
106 push(@titles, &text('virt_limit', $d->{'value'}));
107 push(@icons, "images/limit.gif");
110 push(@links, "dir_index.cgi?idx=".
111 &indexof($d, @$gconf)."&global=1");
112 push(@titles, &text('virt_dir', $d->{'value'}));
113 push(@icons, "images/dir.gif");
116 &icons_table(\@links, \@titles, \@icons, 3);
119 print "<table width=100%><tr><td>\n";
121 print "<form action=create_dir.cgi>\n";
122 print "<input type=hidden name=global value=1>\n";
123 print "<table border>\n";
124 print "<tr $tb> <td><b>$text{'virt_adddir'}</b></td> </tr>\n";
125 print "<tr $cb> <td><table>\n";
126 print "<tr> <td><b>$text{'virt_path'}</b></td>\n";
127 print "<td><input name=dir size=30>\n";
128 print "<input type=submit value=\"$text{'create'}\"></td> </tr>\n";
129 print "</table></td></tr></table></form>\n";
133 print "<form action=create_limit.cgi>\n";
134 print "<input type=hidden name=global value=1>\n";
135 print "<table border>\n";
136 print "<tr $tb> <td><b>$text{'virt_addlimit'}</b></td> </tr>\n";
137 print "<tr $cb> <td><table>\n";
138 print "<tr> <td><b>$text{'virt_cmds'}</b></td>\n";
139 print "<td><input name=cmd size=20>\n";
140 print "<input type=submit value=\"$text{'create'}\"></td> </tr>\n";
141 print "</table></td></tr></table></form>\n";
143 print "</td></tr></table>\n";
146 # Start virtual server list with default
147 push(@vname, $text{'index_defserv'});
148 push(@vlink, "virt_index.cgi");
149 push(@vdesc, $text{'index_defdesc'});
150 push(@vaddr, $text{'index_any'});
151 push(@vserv, &def(&find_directive("ServerName", $conf), $text{'default'}));
153 # Add other virtual servers
154 @virt = &find_directive_struct("VirtualHost", $conf);
156 $vm = $v->{'members'};
157 push(@vname, $text{'index_virt'});
158 push(@vlink, "virt_index.cgi?virt=".&indexof($v, @$conf));
159 push(@vaddr, $v->{'value'});
160 $sname = &find_directive("ServerName", $vm);
161 local $ip = &to_ipaddress($v->{'value'});
162 push(@vdesc, &text('index_vdesc', $ip ? $ip : $text{'index_eip'}));
163 push(@vserv, &def(&find_vdirective("ServerName", $vm, $conf),
164 $text{'index_auto'}));
167 # Show virtual servers
169 print &ui_subheading($text{'index_virts'});
171 if ($config{'show_list'} && scalar(@vname)) {
172 # as list for people with lots of servers
173 print "<table width=100% border=1>\n";
174 print "<tr $tb> <td><b>$text{'index_type'}</b></td> ",
175 "<td><b>$text{'index_addr'}</b></td> ",
176 "<td><b>$text{'index_name'}</b></td> </tr>\n";
177 for($i=0; $i<@vname; $i++) {
179 print "<td><a href=\"$vlink[$i]\">",
180 &html_escape($vname[$i]),"</a></td>\n";
181 print "<td>",&html_escape($vaddr[$i]),"</td>\n";
182 print "<td>",&html_escape($vserv[$i]),"</td>\n";
188 # as icons for niceness
189 print "<table width=100% cellpadding=5>\n";
190 for($i=0; $i<@vname; $i++) {
191 print "<tr> <td valign=top align=center nowrap>";
192 &generate_icon("images/virt.gif", &html_escape($vname[$i]),
194 print "</td> <td valign=top>\n";
195 print &html_escape($vdesc[$i]),"<br>\n";
196 print "<table width=100%><tr>\n";
197 print "<td width=30%><b>$text{'index_addr'}</b> ",
198 &html_escape($vaddr[$i]),"</td>\n";
199 print "<td width=70%><b>$text{'index_name'}</b> ",
200 &html_escape($vserv[$i]),"</td></tr>\n";
201 print "</table></td> </tr>\n";
206 print "<form action=create_virt.cgi>\n";
207 print "<table border>\n";
208 print "<tr $tb> <td><b>$text{'index_create'}</b></td> </tr>\n";
209 print "<tr $cb> <td><table>\n";
210 print "<tr> <td><b>$text{'index_addr'}</b></td>\n";
211 print "<td><input name=addr size=25></td> </tr>\n";
212 print "<tr> <td><b>$text{'index_port'}</b></td>\n";
213 print "<td>",&opt_input(undef, "Port", $text{'default'}, 6),"</td> </tr>\n";
214 print "<tr> <td><b>$text{'index_name'}</b></td>\n";
215 print "<td>",&opt_input(undef, "ServerName", $text{'default'}, 25);
216 print " \n";
217 print "<input type=submit value=\"$text{'create'}\"></td> </tr>\n";
218 print "</table></td></tr></table>\n";
221 # Find out how ProFTPd is running
222 ($inet, $inet_mod) = &running_under_inetd();
224 # Get the FTP server pid
225 $pid = &get_proftpd_pid();
227 print &ui_buttons_start();
229 if (!$inet && $pid) {
230 print &ui_buttons_row("apply.cgi",
231 $text{'index_apply'},
232 &get_proftpd_version() > 1.22 ?
233 $text{'index_applymsg2'} :
234 $text{'index_applymsg'});
235 print &ui_buttons_row("stop.cgi",
236 $text{'index_stop'}, $text{'index_stopmsg'});
238 elsif (!$inet && !$pid) {
239 print &ui_buttons_row("start.cgi",
240 $text{'index_start'},
241 $inet_mod ? &text('index_startmsg', "/$inet_mod/")
242 : $text{'index_startmsg2'});
245 print &ui_buttons_end();
248 &ui_print_footer("/", $text{'index'});