Please note sending emails is disabled in Demo mode. The last email which would have been sent was:
+---------- Header ----------Please note sending emails is disabled in Demo mode. The last email which would have been sent was:
' . $_SESSION['LAST_EMAIL']; - $_SESSION['LAST_EMAIL'] = ''; - } - } - */ } return $retval; @@ -4974,8 +4998,8 @@ function COM_showMessageText($message, $title = '') * Display one of the predefined messages from the $MESSAGE array. If a plugin * name is provided, display that plugin's message instead. * - * @param int $msg ID of message to show - * @param string $plugin Optional name of plugin to lookup plugin defined message + * @param int|string $msg ID of message to show or a string message WHICH MUST BE SAFE AS HTML TEXT + * @param string $plugin Optional name of plugin to lookup plugin defined message * @return string HTML block with message * @see COM_showMessageFromParameter * @see COM_showMessageText @@ -4986,30 +5010,36 @@ function COM_showMessage($msg, $plugin = '') $retval = ''; - $msg = (int) $msg; - if ($msg > 0) { - if (!empty($plugin)) { - $var = 'PLG_' . $plugin . '_MESSAGE' . $msg; - global $$var; - if (isset($$var)) { - $message = $$var; + if (is_int($msg)) { + $msg = (int) $msg; + + if ($msg > 0) { + if (!empty($plugin)) { + $var = 'PLG_' . $plugin . '_MESSAGE' . $msg; + global $$var; + if (isset($$var)) { + $message = $$var; + } else { + $message = sprintf($MESSAGE[61], $plugin); + COM_errorLog($message . ": " . $var, 1); + } } else { - $message = sprintf($MESSAGE[61], $plugin); - COM_errorLog($message . ": " . $var, 1); - } - } else { - $message = $MESSAGE[$msg]; + $message = $MESSAGE[$msg]; - // Ugly workaround for mailstory function (public_html/profiles.php) - if ($msg === 153) { - $speedLimit = (int) Input::fGet('speedlimit', 0); - $message = sprintf($message, $speedLimit, $_CONF['speedlimit']); + // Ugly workaround for mailstory function (public_html/profiles.php) + if ($msg === 153) { + $speedLimit = (int) Input::fGet('speedlimit', 0); + $message = sprintf($message, $speedLimit, $_CONF['speedlimit']); + } } - } - if (!empty($message)) { - $retval .= COM_showMessageText($message); + if (!empty($message)) { + $retval .= COM_showMessageText($message); + } } + } elseif (is_string($msg) && !empty($msg)) { + // $msg MUST BE SAFE AS HTML TEXT! + $retval .= COM_showMessageText($msg); } return $retval; diff --git a/system/classes/Mail.php b/system/classes/Mail.php index 2c628b8c3..366fd8ac5 100644 --- a/system/classes/Mail.php +++ b/system/classes/Mail.php @@ -2,6 +2,17 @@ namespace Geeklog; +use Exception; +use Swift_Attachment; +use Swift_Mailer; +use Swift_MailTransport; +use Swift_Message; +use Swift_Mime_ContentEncoder_Base64ContentEncoder; +use Swift_Plugins_DecoratorPlugin; +use Swift_RfcComplianceException; +use Swift_SendmailTransport; +use Swift_SmtpTransport; + /** * Class Mail * @@ -35,15 +46,15 @@ public static function stripControlCharacters($item) * NOTE: Please note that using CC: will expose the email addresses of * all recipients. Use with care. * - * @param string $to recipients name and email address - * @param string $subject subject of the email - * @param string $body the text of the email - * @param string $from (optional) sender of the the email - * @param bool $html (optional) true if to be sent as HTML email - * @param int $priority (optional) add X-Priority header, if > 0 - * @param mixed $optional (optional) other headers or CC: - * @param array $attachments (optional) attachment files - * @return bool true if successful, otherwise false + * @param string|array $to recipients name and email address + * @param string $subject subject of the email + * @param string $body the text of the email + * @param string|array $from (optional) sender of the the email + * @param bool $html (optional) true if to be sent as HTML email + * @param int $priority (optional) add X-Priority header, if > 0 + * @param mixed $optional (optional) other headers or CC: + * @param array $attachments (optional) attachment files + * @return bool true if successful, otherwise false */ public static function send($to, $subject, $body, $from = '', $html = false, $priority = 0, $optional = null, array $attachments = array()) { @@ -64,11 +75,11 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr switch ($_CONF['mail_settings']['backend']) { case 'sendmail': $arg = $_CONF['mail_settings']['sendmail_path'] . ' ' . $_CONF['mail_settings']['sendmail_args']; - $transport = \Swift_SendmailTransport::newInstance($arg); + $transport = Swift_SendmailTransport::newInstance($arg); break; case 'smtp': - $transport = \Swift_SmtpTransport::newInstance($_CONF['mail_settings']['host'], $_CONF['mail_settings']['port']); + $transport = Swift_SmtpTransport::newInstance($_CONF['mail_settings']['host'], $_CONF['mail_settings']['port']); if (!empty($_CONF['mail_settings']['auth'])) { $transport->setUsername($_CONF['mail_settings']['username']); @@ -78,7 +89,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr break; case 'smtps': - $transport = \Swift_SmtpTransport::newInstance($_CONF['mail_settings']['host'], $_CONF['mail_settings']['port'], 'ssl'); + $transport = Swift_SmtpTransport::newInstance($_CONF['mail_settings']['host'], $_CONF['mail_settings']['port'], 'ssl'); if (!empty($_CONF['mail_settings']['auth'])) { $transport->setUsername($_CONF['mail_settings']['username']); @@ -89,21 +100,21 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr case 'mail': default: - $transport = \Swift_MailTransport::newInstance(); + $transport = Swift_MailTransport::newInstance(); break; } - $mailer = \Swift_Mailer::newInstance($transport); + $mailer = Swift_Mailer::newInstance($transport); // Set up replacements - $decorator = new \Swift_Plugins_DecoratorPlugin(new MailReplacements()); + $decorator = new Swift_Plugins_DecoratorPlugin(new MailReplacements()); $mailer->registerPlugin($decorator); // Create a message - $message = \Swift_Message::newInstance(); + $message = Swift_Message::newInstance(); // Avoid double dots problem - $message->setEncoder(new \Swift_Mime_ContentEncoder_Base64ContentEncoder()); + $message->setEncoder(new Swift_Mime_ContentEncoder_Base64ContentEncoder()); if (!empty($_CONF['mail_charset'])) { $message->setCharset($_CONF['mail_charset']); @@ -124,7 +135,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr // Set to try { $message->setTo($to); - } catch (\Swift_RfcComplianceException $e) { + } catch (Swift_RfcComplianceException $e) { COM_errorLog(__METHOD__ . ': bad "to" ' . $to); return false; @@ -138,7 +149,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr // assume old (optional) CC: header try { $message->setCc($optional); - } catch (\Swift_RfcComplianceException $e) { + } catch (Swift_RfcComplianceException $e) { COM_errorLog(__METHOD__ . ': bad "Cc" ' . $optional); return false; @@ -181,7 +192,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr if (strcasecmp($h, 'Cc') === 0) { try { $message->setCc($v); - } catch (\Swift_RfcComplianceException $e) { + } catch (Swift_RfcComplianceException $e) { COM_errorLog(__METHOD__ . ': bad "Cc" ' . $v); return false; @@ -189,7 +200,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr } elseif (strcasecmp($h, 'Bcc') === 0) { try { $message->setBcc($v); - } catch (\Swift_RfcComplianceException $e) { + } catch (Swift_RfcComplianceException $e) { COM_errorLog(__METHOD__ . ': bad "Bcc" ' . $v); return false; @@ -203,7 +214,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr // Set attachments if (count($attachments) > 0) { foreach ($attachments as $attachment) { - $message->attach(\Swift_Attachment::fromPath($attachment)); + $message->attach(Swift_Attachment::fromPath($attachment)); } } @@ -216,7 +227,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr if ($numSent != 1) { COM_errorLog(__METHOD__ . ': failed to send an email to ' . @$failures[0]); } - } catch (\Exception $e) { + } catch (Exception $e) { COM_errorLog(__METHOD__ . 'Failed to send an email to ' . $to . '. Error message: ' . $e->getMessage()); }