1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-07 23:16:13 +02:00

Fix and clean up a few things, add in error checking, fix header output (hopefully).

git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2591 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-05-17 21:42:27 +00:00
parent 95197ab48b
commit 694471feca
2 changed files with 72 additions and 63 deletions

View File

@ -33,7 +33,7 @@ if( !empty($setmodules) )
// Load default header // Load default header
// //
$no_page_header = TRUE; $no_page_header = TRUE;
$phpbb_root_path = "./../"; $phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx); require('./pagestart.' . $phpEx);
@ -49,84 +49,78 @@ $subject = '';
// //
// Do the job ... // Do the job ...
// //
if( isset($HTTP_POST_VARS['submit']) ) if ( isset($HTTP_POST_VARS['submit']) )
{ {
$subject = stripslashes(trim($HTTP_POST_VARS['subject']));
$message = stripslashes(trim($HTTP_POST_VARS['message']));
$error = FALSE;
$error_msg = '';
if ( empty($subject) )
{
$error = true;
$error_msg .= ( !empty($error_msg) ) ? '<br />' . $lang['Empty_subject'] : $lang['Empty_subject'];
}
if ( empty($message) )
{
$error = true;
$error_msg .= ( !empty($error_msg) ) ? '<br />' . $lang['Empty_message'] : $lang['Empty_message'];
}
$group_id = intval($HTTP_POST_VARS[POST_GROUPS_URL]); $group_id = intval($HTTP_POST_VARS[POST_GROUPS_URL]);
if( $group_id != -1 ) $sql = ( $group_id != -1 ) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE;
{ if ( !($result = $db->sql_query($sql)) )
$sql = "SELECT u.user_email
FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug
WHERE ug.group_id = $group_id
AND ug.user_pending <> " . TRUE . "
AND u.user_id = ug.user_id";
}
else
{
$sql = "SELECT user_email
FROM " . USERS_TABLE;
}
if( !($result = $db->sql_query($sql)) )
{ {
message_die(GENERAL_ERROR, 'Could not select group members', '', __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, 'Could not select group members', '', __LINE__, __FILE__, $sql);
} }
if ( $row = $db->sql_fetchrow($result) )
if( !$db->sql_numrows($result) )
{ {
// $bcc_list = '';
// Output a relevant GENERAL_MESSAGE about users/group do
// not existing {
// $bcc_list .= ( ( $bcc_list != '' ) ? ', ' : '' ) . $row['user_email'];
}
while ( $row = $db->sql_fetchrow($result) );
$db->sql_freeresult($result);
}
else
{
$message = ( $group_id != -1 ) ? $lang['Group_not_exist'] : $lang['No_such_user'];
$error = true;
$error_msg .= ( !empty($error_msg) ) ? '<br />' . $message : $message;
} }
$email_list = $db->sql_fetchrowset($g_result); if ( !$error )
$subject = stripslashes($HTTP_POST_VARS['subject']);
$message = stripslashes($HTTP_POST_VARS['message']);
//
// Error checking needs to go here ... if no subject and/or
// no message then skip over the send and return to the form
//
$error = FALSE;
if( !$error )
{ {
include($phpbb_root_path . 'includes/emailer.'.$phpEx); include($phpbb_root_path . 'includes/emailer.'.$phpEx);
// //
// Let's do some checking to make sure that mass mail functions // Let's do some checking to make sure that mass mail functions
// are working in win32 versions of php. // are working in win32 versions of php.
// //
if( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery'])
{ {
// We are running on windows, force delivery to use $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
// our smtp functions since php's are broken by default
// We are running on windows, force delivery to use our smtp functions
// since php's are broken by default
$board_config['smtp_delivery'] = 1; $board_config['smtp_delivery'] = 1;
$board_config['smtp_host'] = get_cfg_var('SMTP'); $board_config['smtp_host'] = @$ini_val('SMTP');
} }
$emailer = new emailer($board_config['smtp_delivery']); $emailer = new emailer($board_config['smtp_delivery']);
$email_headers = 'From: ' . $board_config['board_email'] . "\n"; $email_headers = 'Return-Path: ' . $userdata['board_email'] . "\r\nFrom: " . $board_config['board_email'] . "\r\n";
$email_headers .= "Bcc: $bcc_list\r\n";
$bcc_list = ''; $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\r\n";
for($i = 0; $i < count($email_list); $i++) $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\r\n";
{ $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\r\n";
$bcc_list .= ( ( $bcc_list != '' ) ? ', ' : '' ) . $email_list[$i]['user_email'];
}
$email_headers .= "Bcc: $bcc_list\n";
$email_headers .= 'Return-Path: ' . $userdata['board_email'] . "\n";
$email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\r\n"; $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\r\n";
$emailer->use_template('admin_send_email'); $emailer->use_template('admin_send_email');
@ -142,12 +136,21 @@ if( isset($HTTP_POST_VARS['submit']) )
$emailer->send(); $emailer->send();
$emailer->reset(); $emailer->reset();
$message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); message_die(GENERAL_MESSAGE, $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'));
message_die(GENERAL_MESSAGE, $message);
} }
} }
if ( $error )
{
$template->set_filenames(array(
'reg_header' => 'error_body.tpl')
);
$template->assign_vars(array(
'ERROR_MESSAGE' => $error_msg)
);
$template->assign_var_from_handle('ERROR_BOX', 'reg_header');
}
// //
// Initial selection // Initial selection
// //

View File

@ -3,7 +3,11 @@
<p>{L_EMAIL_EXPLAIN}</p> <p>{L_EMAIL_EXPLAIN}</p>
<form method="post" action="{S_USER_ACTION}"><table cellspacing="1" cellpadding="4" border="0" align="center" class="forumline"> <form method="post" action="{S_USER_ACTION}">
{ERROR_BOX}
<table cellspacing="1" cellpadding="4" border="0" align="center" class="forumline">
<tr> <tr>
<th class="thHead" colspan="2">{L_COMPOSE}</th> <th class="thHead" colspan="2">{L_COMPOSE}</th>
</tr> </tr>
@ -22,4 +26,6 @@
<tr> <tr>
<td class="catBottom" align="center" colspan="2"><input type="submit" value="{L_EMAIL}" name="submit" class="mainoption" /></td> <td class="catBottom" align="center" colspan="2"><input type="submit" value="{L_EMAIL}" name="submit" class="mainoption" /></td>
</tr> </tr>
</table></form> </table>
</form>