Version 2.2.0 RC-1

This commit is contained in:
Neo committed 2025-12-19 00:22:37 -08:00
1 parent f73f8bff6d
commit 22f1b963ee
1034 files changed
+178610 -70897

No files matched your search

+193 -70
View File
@@ -2,28 +2,18 @@
/*
+--------------------------------------------------------------------------
| Invision Power Board 2.1.7
| Invision Power Board
| =============================================
| by Matthew Mecham
| (c) 2001 - 2005 Invision Power Services, Inc.
| (c) 2001 - 2006 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Tuesday 18th of July 2006 05:56:00 PM
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
+---------------------------------------------------------------------------
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
+---------------------------------------------------------------------------
| > $Date: 2005-12-08 16:32:40 +0000 (Thu, 08 Dec 2005) $
| > $Revision: 96 $
| > $Author: bfarber $
| > $Date: 2006-09-22 11:28:54 +0100 (Fri, 22 Sep 2006) $
| > $Revision: 567 $
| > $Author: matt $
+---------------------------------------------------------------------------
|
| > Sending email module
@@ -45,6 +35,11 @@
// This module is fairly basic, more functionality is expected in future
// versions (such as MIME attachments, SMTP stuff, etc)
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class emailer {
@@ -54,6 +49,7 @@ class emailer {
var $from = "";
var $to = "";
var $subject = "";
var $lang_subject = "";
var $message = "";
var $header = "";
var $footer = "";
@@ -61,13 +57,15 @@ class emailer {
var $error = "";
var $parts = array();
var $bcc = array();
var $mail_headers = "";
var $mail_headers = array();
var $rfc_headers = "";
var $multipart = "";
var $boundry = "";
var $extra_opts = "";
var $html_email = 0;
var $char_set = 'windows-1251';
var $char_set = 'iso-8859-1';
var $header_eol = "\r\n"; //RFC specifies \r\n as eol
var $smtp_fp = FALSE;
var $smtp_msg = "";
@@ -126,7 +124,7 @@ class emailer {
//-----------------------------------------
$this->from = $this->ipsclass->vars['email_out'];
$this->temp_dump = $this->ipsclass->vars['fake_mail'];
$this->temp_dump = isset($this->ipsclass->vars['fake_mail']) ? $this->ipsclass->vars['fake_mail'] : '';
$this->wrap_brackets = $this->ipsclass->vars['mail_wrap_brackets'];
$this->extra_opts = $this->ipsclass->vars['php_mail_extra'];
@@ -135,8 +133,8 @@ class emailer {
// also
//-----------------------------------------
$this->header = $this->ipsclass->vars['email_header'];
$this->footer = $this->ipsclass->vars['email_footer'];
$this->header = isset($this->ipsclass->vars['email_header']) ? $this->ipsclass->vars['email_header'] : '';
$this->footer = isset($this->ipsclass->vars['email_footer']) ? $this->ipsclass->vars['email_footer'] : '';
$this->boundry = "----=_NextPart_000_0022_01C1BD6C.D0C0F9F0"; //"b".md5(uniqid(time()));
$this->char_set = $this->ipsclass->vars['gb_char_set'];
@@ -150,7 +148,6 @@ class emailer {
function add_attachment($data = "", $name = "", $ctype='application/octet-stream')
{
$this->parts[] = array( 'ctype' => $ctype,
'data' => $data,
'encode' => 'base64',
@@ -164,51 +161,41 @@ class emailer {
function build_headers()
{
//-----------------------------------------
// HTML (hitmuhl)
//-----------------------------------------
if ( $this->html_email )
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-type: text/html; charset=\"".$this->char_set."\"\n";
}
else
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-type: text/plain; charset=\"".$this->char_set."\"\n";
}
$extra_headers = array();
$extra_header_rfc = "";
//-----------------------------------------
// Start mail headers
//-----------------------------------------
$this->mail_headers .= "From: \"".$this->ipsclass->vars['board_name']."\" <".$this->from.">\n";
$this->mail_headers['MIME-Version'] = "1.0";
$this->mail_headers['From'] = '"'.$this->ipsclass->vars['board_name'].'" <'.$this->from.'>';
if ( $this->mail_method != 'smtp' )
{
if ( count( $this->bcc ) > 1 )
{
$this->mail_headers .= "Bcc: ".implode( "," , $this->bcc ) . "\n";
$this->mail_headers['Bcc'] = implode( "," , $this->bcc );
}
}
else
{
if ( $this->to )
{
$this->mail_headers .= "To: ".$this->to."\n";
$this->mail_headers['To'] = $this->to;
}
$this->mail_headers .= "Subject: ".$this->subject."\n";
$this->mail_headers['Subject'] = $this->subject;
}
//-----------------------------------------
// we're not spam, really!
//-----------------------------------------
$this->mail_headers .= "Return-Path: ".$this->from."\n";
$this->mail_headers .= "X-Priority: 3\n";
$this->mail_headers .= "X-Mailer: IPB PHP Mailer\n";
$this->mail_headers .= "X-Unique-ID: 52f408a2_988b02f4_b5e6f4ba_af0ae\n";
$this->mail_headers['Return-Path'] = $this->from;
$this->mail_headers['X-Priority'] = "3";
$this->mail_headers['X-Mailer'] = "IPB PHP Mailer";
//-----------------------------------------
// Count.. oh you get the idea
@@ -218,22 +205,81 @@ class emailer {
{
if ( ! $this->html )
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$this->boundry."\"\n\nThis is a MIME encoded message.\n\n--".$this->boundry;
$this->mail_headers .= "\nContent-Type: text/plain;\n\tcharset=\"".$this->char_set."\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
$extra_headers[0]['Content-Type'] = "multipart/mixed;\n\tboundary=\"".$this->boundry."\"";
$extra_headers[0]['notencode'] = "\n\nThis is a MIME encoded message.\n\n--".$this->boundry."\n";
$extra_headers[1]['Content-Type'] = "text/plain;\n\tcharset=\"".$this->char_set."\"";
$extra_headers[1]['Content-Transfer-Encoding'] = "quoted-printable";
$extra_headers[1]['notencode'] = "\n\n".$this->message."\n\n--".$this->boundry;
}
else
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$this->boundry."\"\n\nThis is a MIME encoded message.\n\n--".$this->boundry;
$this->mail_headers .= "\nContent-Type: text/html;\n\tcharset=\"".$this->char_set."\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
$extra_headers[0]['Content-Type'] = "multipart/mixed;\n\tboundary=\"".$this->boundry."\"";
$extra_headers[0]['notencode'] = "\n\nThis is a MIME encoded message.\n\n--".$this->boundry."\n";
$extra_headers[1]['Content-Type'] = "text/html; charset=\"".$this->char_set."\"";
$extra_headers[1]['Content-Transfer-Encoding'] = "quoted-printable";
$extra_headers[1]['notencode'] = "\n\n".$this->message."\n\n--".$this->boundry;
}
$this->mail_headers .= $this->build_multipart();
$extra_headers[2]['notencode'] = $this->build_multipart();
reset($extra_headers);
foreach( $extra_headers as $subset => $the_header )
{
foreach( $the_header as $k => $v )
{
if( $k == 'notencode' )
{
$extra_headers_rfc .= $v;
}
else
{
$v = $this->encode_headers( array( 'v' => $v ) );
$extra_headers_rfc .= $k.': '.$v['v'].$this->header_eol;
}
}
}
$this->message = "";
}
else
{
//-----------------------------------------
// HTML (hitmuhl) ?
//-----------------------------------------
if ( $this->html_email )
{
$this->mail_headers['Content-type'] = 'text/html; charset="'.$this->char_set.'"';
}
else
{
$this->mail_headers['Content-type'] = 'text/plain; charset="'.$this->char_set.'"';
}
}
$this->encode_headers();
foreach( $this->mail_headers as $k => $v )
{
$this->rfc_headers .= $k.": ".$v.$this->header_eol;
}
//-----------------------------------------
// Attachments extra?
//-----------------------------------------
if( $extra_headers_rfc )
{
$this->rfc_headers .= $extra_headers_rfc;
}
}
/*-------------------------------------------------------------------------*/
@@ -242,26 +288,80 @@ class emailer {
function encode_attachment($part)
{
$msg = chunk_split(base64_encode($part['data']));
return "Content-Type: ".$part['ctype']. ($part['name'] ? ";\n\tname =\"".$part['name']."\"" : "").
"\nContent-Transfer-Encoding: ".$part['encode']."\nContent-Disposition: attachment;\n\tfilename=\"".$part['name']."\"\n\n".$msg."\n";
$headers = array();
$header_str = "";
$headers['Content-Type'] = $part['ctype']. ($part['name'] ? "; name =\"".$part['name']."\"" : "");
$headers['Content-Transfer-Encoding'] = $part['encode'];
$headers['Content-Disposition'] = "attachment; filename=\"".$part['name']."\"";
$headers = $this->encode_headers( $headers );
foreach( $headers as $k => $v )
{
$header_str .= $k.': '.$v.$this->header_eol;
}
$header_str .= "\n\n".$msg."\n";
return $header_str;
}
/*-------------------------------------------------------------------------*/
// ENCODE HEADERS - RFC2047
/*-------------------------------------------------------------------------*/
function encode_headers( $headers = array() )
{
$enc_headers = count($headers) ? $headers : $this->mail_headers;
foreach( $enc_headers as $header => $value)
{
preg_match_all( '/(\w*[\x80-\xFF]+\w*)/', $value, $matches );
foreach ($matches[1] as $value)
{
if( $header == 'From' )
{
// Either sendmail or the email servers don't like 'From' encoded...let's remove the board name
// and just move along, as email address cannot contain nasty characters themselves
$this->mail_headers['From'] = $this->from;
continue 2;
}
$replacement = preg_replace_callback( '/([\x80-\xFF])/', create_function( '$match', 'return "=" . strtoupper( dechex( ord( "$match[1]" ) ) );' ), $value );
$value = str_replace( $value, '=?' . $this->char_set . '?Q?' . $replacement . '?=', $value );
}
if( !count($headers) )
{
$this->mail_headers[ $header ] = $value;
}
else
{
$enc_headers[ $header ] = $value;
}
}
return $enc_headers;
}
/*-------------------------------------------------------------------------*/
// BUILD MULTIPART
/*-------------------------------------------------------------------------*/
function build_multipart()
{
$multipart = "";
for ($i = sizeof($this->parts) - 1 ; $i >= 0 ; $i--)
{
$multipart .= "\n".$this->encode_attachment($this->parts[$i]) . "--".$this->boundry;
$multipart .= $this->header_eol.$this->encode_attachment($this->parts[$i]) . "--".$this->boundry;
}
return $multipart . "--\n";
@@ -297,13 +397,20 @@ class emailer {
{
$this->subject .= " ( ".$this->ipsclass->vars['board_name']." )";
}
//-----------------------------------------
// Build headers
//-----------------------------------------
$this->build_headers();
if( $this->mail_method != 'smtp' )
{
$subject = $this->encode_headers( array( 'Subject' => $this->subject ) );
$this->subject = $subject['Subject'];
}
//-----------------------------------------
// Lets go..
//-----------------------------------------
@@ -316,7 +423,7 @@ class emailer {
if ($this->temp_dump == 1)
{
$blah = $this->subject."\n------------\n".$this->mail_headers."\n\n".$this->message;
$blah = $this->subject."\n------------\n".$this->rfc_headers."\n\n".$this->message;
$pathy = $this->root_path.'_mail/'.date("M-j-Y,hi-A").str_replace( '@', '+', $this->to ).".txt";
$fh = fopen ($pathy, 'w');
@@ -331,10 +438,10 @@ class emailer {
if ($this->mail_method != 'smtp')
{
if ( ! @mail( $this->to, $this->subject, $this->message, $this->mail_headers, $this->extra_opts ) )
if ( ! @mail( $this->to, $this->subject, $this->message, $this->rfc_headers, $this->extra_opts ) )
{
# Try without args for safe mode peeps
if ( ! @mail( $this->to, $this->subject, $this->message, $this->mail_headers ) )
if ( ! @mail( $this->to, $this->subject, $this->message, $this->rfc_headers ) )
{
$this->fatal_error("Could not send the email", "Failed at 'mail' command");
}
@@ -359,7 +466,8 @@ class emailer {
$this->from = "";
$this->message = "";
$this->subject = "";
$this->mail_headers = "";
$this->mail_headers = array();
$this->rfc_headers = "";
$this->email_init();
}
@@ -390,7 +498,7 @@ class emailer {
if ( $this->ipsclass->vars['default_language'] == "")
{
$this->ipsclass->vars['default_language'] = 'ru';
$this->ipsclass->vars['default_language'] = 'en';
}
if ($language == "")
@@ -408,7 +516,7 @@ class emailer {
{
$lang = array();
}
require_once( $this->root_path."cache/lang_cache/".$this->ipsclass->vars['default_language']."/lang_email_content.php" );
}
else
@@ -464,9 +572,9 @@ class emailer {
// Also joins header and footer to message and cleans the message for sending
/*-------------------------------------------------------------------------*/
function build_message($words)
function build_message( $words )
{
if ($this->template == "")
if ( $this->template == "" )
{
$this->error++;
$this->fatal_error("Could not build the email message, no template assigned", "Make sure a template is assigned first.");
@@ -474,21 +582,36 @@ class emailer {
$this->message = $this->template;
//-----------------------------------------
// Add some default words
//-----------------------------------------
$words['BOARD_ADDRESS'] = $this->ipsclass->vars['board_url'] . '/index.' . $this->ipsclass->vars['php_ext'];
$words['WEB_ADDRESS'] = $this->ipsclass->vars['home_url'];
$words['BOARD_NAME'] = $this->ipsclass->vars['board_name'];
$words['SIGNATURE'] = $this->ipsclass->vars['signature'];
$words['SIGNATURE'] = isset($this->ipsclass->vars['signature']) ? $this->ipsclass->vars['signature'] : '';
// Swop the words
//-----------------------------------------
// Swap the words
//-----------------------------------------
$this->message = preg_replace( "/<#(.+?)#>/e", "\$words[\\1]", $this->message );
$this->_words = $words;
$this->message = preg_replace_callback( "/<#(.+?)#>/", array( $this, '_swap_words' ), $this->message );
$this->_words = array();
$this->message = $this->clean_message( $this->message );
}
/*-------------------------------------------------------------------------*/
// Swap words.
/*-------------------------------------------------------------------------*/
function _swap_words( $matches )
{
return $this->_words[ $matches[1] ];
}
/*-------------------------------------------------------------------------*/
// clean_message: (Mainly used internally)
@@ -689,7 +812,7 @@ class emailer {
if ( $this->smtp_code == 220 )
{
$data = $this->smtp_crlf_encode( $this->mail_headers."\n" . $this->message);
$data = $this->smtp_crlf_encode( $this->rfc_headers."\n" . $this->message);
//-----------------------------------------
// HELO!, er... HELLO!