fixes #275 - use SCRIPT_FILENAME instead of DOCUMENT_ROOT to get htdocs portal path

This commit is contained in:
Thomas CHEMINEAU 2011-02-04 12:50:24 +00:00
parent 1fd6b1c29f
commit ddb84e6ef2
10 changed files with 28 additions and 8 deletions

View File

@ -27,7 +27,7 @@ my $manager = new Lemonldap::NG::Manager(
our $skin = $manager->{managerSkin};
our $skin_dir = 'skins';
our $main_dir = $ENV{DOCUMENT_ROOT};
our $main_dir = $manager->{managerHtdocsPath};
my $template = HTML::Template->new(
filename => "$main_dir/$skin_dir/$skin/manager.tpl",

View File

@ -31,7 +31,7 @@ my $skin = $cgi->{managerSkin} or $cgi->abort('managerSkin is not defined');
my $css = 'tree.css';
my $css_theme = 'ui-lightness';
my $skin_dir = 'skins';
my $main_dir = $ENV{DOCUMENT_ROOT};
my $main_dir = $cgi->{managerHtdocsPath};
my $template = HTML::Template->new(
filename => "$main_dir/$skin_dir/$skin/sessions.tpl",

View File

@ -6,6 +6,7 @@
package Lemonldap::NG::Manager;
use strict;
use File::Basename;
use Lemonldap::NG::Handler::CGI qw(:globalStorage :locationRules); #inherits
use Lemonldap::NG::Common::Conf; #link protected conf Configuration
use Lemonldap::NG::Common::Conf::Constants; #inherits
@ -52,6 +53,10 @@ sub new {
$self->{managerTreeJqueryCss} = "true"
unless defined $self->{managerTreeJqueryCss};
# Absolute path to the htdocs directory where is manager script.
my ( $mname, $mpath, $msuffix ) = fileparse( $ENV{SCRIPT_FILENAME} );
$self->{managerHtdocsPath} = $mpath;
# Save conf if ?data=
if ( my $rdata = $self->rparam('data') ) {

View File

@ -12,6 +12,7 @@
package Lemonldap::NG::Manager::Sessions;
use strict;
use File::Basename;
use Lemonldap::NG::Handler::CGI qw(:globalStorage :locationRules);
use Lemonldap::NG::Common::Apache::Session; #inherits
use Lemonldap::NG::Common::Conf; #link protected conf Configuration
@ -81,6 +82,10 @@ sub new {
# Multi values separator
$self->{multiValuesSeparator} ||= '; ';
# Absolute path to the htdocs directory where is manager script.
my ( $mname, $mpath, $msuffix ) = fileparse( $ENV{SCRIPT_FILENAME} );
$self->{managerHtdocsPath} = $mpath;
# Now we're ready to display sessions. Choose display type
foreach my $k ( $self->param() ) {

View File

@ -8,7 +8,7 @@ use strict;
my $portal = Lemonldap::NG::Portal::MailReset->new();
my $skin = $portal->{portalSkin};
my $skin_dir = $ENV{DOCUMENT_ROOT} . "/skins";
my $skin_dir = $portal->getApacheHtdocsPath() . "/skins";
my $portal_url = $portal->{portal};
# Process

View File

@ -35,7 +35,7 @@ my $portal = Lemonldap::NG::Portal::SharedConf->new(
);
my $skin = 'common';
my $skin_dir = $ENV{DOCUMENT_ROOT} . '/skins';
my $skin_dir = $portal->getApacheHtdocsPath() . '/skins';
my $skin_file = 'saml2-metadata.tpl';
my $metadata = Lemonldap::NG::Common::Conf::SAML::Metadata->new();
print $portal->header('text/xml; charset=utf-8');

View File

@ -18,7 +18,7 @@ sub display {
my $self = shift;
my $skin = $self->{portalSkin};
my $skin_dir = $ENV{DOCUMENT_ROOT} . "/skins";
my $skin_dir = $self->getApacheHtdocsPath() . "/skins";
my ( $skinfile, %templateParams );
my $http_error = $self->param('lmError');

View File

@ -168,7 +168,7 @@ sub sendConfirmationMail {
# Use HTML template
my $template = HTML::Template->new(
filename => $ENV{DOCUMENT_ROOT} . "skins/common/mail_confirm.tpl",
filename => $self->getApacheHtdocsPath() . "skins/common/mail_confirm.tpl",
filter => sub { $self->translate_template(@_) }
);
$body = $template->output();
@ -205,7 +205,7 @@ sub sendPasswordMail {
# Use HTML template
my $template = HTML::Template->new(
filename => $ENV{DOCUMENT_ROOT} . "skins/common/mail_password.tpl",
filename => $self->getApacheHtdocsPath() . "skins/common/mail_password.tpl",
filter => sub { $self->translate_template(@_) }
);
$body = $template->output();

View File

@ -11,6 +11,7 @@ use warnings;
use Exporter 'import';
use warnings;
use File::Basename;
use MIME::Base64;
use Lemonldap::NG::Common::CGI;
use CGI::Cookie;
@ -813,6 +814,15 @@ sub getApacheSession {
return \%h;
}
##@method string getApacheHtdocsPath()
# Return the absolute path to the htdocs directory where is portal script.
# @return path string
sub getApacheHtdocsPath {
my $self = shift;
my ( $name, $path, $suffix ) = fileparse( $ENV{SCRIPT_FILENAME} );
return $path;
}
## @method protected string _md5hash(string s)
# Return md5(s)
# @param $s String to hash

View File

@ -154,7 +154,7 @@ sub loadService {
# Create Lasso server with service metadata
my $server = $self->createServer(
$service_metadata->serviceToXML(
$ENV{DOCUMENT_ROOT} . "/skins/common/saml2-metadata.tpl", $self
$self->getApacheHtdocsPath() . "/skins/common/saml2-metadata.tpl", $self
),
$privateKeySig,
$privateKeySigPwd,