lessons are made for those gaining experience from them...

git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@4186 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-06-30 17:18:38 +00:00
parent 305eb6c34a
commit 08da796e8e
6 changed files with 28 additions and 43 deletions

View file

@ -213,9 +213,6 @@ class emailer
// Build header // 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: " . 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" : '');
$empty_to_header = ($to == '') ? TRUE : FALSE;
$to = ($to == '') ? (($board_config['sendmail_fix'] && !$this->use_smtp) ? ' ' : 'Undisclosed-recipients:;') : $to;
// Send message ... removed $this->encode() from subject for time being // Send message ... removed $this->encode() from subject for time being
if ( $this->use_smtp ) if ( $this->use_smtp )
{ {
@ -228,6 +225,9 @@ class emailer
} }
else else
{ {
$empty_to_header = ($to == '') ? TRUE : FALSE;
$to = ($to == '') ? (($board_config['sendmail_fix']) ? ' ' : 'Undisclosed-recipients:;') : $to;
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers); $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
if (!$result && !$board_config['sendmail_fix'] && $empty_to_header) if (!$result && !$board_config['sendmail_fix'] && $empty_to_header)

View file

@ -58,16 +58,7 @@ function clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
$entry = str_replace('*', ' ', $entry); $entry = str_replace('*', ' ', $entry);
// 'words' that consist of <3 or >20 characters are removed. // 'words' that consist of <3 or >20 characters are removed.
$entry = explode(' ', $entry); $entry = preg_replace('/[ ]([\S]{1,2}|[\S]{21,})[ ]/',' ', $entry);
for ($i = 0; $i < sizeof($entry); $i++)
{
$entry[$i] = trim($entry[$i]);
if ((strlen($entry[$i]) < 3) || (strlen($entry[$i]) > 20))
{
$entry[$i] = '';
}
}
$entry = implode(' ', $entry);
} }
if ( !empty($stopword_list) ) if ( !empty($stopword_list) )
@ -107,17 +98,8 @@ function split_words(&$entry, $mode = 'post')
return $split_entries[1]; return $split_entries[1];
*/ */
$split_entries = array(); // Trim 1+ spaces to one space and split this trimmed string into words.
$split = explode(' ', $entry); return explode(' ', trim(preg_replace('#\s+#', ' ', $entry)));
for ($i = 0; $i < count($split); $i++)
{
if (trim($split[$i]) != '')
{
$split_entries[] = trim($split[$i]);
}
}
return $split_entries;
} }
function add_search_words($mode, $post_id, $post_text, $post_title = '') function add_search_words($mode, $post_id, $post_text, $post_title = '')

View file

@ -150,13 +150,13 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
while(list(, $mail_to_address) = each($mail_to_array)) while(list(, $mail_to_address) = each($mail_to_array))
{ {
// Add an additional bit of error checking to the To field. // Add an additional bit of error checking to the To field.
$mail_to_address = trim($mail_to_address); $mail_to_address = ($mail_to_address == '') ? 'Undisclosed-recipients:;' : '<' . trim($mail_to_address) . '>';
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address)) if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address))
{ {
fputs($socket, "RCPT TO: <$mail_to_address>\r\n"); fputs($socket, "RCPT TO: $mail_to_address\r\n");
server_parse($socket, "250", __LINE__); server_parse($socket, "250", __LINE__);
} }
$to_header .= (($to_header != '') ? ', ' : '') . "<$mail_to_address>"; $to_header .= (($to_header != '') ? ', ' : '') . "$mail_to_address";
} }
// Ok now do the CC and BCC fields... // Ok now do the CC and BCC fields...

View file

@ -612,7 +612,7 @@ if ( isset($HTTP_POST_VARS['submit']) )
if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN ) if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
{ {
$sql = "SELECT user_email $sql = "SELECT user_email, user_lang
FROM " . USERS_TABLE . " FROM " . USERS_TABLE . "
WHERE user_level = " . ADMIN; WHERE user_level = " . ADMIN;
@ -621,22 +621,25 @@ if ( isset($HTTP_POST_VARS['submit']) )
message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql); 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)) while ($row = $db->sql_fetchrow($result))
{ {
$emailer->bcc(trim($row['user_email'])); $emailer->email_address(trim($row['user_email']));
$emailer->use_template("admin_activate", $row['user_lang']);
$emailer->set_subject($lang['New_account_subject']);
$emailer->assign_vars(array(
'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
);
$emailer->send();
$emailer->reset();
} }
$db->sql_freeresult($result);
$emailer->use_template("admin_activate", $board_config['default_lang']);
$emailer->set_subject($lang['New_account_subject']);
$emailer->assign_vars(array(
'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
);
$emailer->send();
$emailer->reset();
} }
$message = $message . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>'); $message = $message . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');

View file

@ -412,7 +412,7 @@ GO
ALTER TABLE [phpbb_confirm] WITH NOCHECK ADD ALTER TABLE [phpbb_confirm] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_confirm] PRIMARY KEY CLUSTERED CONSTRAINT [PK_phpbb_confirm] PRIMARY KEY CLUSTERED
( (
[session_id, confirm_id] [session_id],[confirm_id]
) ON [PRIMARY] ) ON [PRIMARY]
GO GO

View file

@ -499,7 +499,7 @@ switch ($row['config_value'])
case 'mssql': case 'mssql':
case 'mssql-odbc': case 'mssql-odbc':
$sql[] = 'CREATE TABLE [' . $table_prefix . 'confirm] ([confirm_id] [char] (32) NOT NULL , [session_id] [char] (32) NOT NULL , [code] [char] (6) NOT NULL ) ON [PRIMARY]'; $sql[] = 'CREATE TABLE [' . $table_prefix . 'confirm] ([confirm_id] [char] (32) NOT NULL , [session_id] [char] (32) NOT NULL , [code] [char] (6) NOT NULL ) ON [PRIMARY]';
$sql[] = 'ALTER TABLE [' . $table_prefix . 'confirm] WITH NOCHECK ADD CONSTRAINT [PK_' . $table_prefix . 'confirm] PRIMARY KEY CLUSTERED ( [session_id, confirm_id]) ON [PRIMARY]'; $sql[] = 'ALTER TABLE [' . $table_prefix . 'confirm] WITH NOCHECK ADD CONSTRAINT [PK_' . $table_prefix . 'confirm] PRIMARY KEY CLUSTERED ( [session_id],[confirm_id]) ON [PRIMARY]';
$sql[] = 'ALTER TABLE [' . $table_prefix . 'confirm] WITH NOCHECK ADD CONSTRAINT [DF_' . $table_prefix . 'confirm_confirm_id] DEFAULT (\'\') FOR [confirm_id], CONSTRAINT [DF_' . $table_prefix . 'confirm_session_id] DEFAULT (\'\') FOR [session_id], CONSTRAINT [DF_' . $table_prefix . 'confirm_code] DEFAULT (\'\') FOR [code]'; $sql[] = 'ALTER TABLE [' . $table_prefix . 'confirm] WITH NOCHECK ADD CONSTRAINT [DF_' . $table_prefix . 'confirm_confirm_id] DEFAULT (\'\') FOR [confirm_id], CONSTRAINT [DF_' . $table_prefix . 'confirm_session_id] DEFAULT (\'\') FOR [session_id], CONSTRAINT [DF_' . $table_prefix . 'confirm_code] DEFAULT (\'\') FOR [code]';
break; break;