diff options
Diffstat (limited to 'phpBB/adm/admin_email.php')
| -rw-r--r-- | phpBB/adm/admin_email.php | 138 |
1 files changed, 73 insertions, 65 deletions
diff --git a/phpBB/adm/admin_email.php b/phpBB/adm/admin_email.php index c2c614a644..2a1d0b38ca 100644 --- a/phpBB/adm/admin_email.php +++ b/phpBB/adm/admin_email.php @@ -21,13 +21,8 @@ if (!empty($setmodules)) { - if (!$auth->acl_get('a_email')) - { - return; - } - - $module['GENERAL']['MASS_EMAIL'] = basename(__FILE__) . $SID; - + $file = basename(__FILE__); + $module['GENERAL']['MASS_EMAIL'] = ($auth->acl_get('a_email')) ? "$file$SID" : ''; return; } @@ -43,52 +38,54 @@ if (!$auth->acl_get('a_email')) trigger_error($user->lang['NO_ADMIN']); } -// // Set some vars -// $message = ''; $subject = ''; -// // Do the job ... -// if (isset($_POST['submit'])) { - // // Increase maximum execution time in case of a lot of users, but don't complain about it if it isn't // allowed. - // @set_time_limit(1200); $group_id = intval($_POST['g']); - $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 ($group_id > 0) + { + $sql = 'SELECT u.user_email, u.username, u.user_lang + FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug + WHERE ug.group_id = $group_id + AND g.user_pending <> " . TRUE . " + AND u.user_id = ug.user_id"; + } + else + { + $sql = 'SELECT user_email FROM ' . USERS_TABLE; + } $result = $db->sql_query($sql); - if (!($email_list = $db->sql_fetchrowset($g_result))) + $subject = stripslashes(trim($_POST['subject'])); + $message = stripslashes(trim($_POST['message'])); + + if (!($row = $db->sql_fetchrow($result))) { - // // Output a relevant GENERAL_MESSAGE about users/group // not existing - // + trigger_error($user->lang['GROUP_DOES_NOT_EXIST']); } - $subject = stripslashes($_POST['subject']); - $message = stripslashes($_POST['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) + + if ($subject != '' && $message != '') { include($phpbb_root_path . 'includes/emailer.'.$phpEx); - // + // Let's do some checking to make sure that mass mail functions // are working in win32 versions of php. - // if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) { // We are running on windows, force delivery to use @@ -96,50 +93,60 @@ if (isset($_POST['submit'])) $config['smtp_delivery'] = 1; $config['smtp_host'] = get_cfg_var('SMTP'); } - $emailer = new emailer($config['smtp_delivery']); + $emailer = new emailer(true); - $email_headers = 'From: ' . $config['board_email'] . "\n"; + $extra_headers = 'X-AntiAbuse: Board servername - ' . $config['server_name'] . "\r\n"; + $extra_headers .= 'X-AntiAbuse: User_id - ' . $user->data['user_id'] . "\r\n"; + $extra_headers .= 'X-AntiAbuse: Username - ' . $user->data['username'] . "\r\n"; + $extra_headers .= 'X-AntiAbuse: User IP - ' . $user->ip . "\r\n"; - $bcc_list = ''; - for($i = 0; $i < count($email_list); $i++) + $email_list = array(); + $count = 0; + do { - $bcc_list .= (($bcc_list != '') ? ', ' : '') . $email_list[$i]['user_email']; - } - $email_headers .= "Bcc: $bcc_list\n"; + $email_list[$count]['email'] = $row['user_email']; + $email_list[$count]['name'] = $row['username']; + $email_list[$count]['lang'] = $row['user_lang']; + $count++; + } + while ($row = $db->sql_fetchrow($result)); + $db->sql_freeresult($result); + + foreach ($email_list as $addr) + { + $emailer->template('admin_send_email', $addr['lang']); - $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 - ' . $user_ip . "\n"; + $emailer->subject($subject); + $emailer->headers($extra_headers); - $emailer->use_template('admin_send_email'); - $emailer->email_address($config['board_email']); - $emailer->set_subject($subject); - $emailer->extra_headers($email_headers); + $emailer->replyto($config['board_email']); + $emailer->to($addr['email'], $addr['name']); - $emailer->assign_vars(array( - 'SITENAME' => $config['sitename'], - 'BOARD_EMAIL' => $config['board_email'], - 'MESSAGE' => $message) - ); - $emailer->send(); - $emailer->reset(); + $emailer->assign_vars(array( + 'SITENAME' => $config['sitename'], + 'CONTACT_EMAIL' => $config['board_contact'], + 'MESSAGE' => $message) + ); - message_die(MESSAGE, $user->lang['Email_sent']); + $emailer->send(); + $emailer->reset(); + } + + $emailer->queue->save(); + unset($email_list); + + add_log('admin', 'LOG_MASS_EMAIL'); + trigger_error($user->lang['EMAIL_SENT'], E_USER_NOTICE); } } -// // Initial selection -// - -$sql = "SELECT group_id, group_name - FROM ".GROUPS_TABLE; +$sql = 'SELECT group_id, group_name + FROM ' . GROUPS_TABLE; $result = $db->sql_query($sql); -$select_list = '<select name = "g"><option value = "-1">' . $user->lang['All_users'] . '</option>'; +$select_list = '<select name="g"><option value="-1">' . $user->lang['ALL_USERS'] . '</option>'; if ($row = $db->sql_fetchrow($result)) { do @@ -150,32 +157,33 @@ if ($row = $db->sql_fetchrow($result)) } $select_list .= '</select>'; -adm_page_header($user->lang['Mass_Email']); +adm_page_header($user->lang['MASS_EMAIL']); ?> -<h1><?php echo $user->lang['Mass_Email']; ?></h1> +<h1><?php echo $user->lang['MASS_EMAIL']; ?></h1> -<p><?php echo $user->lang['Mass_email_explain']; ?></p> +<p><?php echo $user->lang['MASS_EMAIL_EXPLAIN']; ?></p> -<form method="post" action="admin_mass_email.<?php echo $phpEx.$SID; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> +<form method="post" action="admin_email.<?php echo $phpEx.$SID; ?>"> +<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> - <th colspan="2"><?php echo $user->lang['Compose']; ?></th> + <th colspan="2"><?php echo $user->lang['COMPOSE']; ?></th> </tr> <tr> - <td class="row1" align="right"><b><?php echo $user->lang['Recipients']; ?></b></td> + <td class="row1" align="right"><b><?php echo $user->lang['RECIPIENTS']; ?></b></td> <td class="row2" align="left"><?php echo $select_list; ?></td> </tr> <tr> - <td class="row1" align="right"><b><?php echo $user->lang['Subject']; ?></b></td> + <td class="row1" align="right"><b><?php echo $user->lang['SUBJECT']; ?></b></td> <td class="row2"><span class="gen"><input type="text" name="subject" size="45" maxlength="100" tabindex="2" class="post" value="<?php echo $subject; ?>" /></span></td> </tr> <tr> - <td class="row1" align="right" valign="top"><span class="gen"><b><?php echo $user->lang['Message']; ?></b></span> + <td class="row1" align="right" valign="top"><span class="gen"><b><?php echo $user->lang['MESSAGE']; ?></b></span> <td class="row2"><textarea class="post" name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3"><?php echo $message; ?></textarea></td> </tr> <tr> - <td class="cat" colspan="2" align="center"><input type="submit" value="<?php echo $user->lang['Email']; ?>" name="submit" class="mainoption" /></td> + <td class="cat" colspan="2" align="center"><input type="submit" value="<?php echo $user->lang['EMAIL']; ?>" name="submit" class="mainoption" /></td> </tr> </table></form> |
