#!/usr/local/bin/perl # edit_dir.cgi # Display information about a protected directory require './htaccess-lib.pl'; &foreign_require($apachemod, "apache-lib.pl"); &ReadParse(); $can_create || &error($text{'dir_ecannotcreate'}); if ($in{'new'}) { &ui_print_header(undef, $text{'dir_title1'}, ""); } else { &ui_print_header(undef, $text{'dir_title2'}, ""); @dirs = &list_directories(); ($dir) = grep { $_->[0] eq $in{'dir'} } @dirs; &can_access_dir($dir->[0]) || &error($text{'dir_ecannot'}); } print "
\n"; print "\n"; print "\n"; print "\n"; print "
$text{'dir_header'}
\n"; # Directory to protect print "\n"; # File containing users print "\n", $dir->[1], &file_chooser_button("file", 0); } else { # Always automatic if ($in{'new'}) { print "$text{'dir_auto'}\n"; } else { print "$dir->[1]\n"; } } # File containing groups if ($can_htgroups) { print "\n", $dir->[4], &file_chooser_button("gfile", 0); } # If MD5 encryption is available, show option for it @crypts = ( 0 ); push(@crypts, 1) if ($config{'md5'}); push(@crypts, 2) if ($config{'sha1'}); push(@crypts, 3) if ($config{'digest'}); if (@crypts > 1) { print "\n"; print "\n"; } else { print "\n"; } # Authentication realm print "\n"; if (!$in{'new'}) { $conf = &foreign_call($apachemod, "get_htaccess_config", "$dir->[0]/$config{'htaccess'}"); $realm = &foreign_call($apachemod, "find_directive", "AuthName", $conf, 1); } printf "\n", $realm; # Users and groups to allow if (!$in{'new'}) { $require = &foreign_call($apachemod, "find_directive_struct", "require", $conf); ($rmode, @rwho) = @{$require->{'words'}} if ($require); } else { $rmode = "valid-user"; } print "\n"; print "\n"; # Webmin synchronization mode if ($can_sync) { print "\n"; %sync = map { $_, 1 } split(/,/, $dir->[3]); foreach $s ('create', 'update', 'delete') { print "\n"; } } print "
$text{'dir_dir'} \n"; if ($in{'new'}) { printf " %s\n", $dir->[0], &file_chooser_button("dir", 1); } else { print "\n"; print "$dir->[0]\n"; } print "
$text{'dir_file'} \n"; if ($can_htpasswd) { # Allow choice of users file if ($in{'new'}) { print " ", "$text{'dir_auto'}
\n"; print " $text{'dir_sel'}\n"; } printf " %s
$text{'dir_gfile'} \n"; printf " %s
\n", $dir->[4] ? "" : "checked", $text{'dir_none'}; if ($in{'new'}) { print " ", "$text{'dir_auto'}
\n"; } printf " %s\n", $dir->[4] ? "checked" : "", $text{'dir_sel'}; printf " %s
$text{'dir_crypt'}",&ui_radio("crypt", int($dir->[2]), [ map { [ $_, $text{'dir_crypt'.$_} ] } @crypts ]),"
$text{'dir_realm'}
$text{'dir_require'}",&ui_radio("require_mode", $rmode, [ [ "valid-user", $text{'dir_requirev'}."
" ], [ "user", $text{'dir_requireu'}." ". &ui_textbox("require_user", $rmode eq "user" ? join(" ", @rwho) : "", 40)."
" ], [ "group", $text{'dir_requireg'}." ". &ui_textbox("require_group", $rmode eq "group" ? join(" ", @rwho) : "", 40)."
" ] ]), "

",$text{'dir_sync_'.$s}," \n"; printf " %s\n", $s, $sync{$s} ? "checked" : "", $text{'yes'}; printf " %s\n", $s, $sync{$s} ? "" : "checked", $text{'no'}; print "
\n"; if ($in{'new'}) { print "\n"; } else { print "\n"; print "\n"; print " ", &text($dir->[4] ? 'dir_remove2' : 'dir_remove', "$config{'htaccess'}", "$config{'htpasswd'}", "$config{'htgroups'}"),"\n"; } print "
\n"; &ui_print_footer("", $text{'index_return'});