#!/usr/local/bin/perl
# ftpaccess_index.cgi
# Display a menu of icons for a per-directory options file

require './proftpd-lib.pl';
&ReadParse();
$conf = &get_ftpaccess_config($in{'file'});
&header($text{'ftpindex_title'}, "",
	undef, undef, undef, undef, "<a href=\"delete_ftpaccess.cgi?file=".
	&urlize($in{'file'})."\">$text{'ftpindex_delete'}</a>");
print "<center><font size=+2><tt>",&html_escape($in{'file'}),
      "</tt></font></center>\n";
print "<hr>\n";
print "<h3>$text{'ftpindex_opts'}</h3>\n";
$ed_icon = { "icon" => "images/edit.gif",
	     "name" => $text{'ftpindex_edit'},
	     "link" => "manual_form.cgi?file=$in{'file'}" };
&config_icons("ftpaccess", "edit_ftpaccess.cgi?file=$in{'file'}&", $ed_icon);

@limit = ( &find_directive_struct("Limit", $conf) );
if (@limit) {
	# Limit sub-directives
	print "<hr>\n";
	print "<h3>$text{'ftpindex_limit'}</h3>\n";
	print "<table width=100% cellpadding=5>\n";
	foreach $l (@limit) {
		if ($i%3 == 0) { print "<tr>\n"; }
		print "<td valign=top align=center width=33%>\n";
		&generate_icon("images/limit.gif", $l->{'value'},
		       	"limit_index.cgi?limit=".&indexof($l, @$conf).
			"&file=$in{'file'}");
		print "</td>\n";
		if ($i++%3 == 2) { print "</tr>\n"; }
		}
	while($i++%3) { print "<td width=33%><br></td>\n"; }
	print "</table><p>\n";
	}

print "<form action=create_limit.cgi>\n";
print "<input type=hidden name=file value='$in{'file'}'>\n";
print "<table border>\n";
print "<tr $tb> <td><b>$text{'ftpindex_addlimit'}</b></td> </tr>\n";
print "<tr $cb> <td><table>\n";
print "<tr> <td><b>$text{'ftpindex_cmds'}</b></td>\n";
print "<td><input name=cmd size=20>\n";
print "<input type=submit value=\"$text{'create'}\"></td> </tr>\n";
print "</table></td></tr></table></form>\n";

print "<hr>\n";
&footer("ftpaccess.cgi", $text{'ftpaccess_return'},
	"", $text{'index_return'});


