phpBB

Code Changes

File: includes/functions_messenger.php

  Unmodified   Added   Modified   Removed
Line 210Line 210
	/**
* Set email template to use
*/

	/**
* Set email template to use
*/

	function template($template_file, $template_lang = '', $template_path = '')

	function template($template_file, $template_lang = '', $template_path = '', $template_dir_prefix = '')

	{
global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager;

	{
global $config, $phpbb_root_path, $phpEx, $user, $phpbb_extension_manager;

 

$template_dir_prefix = (!$template_dir_prefix || $template_dir_prefix[0] === '/') ? $template_dir_prefix : '/' . $template_dir_prefix;


$this->setup_template();



$this->setup_template();


Line 228Line 230
			// $this->template->set_filenames will do a trigger_error
$template_lang = basename($config['default_lang']);
}

			// $this->template->set_filenames will do a trigger_error
$template_lang = basename($config['default_lang']);
}

 

$ext_template_paths = array(
array(
'name' => $template_lang . '_email',
'ext_path' => 'language/' . $template_lang . '/email' . $template_dir_prefix,
),
);


if ($template_path)
{
$template_paths = array(


if ($template_path)
{
$template_paths = array(

				$template_path,

				$template_path . $template_dir_prefix,

			);
}
else

			);
}
else

Line 241Line 250
			$template_path .= $template_lang . '/email';

$template_paths = array(

			$template_path .= $template_lang . '/email';

$template_paths = array(

				$template_path,

				$template_path . $template_dir_prefix,

			);

			);

 

$board_language = basename($config['default_lang']);


// we can only specify default language fallback when the path is not a custom one for which we
// do not know the default language alternative


// we can only specify default language fallback when the path is not a custom one for which we
// do not know the default language alternative

			if ($template_lang !== basename($config['default_lang']))

			if ($template_lang !== $board_language)

			{
$fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/';

			{
$fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/';

				$fallback_template_path .= basename($config['default_lang']) . '/email';

				$fallback_template_path .= $board_language . '/email';





				$template_paths[] = $fallback_template_path;



















				$template_paths[] = $fallback_template_path . $template_dir_prefix;

$ext_template_paths[] = array(
'name' => $board_language . '_email',
'ext_path' => 'language/' . $board_language . '/email' . $template_dir_prefix,
);
}
// If everything fails just fall back to en template
if ($template_lang !== 'en' && $board_language !== 'en')
{
$fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/';
$fallback_template_path .= 'en/email';

$template_paths[] = $fallback_template_path . $template_dir_prefix;

$ext_template_paths[] = array(
'name' => 'en_email',
'ext_path' => 'language/en/email' . $template_dir_prefix,
);

			}
}


			}
}


		$this->set_template_paths(array(
array(
'name' => $template_lang . '_email',
'ext_path' => 'language/' . $template_lang . '/email'
),
), $template_paths);

		$this->set_template_paths($ext_template_paths, $template_paths);







$this->template->set_filenames(array(
'body' => $template_file . '.txt',


$this->template->set_filenames(array(
'body' => $template_file . '.txt',

Line 288Line 312

/**
* Send the mail out to the recipients set previously in var $this->addresses


/**
* Send the mail out to the recipients set previously in var $this->addresses

 
	*
* @param int $method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH
* @param bool $break Flag indicating if the function only formats the subject
* and the message without sending it
*
* @return bool

	*/
function send($method = NOTIFY_EMAIL, $break = false)
{

	*/
function send($method = NOTIFY_EMAIL, $break = false)
{

		global $config, $user;

		global $config, $user, $phpbb_dispatcher;


// We add some standard variables we always use, no need to specify them always
$this->assign_vars(array(


// We add some standard variables we always use, no need to specify them always
$this->assign_vars(array(

Line 299Line 329
			'EMAIL_SIG'	=> str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])),
'SITENAME' => htmlspecialchars_decode($config['sitename']),
));

			'EMAIL_SIG'	=> str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])),
'SITENAME' => htmlspecialchars_decode($config['sitename']),
));

 

$subject = $this->subject;
$message = $this->msg;
/**
* Event to modify notification message text before parsing
*
* @event core.modify_notification_message
* @var int method User notification method NOTIFY_EMAIL|NOTIFY_IM|NOTIFY_BOTH
* @var bool break Flag indicating if the function only formats the subject
* and the message without sending it
* @var string subject The message subject
* @var string message The message text
* @since 3.1.11-RC1
*/
$vars = array(
'method',
'break',
'subject',
'message',
);
extract($phpbb_dispatcher->trigger_event('core.modify_notification_message', compact($vars)));
$this->subject = $subject;
$this->msg = $message;
unset($subject, $message);


// Parse message through template
$this->msg = trim($this->template->assign_display('body'));


// Parse message through template
$this->msg = trim($this->template->assign_display('body'));

Line 414Line 468
	*/
function build_header($to, $cc, $bcc)
{

	*/
function build_header($to, $cc, $bcc)
{

		global $config;

		global $config, $phpbb_dispatcher;


// We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility
$headers = array();


// We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility
$headers = array();

Line 445Line 499
		$headers[] = 'X-Mailer: phpBB3';
$headers[] = 'X-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());

		$headers[] = 'X-Mailer: phpBB3';
$headers[] = 'X-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());

 

/**
* Event to modify email header entries
*
* @event core.modify_email_headers
* @var array headers Array containing email header entries
* @since 3.1.11-RC1
*/
$vars = array('headers');
extract($phpbb_dispatcher->trigger_event('core.modify_email_headers', compact($vars)));


if (sizeof($this->extra_headers))
{


if (sizeof($this->extra_headers))
{

Line 510Line 574

foreach ($address_ary as $which_ary)
{


foreach ($address_ary as $which_ary)
{

				$$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']);

				${$type} .= ((${$type} != '') ? ', ' : '') . (($which_ary['name'] != '') ? mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>' : $which_ary['email']);

			}
}


			}
}


Line 591Line 655
		if (!$use_queue)
{
include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);

		if (!$use_queue)
{
include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);

			$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl']);

			$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl'], $config['jab_verify_peer'], $config['jab_verify_peer_name'], $config['jab_allow_self_signed']);


if (!$this->jabber->connect())
{


if (!$this->jabber->connect())
{

Line 766Line 830
					}

include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);

					}

include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx);

					$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl']);

					$this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'], htmlspecialchars_decode($config['jab_password']), $config['jab_use_ssl'], $config['jab_verify_peer'], $config['jab_verify_peer_name'], $config['jab_allow_self_signed']);


if (!$this->jabber->connect())
{


if (!$this->jabber->connect())
{

Line 858Line 922
			{
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>");
fclose($fp);

			{
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>");
fclose($fp);

 

if (function_exists('opcache_invalidate'))
{
@opcache_invalidate($this->cache_file);
}


phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);
}


phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);
}

Line 900Line 969
		{
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");
fclose($fp);

		{
fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");
fclose($fp);

 

if (function_exists('opcache_invalidate'))
{
@opcache_invalidate($this->cache_file);
}


phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);


phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);

 

$this->data = array();

		}

$lock->release();

		}

$lock->release();

Line 1000Line 1076
	}
$collector = new \phpbb\error_collector;
$collector->install();

	}
$collector = new \phpbb\error_collector;
$collector->install();

	$smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);













$options = array();
$verify_peer = (bool) $config['smtp_verify_peer'];
$verify_peer_name = (bool) $config['smtp_verify_peer_name'];
$allow_self_signed = (bool) $config['smtp_allow_self_signed'];
$remote_socket = $config['smtp_host'] . ':' . $config['smtp_port'];

// Set ssl context options, see http://php.net/manual/en/context.ssl.php
$options['ssl'] = array('verify_peer' => $verify_peer, 'verify_peer_name' => $verify_peer_name, 'allow_self_signed' => $allow_self_signed);
$socket_context = stream_context_create($options);

$smtp->socket = @stream_socket_client($remote_socket, $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $socket_context);

	$collector->uninstall();
$error_contents = $collector->format_errors();


	$collector->uninstall();
$error_contents = $collector->format_errors();