FastCGI portal

environments/ppa-mbqj77/deployments/1
Xavier Guimard 12 years ago
parent 1fc09658d8
commit e174ff4732
  1. 30
      lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm
  2. 1
      lemonldap-ng-portal/MANIFEST
  3. 66
      lemonldap-ng-portal/example/index.fcgi
  4. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm

@ -18,8 +18,8 @@ use Net::CIDR::Lite;
#parameter syslog Indicates syslog facility for logging user actions
our $VERSION = '1.2.3';
use base qw(CGI);
our $_SUPER;
our @ISA;
BEGIN {
if ( exists $ENV{MOD_PERL} ) {
@ -33,6 +33,18 @@ BEGIN {
else {
eval 'use constant MP => 0;';
}
$_SUPER = 'CGI';
@ISA = ('CGI');
}
sub import {
my $pkg = shift;
if ( $pkg eq __PACKAGE__ and @_ and $_[0] eq "fast" ) {
eval 'use CGI::Fast';
die($@) if ($@);
unshift @ISA, 'CGI::Fast';
$_SUPER = 'CGI::Fast';
}
}
## @cmethod Lemonldap::NG::Common::CGI new(@p)
@ -42,7 +54,7 @@ BEGIN {
# @return new Lemonldap::NG::Common::CGI object
sub new {
my $class = shift;
my $self = CGI->new(@_);
my $self = $_SUPER->new(@_) or return undef;
$self->{_prm} = {};
my @tmp = $self->param();
foreach (@tmp) {
@ -209,7 +221,7 @@ sub header_public {
$ref = timegm( $6, $5, $4, $1, $m, $3 );
if ( $ref == $date ) {
print $self->SUPER::header( -status => '304 Not Modified', @_ );
exit;
$self->quit();
}
}
}
@ -260,7 +272,7 @@ a {
print
'<center><a href="http://lemonldap-ng.org">LemonLDAP::NG</a></center>';
print STDERR ( ref($self) || $self ) . " error: $t1, $t2\n";
exit;
$self->quit();
}
##@method private void startSyslog()
@ -404,7 +416,13 @@ sub session_template {
## @method private void quit()
# Simply exit.
sub quit {
exit;
my $self = shift;
if ( $_SUPER eq 'CGI::Fast' ) {
next LMAUTH;
}
else {
exit;
}
}
##@method string ipAddr()

@ -1,6 +1,7 @@
Changes
example/cas.pl
example/cdc.pl
example/index.fcgi
example/index.pl
example/index_simple.pl
example/index_skin.pl

@ -0,0 +1,66 @@
#!/usr/bin/perl
use Lemonldap::NG::Common::CGI qw(fast);
use Lemonldap::NG::Portal::SharedConf;
use HTML::Template;
use strict;
LMAUTH:
while (
my $portal = Lemonldap::NG::Portal::SharedConf->new(
{
# ACCESS TO CONFIGURATION
# By default, Lemonldap::NG uses the default lemonldap-ng.ini file to
# know where to find its configuration
# (generaly /etc/lemonldap-ng/lemonldap-ng.ini)
# You can specify by yourself this file :
#configStorage => { confFile => '/path/to/my/file' },
# or set explicitely parameters :
#configStorage => {
# type => 'File',
# dirName => '/usr/local/lemonldap-ng/data//conf'
#},
# Note that YOU HAVE TO SET configStorage here if you've declared this
# portal as SOAP configuration server in the manager
# OTHERS
# You can also overload any parameter issued from manager
# configuration. Example:
#globalStorage => 'Apache::Session::File',
#globalStorageOptions => {
# 'Directory' => '/var/lib/lemonldap-ng/sessions/',
# 'LockDirectory' => '/var/lib/lemonldap-ng/sessions/lock/',
#},
# Note that YOU HAVE TO SET globalStorage here if you've declared this
# portal as SOAP session server in the manager
}
)
)
{
# Get skin and template parameters
my ( $templateName, %templateParams ) = $portal->display();
# HTML template creation
my $template = HTML::Template->new(
filename => "$templateName",
die_on_bad_params => 0,
cache => 0,
global_vars => 1,
loop_context_vars => 1,
filter => [
sub { $portal->translate_template(@_) },
sub { $portal->session_template(@_) }
],
);
# Give parameters to the template
while ( my ( $k, $v ) = each %templateParams ) {
$template->param( $k, $v );
}
# Display it
print $portal->header('text/html; charset=utf-8');
print $template->output;
}

@ -233,7 +233,7 @@ sub new {
binmode( STDOUT, ":utf8" );
my $class = shift;
return $class if ( ref($class) );
my $self = $class->SUPER::new();
my $self = $class->SUPER::new() or return undef;
# Reinit _url
$self->{_url} = '';

Loading…
Cancel
Save