diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2003-06-01 11:29:29 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2003-06-01 11:29:29 +0000 |
commit | 0c101c3dd4939074d2851518d9c021509ba49d67 (patch) | |
tree | 7a3147f1e1daf63116c2db5c496c7331b2c47a4f /phpBB | |
parent | 0e96aa60c2cf94e72434f9ab91de70a3a0848ae8 (diff) | |
download | forums-0c101c3dd4939074d2851518d9c021509ba49d67.tar forums-0c101c3dd4939074d2851518d9c021509ba49d67.tar.gz forums-0c101c3dd4939074d2851518d9c021509ba49d67.tar.bz2 forums-0c101c3dd4939074d2851518d9c021509ba49d67.tar.xz forums-0c101c3dd4939074d2851518d9c021509ba49d67.zip |
some updates, email related.
git-svn-id: file:///svn/phpbb/trunk@4070 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/adm/admin_board.php | 4 | ||||
-rw-r--r-- | phpBB/adm/admin_email.php | 138 | ||||
-rwxr-xr-x | phpBB/includes/emailer.php | 8 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_basic.sql | 1 | ||||
-rw-r--r-- | phpBB/language/en/email/admin_send_email.txt | 2 | ||||
-rw-r--r-- | phpBB/language/en/lang_admin.php | 13 |
6 files changed, 91 insertions, 75 deletions
diff --git a/phpBB/adm/admin_board.php b/phpBB/adm/admin_board.php index 344ead2100..9ff1bb82e7 100644 --- a/phpBB/adm/admin_board.php +++ b/phpBB/adm/admin_board.php @@ -480,6 +480,10 @@ switch ($mode) <td class="row2"><input type="radio" name="board_email_form" value="1" <?php echo $board_email_form_yes; ?> /> <?php echo $user->lang['ENABLED']; ?> <input type="radio" name="board_email_form" value="0" <?php echo $board_email_form_no; ?> /> <?php echo $user->lang['DISABLED']; ?></td> </tr> <tr> + <td class="row1" width="50%"><?php echo $user->lang['EMAIL_PACKAGE_SIZE']; ?>: <br /><span class="gensmall"><?php echo $user->lang['EMAIL_PACKAGE_SIZE_EXPLAIN']; ?></span></td> + <td class="row2"><input class="post" type="text" size="5" maxlength="5" name="email_package_size" value="<?php echo $new['email_package_size']; ?>" /></td> + </tr> + <tr> <td class="row1" width="50%"><?php echo $user->lang['CONTACT_EMAIL']; ?>: <br /><span class="gensmall"><?php echo $user->lang['CONTACT_EMAIL_EXPLAIN']; ?></span></td> <td class="row2"><input class="post" type="text" size="25" maxlength="100" name="board_contact" value="<?php echo $new['board_contact']; ?>" /></td> </tr> 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> diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index 8deba01c4d..d08ca0f3a6 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -30,11 +30,13 @@ class emailer function emailer($use_queue = false) { + global $config; + $this->use_queue = $use_queue; if ($use_queue) { $this->queue = new Queue(); - $this->queue->init('emailer', 100); + $this->queue->init('emailer', $config['email_package_size']); } $this->reset(); } @@ -472,7 +474,7 @@ class Queue } //--TEMP - function queue_filled() + function is_queue_filled() { if (file_exists($this->cache_file)) { @@ -579,7 +581,7 @@ class Queue $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . time() . "' WHERE config_name = 'last_queue_run'"; - $db->sql_query(); + $db->sql_query($sql); } function save() diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index e8c02f1f8d..59152ebd62 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -83,6 +83,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_edite INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_sig','Thanks, The Management'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email','address@yourdomain.tld'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact','contact@yourdomain.tld'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size','50'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_delivery','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host',''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port','25'); diff --git a/phpBB/language/en/email/admin_send_email.txt b/phpBB/language/en/email/admin_send_email.txt index 234f61df52..a0da5e28ba 100644 --- a/phpBB/language/en/email/admin_send_email.txt +++ b/phpBB/language/en/email/admin_send_email.txt @@ -2,7 +2,7 @@ Charset: iso-8859-1 The following is an email sent to you by an administrator of "{SITENAME}". If this message is spam, contains abusive or other comments you find offensive please contact the webmaster of the board at the following address: -{BOARD_EMAIL} +{CONTACT_EMAIL} Include this full email (particularly the headers). diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index be7a027c34..61e7185f36 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -95,7 +95,7 @@ $lang = array_merge($lang, array( 'log_index_activate' => '<b>Activated inactive users</b><br />%s users', 'log_index_delete' => '<b>Deleted inactive users</b><br />%s', 'LOG_INDEX_REMIND' => '<b>Sent reminder emails to inactive users</b><br />%s', - 'log_mass_email' => '<b>Sent mass email</b><br />%s', + 'LOG_MASS_EMAIL' => '<b>Sent mass email</b><br />%s', 'log_delete_word' => '<b>Deleted word censor</b>', 'log_edit_word' => '<b>Edited word censor</b><br />%s', 'log_add_word' => '<b>Added word censor</b><br />%s', @@ -507,6 +507,8 @@ $lang = array_merge($lang, array( 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all.', 'BOARD_EMAIL_FORM' => 'Users send email via board', 'BOARD_EMAIL_FORM_EXPLAIN' => 'This function keeps email addresses completely private.', + 'EMAIL_PACKAGE_SIZE' => 'Email Package Size', + 'EMAIL_PACKAGE_SIZE_EXPLAIN' => 'This is the number of emails sent in one package.', 'ADMIN_EMAIL' => 'Return Email Address', 'ADMIN_EMAIL_EXPLAIN' => 'This will be used as the return address on all emails.', 'EMAIL_SIG' => 'Email Signature', @@ -839,11 +841,10 @@ $lang = array_merge($lang, array( 'WORD_REMOVED' => 'The selected word censor has been successfully removed', - 'Mass_email_explain' => 'Here you can email a message to either all of your users, or all users of a specific group. To do this, an email will be sent out to the administrative email address supplied, with a blind carbon copy sent to all recipients. If you are emailing a large group of people please be patient after submitting and do not stop the page halfway through. It is normal for a mass emailing to take a long time, you will be notified when the script has completed', - 'Compose' => 'Compose', - 'Recipients' => 'Recipients', - 'All_users' => 'All Users', - 'Email_successfull' => 'Your message has been sent', + 'MASS_EMAIL_EXPLAIN' => 'Here you can email a message to either all of your users, or all users of a specific group. To do this, an email will be sent out to the administrative email address supplied, with a blind carbon copy sent to all recipients. If you are emailing a large group of people please be patient after submitting and do not stop the page halfway through. It is normal for a mass emailing to take a long time, you will be notified when the script has completed', + 'COMPOSE' => 'Compose', + 'RECIPIENTS' => 'Recipients', + 'ALL_USERS' => 'All Users', 'RANKS_EXPLAIN' => 'Using this form you can add, edit, view and delete ranks. You can also create custom ranks which can be applied to a user via the user management facility', |