mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Added error control and email handler
This commit is contained in:
parent
bd30625532
commit
48f7fa50dd
@ -267,6 +267,7 @@ echo '<div id="ver_num">'.$pandora_version.(($develop_bypass == 1) ? ' '.__('Bui
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
if ($mail != "") {
|
if ($mail != "") {
|
||||||
|
if ($email_error_message == '') {
|
||||||
echo '<div id="reset_correct" title="' . __('Password reset') . '">';
|
echo '<div id="reset_correct" title="' . __('Password reset') . '">';
|
||||||
echo '<div class="content_alert">';
|
echo '<div class="content_alert">';
|
||||||
echo '<div class="icon_message_alert">';
|
echo '<div class="icon_message_alert">';
|
||||||
@ -284,6 +285,25 @@ if ($mail != "") {
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
echo '<div id="reset_correct" title="' . __('Password reset') . '">';
|
||||||
|
echo '<div class="content_alert">';
|
||||||
|
echo '<div class="icon_message_alert">';
|
||||||
|
echo html_print_image('images/icono_stop.png', true, array("alt" => __('Password reset'), "border" => 0));
|
||||||
|
echo '</div>';
|
||||||
|
echo '<div class="content_message_alert">';
|
||||||
|
echo '<div class="text_message_alert">';
|
||||||
|
echo '<h1>' . __('ERROR') . '</h1>';
|
||||||
|
echo '<p>' . $email_error_message . '</p>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '<div class="button_message_alert">';
|
||||||
|
html_print_submit_button("Ok", 'reset_correct_button', false);
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset ($login_failed)) {
|
if (isset ($login_failed)) {
|
||||||
echo '<div id="login_failed" title="' . __('Login failed') . '">';
|
echo '<div id="login_failed" title="' . __('Login failed') . '">';
|
||||||
|
20
pandora_console/include/email_config_user.php
Normal file
20
pandora_console/include/email_config_user.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
// ______ __ _______ _______ _______
|
||||||
|
//| __ \.---.-.-----.--| |.-----.----.---.-. | ___| | | __|
|
||||||
|
//| __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
//|___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
// Copyright (c) 2007-2010 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||||
|
// This code is NOT free software. This code is NOT licenced under GPL2 licence
|
||||||
|
// You cannnot redistribute it without written permission of copyright holder.
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
//Please setup your config to send emails
|
||||||
|
|
||||||
|
$email_from = array('pandora@pandorafms.org' => 'Pandora FMS');
|
||||||
|
$email_smtpServer = '127.0.0.1';
|
||||||
|
$email_smtpPort = 25;
|
||||||
|
$email_username = '';
|
||||||
|
$email_password = '';
|
||||||
|
?>
|
@ -2730,4 +2730,38 @@ function remove_right_zeros ($value) {
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function send_email_to_user ($to, $body, $subject) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
require_once($config['homedir'] . '/include/swiftmailer/swift_required.php');
|
||||||
|
require_once($config['homedir'] . '/include/email_config_user.php');
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
try {
|
||||||
|
$transport = Swift_SmtpTransport::newInstance($email_smtpServer, $email_smtpPort);
|
||||||
|
$transport->setUsername($email_username);
|
||||||
|
$transport->setPassword($email_password);
|
||||||
|
|
||||||
|
$mailer = Swift_Mailer::newInstance($transport);
|
||||||
|
|
||||||
|
$message = Swift_Message::newInstance($subject);
|
||||||
|
$message->setFrom($email_from);
|
||||||
|
$to = trim($to);
|
||||||
|
$message->setTo(array($to => $to));
|
||||||
|
$message->setBody($body, 'text/html');
|
||||||
|
|
||||||
|
ini_restore ('sendmail_from');
|
||||||
|
html_debug("AAAA", true);
|
||||||
|
$result = $mailer->send($message);
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
error_log($e->getMessage());
|
||||||
|
db_pandora_audit("Pandora mail", $e->getMessage());
|
||||||
|
html_debug($e->getMessage(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -592,7 +592,24 @@ if (! isset ($config['id_user'])) {
|
|||||||
require_once ('general/reset_pass.php');
|
require_once ('general/reset_pass.php');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// MANDAR CORREO ELECTRÓNICO AL USUARIO Y VOLVER A LA PÁGINA DE INICIO
|
$subject = '[Pandora] '.__('Reset password');
|
||||||
|
$body = __('This is the automatic message');
|
||||||
|
$body .= ' "<strong>' . $user_reset_pass . '"</strong>';
|
||||||
|
$body .= '<p />';
|
||||||
|
$body .= __('Please, click in the link below to reset your password');
|
||||||
|
$body .= '<p />';
|
||||||
|
$body .= '<a href="">' . __('Reset your password') . '</a>';
|
||||||
|
$body .= '<p />';
|
||||||
|
$body .= 'Pandora FMS';
|
||||||
|
$body .= '<p />';
|
||||||
|
$body .= '<em>'.__('Please do not answer or reply to this email').'</em>';
|
||||||
|
|
||||||
|
$result = send_email_to_user($mail, $body, $subject);
|
||||||
|
|
||||||
|
$email_error_message = "";
|
||||||
|
if (!$result) {
|
||||||
|
$email_error_message = __('Error at sending the email');
|
||||||
|
}
|
||||||
|
|
||||||
require_once ('general/login_page.php');
|
require_once ('general/login_page.php');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user