Apache-Voodoo
view release on metacpan or search on metacpan
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
my $status = shift;
if (defined($debug)) {
$debug->status($status);
$debug->session($self->{'session'});
}
if (defined($self->_app) && defined($self->{'session_handler'})) {
if ($self->{'p'}->{'uri'} =~ /\/?logout(_[^\/]+)?$/) {
$self->{'mp'}->set_cookie($self->_app->config->{'cookie_name'},'!','now');
$self->{'session_handler'}->destroy();
}
else {
$self->{'session_handler'}->disconnect();
}
$debug->mark(Time::HiRes::time,'Session detachment');
}
}
sub finish {
my $self = shift;
$debug->mark(Time::HiRes::time,'Cleaning up.');
delete $self->{'app_id'};
delete $self->{'session_handler'};
delete $self->{'session'};
delete $self->{'p'};
delete $self->{'dbh'};
if (defined($debug)) {
$debug->mark(Time::HiRes::time,'END');
$debug->shutdown();
}
}
sub attach_session {
my $self = shift;
my $conf = $self->_app->config;
my $session_id = $self->{'mp'}->get_cookie($conf->{'cookie_name'});
my $session = $self->_app->{'session_handler'}->attach($session_id,$self->{'dbh'});
if (!defined($session_id) || $session->id() ne $session_id) {
# This is a new session, or there was an old cookie from a previous sesion,
$self->{'mp'}->set_cookie($conf->{'cookie_name'},$session->id());
}
elsif ($session->has_expired($conf->{'session_timeout'})) {
# the session has expired
$self->{'mp'}->set_cookie($conf->{'cookie_name'},'!','now');
$session->destroy;
Apache::Voodoo::Exception::Application::SessionTimeout->throw(
target => $self->_adjust_url("/timeout"),
error => "Session has expired"
);
}
# update the session timer
$session->touch();
return $session;
}
sub history_capture {
my $self = shift;
my $uri = shift;
my $params = shift;
my $session = $self->{'session'};
$uri = "/".$uri if $uri !~ /^\//;
# don't put the login page in the referrer queue
return if $uri eq "/login";
if (!defined($session->{'history'}) ||
$session->{'history'}->[0]->{'uri'} ne $uri) {
# queue is empty or this is a new page
unshift(@{$session->{'history'}}, {'uri' => $uri, 'params' => join("&",map { $_."=".$params->{$_} } keys %{$params})});
}
else {
# re-entrant call to page, update the params
$session->{'history'}->[0]->{'params'} = join("&",map { $_."=".$params->{$_} } keys %{$params});
}
if (scalar(@{$session->{'history'}}) > 30) {
# keep the queue at 10 items
pop @{$session->{'history'}};
}
$debug->mark(Time::HiRes::time,"history capture");
}
sub get_model {
my $self = shift;
my $app_id = shift;
my $model = shift;
unless ($self->valid_app($app_id)) {
Apache::Voodoo::Exception::Application->throw(
"Application id '$app_id' unknown. Valid ids are: ".join(",",$self->get_apps())
);
}
return $self->{'apps'}->{$app_id}->{'models'}->{$model};
}
sub execute_controllers {
my $self = shift;
my $uri = shift;
my $params = shift;
$uri =~ s/^\///;
$debug->url($uri);
my $app = $self->_app;
( run in 0.713 second using v1.01-cache-2.11-cpan-39bf76dae61 )