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