From 6e29a5addbcbaff70579ced463ebd5904bf5a87b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 18 Jul 2003 16:34:01 +0000 Subject: [PATCH] as told... the latest changes. git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@4280 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/emailer.php | 44 ++++++++---------------------- phpBB/includes/smtp.php | 27 +++++++----------- phpBB/includes/usercp_register.php | 16 +++++++++-- 3 files changed, 35 insertions(+), 52 deletions(-) diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index 0073a7dbb9..9a99fa1886 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -46,25 +46,19 @@ class emailer } // Sets an email address to send to - function email_address($address, $realname = '') + function email_address($address) { - $pos = sizeof($this->addresses['to']); - $this->addresses['to'][$pos]['email'] = trim($address); - $this->addresses['to'][$pos]['name'] = trim($realname); + $this->addresses['to'] = trim($address); } - function cc($address, $realname = '') + function cc($address) { - $pos = sizeof($this->addresses['cc']); - $this->addresses['cc'][$pos]['email'] = trim($address); - $this->addresses['cc'][$pos]['name'] = trim($realname); + $this->addresses['cc'][] = trim($address); } - function bcc($address, $realname = '') + function bcc($address) { - $pos = sizeof($this->addresses['bcc']); - $this->addresses['bcc'][$pos]['email'] = trim($address); - $this->addresses['bcc'][$pos]['name'] = trim($realname); + $this->addresses['bcc'][] = trim($address); } function replyto($address) @@ -80,7 +74,7 @@ class emailer // set up subject for mail function set_subject($subject = '') { - $this->subject = trim($subject); + $this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject)); } // set up extra mail headers @@ -191,27 +185,13 @@ class emailer $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg)); } - $to = $cc = $bcc = ''; - // Build to, cc and bcc strings - @reset($this->addresses); - while (list($type, $address_ary) = each($this->addresses)) - { - @reset($address_ary); - while (list(, $which_ary) = each($address_ary)) - { - if ($type != 'to') - { - $$type .= (($$type != '') ? ',' : '') . (($which_ary['name'] != '') ? '"' . $this->encode($which_ary['name']) . '" <' . $which_ary['email'] . '>' : '<' . $which_ary['email'] . '>'); - } - else - { - $$type .= (($$type != '') ? ',' : '') . $which_ary['email']; - } - } - } + $to = $this->addresses['to']; + + $cc = (count($this->addresses['cc'])) ? implode(', ', $this->addresses['cc']) : ''; + $bcc = (count($this->addresses['bcc'])) ? implode(', ', $this->addresses['bcc']) : ''; // Build header - $this->extra_headers = (($this->replyto != '') ? "Reply-to: <$this->replyto>\n" : '') . (($this->from != '') ? "From: <$this->from>\n" : "From: <" . $board_config['board_email'] . ">\n") . "Return-Path: <" . $board_config['board_email'] . ">\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc:$cc\n" : '') . (($bcc != '') ? "Bcc:$bcc\n" : ''); + $this->extra_headers = (($this->replyto != '') ? "Reply-to: $this->replyto\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $board_config['board_email'] . "\n") . "Return-Path: " . $board_config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : ''); // Send message ... removed $this->encode() from subject for time being if ( $this->use_smtp ) diff --git a/phpBB/includes/smtp.php b/phpBB/includes/smtp.php index 5abbac3fe4..7f0923ac2f 100644 --- a/phpBB/includes/smtp.php +++ b/phpBB/includes/smtp.php @@ -90,8 +90,8 @@ function smtpmail($mail_to, $subject, $message, $headers = '') } $headers = chop($headers); - $cc = explode(',', $cc); - $bcc = explode(',', $bcc); + $cc = explode(', ', $cc); + $bcc = explode(', ', $bcc); } if (trim($subject) == '') @@ -104,8 +104,6 @@ function smtpmail($mail_to, $subject, $message, $headers = '') message_die(GENERAL_ERROR, "Email message was blank", "", __LINE__, __FILE__); } - $mail_to_array = explode(',', $mail_to); - // Ok we have error checked as much as we can to this point let's get on // it already. if( !$socket = fsockopen($board_config['smtp_host'], 25, $errno, $errstr, 20) ) @@ -146,17 +144,12 @@ function smtpmail($mail_to, $subject, $message, $headers = '') // Specify each user to send to and build to header. $to_header = ''; - @reset($mail_to_array); - while(list(, $mail_to_address) = each($mail_to_array)) + // Add an additional bit of error checking to the To field. + $mail_to = (trim($mail_to) == '') ? 'Undisclosed-recipients:;' : trim($mail_to); + if (preg_match('#[^ ]+\@[^ ]+#', $mail_to)) { - // Add an additional bit of error checking to the To field. - $mail_to_address = ($mail_to_address == '') ? 'Undisclosed-recipients:;' : '<' . trim($mail_to_address) . '>'; - if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address)) - { - fputs($socket, "RCPT TO: $mail_to_address\r\n"); - server_parse($socket, "250", __LINE__); - } - $to_header .= (($to_header != '') ? ', ' : '') . "$mail_to_address"; + fputs($socket, "RCPT TO: <$mail_to>\r\n"); + server_parse($socket, "250", __LINE__); } // Ok now do the CC and BCC fields... @@ -167,7 +160,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '') $bcc_address = trim($bcc_address); if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address)) { - fputs($socket, "RCPT TO: $bcc_address\r\n"); + fputs($socket, "RCPT TO: <$bcc_address>\r\n"); server_parse($socket, "250", __LINE__); } } @@ -179,7 +172,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '') $cc_address = trim($cc_address); if (preg_match('#[^ ]+\@[^ ]+#', $cc_address)) { - fputs($socket, "RCPT TO: $cc_address\r\n"); + fputs($socket, "RCPT TO: <$cc_address>\r\n"); server_parse($socket, "250", __LINE__); } } @@ -194,7 +187,7 @@ function smtpmail($mail_to, $subject, $message, $headers = '') fputs($socket, "Subject: $subject\r\n"); // Now the To Header. - fputs($socket, "To: $to_header\r\n"); + fputs($socket, "To: $mail_to\r\n"); // Now any custom headers.... fputs($socket, "$headers\r\n\r\n"); diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php index ebde9cde3a..cc231266eb 100644 --- a/phpBB/includes/usercp_register.php +++ b/phpBB/includes/usercp_register.php @@ -165,6 +165,16 @@ if ( } $user_timezone = ( isset($HTTP_POST_VARS['timezone']) ) ? doubleval($HTTP_POST_VARS['timezone']) : $board_config['board_timezone']; + + $sql = "SELECT config_value + FROM " . CONFIG_TABLE . " + WHERE config_name = 'default_dateformat'"; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not select default dateformat', '', __LINE__, __FILE__, $sql); + } + $row = $db->sql_fetchrow($result); + $board_config['default_dateformat'] = $row['config_value']; $user_dateformat = ( !empty($HTTP_POST_VARS['dateformat']) ) ? trim(htmlspecialchars($HTTP_POST_VARS['dateformat'])) : $board_config['default_dateformat']; $user_avatar_local = ( isset($HTTP_POST_VARS['avatarselect']) && !empty($HTTP_POST_VARS['submitavatar']) && $board_config['allow_avatar_local'] ) ? $HTTP_POST_VARS['avatarselect'] : ( ( isset($HTTP_POST_VARS['avatarlocal']) ) ? htmlspecialchars($HTTP_POST_VARS['avatarlocal']) : '' ); @@ -621,11 +631,11 @@ if ( isset($HTTP_POST_VARS['submit']) ) message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql); } - $emailer->from($board_config['board_email']); - $emailer->replyto($board_config['board_email']); - while ($row = $db->sql_fetchrow($result)) { + $emailer->from($board_config['board_email']); + $emailer->replyto($board_config['board_email']); + $emailer->email_address(trim($row['user_email'])); $emailer->use_template("admin_activate", $row['user_lang']); $emailer->set_subject($lang['New_account_subject']);