require 'apache-lib.pl';
# acl_security_form(&options)
# Output HTML for editing security options for the apache module
sub acl_security_form
{
print "
$text{'acl_virts'} \n";
print "\n";
printf " %s\n",
$_[0]->{'virts'} eq '*' ? 'checked' : '', $text{'acl_vall'};
printf " %s \n",
$_[0]->{'virts'} eq '*' ? '' : 'checked', $text{'acl_vsel'};
print "\n";
local $conf = &get_config();
local @virts = ( { 'value' => '__default__' },
&find_directive_struct("VirtualHost", $conf) );
local %vcan = map { $_, 1 } split(/\s+/, $_[0]->{'virts'});
local $v;
foreach $v (@virts) {
local @vn = &virt_acl_name($v);
local ($can) = grep { $vcan{$_} } @vn;
local $vn = $can || $vn[0];
printf "%s \n",
$vn, $can ? "selected" : "",
$vn eq "__default__" ? $text{'acl_defserv'} : $vn;
delete($vcan{$can}) if ($can);
}
foreach $vn (keys %vcan) {
next if ($vn eq "*");
printf "%s \n",
$vn, "selected",
$vn eq "__default__" ? $text{'acl_defserv'} : $vn;
}
print " \n";
print "$text{'acl_global'} \n";
printf "$text{'yes'} \n",
$_[0]->{'global'} == 1 ? "selected" : "";
printf "$text{'acl_htaccess'} \n",
$_[0]->{'global'} == 2 ? "selected" : "";
printf "$text{'no'} \n",
$_[0]->{'global'} == 0 ? "selected" : "";
print " $text{'acl_create'} \n";
printf " $text{'yes'}\n",
$_[0]->{'create'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'create'} ? "" : "checked";
print " $text{'acl_vuser'} \n";
printf " $text{'yes'}\n",
$_[0]->{'vuser'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'vuser'} ? "" : "checked";
print " $text{'acl_vaddr'} \n";
printf " $text{'yes'}\n",
$_[0]->{'vaddr'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'vaddr'} ? "" : "checked";
print " $text{'acl_pipe'} \n";
printf " $text{'yes'}\n",
$_[0]->{'pipe'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'pipe'} ? "" : "checked";
print "$text{'acl_stop'} \n";
printf " $text{'yes'}\n",
$_[0]->{'stop'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'stop'} ? "" : "checked";
print " $text{'acl_apply'} \n";
printf " $text{'yes'}\n",
$_[0]->{'apply'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'apply'} ? "" : "checked";
print "$text{'acl_names'} \n";
printf " $text{'yes'}\n",
$_[0]->{'names'} ? "checked" : "";
printf " $text{'no'} \n",
$_[0]->{'names'} ? "" : "checked";
print " $text{'acl_dir'} \n";
printf " %s \n",
$_[0]->{'dir'}, &file_chooser_button("dir", 1);
print " $text{'acl_aliasdir'} \n";
printf " %s \n",
$_[0]->{'aliasdir'}, &file_chooser_button("aliasdir", 1);
print " $text{'acl_types'} \n";
print "\n";
printf " $text{'acl_all'} \n",
$_[0]->{'types'} eq '*' ? "checked" : "";
printf " $text{'acl_sel'} \n",
$_[0]->{'types'} eq '*' ? "" : "checked";
map { $types{$_}++ } split(/\s+/, $_[0]->{'types'});
print "\n";
for($i=0; $text{"type_$i"}; $i++) {
printf "%s \n",
$i, $types{$i} ? "selected" : "", $text{"type_$i"};
}
print " \n";
print " $text{'acl_dirs'} \n";
print "\n";
print &ui_radio("dirsmode", $_[0]->{'dirsmode'},
[ [ 0, $text{'acl_dirs0'} ],
[ 1, $text{'acl_dirs1'} ],
[ 2, $text{'acl_dirs2'} ] ])," \n";
print &ui_textarea("dirs", join("\n", split(/\s+/, $_[0]->{'dirs'})), 5, 50);
print " \n";
}
# acl_security_save(&options)
# Parse the form for security options for the apache module
sub acl_security_save
{
if ($in{'virts_def'}) {
$_[0]->{'virts'} = "*";
}
else {
$_[0]->{'virts'} = join(" ", split(/\0/, $in{'virts'}));
}
$_[0]->{'global'} = $in{'global'};
$_[0]->{'create'} = $in{'create'};
$_[0]->{'vuser'} = $in{'vuser'};
$_[0]->{'stop'} = $in{'stop'};
$_[0]->{'apply'} = $in{'apply'};
$_[0]->{'vaddr'} = $in{'vaddr'};
$_[0]->{'dir'} = $in{'dir'};
$_[0]->{'aliasdir'} = $in{'aliasdir'};
$_[0]->{'types'} = $in{'types_def'} ? '*'
: join(" ", split(/\0/, $in{'types'}));
$_[0]->{'pipe'} = $in{'pipe'};
$_[0]->{'names'} = $in{'names'};
$_[0]->{'dirsmode'} = $in{'dirsmode'};
$_[0]->{'dirs'} = join(" ", split(/\s+/, $in{'dirs'}));
}