1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#!/usr/bin/perl
use Lemonldap::NG::Portal::MailReset;
use HTML::Template;
use strict;
# Load portal module
my $portal = Lemonldap::NG::Portal::MailReset->new();
my $skin_dir = $portal->getApacheHtdocsPath() . "/skins";
my $portal_url = $portal->{portal};
my $portalPath = $portal->{portal};
$portalPath =~ s#^https?://[^/]+/?#/#;
$portalPath =~ s#[^/]+\.pl$##;
# Process
$portal->process();
my $skin = $portal->getSkin();
# Template creation
my $template = HTML::Template->new(
filename => "$skin_dir/$skin/mail.tpl",
die_on_bad_params => 0,
cache => 0,
filter => [
sub { $portal->translate_template(@_) },
sub { $portal->session_template(@_) }
],
);
$template->param(
PORTAL_URL => $portal_url,
SKIN_PATH => $portalPath . "skins",
SKIN => $skin,
AUTH_ERROR => $portal->error,
AUTH_ERROR_TYPE => $portal->error_type,
CHOICE_PARAM => $portal->{authChoiceParam},
CHOICE_VALUE => $portal->{_authChoice},
EXPMAILDATE => $portal->{expMailDate},
EXPMAILTIME => $portal->{expMailTime},
STARTMAILDATE => $portal->{startMailDate},
STARTMAILTIME => $portal->{startMailTime},
MAILALREADYSENT => $portal->{mail_already_sent},
MAIL => $portal->checkXSSAttack( 'mail', $portal->{mail} ) ? ""
: $portal->{mail},
MAIL_TOKEN => $portal->checkXSSAttack( 'mail_token', $portal->{mail_token} )
? ""
: $portal->{mail_token},
);
# Display form the first time
if (
(
$portal->{error} == PE_MAILFORMEMPTY
or $portal->{error} == PE_MAILFIRSTACCESS
or $portal->{error} == PE_MAILNOTFOUND
or $portal->{error} == PE_CAPTCHAERROR
or $portal->{error} == PE_CAPTCHAEMPTY
)
and !$portal->{mail_token}
)
{
$template->param(
DISPLAY_FORM => 1,
DISPLAY_RESEND_FORM => 0,
DISPLAY_CONFIRMMAILSENT => 0,
DISPLAY_MAILSENT => 0,
DISPLAY_PASSWORD_FORM => 0,
);
}
# Display captcha if it's enabled
if ( $portal->{captcha_mail_enabled} ) {
$template->param(
CAPTCHA_IMG => $portal->{captcha_img},
CAPTCHA_CODE => $portal->{captcha_code},
CAPTCHA_SIZE => $portal->{captcha_size}
);
}
# Display mail confirmation resent form
if ( $portal->{error} == PE_MAILCONFIRMATION_ALREADY_SENT ) {
$template->param(
DISPLAY_FORM => 0,
DISPLAY_RESEND_FORM => 1,
DISPLAY_CONFIRMMAILSENT => 0,
DISPLAY_MAILSENT => 0,
DISPLAY_PASSWORD_FORM => 0,
);
}
# Display confirmation mail sent
if ( $portal->{error} == PE_MAILCONFIRMOK ) {
$template->param(
DISPLAY_FORM => 0,
DISPLAY_RESEND_FORM => 0,
DISPLAY_CONFIRMMAILSENT => 1,
DISPLAY_MAILSENT => 0,
DISPLAY_PASSWORD_FORM => 0,
);
}
# Display mail sent
if ( $portal->{error} == PE_MAILOK ) {
$template->param(
DISPLAY_FORM => 0,
DISPLAY_RESEND_FORM => 0,
DISPLAY_CONFIRMMAILSENT => 0,
DISPLAY_MAILSENT => 1,
DISPLAY_PASSWORD_FORM => 0,
);
}
# Display password change form
if ( $portal->{mail_token}
and $portal->{error} != PE_MAILERROR
and $portal->{error} != PE_BADMAILTOKEN
and $portal->{error} != PE_MAILOK )
{
$template->param(
DISPLAY_FORM => 0,
DISPLAY_RESEND_FORM => 0,
DISPLAY_CONFIRMMAILSENT => 0,
DISPLAY_MAILSENT => 0,
DISPLAY_PASSWORD_FORM => 1,
);
}
# Custom template parameters
if ( my $customParams = $portal->getCustomTemplateParameters() ) {
foreach ( keys %$customParams ) {
$template->param( $_, $customParams->{$_} );
}
}
print $portal->header('text/html; charset=utf-8');
print $template->output;
|