diff --git a/core/class/helper.class.php b/core/class/helper.class.php index d6f1e149..d7706a6e 100755 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -445,4 +445,27 @@ class helper { return $text; } + /** + * Cryptation + * @param string $key la clé d'encryptage + * @param string $payload la chaine à coder + * @return string + */ + public static function encrypt($key, $payload) { + $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')); + $encrypted = openssl_encrypt($payload, 'aes-256-cbc', $key, 0, $iv); + return base64_encode($encrypted . '::' . $iv); + } + + /** + * Décryptation + * @param string $key la clé d'encryptage + * @param string $garble la chaine à décoder + * @return string + */ + public static function decrypt($key, $garble) { + list($encrypted_data, $iv) = explode('::', base64_decode($garble), 2); + return openssl_decrypt($encrypted_data, 'aes-256-cbc', $key, 0, $iv); + } + } \ No newline at end of file diff --git a/core/core.php b/core/core.php index d34d6706..4a1bc75c 100755 --- a/core/core.php +++ b/core/core.php @@ -852,34 +852,39 @@ class common { ob_start(); include 'core/layout/mail.php'; $layout = ob_get_clean(); - $mail = new PHPMailer\PHPMailer\PHPMailer; + $mail = new PHPMailer\PHPMailer\PHPMailer; + $mail->CharSet = 'UTF-8'; // Mail try{ // Paramètres SMTP if ($this->getdata(['config','smtp','enable'])) { - // $mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; + //$mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->SMTPAutoTLS = false; $mail->Host = $this->getdata(['config','smtp','host']); $mail->Port = (int) $this->getdata(['config','smtp','port']); if ($this->getData(['config','smtp','auth'])) { $mail->Username = $this->getData(['config','smtp','username']); - $mail->Password = $this->getData(['config','smtp','password']); + $mail->Password = helper::decrypt($this->getData(['config','smtp','username']),$this->getData(['config','smtp','password'])); $mail->SMTPAuth = $this->getData(['config','smtp','auth']); $mail->SMTPSecure = $this->getData(['config','smtp','secure']); - $mail->setFrom($this->getData(['config','smtp','sender'])); + $mail->setFrom($this->getData(['config','smtp','username'])); + if (is_null($replyTo)) { + $mail->addReplyTo($this->getData(['config','smtp','username'])); + } else { + $mail->addReplyTo($replyTo); + } } // Fin SMTP } else { $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); - $mail->setFrom('no-reply@' . $host, $this->getData(['config', 'title'])); + $mail->setFrom('no-reply@' . $host, $this->getData(['config', 'title'])); if (is_null($replyTo)) { $mail->addReplyTo('no-reply@' . $host, $this->getData(['config', 'title'])); } else { $mail->addReplyTo($replyTo); - } + } } - $mail->CharSet = 'UTF-8'; if(is_array($to)) { foreach($to as $userMail) { $mail->addAddress($userMail); diff --git a/core/module/config/config.php b/core/module/config/config.php index c36fb81c..5b9a4f6f 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -438,12 +438,12 @@ class config extends common { 'auth' => $this->getInput('configSmtpAuth',helper::FILTER_BOOLEAN), 'secure' => $this->getInput('configSmtpSecure'), 'username' => $this->getInput('configSmtpUsername',helper::FILTER_STRING_SHORT), - 'password' => $this->getInput('configSmtpPassword'), + 'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('configSmtpPassword')), 'sender' => $this->getInput('configSmtpSender',helper::FILTER_MAIL) ] ] ]); - + if(self::$inputNotices === []) { // Ecrire les fichiers de script file_put_contents(self::DATA_DIR . 'head.inc.html',$this->getInput('configScriptHead',null)); diff --git a/core/module/config/view/index/index.js.php b/core/module/config/view/index/index.js.php index f0faf8c7..5163cd57 100755 --- a/core/module/config/view/index/index.js.php +++ b/core/module/config/view/index/index.js.php @@ -10,16 +10,54 @@ * @link http://zwiicms.com/ */ -/** - * Modification de l'affichage de l'icône de langues - */ +$( document).ready(function() { + /** + * Afficher et masquer options SMTP + */ + if ($("input[name=configSmtpEnable]").is(':checked')) { + $("#configSmtpParam").addClass("disabled"); + $("#configSmtpParam").slideDown(); + } else { + $("#configSmtpParam").removeClass("disabled"); + $("#configSmtpParam").slideUp(); + } + /** + * Afficher et masquer options Auth + */ + + if ($("select[name=configSmtpAuth]").val() == true) { + $("#configSmtpAuthParam").addClass("disabled"); + $("#configSmtpAuthParam").slideDown(); + } else { + $("#configSmtpAuthParam").removeClass("disabled"); + $("#configSmtpAuthParam").slideUp(); + } +}); + +/** + * Afficher et masquer options SMTP + */ $("input[name=configSmtpEnable]").on("change", function() { if ($("input[name=configSmtpEnable]").is(':checked')) { - $(".configSmtpParam").addClass("disabled"); - $(".configSmtpParam").slideDown(); + $("#configSmtpParam").addClass("disabled"); + $("#configSmtpParam").slideDown(); } else { - $(".configSmtpParam").removeClass("disabled"); - $(".configSmtpParam").slideUp(); + $("#configSmtpParam").removeClass("disabled"); + $("#configSmtpParam").slideUp(); } -}); \ No newline at end of file +}); + +/** + * Afficher et masquer options Auth + */ + +$("select[name=configSmtpAuth]").on("change", function() { + if ($("select[name=configSmtpAuth]").val() == true) { + $("#configSmtpAuthParam").addClass("disabled"); + $("#configSmtpAuthParam").slideDown(); + } else { + $("#configSmtpAuthParam").removeClass("disabled"); + $("#configSmtpAuthParam").slideUp(); + } +}); diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index 4642b2be..4f8b07c2 100755 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -335,21 +335,15 @@ ]); ?> -
+
-
+
'Adresse SMTP', 'placeholder' => 'smtp.fr', 'value' => $this->getData(['config', 'smtp','host']) ]); ?> -
-
- 'Mail expéditeur', - 'value' => $this->getData(['config', 'smtp','sender']) - ]); ?> -
+
'Port SMTP', @@ -357,34 +351,36 @@ 'value' => $this->getData(['config', 'smtp','port']) ]); ?>
-
-
'Authentification', 'selected' => $this->getData(['config', 'smtp','auth']) ]); ?> -
-
- 'Nom utilisateur', - 'value' => $this->getData(['config', 'smtp','username' ]) - ]); ?> -
-
- 'Mot de passe', - 'autocomplete' => 'off', - 'value' => $this->getData(['config', 'smtp','password' ]) - ]); ?> -
-
- 'Sécurité', - 'selected' => $this->getData(['config', 'smtp','secure']) - ]); ?> -
-
+
+
+
+
+
+ 'Nom utilisateur', + 'value' => $this->getData(['config', 'smtp','username' ]) + ]); ?> +
+
+ 'Mot de passe', + 'autocomplete' => 'off', + 'value' => $this->getData(['config','smtp','password']) + ]); ?> +
+
+ 'Sécurité', + 'selected' => $this->getData(['config', 'smtp','secure']) + ]); ?> +
+
+