Vergleich inc/class_mailhandler.php - 1.4.1 - 1.4.14

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: class_mailhandler.php 4098 2008-08-10 03:18:01Z chris $

 * $Id: class_mailhandler.php 4850 2010-03-31 08:14:21Z RyanGordon $

 */

/**

 */

/**

Zeile 34Zeile 34
	 * @var string
*/
var $from;

	 * @var string
*/
var $from;

 
	
/**
* Who the email should return to.
*
* @var string
*/
var $return_email;





	/**

	/**

	 * The subject of mail.
*
* @var string
*/

	 * The subject of mail.
*
* @var string
*/

	var $subject;








	var $subject;

/**
* The unaltered subject of mail.
*
* @var string
*/
var $orig_subject;


/**
* The message of the mail.


/**
* The message of the mail.

Zeile 90Zeile 104
	 * @param string headers of email.
* @param string format of the email (HTML, plain text, or both?).
* @param string plain text version of the email.

	 * @param string headers of email.
* @param string format of the email (HTML, plain text, or both?).
* @param string plain text version of the email.

 
	 * @param string the return email address.

	 */

	 */

	function build_message($to, $subject, $message, $from="", $charset="", $headers="", $format="text", $message_text="")

	function build_message($to, $subject, $message, $from="", $charset="", $headers="", $format="text", $message_text="", $return_email="")

	{
global $parser, $lang, $mybb;


	{
global $parser, $lang, $mybb;


Zeile 101Zeile 116
		if($from)
{
$this->from = $from;

		if($from)
{
$this->from = $from;

 
		}
else
{
$this->from = "";
}

if($return_email)
{
$this->return_email = $return_email;
}
else
{
$this->return_email = "";

		}

$this->set_to($to);
$this->set_subject($subject);
if($charset)

		}

$this->set_to($to);
$this->set_subject($subject);
if($charset)

		{

		{

			$this->set_charset($charset);
}
$this->parse_format = $format;
$this->set_common_headers();
$this->set_message($message, $message_text);

			$this->set_charset($charset);
}
$this->parse_format = $format;
$this->set_common_headers();
$this->set_message($message, $message_text);


}

/**


}

/**

	 * Sets the charset.
*
* @param string charset

	 * Sets the charset.
*
* @param string charset

Zeile 142Zeile 170
	function set_message($message, $message_text="")
{
if($this->parse_format == "html" || $this->parse_format == "both")

	function set_message($message, $message_text="")
{
if($this->parse_format == "html" || $this->parse_format == "both")

		{

		{

			$this->set_html_headers($message, $message_text);
}
else

			$this->set_html_headers($message, $message_text);
}
else

Zeile 150Zeile 178
			$this->message = $message;
$this->set_plain_headers();
}

			$this->message = $message;
$this->set_plain_headers();
}

	}


	}


	/**
* Sets and formats the email subject.
*
* @param string subject

	/**
* Sets and formats the email subject.
*
* @param string subject

	 */

	 */

	function set_subject($subject)

	function set_subject($subject)

	{
$this->subject = $this->cleanup($subject);
$this->subject = $this->utf8_encode($subject);
}


	{
$this->orig_subject = $this->cleanup($subject);
$this->subject = $this->utf8_encode($this->orig_subject);
}


	/**
* Sets and formats the recipient address.
*

	/**
* Sets and formats the recipient address.
*

Zeile 171Zeile 199
	function set_to($to)
{
$to = $this->cleanup($to);

	function set_to($to)
{
$to = $this->cleanup($to);





		$this->to = $this->cleanup($to);
}


		$this->to = $this->cleanup($to);
}


Zeile 179Zeile 207
	 * Sets the plain headers, text/plain
*/
function set_plain_headers()

	 * Sets the plain headers, text/plain
*/
function set_plain_headers()

	{

	{

		$this->headers .= "Content-Type: text/plain; charset={$this->charset}{$this->delimiter}";
}


		$this->headers .= "Content-Type: text/plain; charset={$this->charset}{$this->delimiter}";
}


Zeile 193Zeile 221
		if(!$message_text && $this->parse_format == 'both')
{
$message_text = strip_tags($message);

		if(!$message_text && $this->parse_format == 'both')
{
$message_text = strip_tags($message);

		}

		}

		
if($this->parse_format == 'both')
{

		
if($this->parse_format == 'both')
{

Zeile 201Zeile 229

$this->headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"{$this->delimiter}";
$this->message = "This is a multi-part message in MIME format.{$this->delimiter}{$this->delimiter}";


$this->headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"{$this->delimiter}";
$this->message = "This is a multi-part message in MIME format.{$this->delimiter}{$this->delimiter}";





			$this->message .= "--{$mime_boundary}{$this->delimiter}";
$this->message .= "Content-Type: text/plain; charset=\"{$this->charset}\"{$this->delimiter}";
$this->message .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}";
$this->message .= $message_text."{$this->delimiter}{$this->delimiter}";

			$this->message .= "--{$mime_boundary}{$this->delimiter}";
$this->message .= "Content-Type: text/plain; charset=\"{$this->charset}\"{$this->delimiter}";
$this->message .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}";
$this->message .= $message_text."{$this->delimiter}{$this->delimiter}";





			$this->message .= "--{$mime_boundary}{$this->delimiter}";

$this->message .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}";

			$this->message .= "--{$mime_boundary}{$this->delimiter}";

$this->message .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}";

Zeile 215Zeile 243

$this->message .= "--{$mime_boundary}--{$this->delimiter}{$this->delimiter}";
}


$this->message .= "--{$mime_boundary}--{$this->delimiter}{$this->delimiter}";
}

		else {


		else
{

			$this->headers .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}";
$this->headers .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}";
$this->message = $message."{$this->delimiter}{$this->delimiter}";

			$this->headers .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}";
$this->headers .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}";
$this->message = $message."{$this->delimiter}{$this->delimiter}";

Zeile 232Zeile 261
		// Build mail headers
if(!trim($this->from))
{

		// Build mail headers
if(!trim($this->from))
{

			$this->from = '"'.$this->utf8_encode($mybb->settings['bbname'].'"');
$this->from .= " <{$mybb->settings['adminemail']}>";








			if($mybb->settings['mail_handler'] == 'smtp')
{
$this->from = $mybb->settings['adminemail'];
}
else
{
$this->from = '"'.$this->utf8_encode($mybb->settings['bbname']).'"';
$this->from .= " <{$mybb->settings['adminemail']}>";
}

		}

$this->headers .= "From: {$this->from}{$this->delimiter}";


		}

$this->headers .= "From: {$this->from}{$this->delimiter}";


		if($mybb->settings['returnemail'])






		if($this->return_email)
{
$this->headers .= "Return-Path: {$this->return_email}{$this->delimiter}";
$this->headers .= "Reply-To: {$this->return_email}{$this->delimiter}";
}
elseif($mybb->settings['returnemail'])

		{
$this->headers .= "Return-Path: {$mybb->settings['returnemail']}{$this->delimiter}";
$this->headers .= "Reply-To: {$mybb->settings['adminemail']}{$this->delimiter}";

		{
$this->headers .= "Return-Path: {$mybb->settings['returnemail']}{$this->delimiter}";
$this->headers .= "Reply-To: {$mybb->settings['adminemail']}{$this->delimiter}";

Zeile 269Zeile 310
		$this->headers .= "X-Priority: 3{$this->delimiter}";
$this->headers .= "X-MSMail-Priority: Normal{$this->delimiter}";
$this->headers .= "X-Mailer: MyBB{$this->delimiter}";

		$this->headers .= "X-Priority: 3{$this->delimiter}";
$this->headers .= "X-MSMail-Priority: Normal{$this->delimiter}";
$this->headers .= "X-Mailer: MyBB{$this->delimiter}";

		if(defined("IN_ADMINCP"))
{
$_SERVER['PHP_SELF'] = str_replace($mybb->config['admin_dir']."/", "admin-", $_SERVER['PHP_SELF']);
}
$this->headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}{$this->delimiter}";

 
		$this->headers .= "MIME-Version: 1.0{$this->delimiter}";
}


		$this->headers .= "MIME-Version: 1.0{$this->delimiter}";
}


Zeile 288Zeile 324
		global $db;

$mail_error = array(

		global $db;

$mail_error = array(

			"subject" => $db->escape_string($this->subject),

			"subject" => $db->escape_string($this->orig_subject),

			"message" => $db->escape_string($this->message),
"toaddress" => $db->escape_string($this->to),
"fromaddress" => $db->escape_string($this->from),

			"message" => $db->escape_string($this->message),
"toaddress" => $db->escape_string($this->to),
"fromaddress" => $db->escape_string($this->from),

Zeile 325Zeile 361
	 */
function utf8_encode($string)
{

	 */
function utf8_encode($string)
{

		$encoded_string = $string;
if(strtolower($this->charset) == 'utf-8' && preg_match('/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/', $string))

		if(strtolower($this->charset) == 'utf-8' && preg_match('/[^\x20-\x7E]/', $string))


		{

		{

			// Define start delimimter, end delimiter and spacer
$end = "?=";
$start = "=?" . $this->charset . "?B?";
$spacer = $end . ' ' . $start;

			$chunk_size = 47; // Derived from floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
$len = strlen($string);
$output = '';
$pos = 0;





			// Determine length of encoded text within chunks and ensure length is even (should NOT use the my_strlen functions)
$length = 75 - strlen($start) - strlen($end);
$length = floor($length/4) * 4;

            while($pos < $len)
{
$newpos = min($pos + $chunk_size, $len);





			// Encode the string and split it into chunks with spacers after each chunk
$encoded_string = base64_encode($encoded_string);
$encoded_string = chunk_split($encoded_string, $length, $spacer);



				while(ord($string[$newpos]) >= 0x80 && ord($string[$newpos]) < 0xC0)
{
// Reduce len until it's safe to split UTF-8.
$newpos--;
}





			// Remove trailing spacer and add start and end delimiters
$spacer = preg_quote($spacer);
$encoded_string = preg_replace("/" . $spacer . "$/", "", $encoded_string);
$encoded_string = $start . $encoded_string . $end;



				$chunk = substr($string, $pos, $newpos - $pos);
$pos = $newpos;

$output .= " =?UTF-8?B?".base64_encode($chunk)."?=\n";
}
return trim($output);

		}

		}

		return $encoded_string;
}

		return $string;
}

}
?>

}
?>