#!/usr/local/bin/perl
# edit_users.cgi
# Display user access control form

require './usermin-lib.pl';
$access{'users'} || &error($text{'acl_ecannot'});
&header($text{'users_title'}, "");
print "<hr>\n";
&get_usermin_miniserv_config(\%miniserv);

if (&get_usermin_version() < 0.76) {
	print "<p>$text{'users_eversion'}<p>\n";
	print "<hr>\n";
	&footer("", $text{'index_return'});
	exit;
	}

print $text{'users_desc'},"<p>\n";

print "<form action=change_users.cgi method=post>\n";
print "<table border>\n";
print "<tr $tb> <td><b>$text{'users_header'}</b></td> </tr>\n";
print "<tr $cb> <td><table><tr><td valign=top nowrap>\n";
printf "<input type=radio name=access value=0 %s>\n",
	$miniserv{"allowusers"} || $miniserv{"denyusers"} ? "" : "checked";
print "$text{'users_all'}<br>\n";
printf "<input type=radio name=access value=1 %s>\n",
	$miniserv{"allowusers"} ? "checked" : "";
print "$text{'users_allow'}<br>\n";
printf "<input type=radio name=access value=2 %s>\n",
	$miniserv{"denyusers"} ? "checked" : "";
print "$text{'users_deny'}<br>\n";
print "</td> <td valign=top>\n";
printf "<textarea name=user rows=6 cols=30>%s</textarea></td> </tr>\n",
 $miniserv{"allowusers"} ? join("\n", split(/\s+/, $miniserv{"allowusers"})) :
 $miniserv{"denyusers"} ? join("\n", split(/\s+/, $miniserv{"denyusers"})) : "";

if (&get_usermin_version() > 0.95) {
	print "<tr> <td colspan=2>\n";
	printf "<input type=checkbox name=shells_deny value=1 %s> %s\n",
		$miniserv{'shells_deny'} ? "checked" : "",$text{'users_shells'};
	printf "<input name=shells size=25 value='%s'> %s</td> </tr>\n",
		$miniserv{'shells_deny'} || "/etc/shells",
		&file_chooser_button("shells");
	}

print "</table></td> </tr></table>\n";
print "<input type=submit value=\"$text{'save'}\"></form>\n";

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

