package LiveGeez::Config; use base qw(Exporter); BEGIN { use strict; use vars qw( $VERSION %DEFAULTS %URIS @EXPORT_OK ); $VERSION = '0.20'; require 5.000; %URIS = ( webroot => "/usr/local/apache/htdocs", # where you keep HTML files cgidir => "/usr/local/apache/cgi-bin", # where you keep CGI files zauthority => "http://zobel.geez.org", # Zobel URL zpath => "/", # Zobel from the server root cacheremote => "/usr/local/apache/htdocs/cache", # where to cache URL documents cachelocal => "/usr/local/apache/htdocs/cache", # where to cache local files ipath => "/f", # where we keep fidel images, if any ); %DEFAULTS =( URIS => \%URIS, LANG => "amh", # assumed preferred language SYSIN => "sera", # assume files are in this system SYSOUT => "UTF8", # default font conversion PROCESSURLS => 1, # should we let people use our bandwidth? CHECKFILEDATES => 1, # should we compare local file dates with cache? BGCOLOR => "#f0f0f0", # default background color of pages COOKIEDOMAIN => ".geez.org", COOKIEEXPIRES => "Thu, 11-Nov-01 00:00:00 GMT", USEAPACHE => 1, USECGI_PM => 0, USEFRAMES => "false", SET_LOCAL_BASE => 0, USECOOKIES => 0, # use cookies instead of inserting LIVEGEEZLINK and LIVEGEEZSYS in certain places USEMOD_GZIP => 0, ADMINEMAIL => "support\@geez.org", REGION => "et", # er, et, or "*" # $NOCACHEING => 1, # $ADMINPASSWORD => "snork", ); $URIS{zuri} = $URIS{zauthority}.$URIS{zpath}; $URIS{file_query} = $URIS{zuri}."?sys=LIVEGEEZSYS\&file="; $URIS{file_query} =~ s|/\?|/|; @EXPORT_OK = qw ( %URIS ); } sub import { if ( @_ == 2 ) { LiveGeez::Config->export_to_level (1, @_); return; } shift; return unless @_; my %config = @_; my $uri_update = 0; foreach (keys %config) { if ( /uri_(.*)/i ) { my $k = lc($1); $uri_update = 1; $URIS{$k} = $config{$_} if ( exists ($URIS{$k}) ); } else { my $k = uc($_); $DEFAULTS{$k} = $config{$_} if ( exists ($DEFAULTS{$k}) ); } } if ( $uri_update ) { if ( grep { /(zauthority|zpath)/i } (keys %config) ) { $URIS{zuri} = $URIS{zauthority}.$URIS{zpath}; $URIS{file_query} = $URIS{zuri}."?sys=LIVEGEEZSYS\&file="; } if ( exists($config{zuri} ) || exists($config{ZURI}) ) { $URIS{file_query} = $URIS{zuri}."?sys=LIVEGEEZSYS\&file="; } $URIS{file_query} =~ s|/\?|/|; } } sub init { my $self = shift; my %config = @_ if ( @_ ); foreach ( keys %DEFAULTS ) { next if ( /URI/ ); $self->{lc($_)} = $DEFAULTS{$_}; } foreach ( keys %URIS ) { $self->{uris}{lc($_)} = $URIS{$_}; } if ( @_ ) { my $uri_update = 0; foreach ( keys %config ) { if ( /uri_(.*)/i ) { my $k = lc($1); $uri_update = 1; $self->{uris}{$k} = $config{$_} if ( exists($self->{uris}{$k}) ); } else { $self->{$_} = $config{$_} if ( exists($self->{$_}) ); } } if ( $uri_update ) { if ( grep { /(zauthority|zpath)/i } (keys %config) ) { # if ( exists($config{uri_zauthority} ) || exists($config{uri_zpath}) ) { $self->{uris}{zuri} = $self->{uris}{zauthority}.$self->{uris}{zpath}; $self->{uris}{file_query} = $self->{uris}{zuri}."?sys=LIVEGEEZSYS\&file="; } if ( exists($config{uri_zuri} ) || exists($config{URI_ZURI}) ) { $self->{uris}{file_query} = $self->{uris}{zuri}."?sys=LIVEGEEZSYS\&file="; } $self->{uris}{file_query} =~ s|/\?|/|; } } } sub new { my $self = {}; my $blessing = bless ( $self, shift ); $self->init ( @_ ); $blessing; } sub status { my ( $self, $r ) = @_; $r->print ("Package Defaults:\n"); $r->print ("