# # _modules/config.pm # # Developed by Lubomir Host 'rajo' # Copyright (c) 2004-2006 Platon Group, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 17/04/2004 - created # # $Id: config.pm,v 1.4 2006/01/25 15:19:24 rajo Exp $ package config; use strict; use Env; use English; use Carp; use Cwd; use File::Basename qw( basename fileparse ); use vars qw($VERSION $DEBUG @ISA @EXPORT $AUTOLOAD); @ISA = qw(Exporter); @EXPORT = qw( run runcount ); $VERSION = sprintf("%d", q$Revision: 1.4 $ =~ /(\d+)/); $DEBUG = 0 unless defined $DEBUG; use vars qw ( $hostname $site_title $site_root $fastcgi_name $runlimit ); BEGIN { # {{{ $site_title = 'FastCGI Gallery homepage'; $site_root = getcwd(); $hostname = `hostname -f`; $hostname =~ s/\s//g; # # Get name of FastCGI script # # I don't like '.fcgi' extension in URL (as you can see on demo page # http://fastcgi-gallery.platon.sk/index?gallery=%2F&lang=en ), so we # keep only filename withouth extension. # # You ***NEED*** to enable "Multiviews" option in your Apache configuration. # See doc/httpd-example.conf # # And here is the reason, why I don't use script extension: # http://rajo.platon.sk/index/en/show:gallery # ^^^^-- language is here # http://rajo.platon.sk/index/sk/show:gallery # ^^^^-- language is here my ($name, $path, $suffix) = fileparse($0, '.fcgi', '.cgi'); $fastcgi_name = $name eq '' ? 'index' : $name; # default index if ($hostname =~ m/Idea/i) { } else { } $runlimit = 1000; } # }}} sub new { #{{{ my $this = shift; my $class = ref($this) || $this; my $self = { runcount => 0, runlimit => $runlimit, hostname => $hostname, site_title => $site_title, site_root => $site_root, fastcgi_name => $fastcgi_name, # }}} }; bless $self, $class; return $self; } # }}} # check, if $runcount < $runlimit sub run() { # {{{ my $self = shift; return 1 if ($self->runcount < $self->runlimit); } # }}} run # return value of $self->{runcount} and increase value sub runcount() { # {{{ my $self = shift; return $self->{runcount}++; } # }}} runcount sub AUTOLOAD() { # {{{ my $self = shift; my $type = ref($self) || croak "$self is not object"; my $name = $AUTOLOAD; $name =~ s/.*://; unless (exists $self->{$name}) { croak "Can't access array '$name' in object class '$type'"; } if (@_) { return $self->{$name} = shift; } else { return $self->{$name}; } } # }}} sub DESTROY() { # {{{ my $self = shift; undef $self; } # }}} 1; 1; __END__ =head1 NAME config - <<>> =head1 SYNOPSIS use config; my $xxx = new config; =head1 DESCRIPTION The config module allows you ... <<>> =head2 EXPORT <>> =head1 SEE ALSO =head1 AUTHORS Lubomir Host 'rajo', =cut # vim: ts=4 # vim600: fdm=marker fdl=0 fdc=3