message/mail updates

git-svn-id: file:///svn/phpbb/trunk@4898 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2004-05-26 20:32:51 +00:00
parent 40203496d8
commit 1b7c32f825
5 changed files with 43 additions and 93 deletions

View file

@ -38,7 +38,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
}
else if ($row['left_id'] > $right + 1)
{
$padding = $padding_store[$row['parent_id']];
$padding = (isset($padding_store[$row['parent_id']])) ? $padding_store[$row['parent_id']] : '';
}
$right = $row['right_id'];

View file

@ -145,6 +145,11 @@ function display_forums($root_data = '', $display_moderators = TRUE)
}
}
if (!isset($row['mark_time']))
{
$row['mark_time'] = 0;
}
$mark_time_forum = ($config['load_db_lastread']) ? $row['mark_time'] : ((isset($tracking_topics[$forum_id][0])) ? base_convert($tracking_topics[$forum_id][0], 36, 10) + $config['board_startdate'] : 0);
if ($mark_time_forum < $row['forum_last_post_time'] && $user->data['user_id'] != ANONYMOUS)
@ -440,7 +445,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
{
$l_downloaded_viewed = '';
$download_link = '';
$additional_array = array();
$additional_array['VAR'] = $additional_array['VAL'] = array();
$display_cat = $extensions[$attachment['extension']]['display_cat'];

View file

@ -13,8 +13,8 @@
class messenger
{
var $msg, $subject, $extra_headers;
var $to_addres, $cc_address, $bcc_address, $reply_to, $from;
var $msg, $subject, $extra_headers, $encoding;
var $to_address, $cc_address, $bcc_address, $reply_to, $from;
var $queue, $jabber;
var $mail_priority = MAIL_NORMAL_PRIORITY;
@ -35,7 +35,7 @@ class messenger
$this->use_queue = $use_queue;
}
// Resets all the data (address, template file, etc etc to default
// Resets all the data (address, template file, etc etc) to default
function reset()
{
$this->addresses = array();
@ -147,7 +147,7 @@ class messenger
}
// Send the mail out to the recipients set previously in var $this->address
function send($method = NOTIFY_EMAIL, $log_session = false)
function send($method = NOTIFY_EMAIL)
{
global $config, $user;
@ -201,13 +201,13 @@ class messenger
switch ($method)
{
case NOTIFY_EMAIL:
$result = $this->msg_email($log_session);
$result = $this->msg_email();
break;
case NOTIFY_IM:
$result = $this->msg_jabber();
break;
case NOTIFY_BOTH:
$result = $this->msg_email($log_session);
$result = $this->msg_email();
$this->msg_jabber();
break;
}
@ -231,7 +231,7 @@ class messenger
// Messenger methods
//
function msg_email($log_session = false)
function msg_email()
{
global $config, $user;
@ -257,7 +257,7 @@ class messenger
{
foreach ($address_ary as $which_ary)
{
$$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? '"' . mail_encode($which_ary['name']) . '" <' . $which_ary['email'] . '>' : $which_ary['email']);
$$type .= (($$type != '') ? ', ' : '') . (($which_ary['name'] != '') ? '"' . mail_encode($which_ary['name'], $this->encoding) . '" <' . $which_ary['email'] . '>' : $which_ary['email']);
}
}
@ -296,7 +296,7 @@ class messenger
$mail_to = ($to == '') ? 'Undisclosed-Recipient:;' : $to;
$err_msg = '';
$result = ($config['smtp_delivery']) ? smtpmail($this->addresses, $this->subject, wordwrap($this->msg), $err_msg, $headers, $log_session) : @$config['email_function_name']($mail_to, $this->subject, implode("\n", preg_split("/\r?\n/", wordwrap($this->msg))), $headers);
$result = ($config['smtp_delivery']) ? smtpmail($this->addresses, $this->subject, wordwrap($this->msg), $err_msg, $this->encoding, $headers) : @$config['email_function_name']($mail_to, $this->subject, implode("\n", preg_split("/\r?\n/", wordwrap($this->msg))), $headers);
if (!$result)
{
@ -313,7 +313,7 @@ class messenger
'addresses' => $this->addresses,
'subject' => $this->subject,
'msg' => $this->msg,
'log_session' => $log_session,
'encoding' => $this->encoding,
'headers' => $headers)
);
}
@ -362,13 +362,13 @@ class messenger
if (!$this->jabber->Connect())
{
$this->error('JABBER', 'Could not connect to Jabber server');
trigger_error('Could not connect to Jabber server', E_USER_ERROR);
return false;
}
if (!$this->jabber->SendAuth())
{
$this->error('JABBER', 'Could not authorise on Jabber server');
trigger_error('Could not authorise on Jabber server', E_USER_ERROR);
return false;
}
$this->jabber->SendPresence(NULL, NULL, 'online');
@ -500,7 +500,7 @@ class queue
$err_msg = '';
$to = (!$to) ? 'Undisclosed-Recipient:;' : $to;
$result = ($config['smtp_delivery']) ? smtpmail($addresses, $subject, wordwrap($msg), $err_msg, $headers, $log_session) : @$config['email_function_name']($to, $subject, implode("\n", preg_split("/\r?\n/", wordwrap($msg))), $headers);
$result = ($config['smtp_delivery']) ? smtpmail($addresses, $subject, wordwrap($msg), $err_msg, $encoding, $headers) : @$config['email_function_name']($to, $subject, implode("\n", preg_split("/\r?\n/", wordwrap($msg))), $headers);
if (!$result)
{
@ -619,7 +619,7 @@ class queue
}
// Replacement or substitute for PHP's mail command
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log_session = false)
function smtpmail($addresses, $subject, $message, &$err_msg, $encoding, $headers = '')
{
global $config, $user;
@ -672,7 +672,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
// Build correct addresses for RCPT TO command and the client side display (TO, CC)
foreach ($addresses['to'] as $which_ary)
{
$mail_to[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
$mail_to[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name']), $encoding) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
$mail_rcpt['to'][] = '<' . trim($which_ary['email']) . '>';
}
@ -683,19 +683,12 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
foreach ($addresses['cc'] as $which_ary)
{
$mail_cc[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
$mail_cc[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name']), $encoding) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
$mail_rcpt['cc'][] = '<' . trim($which_ary['email']) . '>';
}
$smtp = new smtp_class;
$smtp->log_session = $log_session;
if ($smtp->log_session)
{
$smtp->session = 'Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port'] . "\r\n";
}
// Ok we have error checked as much as we can to this point let's get on
// it already.
if (!$smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20))
@ -815,26 +808,17 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
class smtp_class
{
var $server_response = '';
var $session = '';
var $socket = 0;
var $responses = array();
var $commands = array();
var $numeric_response_code = 0;
var $log_session = false;
// Send command to smtp server
function server_send($command, $sensitive_informations = false)
function server_send($command)
{
fputs($this->socket, $command . "\r\n");
if ($this->log_session && !$sensitive_informations)
{
$this->session .= "# $command\r\n";
}
else if ($this->log_session)
{
$this->session .= "# Ommitting sensitive Informations\r\n";
}
// We could put additional code here
}
// We use the line to give the support people an indication at which command the error occurred
@ -852,22 +836,12 @@ class smtp_class
}
$this->responses[] = substr(rtrim($this->server_response), 4);
$this->numeric_response_code = (int) substr($this->server_response, 0, 3);
if ($this->log_session)
{
$this->session .= $this->server_response;
}
}
if (!(substr($this->server_response, 0, 3) == $response))
{
$this->numeric_response_code = (int) substr($this->server_response, 0, 3);
return "Ran into problems sending Mail at <b>Line $line</b>. Response: $this->server_response";
if ($this->log_session)
{
$this->session .= $this->server_response;
}
}
return 0;
@ -875,23 +849,7 @@ class smtp_class
function close_session()
{
global $err_msg, $phpbb_root_path, $phpEx, $user;
fclose($this->socket);
if ($this->log_session)
{
if (!function_exists('add_log'))
{
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
$user->start();
$this->session .= $err_msg;
add_log('admin', 'LOG_MAIL_SESSION', str_replace("\r\n", '<br />', htmlspecialchars($this->session)));
$this->session = '';
}
}
// Log into server and get possible auth codes if neccessary
@ -904,11 +862,6 @@ class smtp_class
if ($default_auth_method == 'POP-BEFORE-SMTP' && $username && $password)
{
$result = $this->pop_before_smtp($hostname, $username, $password);
if ($this->log_session)
{
$this->session .= $result;
}
$username = $password = $default_auth_method = '';
}
@ -990,12 +943,6 @@ class smtp_class
{
$old_socket = $this->socket;
if ($this->log_session)
{
$this->session .= "\r\nAuthenticating with pop-before-smtp\r\n";
$this->session .= "Connecting to $hostname:110\r\n";
}
if (!$this->socket = fsockopen($hostname, 110, $errno, $errstr, 20))
{
$this->socket = $old_socket;
@ -1032,7 +979,7 @@ class smtp_class
}
$base64_method_plain = base64_encode("\0" . $username . "\0" . $password);
$this->server_send($base64_method_plain, true);
$this->server_send($base64_method_plain);
if ($err_msg = $this->server_parse('235', __LINE__))
{
return $err_msg;
@ -1049,13 +996,13 @@ class smtp_class
return ($this->numeric_response_code == 503) ? false : $err_msg;
}
$this->server_send(base64_encode($username), true);
$this->server_send(base64_encode($username));
if ($err_msg = $this->server_parse('334', __LINE__))
{
return $err_msg;
}
$this->server_send(base64_encode($password), true);
$this->server_send(base64_encode($password));
if ($err_msg = $this->server_parse('235', __LINE__))
{
return $err_msg;
@ -1079,7 +1026,7 @@ class smtp_class
$base64_method_cram_md5 = base64_encode($username . ' ' . $md5_digest);
$this->server_send($base64_method_cram_md5, true);
$this->server_send($base64_method_cram_md5);
if ($err_msg = $this->server_parse('235', __LINE__))
{
return $err_msg;
@ -1182,7 +1129,7 @@ class smtp_class
}
$base64_method_digest_md5 = base64_encode($input_string);
$this->server_send($base64_method_digest_md5, true);
$this->server_send($base64_method_digest_md5);
if ($err_msg = $this->server_parse('334', __LINE__))
{
return $err_msg;
@ -1202,9 +1149,9 @@ class smtp_class
// from php.net and modified. There is an alternative encoding method which
// may produce less output but it's questionable as to its worth in this
// scenario IMO
function mail_encode($str)
function mail_encode($str, $encoding)
{
if ($this->encoding == '')
if ($encoding == '')
{
return $str;
}

View file

@ -105,7 +105,7 @@ function format_display(&$message, &$signature, $uid, $siguid, $enable_html, $en
// If we allow users to disable display of emoticons we'll need an appropriate
// check and preg_replace here
$message = smilie_text($message, !$enbale_smilies);
$message = smilie_text($message, !$enable_smilies);
// Replace naughty words such as farty pants
$message = str_replace("\n", '<br />', censor_text($message));
@ -513,10 +513,6 @@ function create_thumbnail($source, $new_file, $mimetype)
return true;
}
//
// TODO
//
// DECODE TEXT -> This will/should be handled by bbcode.php eventually
function decode_text(&$message, $bbcode_uid = '')
{
@ -654,7 +650,7 @@ function posting_gen_inline_attachments($message_parser)
function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
{
global $auth, $user, $template;
global $auth, $user, $template, $topic_type;
$toggle = false;

View file

@ -713,7 +713,7 @@ class parse_message
$num_attachments = sizeof($this->attachment_data);
$this->filename_data['filecomment'] = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', request_var('filecomment', ''));
$this->filename_data['filename'] = ($_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : '';
$this->filename_data['filename'] = (isset($_FILES['fileupload']) && $_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : '';
$add_file = (isset($_POST['add_file']));
$delete_file = (isset($_POST['delete_file']));
@ -854,7 +854,7 @@ class parse_message
global $_FILES, $_POST;
$this->filename_data['filecomment'] = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', request_var('filecomment', ''));
$this->filename_data['filename'] = ($_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : '';
$this->filename_data['filename'] = (isset($_FILES['fileupload']) && $_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : '';
$this->attachment_data = (isset($_POST['attachment_data'])) ? $_POST['attachment_data'] : array();
@ -1000,11 +1000,11 @@ class fulltext_search
{
$text = str_replace($replace_synonym, $match_synonym, $text);
}
return $text;
}
function add(&$mode, &$post_id, &$message, &$subject)
function add($mode, $post_id, $message, $subject)
{
global $config, $db;
@ -1147,7 +1147,7 @@ class fulltext_search
// Run the cleanup infrequently, once per session cleanup
if ($config['search_last_gc'] < time() - $config['search_gc'])
{
// $this->search_tidy();
$this->search_tidy();
}
}
@ -1206,7 +1206,7 @@ class fulltext_search
// Remove words with no matches ... this is a potentially nasty query
$sql = 'SELECT w.word_id
FROM ( ' . SEARCH_WORD_TABLE . ' w
FROM ' . SEARCH_WORD_TABLE . ' w
LEFT JOIN ' . SEARCH_MATCH_TABLE . ' m ON w.word_id = m.word_id
AND m.word_id IS NULL
GROUP BY m.word_id';
@ -1227,6 +1227,8 @@ class fulltext_search
unset($sql_in);
}
$db->sql_freeresult($result);
set_config('search_last_gc', time());
}
}