diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-10-12 12:37:25 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-10-12 12:37:25 +0000 |
commit | 3d1731b7cc10657440546197e14640b9e41fab32 (patch) | |
tree | e1107a039a976cd7ff85e62d48ba35216181a3dc /phpBB/adm/admin_email.php | |
parent | 14928b2780c831ee123a908422cecceef9d50b81 (diff) | |
download | forums-3d1731b7cc10657440546197e14640b9e41fab32.tar forums-3d1731b7cc10657440546197e14640b9e41fab32.tar.gz forums-3d1731b7cc10657440546197e14640b9e41fab32.tar.bz2 forums-3d1731b7cc10657440546197e14640b9e41fab32.tar.xz forums-3d1731b7cc10657440546197e14640b9e41fab32.zip |
Mass email messenger updates, can mass email selected users
git-svn-id: file:///svn/phpbb/trunk@4580 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/adm/admin_email.php')
-rw-r--r-- | phpBB/adm/admin_email.php | 98 |
1 files changed, 47 insertions, 51 deletions
diff --git a/phpBB/adm/admin_email.php b/phpBB/adm/admin_email.php index e8006ea78f..43b530795b 100644 --- a/phpBB/adm/admin_email.php +++ b/phpBB/adm/admin_email.php @@ -36,39 +36,39 @@ $message = $subject = $group_id = ''; // 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); - // Error checking needs to go here ... if no subject and/or no message then skip // over the send and return to the form - $group_id = request_var('g', 0); - $subject = preg_replace('#&(\#[0-9]+;)#', '&\1', request_var('subject', '')); - $message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : ''; - $message = preg_replace('#&(\#[0-9]+;)#', '&\1', $message); + $group_id = request_var('g', 0); + $usernames = request_var('usernames', ''); + $subject = preg_replace('#&(\#[0-9]+;)#', '&\1', strtr(request_var('subject', ''), array_flip(get_html_translation_table(HTML_ENTITIES)))); + $message = preg_replace('#&(\#[0-9]+;)#', '&\1', strtr(request_var('message', ''), array_flip(get_html_translation_table(HTML_ENTITIES)))); $error = array(); - if ($subject == '') + if (!$subject) { $error[] = $user->lang['NO_EMAIL_SUBJECT']; } - if ($message == '') + if (!$message) { $error[] = $user->lang['NO_EMAIL_MESSAGE']; } if (!sizeof($error)) { - $sql = ($group_id) ? 'SELECT u.user_email, u.username, u.user_lang - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug - WHERE ug.group_id = $group_id - AND ug.user_pending <> 1 - AND u.user_id = ug.user_id - AND u.user_allow_massemail = 1" : - 'SELECT user_email - FROM ' . USERS_TABLE . ' - WHERE user_allow_massemail = 1'; + if ($usernames) + { + $usernames = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", explode("\n", $usernames))); + + $sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang + FROM ' . USERS_TABLE . ' + WHERE username IN (' . $usernames . ') + AND user_allow_massemail = 1'; + } + else + { + $sql = ($group_id) ? 'SELECT u.user_email, u.username, u.user_lang, u.user_jabber, u.user_notify_type FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> 1 AND u.user_id = ug.user_id AND u.user_allow_massemail = 1" : 'SELECT username, user_email, user_jabber, user_notify_type, user_lang FROM ' . USERS_TABLE . ' WHERE user_allow_massemail = 1'; + } $result = $db->sql_query($sql); if (!($row = $db->sql_fetchrow($result))) @@ -81,56 +81,48 @@ if (isset($_POST['submit'])) $email_list = array(); do { + $email_list[$row['user_lang']][$i]['method'] = $row['user_notify_type']; $email_list[$row['user_lang']][$i]['email'] = $row['user_email']; $email_list[$row['user_lang']][$i]['name'] = $row['username']; + $email_list[$row['user_lang']][$i]['jabber'] = $row['user_jabber']; $i++; } while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); + // Send the messages + include_once($phpbb_root_path . 'includes/functions_messenger.'.$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'] && phpversion() < '4.3') - { - // We are running on windows, force delivery to use our smtp functions since - // php's are broken by default - $config['smtp_delivery'] = 1; - $config['smtp_host'] = @ini_get('SMTP'); - } - - - include($phpbb_root_path . 'includes/emailer.'.$phpEx); - $emailer = new emailer(true); - - $extra_headers = 'X-AntiAbuse: Board servername - ' . $config['server_name'] . "\n"; - $extra_headers .= 'X-AntiAbuse: User_id - ' . $user->data['user_id'] . "\n"; - $extra_headers .= 'X-AntiAbuse: Username - ' . $user->data['username'] . "\n"; - $extra_headers .= 'X-AntiAbuse: User IP - ' . $user->ip . "\n"; + $messenger = new messenger(); foreach ($email_list as $lang => $to_ary) { foreach ($to_ary as $to) { - $emailer->template('admin_send_email', $lang); + $messenger->template('admin_send_email', $lang); - $emailer->subject($subject); - $emailer->headers($extra_headers); + $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); + $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); + $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); + $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); - $emailer->replyto($config['board_email']); - $emailer->to($to['email'], $to['name']); + $messenger->subject($subject); + $messenger->headers($extra_headers); - $emailer->assign_vars(array( + $messenger->replyto($config['board_email']); + $messenger->to($to['email'], $to['name']); + + $messenger->assign_vars(array( 'SITENAME' => $config['sitename'], 'CONTACT_EMAIL' => $config['board_contact'], 'MESSAGE' => $message) ); - $emailer->send(); - $emailer->reset(); + $messenger->send($to['method']); } } - $emailer->mail_queue->save(); + $messenger->queue->save(); unset($email_list); if ($group_id) @@ -182,7 +174,7 @@ adm_page_header($user->lang['MASS_EMAIL']); <p><?php echo $user->lang['MASS_EMAIL_EXPLAIN']; ?></p> -<form method="post" action="admin_email.<?php echo $phpEx.$SID; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> +<form method="post" action="<?php echo "admin_email.$phpEx.$SID"; ?>" name="email"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> <th colspan="2"><?php echo $user->lang['COMPOSE']; ?></th> </tr> @@ -201,16 +193,20 @@ adm_page_header($user->lang['MASS_EMAIL']); ?> <tr> - <td class="row1" align="right"><b><?php echo $user->lang['RECIPIENTS']; ?></b></td> - <td class="row2" align="left"><select name="g"><?php echo $select_list; ?></select></td> + <td class="row1" width="40%"><b><?php echo $user->lang['SEND_TO_GROUP']; ?>: </b></td> + <td class="row2"><select name="g"><?php echo $select_list; ?></select></td> + </tr> + <tr> + <td class="row1" valign="top"><b><?php echo $user->lang['SEND_TO_USERS']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['SEND_TO_USERS_EXPLAIN']; ?><br />[ <a href="" onclick="window.open('<?php echo "../memberlist.$phpEx$SID"; ?>&mode=searchuser&form=email&field=usernames', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;"><?php echo $user->lang['FIND_USERNAME']; ?></a> ]</span></td> + <td class="row2" align="left"><textarea name="usernames" rows="5" cols="40"><?php echo $usernames; ?></textarea></td> </tr> <tr> - <td class="row1" align="right"><b><?php echo $user->lang['SUBJECT']; ?></b></td> + <td class="row1"><b><?php echo $user->lang['SUBJECT']; ?>: </b></td> <td class="row2"><input class="post" type="text" name="subject" size="45" maxlength="100" tabindex="2" value="<?php echo $subject; ?>" /></td> </tr> <tr> - <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="10" cols="76" wrap="virtual" tabindex="3"><?php echo $message; ?></textarea></td> + <td class="row1" valign="top"><span class="gen"><b><?php echo $user->lang['MASS_MESSAGE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['MASS_MESSAGE_EXPLAIN']; ?></span></td> + <td class="row2"><textarea class="post" name="message" rows="10" cols="60" 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="btnmain" /></td> |