#!/usr/local/bin/perl # index.cgi # Display the icons for various types of proftpd config options require './proftpd-lib.pl'; # Check if proftpd is installed @st = stat($config{'proftpd_path'}); if (!@st) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("proftpd", "man", "doc", "google")); print &text('index_eproftpd', "$config{'proftpd_path'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"
\n"; &foreign_require("software", "software-lib.pl"); $lnk = &software::missing_install_link("proftpd",$text{'index_proftpd'}, "../$module_name/", $text{'index_title'}); print $lnk,"
\n" if ($lnk); &ui_print_footer("/", $text{'index'}); exit; } # Check if the config file exists $conf = &get_config(); if (!@$conf) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("proftpd", "man", "doc", "google")); print &text('index_econf', "$config{'proftpd_conf'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"
\n"; &ui_print_footer("/", $text{'index'}); exit; } # Check if the executable has changed .. if ($site{'size'} != $st[7]) { # Check if it really is proftpd and the right version $site{'size'} = $st[7]; $ver = &get_proftpd_version(\$out); if (!$ver) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("proftpd", "man", "doc", "google")); print &text('index_eproftpd2', "$config{'proftpd_path'}", "$gconfig{'webprefix'}/config.cgi?$module_name", "$config{'proftpd_path'} -v", "
$out"),"
\n"; &ui_print_footer("/", $text{'index'}); exit; } $site{'version'} = $ver; if ($site{'version'} < 0.99) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("proftpd", "man", "doc", "google")); print &text('index_eversion', "$config{'proftpd_path'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"
\n";
&ui_print_footer("/", $text{'index'});
exit;
}
# Get the list of modules
local @mods;
open(MODS, "$config{'proftpd_path'} -l |");
while(
\n";
# Start virtual server list with default
push(@vname, $text{'index_defserv'});
push(@vlink, "virt_index.cgi");
push(@vdesc, $text{'index_defdesc'});
push(@vaddr, $text{'index_any'});
push(@vserv, &def(&find_directive("ServerName", $conf), $text{'default'}));
# Add other virtual servers
@virt = &find_directive_struct("VirtualHost", $conf);
foreach $v (@virt) {
$vm = $v->{'members'};
push(@vname, $text{'index_virt'});
push(@vlink, "virt_index.cgi?virt=".&indexof($v, @$conf));
push(@vaddr, $v->{'value'});
$sname = &find_directive("ServerName", $vm);
local $ip = &to_ipaddress($v->{'value'});
push(@vdesc, &text('index_vdesc', $ip ? $ip : $text{'index_eip'}));
push(@vserv, &def(&find_vdirective("ServerName", $vm, $conf),
$text{'index_auto'}));
}
# Show virtual servers
print &ui_hr();
print &ui_subheading($text{'index_virts'});
if ($config{'show_list'} && scalar(@vname)) {
# as list for people with lots of servers
print "\n";
print "\n";
print " \n";
print "\n";
print " \n";
print "
\n";
}
else {
# as icons for niceness
print " \n";
for($i=0; $i<@vname; $i++) {
print "$text{'index_type'} ",
"$text{'index_addr'} ",
"$text{'index_name'} \n";
print " \n";
}
print "",
&html_escape($vname[$i])," \n";
print "",&html_escape($vaddr[$i])," \n";
print "",&html_escape($vserv[$i])," \n";
print "\n";
for($i=0; $i<@vname; $i++) {
print "
\n";
}
print "\n";
# Find out how ProFTPd is running
($inet, $inet_mod) = &running_under_inetd();
if (!$inet) {
# Get the FTP server pid
$pid = &get_proftpd_pid();
print &ui_hr();
print &ui_buttons_start();
}
if (!$inet && $pid) {
print &ui_buttons_row("apply.cgi",
$text{'index_apply'},
&get_proftpd_version() > 1.22 ?
$text{'index_applymsg2'} :
$text{'index_applymsg'});
print &ui_buttons_row("stop.cgi",
$text{'index_stop'}, $text{'index_stopmsg'});
}
elsif (!$inet && !$pid) {
print &ui_buttons_row("start.cgi",
$text{'index_start'},
$inet_mod ? &text('index_startmsg', "/$inet_mod/")
: $text{'index_startmsg2'});
}
if (!$inet) {
print &ui_buttons_end();
}
&ui_print_footer("/", $text{'index'});
\n";
}
print "";
&generate_icon("images/virt.gif", &html_escape($vname[$i]),
$vlink[$i]);
print " \n";
print &html_escape($vdesc[$i]),"
\n";
print "\n";
print " \n";
print "$text{'index_addr'} ",
&html_escape($vaddr[$i])," \n";
print "$text{'index_name'} ",
&html_escape($vserv[$i]),"