diff --git a/Webperl/AppUser.pm b/Webperl/AppUser.pm index d5bb86b..4518dca 100644 --- a/Webperl/AppUser.pm +++ b/Webperl/AppUser.pm @@ -46,10 +46,10 @@ # to call the overridden methods this class via `$self -> SUPER::pre_authenticate()` # or `$self -> SUPER::pre_authenticate()` to extend the default behaviour with # system-specifics rather than entirely replacing it. -package AppUser; +package Webperl::AppUser; use strict; -use base qw(SystemModule); # Extend SystemModule to get error handling +use base qw(Webperl::SystemModule); # Extend SystemModule to get error handling use constant ANONYMOUS_ID => 1; # Default anonymous user id. use constant ADMIN_TYPE => 3; # User type for admin users. @@ -57,8 +57,8 @@ use constant ADMIN_TYPE => 3; # User type for admin users. # ============================================================================ # Constructor -## @cmethod AppUser new(%args) -# Create a new AppUser object. This will create an AppUser object that may be +## @cmethod Webperl::AppUser new(%args) +# Create a new Webperl::AppUser object. This will create a Webperl::AppUser object that may be # passed to the Auth class to provide application-specific user handling. # # @param args A hash of arguments to initialise the AppUser object with. diff --git a/Webperl/Application.pm b/Webperl/Application.pm index cf21c14..83ce42b 100644 --- a/Webperl/Application.pm +++ b/Webperl/Application.pm @@ -23,11 +23,11 @@ # the developer needs to do is: # # use lib "/path/to/webperl"; -# use lib "modules"; -# use Application; -# use AppUser::MySystem; # Implemented in modules/AppUser/MySystem.pm +# use lib "/your/webapp/modules"; +# use Webperl::Application; +# use Webperl::AppUser::MySystem; # Implemented in modules/Webperl/AppUser/MySystem.pm # -# my $app = Application -> new(appuser => AppUser::MySystem -> new()); +# my $app = Application -> new(appuser => Webperl::AppUser::MySystem -> new()); # $app -> run(); # # In general, you will also want to load CGI::Carp and set it up, to handle @@ -36,7 +36,7 @@ # up as needed, this just simplifies the process. See the @ref overview Overview # documentation for more details about the operation of this class. # -package Application; +package Webperl::Application; use strict; @@ -47,15 +47,15 @@ use Module::Load; use Time::HiRes qw(time); # Webperl modules -use Auth; -use BlockSelector; -use ConfigMicro; -use Logger; -use Template; -use SessionHandler; -use Modules; -use Message::Queue; -use Utils qw(path_join is_defined_numeric get_proc_size); +use Webperl::Auth; +use Webperl::BlockSelector; +use Webperl::ConfigMicro; +use Webperl::Logger; +use Webperl::Template; +use Webperl::SessionHandler; +use Webperl::Modules; +use Webperl::Message::Queue; +use Webperl::Utils qw(path_join is_defined_numeric get_proc_size); our $errstr; @@ -67,29 +67,31 @@ BEGIN { # ============================================================================ # Constructor -## @cmethod Application new(%args) -# Create a new Application object. This will create an Application object that -# can be used to generate the pages of a web application. Supported arguments -# are: +## @cmethod Webperl::Application new(%args) +# Create a new Webperl::Application object. This will create a Webperl::Application +# object that can be used to generate the pages of a web application. Supported +# arguments are: # # - `config`, the location of the application config file, defaults to `config/site.cfg`. +# If a relative path is provided, it is assumed to be relative to the index.cgi # - `use_phpbb`, if set, the phpBB3 support module is loaded (and takes over auth: the # `auth` argument is ignored if `use_phpbb` is set). -# - `appuser`, a reference to an AppUser subclass object to do application-specific +# - `appuser`, a reference to a Webperl::AppUser subclass object to do application-specific # user tasks during auth. Can be omitted if use_phpbb is set. # - `auth`, an optional reference to an auth object. If not specified, and `use_phpbb` -# is not set, an Auth object is made for you. -# - `block_selector`, an optional reference to a BlockSelector subclass. If not specified, -# the default BlockSelector is used instead to provide standard block selection behaviour. -# - `system`, an optional reference to a System object. If specified, the init() method -# in this module is called with a hash of arguments containing the database handle, +# is not set, a Webperl::Auth object is made for you. +# - `block_selector`, an optional reference to a Webperl::BlockSelector subclass. If not +# specified, the default Webperl::BlockSelector is used instead to provide standard +# block selection behaviour. +# - `system`, an optional reference to a Webperl::System object. If specified, the init() +# method in this module is called with a hash of arguments containing the database handle, # cgi object, settings, session handler, template handler, and module loader. # - `upload_hook`, an optional reference to a function to use as a CGI upload hook. # - `post_max`, the maximum size of uploaded data in MB. If not set, the default is to # limit posts to 128MB. # -# @param args A hash of arguments to initialise the Application object with. -# @return A new Application object. +# @param args A hash of arguments to initialise the Webperl::Application object with. +# @return A new Webperl::Application object. sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; @@ -116,11 +118,11 @@ sub run { $self -> {"starttime"} = time(); - $self -> {"logger"} = Logger -> new() + $self -> {"logger"} = Webperl::Logger -> new() or die "FATAL: Unable to create logger object"; # Load the system config - $self -> {"settings"} = ConfigMicro -> new($self -> {"config"}) + $self -> {"settings"} = Webperl::ConfigMicro -> new($self -> {"config"}) or $self -> {"logger"} -> die_log("Not avilable", "Application: Unable to obtain configuration file: ".$ConfigMicro::errstr); # Create a new CGI object to generate page content through @@ -144,31 +146,31 @@ sub run { $self -> {"logger"} -> start_log($self -> {"settings"} -> {"config"} -> {"logfile"}) if($self -> {"settings"} -> {"config"} -> {"logfile"}); # Message queue handling - $self -> {"messages"} = Message::Queue -> new(logger => $self -> {"logger"}, - dbh => $self -> {"dbh"}, - settings => $self -> {"settings"}) + $self -> {"messages"} = Webperl::Message::Queue -> new(logger => $self -> {"logger"}, + dbh => $self -> {"dbh"}, + settings => $self -> {"settings"}) or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to create message handler: ".$SystemModule::errstr); # Create the template handler object - $self -> {"template"} = Template -> new(logger => $self -> {"logger"}, - basedir => $self -> {"settings"} -> {"config"} -> {"template_dir"} || "templates", - timefmt => $self -> {"settings"} -> {"config"} -> {"timefmt"}, - blockname => 1, - mailcmd => '/usr/sbin/sendmail -t -f '.$self -> {"settings"} -> {"config"} -> {"Core:envelope_address"}, - settings => $self -> {"settings"}) + $self -> {"template"} = Webperl::Template -> new(logger => $self -> {"logger"}, + basedir => $self -> {"settings"} -> {"config"} -> {"template_dir"} || "templates", + timefmt => $self -> {"settings"} -> {"config"} -> {"timefmt"}, + blockname => 1, + mailcmd => '/usr/sbin/sendmail -t -f '.$self -> {"settings"} -> {"config"} -> {"Core:envelope_address"}, + settings => $self -> {"settings"}) or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to create template handling object: ".$Template::errstr); # If phpbb mode is enabled, it takes over auth. if($self -> {"use_phpbb"}) { - load phpBB3; - $self -> {"phpbb"} = phpBB3 -> new(logger => $self -> {"logger"}, - prefix => $self -> {"settings"} -> {"database"} -> {"phpbb_prefix"}, - cgi => $self -> {"cgi"}, - data_src => $self -> {"settings"} -> {"database"} -> {"phpbb_database"}, - username => $self -> {"settings"} -> {"database"} -> {"phpbb_username"}, - password => $self -> {"settings"} -> {"database"} -> {"phpbb_password"}, - codepath => path_join($self -> {"settings"} -> {"config"} -> {"base"}, "templates", "default"), - url => $self -> {"settings"} -> {"config"} -> {"forumurl"}) + load Webperl::phpBB3; + $self -> {"phpbb"} = Webperl::phpBB3 -> new(logger => $self -> {"logger"}, + prefix => $self -> {"settings"} -> {"database"} -> {"phpbb_prefix"}, + cgi => $self -> {"cgi"}, + data_src => $self -> {"settings"} -> {"database"} -> {"phpbb_database"}, + username => $self -> {"settings"} -> {"database"} -> {"phpbb_username"}, + password => $self -> {"settings"} -> {"database"} -> {"phpbb_password"}, + codepath => path_join($self -> {"settings"} -> {"config"} -> {"base"}, "templates", "default"), + url => $self -> {"settings"} -> {"config"} -> {"forumurl"}) or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Unable to create phpbb object: ".$phpBB3::errstr); $self -> {"auth"} = $self -> {"phpbb"}; @@ -179,19 +181,19 @@ sub run { $self -> {"appuser"} -> init($self -> {"cgi"}, $self -> {"dbh"}, $self -> {"settings"}, $self -> {"logger"}); # If the auth object is not set, make one - $self -> {"auth"} = Auth -> new() if(!$self -> {"auth"}); + $self -> {"auth"} = Webperl::Auth -> new() if(!$self -> {"auth"}); # Initialise the auth object $self -> {"auth"} -> init($self -> {"cgi"}, $self -> {"dbh"}, $self -> {"appuser"}, $self -> {"settings"}, $self -> {"logger"}); } # Start the session engine... - $self -> {"session"} = SessionHandler -> new(logger => $self -> {"logger"}, - cgi => $self -> {"cgi"}, - dbh => $self -> {"dbh"}, - auth => $self -> {"auth"}, - template => $self -> {"template"}, - settings => $self -> {"settings"}) + $self -> {"session"} = Webperl::SessionHandler -> new(logger => $self -> {"logger"}, + cgi => $self -> {"cgi"}, + dbh => $self -> {"dbh"}, + auth => $self -> {"auth"}, + template => $self -> {"template"}, + settings => $self -> {"settings"}) or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to create session object: ".$SessionHandler::errstr); # At this point, there's potentially a real user associated with the session. If appropriate, @@ -209,16 +211,16 @@ sub run { } # And now we can make the module handler - $self -> {"modules"} = Modules -> new(logger => $self -> {"logger"}, - cgi => $self -> {"cgi"}, - dbh => $self -> {"dbh"}, - settings => $self -> {"settings"}, - template => $self -> {"template"}, - session => $self -> {"session"}, - phpbb => $self -> {"phpbb"}, # this will handily be undef if phpbb mode is disabled - blockdir => $self -> {"settings"} -> {"paths"} -> {"blocks"} || "blocks", - system => $self -> {"system"}, - messages => $self -> {"messages"}) + $self -> {"modules"} = Webperl::Modules -> new(logger => $self -> {"logger"}, + cgi => $self -> {"cgi"}, + dbh => $self -> {"dbh"}, + settings => $self -> {"settings"}, + template => $self -> {"template"}, + session => $self -> {"session"}, + phpbb => $self -> {"phpbb"}, # this will handily be undef if phpbb mode is disabled + blockdir => $self -> {"settings"} -> {"paths"} -> {"blocks"} || "blocks", + system => $self -> {"system"}, + messages => $self -> {"messages"}) or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to create module handling object: ".$Modules::errstr); $self -> {"messages"} -> set_module_obj($self -> {"modules"}); @@ -239,7 +241,7 @@ sub run { } # Has a block selector been specified? If not, make a default one - $self -> {"block_selector"} = BlockSelector -> new() + $self -> {"block_selector"} = Webperl::BlockSelector -> new() if(!defined($self -> {"block_selector"})); # Obtain the page moduleid, fall back on the default if this fails diff --git a/Webperl/Auth.pm b/Webperl/Auth.pm index 9164a4e..7057f53 100644 --- a/Webperl/Auth.pm +++ b/Webperl/Auth.pm @@ -26,15 +26,15 @@ # # This class requires an entry in the settings table with the name 'Auth:unique_id', # and settings as required by SessionHandler. -package Auth; +package Webperl::Auth; use strict; -use base qw(SystemModule); +use base qw(Webperl::SystemModule); use HTML::Entities; # Custom module imports -use AuthMethods; +use Webperl::AuthMethods; # ============================================================================ # Constructor @@ -92,12 +92,12 @@ sub init { return "logger object not set" unless($self -> {"logger"}); # Create the authmethods object to handle invocation of individual methods - $self -> {"methods"} = AuthMethods -> new(cgi => $self -> {"cgi"}, - dbh => $self -> {"dbh"}, - settings => $self -> {"settings"}, - app => $self -> {"app"}, - logger => $self -> {"logger"}) - or return "Unable to create AuthMethods object: ".$AuthMethods::errstr; + $self -> {"methods"} = Webperl::AuthMethods -> new(cgi => $self -> {"cgi"}, + dbh => $self -> {"dbh"}, + settings => $self -> {"settings"}, + app => $self -> {"app"}, + logger => $self -> {"logger"}) + or return "Unable to create Webperl::AuthMethods object: ".$Webperl::AuthMethods::errstr; $self -> {"ANONYMOUS"} = $self -> {"app"} -> anonymous_user(); $self -> {"ADMINTYPE"} = $self -> {"app"} -> adminuser_type(); diff --git a/Webperl/AuthMethod.pm b/Webperl/AuthMethod.pm index a30a2e2..c2c2dc4 100644 --- a/Webperl/AuthMethod.pm +++ b/Webperl/AuthMethod.pm @@ -21,7 +21,7 @@ # mainly present for documentation purposes - it doesn't actually provide # any meaningful implementation of an authentication method, and the # actually interesting stuff should happen in subclasses of it. -package AuthMethod; +package Webperl::AuthMethod; use strict; diff --git a/Webperl/AuthMethod/Database.pm b/Webperl/AuthMethod/Database.pm index 6637648..c92fcd8 100644 --- a/Webperl/AuthMethod/Database.pm +++ b/Webperl/AuthMethod/Database.pm @@ -35,10 +35,10 @@ # # * bcrypt_cost - the number of iterations of hashing to perform. This # defaults to COST_DEFAULT if not specified. -package AuthMethod::Database; +package Webperl::AuthMethod::Database; use strict; -use base qw(AuthMethod); # This class extends AuthMethod +use base qw(Webperl::AuthMethod); # This class extends AuthMethod use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64); use constant COST_DEFAULT => 14; # The default cost to use if bcrypt_cost is not set. @@ -67,9 +67,9 @@ sub new { $self -> {"bcrypt_cost"} = COST_DEFAULT; # check that required settings are set... - return "AuthMethod::Database missing 'table' argument in new()" if(!$self -> {"table"}); - return "AuthMethod::Database missing 'userfield' argument in new()" if(!$self -> {"userfield"}); - return "AuthMethod::Database missing 'passfield' argument in new()" if(!$self -> {"passfield"}); + return "Webperl::AuthMethod::Database missing 'table' argument in new()" if(!$self -> {"table"}); + return "Webperl::AuthMethod::Database missing 'userfield' argument in new()" if(!$self -> {"userfield"}); + return "Webperl::AuthMethod::Database missing 'passfield' argument in new()" if(!$self -> {"passfield"}); return $self; } diff --git a/Webperl/AuthMethod/LDAPS.pm b/Webperl/AuthMethod/LDAPS.pm index 930cb67..5d14380 100644 --- a/Webperl/AuthMethod/LDAPS.pm +++ b/Webperl/AuthMethod/LDAPS.pm @@ -36,10 +36,10 @@ # * adminpass - The password to use when logging in as the admin user. # * reuseconn - If set to a true value, the connection to the LDAPS is reused # for authentication after finding the user's dn. -package AuthMethod::LDAPS; +package Webperl::AuthMethod::LDAPS; use strict; -use base qw(AuthMethod); # This class extends AuthMethod +use base qw(Webperl::AuthMethod); # This class extends AuthMethod use Net::LDAPS; ## @cmethod $ new(%args) @@ -59,9 +59,9 @@ sub new { return $class -> SUPER::get_error() if(!$self); # check that required settings are set... - return "AuthMethod::LDAPS missing 'server' argument in new()" if(!$self -> {"server"}); - return "AuthMethod::LDAPS missing 'base' argument in new()" if(!$self -> {"base"}); - return "AuthMethod::LDAPS missing 'searchfield' argument in new()" if(!$self -> {"searchfield"}); + return "Webperl::AuthMethod::LDAPS missing 'server' argument in new()" if(!$self -> {"server"}); + return "Webperl::AuthMethod::LDAPS missing 'base' argument in new()" if(!$self -> {"base"}); + return "Webperl::AuthMethod::LDAPS missing 'searchfield' argument in new()" if(!$self -> {"searchfield"}); return $self; } diff --git a/Webperl/AuthMethod/SSH.pm b/Webperl/AuthMethod/SSH.pm index d8e738b..b818557 100644 --- a/Webperl/AuthMethod/SSH.pm +++ b/Webperl/AuthMethod/SSH.pm @@ -34,10 +34,10 @@ # specified (values less than 5 are only recommended on fast # networks and when talking to servers that respond rapidly). # * binary - the location of the ssh binary. Defaults to /usr/bin/ssh. -package AuthMethod::SSH; +package Webperl::AuthMethod::SSH; use strict; -use base qw(AuthMethod); # This class extends AuthMethod +use base qw(Webperl::AuthMethod); # This class extends AuthMethod use Net::SSH::Expect; # Custom module imports @@ -61,7 +61,7 @@ sub new { return $class -> SUPER::get_error() if(!$self); # check that required settings are set... - return "AuthMethod::SSH missing 'server' argument in new()" if(!$self -> {"server"}); + return "Webperl::AuthMethod::SSH missing 'server' argument in new()" if(!$self -> {"server"}); # Check whether the timeout and binary settings are, well, set... $self -> {"timeout"} = 5 unless(defined($self -> {"timeout"})); diff --git a/Webperl/AuthMethods.pm b/Webperl/AuthMethods.pm index da6e016..bbfce50 100644 --- a/Webperl/AuthMethods.pm +++ b/Webperl/AuthMethods.pm @@ -22,10 +22,10 @@ # on information stored in the auth_methods and auth_params tables to # load AuthMethod subclasses, initialise them, and pass them back to # the caller to use. -package AuthMethods; +package Webperl::AuthMethods; use strict; -use base qw(SystemModule); +use base qw(Webperl::SystemModule); use Module::Load; # ============================================================================ diff --git a/Webperl/Block.pm b/Webperl/Block.pm index 09c7611..4e3fffb 100644 --- a/Webperl/Block.pm +++ b/Webperl/Block.pm @@ -29,12 +29,12 @@ # which may be generated solely by the Block subclass, or by the subclass # loading other Blocks and using their inline block fragments to construct the # overall page content. -package Block; +package Webperl::Block; use strict; -use base qw(SystemModule); +use base qw(Webperl::SystemModule); -use HTMLValidator; -use Utils qw(is_defined_numeric); +use Webperl::HTMLValidator; +use Webperl::Utils qw(is_defined_numeric); use Encode; use HTML::Entities; diff --git a/Webperl/BlockSelector.pm b/Webperl/BlockSelector.pm index 89548da..f8a7492 100644 --- a/Webperl/BlockSelector.pm +++ b/Webperl/BlockSelector.pm @@ -26,10 +26,10 @@ # and valid, or falls back on a default block id otherwise. Other # applications may wish to extend this behaviour, or replace it entirely # by subclassing this class and overriding the get_block() method. -package BlockSelector; +package Webperl::BlockSelector; use strict; -use base qw(SystemModule); +use base qw(Webperl::SystemModule); # ============================================================================ diff --git a/Webperl/ConfigMicro.pm b/Webperl/ConfigMicro.pm index 9bf0202..80e1528 100644 --- a/Webperl/ConfigMicro.pm +++ b/Webperl/ConfigMicro.pm @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -## @class ConfigMicro +## @class # A simple configuration class intended to allow ini files to be read and saved. This # class reads the contents of an .ini style file, and stores the sections and # key/value pairs in the object's hash. A typical configuration file could look like @@ -59,10 +59,10 @@ # load_db_config() method in any ConfigMicro object allows a table containing key/value # pairs to be read into a configuration section. save_db_config() and set_db_config() # allow modifications made to configuration settings to be saved back into the table. -package ConfigMicro; +package Webperl::ConfigMicro; use strict; -use base qw(SystemModule); # Extend SystemModule to get error handling +use base qw(Webperl::SystemModule); # Extend SystemModule to get error handling use DBI; @@ -70,14 +70,14 @@ use DBI; # Constructor and basic file-based config functions ## @cmethod $ new(%args) -# Create a new ConfigMicro object. This creates an object that provides functions +# Create a new Webperl::ConfigMicro object. This creates an object that provides functions # for loading and saving configurations, and pulling config data from a database. # Meaningful options for this are: # filename - The name of the configuration file to read initial settings from. This # is optional, and if not specified you will get an empty object back. # You may also pass in one or more initial configuration settings. # @param args A hash of key, value pairs to initialise the object with. -# @return A new ConfigMicro object, or undef if a problem occured. +# @return A new Webperl::ConfigMicro object, or undef if a problem occured. sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; diff --git a/Webperl/HTMLValidator.pm b/Webperl/HTMLValidator.pm index 71b21f4..a5b4d54 100644 --- a/Webperl/HTMLValidator.pm +++ b/Webperl/HTMLValidator.pm @@ -19,7 +19,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -package HTMLValidator; +package Webperl::HTMLValidator; require Exporter; use Encode; diff --git a/Webperl/Logger.pm b/Webperl/Logger.pm index 76d8c07..18cafc0 100644 --- a/Webperl/Logger.pm +++ b/Webperl/Logger.pm @@ -22,7 +22,7 @@ # together the various functions needed for displaying log messages and errors # at various levels of verbosity, in an attempt to cut down on duplicate # parameter passing throughout the rest of the system. -package Logger; +package Webperl::Logger; use strict; require Exporter; diff --git a/Webperl/MediaWiki/Simple.pm b/Webperl/MediaWiki/Simple.pm index d1b1b7e..9b51384 100644 --- a/Webperl/MediaWiki/Simple.pm +++ b/Webperl/MediaWiki/Simple.pm @@ -27,13 +27,13 @@ # need the full features of MediaWiki::Bot, you can obtain a reference to a # MediaWiki::API object to issue API requests directly to by calling the wiki() # function. -package MediaWiki::Simple; +package Webperl::MediaWiki::Simple; use v5.12; -use base qw(SystemModule); +use base qw(Webperl::SystemModule); use Data::Dumper; use MediaWiki::API; -use Utils qw(path_join); +use Webperl::Utils qw(path_join); # ============================================================================ # Constructor diff --git a/Webperl/Message.pm b/Webperl/Message.pm index 7456fb6..b58b351 100644 --- a/Webperl/Message.pm +++ b/Webperl/Message.pm @@ -19,10 +19,10 @@ ## @class Message # This is the 'base' class for the Message modules. It provides any functionality # that needs to be shared between the Message::* modules. -package Message; +package Webperl::Message; use strict; -use base qw(SystemModule); -use Utils qw(hash_or_hashref); +use base qw(Webperl::SystemModule); +use Webperl::Utils qw(hash_or_hashref); # ============================================================================ # Constructor diff --git a/Webperl/Message/Queue.pm b/Webperl/Message/Queue.pm index 834a589..2e9d9c0 100644 --- a/Webperl/Message/Queue.pm +++ b/Webperl/Message/Queue.pm @@ -16,15 +16,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -## @class Message::Queue +## @class # This class allows messages to be added to the message queue, or retrieved from # it in a format suitable for passing to Message::Sender. # # -package Message::Queue; +package Webperl::Message::Queue; + use strict; -use base qw(Message); -use Utils qw(hash_or_hashref); +use base qw(Webperl::Message); +use Webperl::Utils qw(hash_or_hashref); # ============================================================================ # Constructor diff --git a/Webperl/Message/Transport.pm b/Webperl/Message/Transport.pm index 2b34d5f..8646d68 100644 --- a/Webperl/Message/Transport.pm +++ b/Webperl/Message/Transport.pm @@ -16,13 +16,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -## @class Message::Transport +## @class # This is the 'base' class for the Message::Transport modules. It provides # any functionality that needs to be shared between the Message::Transport::* # modules. -package Message::Transport; +package Webperl::Message::Transport; + use strict; -use base qw(Message); +use base qw(Webperl::Message); # ============================================================================ # Delivery diff --git a/Webperl/Message/Transport/Email.pm b/Webperl/Message/Transport/Email.pm index e6c2148..e427a41 100644 --- a/Webperl/Message/Transport/Email.pm +++ b/Webperl/Message/Transport/Email.pm @@ -16,12 +16,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -## @class Message::Transport::Email +## @class # This class implements the email transport system; lasciate ogne speranza, voi ch'intrate. # -package Message::Transport::Email; +package Webperl::Message::Transport::Email; + use strict; -use base qw(Message::Transport); +use base qw(Webperl::Message::Transport); use Encode; use Email::MIME; use Email::Sender::Simple qw(sendmail); diff --git a/Webperl/Message/Transport/Local.pm b/Webperl/Message/Transport/Local.pm index 7012feb..e9cd0e1 100644 --- a/Webperl/Message/Transport/Local.pm +++ b/Webperl/Message/Transport/Local.pm @@ -16,13 +16,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -## @class Message::Transport::Local +## @class # This class implements the local delivery transport. Local delivery actually involves # no work whatsoever - any messages that are queued for local deliver can always be # delivered. -package Message::Transport::Local; +package Webperl::Message::Transport::Local; + use strict; -use base qw(Message::Transport); +use base qw(Webperl::Message::Transport); # ============================================================================ # Delivery diff --git a/Webperl/Modules.pm b/Webperl/Modules.pm index 26567f1..48015db 100644 --- a/Webperl/Modules.pm +++ b/Webperl/Modules.pm @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -## @class Modules +## @class # A class to simplify runtime loading of modules. This class simplifies the # process of loading modules implementing system functionality at runtime: it # is primarily designed to load webapp block modules, but it can be used to @@ -53,11 +53,12 @@ # the contents of the Modules object's $self added to it, so that your loaded # modules will be given the standard value listed above in addition to any # values you specify in the argument hash. -package Modules; +package Webperl::Modules; + use strict; -use base qw(SystemModule); -use DBI; +use base qw(Webperl::SystemModule); use Module::Load; +use Webperl::Utils qw(path_join); # ============================================================================== # Creation @@ -112,6 +113,10 @@ sub add_load_path { my $self = shift; my $path = shift; + # If the load path is relative, assume it is relative to the script base path + $path = path_join($self -> {"settings"} -> {"config"} -> {"base"}, $path) + unless($path =~ m|^/|); + unshift(@INC, $path); } diff --git a/Webperl/SessionHandler.pm b/Webperl/SessionHandler.pm index 3c24b74..2979041 100644 --- a/Webperl/SessionHandler.pm +++ b/Webperl/SessionHandler.pm @@ -124,19 +124,15 @@ # KEY `session_id` (`session_id`), # KEY `sess_name_map` (`session_id`,`var_name`) # ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Session-related variables'; -package SessionHandler; +package Webperl::SessionHandler; -require 5.005; use strict; # Standard module imports -use DBI; use Digest::MD5 qw(md5_hex); use Compress::Bzip2; use MIME::Base64; -use Data::Dumper; - # Globals... our $errstr; diff --git a/Webperl/System.pm b/Webperl/System.pm index ce0ebc3..5e87d6f 100644 --- a/Webperl/System.pm +++ b/Webperl/System.pm @@ -21,10 +21,10 @@ # The base class for appplication-specific module loading. Subclasses of # this class allow applications to load and initialise any system-specific # modules. -package System; +package Webperl::System; use strict; -use base qw(SystemModule); +use base qw(Webperl::SystemModule); # ============================================================================ # Constructor and initialiser diff --git a/Webperl/SystemModule.pm b/Webperl/SystemModule.pm index bc55eb4..5a146bd 100644 --- a/Webperl/SystemModule.pm +++ b/Webperl/SystemModule.pm @@ -22,7 +22,7 @@ # Subclasses will generally only need to override the constructor, usually # chaining it with `$class -> SUPER::new(..., @_);`. If attempting to call # set_error() in a subclass, remember to use SystemModule::set_error(). -package SystemModule; +package Webperl::SystemModule; use strict; diff --git a/Webperl/Template.pm b/Webperl/Template.pm index e317b30..d2e8aee 100644 --- a/Webperl/Template.pm +++ b/Webperl/Template.pm @@ -114,10 +114,10 @@ # - `{V_[commonpath]}` is replaced by the path from the base of the web # application to the common template directory (useful for image and other resource # paths inside the common template). This will always have a trailing '/'. -package Template; +package Webperl::Template; use POSIX qw(strftime); -use Utils qw(path_join superchomp); +use Webperl::Utils qw(path_join superchomp); use strict; our ($errstr, $utfentities, $entities, $ords, @timescales); diff --git a/Webperl/Utils.pm b/Webperl/Utils.pm index 51995b4..9544ecd 100644 --- a/Webperl/Utils.pm +++ b/Webperl/Utils.pm @@ -22,7 +22,7 @@ # System-wide utility functions. The functions in this file may be useful at # any point throughout the system, so they are collected here to prevent the # need for multiple copies around various modules. -package Utils; +package Webperl::Utils; require Exporter; use File::Spec; use File::Path; diff --git a/Webperl/phpBB3.pm b/Webperl/phpBB3.pm index 21f83c6..a504154 100644 --- a/Webperl/phpBB3.pm +++ b/Webperl/phpBB3.pm @@ -28,7 +28,7 @@ # into a phpBB3 account. # # -package phpBB3; +package Webperl::phpBB3; use strict; @@ -39,7 +39,7 @@ use Time::HiRes qw(gettimeofday); use WWW::Mechanize; # Needed to register via phpBB's registration form # Custom module imports -use Utils qw(path_join); +use Webperl::Utils qw(path_join); # Globals... our ($ANONYMOUS, $errstr, %fmt_map);