3 # Finds all per-directory options files under the all the document roots
5 require './apache-lib.pl';
7 $access{'global'} || &error($text{'htaccess_ecannot'});
9 $in{'from'}=1 if ($access{'dir'} ne '/');
10 if ($in{'from'} == 1 && !(-d $in{'dir'})) {
11 &error(&text('htaccess_edir', $in{'dir'}));
13 &read_file("$module_config_directory/site", \%site);
14 foreach $f (split(/\s+/, $site{'htaccess'})) {
15 if (-r $f) { push(@rv, $f); }
18 # Find the default document root and access file
19 $conf = &get_config();
20 $def_htaccess = &find_directive("AccessFileName", $conf);
21 if (!$def_htaccess) { $def_htaccess = ".htaccess"; }
22 $def_root = &find_directive("DocumentRoot", $conf);
23 if (!$def_root) { $def_root = "/"; }
25 # find virtual server doc roots and access files
26 push(@dirs, $def_root); push(@files, $def_htaccess);
27 foreach $v (&find_directive_struct("VirtualHost", $conf)) {
28 $root = &find_directive("DocumentRoot", $v->{'members'});
29 push(@dirs, $root ? $root : $def_root);
30 $htaccess = &find_directive("AccessFileName", $v->{'members'});
31 push(@files, $htaccess ? $htaccess : $def_htaccess);
34 if ($in{'from'} == 0) {
35 # search under all directories
36 for($i=0; $i<@dirs; $i++) {
37 open(FIND, "find $dirs[$i] -name $files[$i] -print |");
46 # search under the given directory only
47 foreach $f (&unique(@files)) { push(@args, "-name $f"); }
48 $args = join(' -o ', @args);
49 open(FIND, "find ".quotemeta($in{'dir'})." $args -print |");
58 $site{'htaccess'} = join(' ', &unique(@rv));
59 &write_file("$module_config_directory/site", \%site);
60 &redirect("htaccess.cgi");