# Read and parse the configuration files
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-06-09
+# Last modified: 2005-08-24
#
use strict;
$config->{'errors'} = parse_config($config->{'error_file'});
$config->{'templates'} = parse_config($config->{'template_file'});
+ # Check if we have to parse the user config file
+
+ if($ENV{'REMOTE_USER'} && $config->{'userconf_file'} && -f $config->{'userconf_file'})
+ {
+ my $userconf = parse_config($config->{'userconf_file'});
+
+ if($userconf->{$ENV{'REMOTE_USER'}})
+ {
+ # The current HTTP Auth user has got an individual configuration
+ # Overwrite the default values
+
+ my $new_conf = $userconf->{$ENV{'REMOTE_USER'}};
+
+ $config->{'fileroot'} = $new_conf->{'fileroot'} if($new_conf->{'fileroot'});
+ $config->{'httproot'} = $new_conf->{'httproot'} if($new_conf->{'httproot'});
+
+ $config->{'forbidden'} = $new_conf->{'forbidden'} if(defined $new_conf->{'forbidden'});
+
+ $config->{'user_config'} = 1;
+ }
+ }
+
# Parse list of forbidden files
if($config->{'forbidden'})
$config->{'forbidden'} = \@files;
}
+ else
+ {
+ $config->{'forbidden'} = [];
+ }
return $config;
}
my @lines = split(/\015\012|\012|\015/,$data);
my $config = {};
my $count = 0;
+ my $sect;
foreach my $line(@lines)
{
$count++;
next if($line =~ /^\s*#/);
- next if($line !~ /^\s*\S+\s*=.*$/);
- my ($key,$value) = split(/=/,$line,2);
+ if($line =~ /^\s*\[(\S+)\]\s*$/)
+ {
+ # Switch to new section
+
+ $sect = $1;
+ }
+ elsif($line =~ /^\s*\S+\s*=.*$/)
+ {
+ # A normal "key = value" line
+
+ my ($key,$value) = split(/=/,$line,2);
+
+ # Remove whitespaces at the beginning and at the end
- # Remove whitespaces at the beginning and at the end
+ $key =~ s/^\s+//g;
+ $key =~ s/\s+$//g;
+ $value =~ s/^\s+//g;
+ $value =~ s/\s+$//g;
- $key =~ s/^\s+//g;
- $key =~ s/\s+$//g;
- $value =~ s/^\s+//g;
- $value =~ s/\s+$//g;
+ if($sect)
+ {
+ $config->{$sect} = {} if(ref($config->{$sect}) ne 'HASH');
- croak "Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key});
+ croak "Configuration option '$key' of section '$sect' defined twice in line $count of configuration file '$file'" if($config->{$sect}->{$key});
- $config->{$key} = $value;
+ $config->{$sect}->{$key} = $value;
+ }
+ else
+ {
+ croak "Configuration option '$key' defined twice in line $count of configuration file '$file'" if($config->{$key});
+
+ $config->{$key} = $value;
+ }
+ }
}
return $config;
<td align="right" style="white-space:nowrap">[SUBDIR]</td>
<td style="padding-left:15pt;white-space:nowrap;">{DATE}{IF gmt} (GMT){ENDIF}</td>
<td style="padding-left:15pt;white-space:nowrap;">{IF !forbidden}{IF readable}<a href="{SCRIPT}?command=show&file={DIR_URL}{IF filter}&filter={FILTER_URL}{ENDIF}">{DIR_NAME}/</a>{ELSE}<span style="color:#C0C0C0" title="Not accessible">{DIR_NAME}/</span>{ENDIF}{ELSE}<span style="color:#C0C0C0" title="File access forbidden by Dev-Editor's configuration">{DIR_NAME}/</span>{ENDIF}</td>
-<td style="padding-left:15pt;white-space:nowrap;">({IF !forbidden}{IF readable}<a href="{SCRIPT}?command=copy&file={DIR_URL}">Copy</a> | {ENDIF}{IF dir_writeable}<a href="{SCRIPT}?command=rename&file={DIR_URL}">Rename</a> | <a href="{SCRIPT}?command=remove&file={DIR_URL}">Delete</a> |{ENDIF}{IF users} <a href="{SCRIPT}?command=chprop&file={DIR_URL}">Chmod/Chgrp</a> |{ENDIF}{ENDIF} <a href="{URL}" target="_blank">View in Browser</a>)</td>
+<td style="padding-left:15pt;white-space:nowrap;">({IF !forbidden}{IF readable}<a href="{SCRIPT}?command=copy&file={DIR_URL}">Copy</a> | {ENDIF}{IF dir_writeable}<a href="{SCRIPT}?command=rename&file={DIR_URL}">Rename</a> | <a href="{SCRIPT}?command=remove&file={DIR_URL}">Delete</a> |{ENDIF}{IF users} <a href="{SCRIPT}?command=chprop&file={DIR_URL}">Chmod/Chgrp</a> |{ENDIF} {ENDIF}<a href="{URL}" target="_blank">View in Browser</a>)</td>
</tr>