#!/usr/local/bin/perl
# htaccess.cgi
# Display a list of per-directory config files

require './apache-lib.pl';
$access{'global'} || &error($text{'htaccess_ecannot'});
&header($text{'htaccess_title'}, "");
print "<hr>\n";

print "$text{'htaccess_desc'} <p>\n";
@htaccess_files = grep { &allowed_auth_file($_) } @htaccess_files;
if (@htaccess_files) {
	print "<table border width=100%>\n";
	print "<tr $tb> <td><b>$text{'htaccess_title'}</b></td> </tr>\n";
	print "<tr $cb><td><table width=100%>\n";
	for($i=0; $i<@htaccess_files; $i++) {
		if ($i%2 == 0) { print "<tr>\n"; }
		print "<td width=50%><a href=\"htaccess_index.cgi?file=",
		      &urlize($htaccess_files[$i]),"\">",$htaccess_files[$i],
		      "</a></td>\n";
		if ($i%2 == 1) { print "</tr>\n"; }
		}
	print "</table></td></tr></table><p>\n";
	}
print "<form action=create_htaccess.cgi>\n";
print "<input type=submit value=\"$text{'htaccess_create'}\">\n";
print "<input name=file size=30>\n",
	&file_chooser_button("file", 0, 0);
print "</form>\n";

print "<form action=find_htaccess.cgi>\n";
print "<input type=submit value=\"$text{'htaccess_find'}\">\n";
if ($access{'dir'} eq '/') {
	print "<input type=radio name=from value=0 checked>",
	      "$text{'htaccess_auto'}&nbsp;&nbsp;\n";
	print "<input type=radio name=from value=1>\n";
	}
print "$text{'htaccess_from'}\n";
print "<input name=dir size=30 value=$access{'dir'}>\n",
	&file_chooser_button("dir", 1, 1);
print "</form>\n";

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

