From a94ed97992ef41c5fe513777aa0d04f57060cbf5 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 19 Dec 2008 20:36:18 +0000 Subject: Missing read permission from calls to phpbb_chmod() git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9208 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index cbec2582a9..17c59e5274 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -708,7 +708,7 @@ class queue @flock($fp, LOCK_UN); fclose($fp); - phpbb_chmod($this->cache_file, CHMOD_WRITE); + phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } } @@ -749,7 +749,7 @@ class queue @flock($fp, LOCK_UN); fclose($fp); - phpbb_chmod($this->cache_file, CHMOD_WRITE); + phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } } } -- cgit v1.2.1 From d9468c35da7df11ff12b0575b69ff97719cc3480 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 11 Mar 2009 12:53:54 +0000 Subject: add IN_PHPBB check to generated cache files git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9363 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 17c59e5274..ba38d6d0f1 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -704,7 +704,7 @@ class queue if ($fp = @fopen($this->cache_file, 'wb')) { @flock($fp, LOCK_EX); - fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); + fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); @flock($fp, LOCK_UN); fclose($fp); @@ -745,7 +745,7 @@ class queue if ($fp = @fopen($this->cache_file, 'w')) { @flock($fp, LOCK_EX); - fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); + fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); @flock($fp, LOCK_UN); fclose($fp); -- cgit v1.2.1 From 61135f65b94a4949d37f77e6d65e0aeeff8368ce Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 11 Mar 2009 16:23:12 +0000 Subject: Use OS-specific line endings for mail headers. (related to Bug #42755) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9364 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 48 +++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ba38d6d0f1..14465ef13c 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -28,6 +28,7 @@ class messenger var $mail_priority = MAIL_NORMAL_PRIORITY; var $use_queue = true; var $tpl_msg = array(); + var $eol = "\n"; /** * Constructor @@ -38,6 +39,9 @@ class messenger $this->use_queue = (!$config['email_package_size']) ? false : $use_queue; $this->subject = ''; + + // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac) + $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL; } /** @@ -309,6 +313,7 @@ class messenger { global $config; + // We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility $headers = array(); $headers[] = 'From: ' . $this->from; @@ -338,15 +343,12 @@ class messenger $headers[] = 'X-MimeOLE: phpBB3'; $headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url()); - // We use \n here instead of \r\n because our smtp mailer is adjusting it to \r\n automatically, whereby the php mail function only works - // if using \n. - if (sizeof($this->extra_headers)) { - $headers[] = implode("\n", $this->extra_headers); + $headers = array_merge($headers, $this->extra_headers); } - return implode("\n", $headers); + return $headers; } /** @@ -412,6 +414,10 @@ class messenger } else { + // We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used... + // Reference: http://bugs.php.net/bug.php?id=15841 + $headers = implode($this->eol, $headers); + ob_start(); $result = $config['email_function_name']($mail_to, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers); $err_msg = ob_get_clean(); @@ -652,7 +658,7 @@ class queue else { ob_start(); - $result = $config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers); + $result = $config['email_function_name']($to, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), implode($this->eol, $headers)); $err_msg = ob_get_clean(); } @@ -757,40 +763,37 @@ class queue /** * Replacement or substitute for PHP's mail command */ -function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '') +function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false) { global $config, $user; // Fix any bare linefeeds in the message to make it RFC821 Compliant. $message = preg_replace("#(? 1) ? join("\n", $headers) : $headers[0]; + // Make sure there are no bare linefeeds in the headers + $headers = preg_replace('#(?server_send("$headers\r\n"); + if ($headers !== false) + { + $smtp->server_send("$headers\r\n"); + } // Ok now we are ready for the message... $smtp->server_send($message); -- cgit v1.2.1 From a80f7a5ea10b039ec1549d391ecd8431240c640e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 17 Mar 2009 15:23:57 +0000 Subject: Use FQDN for SMTP EHLO/HELO command. (Bug #41025) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9387 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 14465ef13c..6c8f8aa32d 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -1073,7 +1073,7 @@ class smtp_class global $user; $err_msg = ''; - $local_host = (function_exists('php_uname')) ? php_uname('n') : $user->host; + $local_host = (function_exists('php_uname')) ? gethostbyaddr(gethostbyname(php_uname('n'))) : $user->host; // If we are authenticating through pop-before-smtp, we // have to login ones before we get authenticated -- cgit v1.2.1 From 1e36ed1f741631be7c3c097b1a1cdd0db72baccb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 17 Mar 2009 15:50:19 +0000 Subject: Mass Email works again for users with empty jabber address but notification set to 'both'. (Bug #39755) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9389 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 6c8f8aa32d..158d6804e3 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -61,6 +61,11 @@ class messenger { global $config; + if (!trim($address)) + { + return; + } + $pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0; $this->addresses['to'][$pos]['email'] = trim($address); @@ -81,6 +86,11 @@ class messenger */ function cc($address, $realname = '') { + if (!trim($address)) + { + return; + } + $pos = isset($this->addresses['cc']) ? sizeof($this->addresses['cc']) : 0; $this->addresses['cc'][$pos]['email'] = trim($address); $this->addresses['cc'][$pos]['name'] = trim($realname); @@ -91,6 +101,11 @@ class messenger */ function bcc($address, $realname = '') { + if (!trim($address)) + { + return; + } + $pos = isset($this->addresses['bcc']) ? sizeof($this->addresses['bcc']) : 0; $this->addresses['bcc'][$pos]['email'] = trim($address); $this->addresses['bcc'][$pos]['name'] = trim($realname); @@ -102,7 +117,7 @@ class messenger function im($address, $realname = '') { // IM-Addresses could be empty - if (!$address) + if (!trim($address)) { return; } @@ -363,6 +378,13 @@ class messenger return false; } + // Addresses to send to? + if (empty($this->addresses) || (empty($this->addresses['to']) && empty($this->addresses['cc']) && empty($this->addresses['bcc']))) + { + // Send was successful. ;) + return true; + } + $use_queue = false; if ($config['email_package_size'] && $this->use_queue) { @@ -457,7 +479,8 @@ class messenger if (empty($this->addresses['im'])) { - return false; + // Send was successful. ;) + return true; } $use_queue = false; -- cgit v1.2.1 From abc458bc2aed41dee565c5a6a0771e94fca7ea0f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 8 Apr 2009 16:40:39 +0000 Subject: make sure eol is set (if PHP_EOL is empty? :o) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9427 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 158d6804e3..f014e2ac67 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -42,6 +42,7 @@ class messenger // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac) $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL; + $this->eol = (!$this->eol) ? "\n" : $this->eol; } /** -- cgit v1.2.1 From 2155bbbf8a16510548b2eaf86c1bb4cd52083672 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 8 Apr 2009 18:08:54 +0000 Subject: Erm, yes, we use EOL in queue too. :/ (me is ashamed). Paul, thanks for giving me access to debug this. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9429 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index f014e2ac67..866acc7f1a 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -549,6 +549,7 @@ class queue var $queue_data = array(); var $package_size = 0; var $cache_file = ''; + var $eol = "\n"; /** * constructor @@ -559,6 +560,10 @@ class queue $this->data = array(); $this->cache_file = "{$phpbb_root_path}cache/queue.$phpEx"; + + // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac) + $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL; + $this->eol = (!$this->eol) ? "\n" : $this->eol; } /** -- cgit v1.2.1 From d7a8d7ad09f06050526d114abf5708b720cb67be Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 10 Apr 2009 07:54:52 +0000 Subject: Correctly split long subject lines according to the used RFC. This fixes extra spaces within long subjects. (Bug #43715) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9430 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 866acc7f1a..aad064d5e6 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -1446,9 +1446,10 @@ function mail_encode($str) // define start delimimter, end delimiter and spacer $start = "=?UTF-8?B?"; $end = "?="; - $spacer = $end . ' ' . $start; - $split_length = 64; + $delimiter = "\r\n "; + // Maximum length is 75 for everything. 75 - length of start/end/delimiter == 63 + $split_length = 63; $encoded_str = base64_encode($str); // If encoded string meets the limits, we just return with the correct data. @@ -1460,7 +1461,7 @@ function mail_encode($str) // If there is only ASCII data, we just return what we want, correctly splitting the lines. if (strlen($str) === utf8_strlen($str)) { - return $start . implode($spacer, str_split($encoded_str, $split_length)) . $end; + return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end; } // UTF-8 data, compose encoded lines @@ -1476,10 +1477,10 @@ function mail_encode($str) $text .= array_shift($array); } - $str .= $start . base64_encode($text) . $end . ' '; + $str .= $start . base64_encode($text) . $end . $delimiter; } - return substr($str, 0, -1); + return substr($str, 0, -strlen($delimiter)); } ?> \ No newline at end of file -- cgit v1.2.1 From 0a139376abd49b089cd6d9de1d064f6f3098a629 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 16 Apr 2009 15:39:29 +0000 Subject: fix revision #r9430 - all hail the math! git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9449 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index aad064d5e6..d2c738967c 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -1448,8 +1448,8 @@ function mail_encode($str) $end = "?="; $delimiter = "\r\n "; - // Maximum length is 75 for everything. 75 - length of start/end/delimiter == 63 - $split_length = 63; + // Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!! + $split_length = 60; $encoded_str = base64_encode($str); // If encoded string meets the limits, we just return with the correct data. -- cgit v1.2.1 From b8b578cd99641370756d116b31917f2a18fa9446 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 17 Apr 2009 09:08:34 +0000 Subject: Messenger now also able to use a custom language path. (Bug #36545) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9450 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_messenger.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_messenger.php') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index d2c738967c..4fd5fd19e0 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -173,7 +173,7 @@ class messenger */ function template($template_file, $template_lang = '') { - global $config, $phpbb_root_path; + global $config, $phpbb_root_path, $user; if (!trim($template_file)) { @@ -187,7 +187,8 @@ class messenger if (empty($this->tpl_msg[$template_lang . $template_file])) { - $tpl_file = "{$phpbb_root_path}language/$template_lang/email/$template_file.txt"; + $tpl_file = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; + $tpl_file .= $template_lang . "/email/$template_file.txt"; if (!file_exists($tpl_file)) { -- cgit v1.2.1