From: pcanterino <> Date: Thu, 25 Aug 2005 11:35:17 +0000 (+0000) Subject: - Now, Dev-Editor is able to switch some configuration values depending on the X-Git-Tag: version_3_0~6 X-Git-Url: https://git.p6c8.net/devedit.git/commitdiff_plain/7efda2bd1d1eb1d06b1513f459e14164ad4689f7?ds=sidebyside - Now, Dev-Editor is able to switch some configuration values depending on the current HTTP Auth user. This is controlled by a separate configuration file that contains sections like Windows INI files (thus the configuration file parser is now able to parse files containing sections in square brackets). You may overwrite the following configuration values: - fileroot - httproot - forbidden (you may also clear the default "forbidden" list) - Fixed a bug occuring if the user placed an empty "forbidden" configuration option in the main configuration file. In this case we create an empty Array Reference. - Fixed an error in an {IF} block in dirlist_dir.htm --- diff --git a/modules/Config/DevEdit.pm b/modules/Config/DevEdit.pm index c387514..aa76b5e 100644 --- a/modules/Config/DevEdit.pm +++ b/modules/Config/DevEdit.pm @@ -6,7 +6,7 @@ package Config::DevEdit; # Read and parse the configuration files # # Author: Patrick Canterino -# Last modified: 2005-06-09 +# Last modified: 2005-08-24 # use strict; @@ -39,6 +39,28 @@ sub read_config($) $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'}) @@ -57,6 +79,10 @@ sub read_config($) $config->{'forbidden'} = \@files; } + else + { + $config->{'forbidden'} = []; + } return $config; } @@ -81,26 +107,48 @@ sub parse_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; diff --git a/templates/dirlist_dir.htm b/templates/dirlist_dir.htm index 14b5628..29ec634 100644 --- a/templates/dirlist_dir.htm +++ b/templates/dirlist_dir.htm @@ -2,5 +2,5 @@ [SUBDIR] {DATE}{IF gmt} (GMT){ENDIF} {IF !forbidden}{IF readable}{DIR_NAME}/{ELSE}{DIR_NAME}/{ENDIF}{ELSE}{DIR_NAME}/{ENDIF} -({IF !forbidden}{IF readable}Copy | {ENDIF}{IF dir_writeable}Rename | Delete |{ENDIF}{IF users} Chmod/Chgrp |{ENDIF}{ENDIF} View in Browser) +({IF !forbidden}{IF readable}Copy | {ENDIF}{IF dir_writeable}Rename | Delete |{ENDIF}{IF users} Chmod/Chgrp |{ENDIF} {ENDIF}View in Browser)