[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /*************************************************************************** 3 * admin_mass_email.php 4 * ------------------- 5 * begin : Thu May 31, 2001 6 * copyright : (C) 2001 The phpBB Group 7 * email : support@phpbb.com 8 * 9 * $Id: admin_mass_email.php 3966 2003-05-03 23:24:04Z acydburn $ 10 * 11 ****************************************************************************/ 12 13 /*************************************************************************** 14 * 15 * This program is free software; you can redistribute it and/or modify 16 * it under the terms of the GNU General Public License as published by 17 * the Free Software Foundation; either version 2 of the License, or 18 * (at your option) any later version. 19 * 20 ***************************************************************************/ 21 22 define('IN_PHPBB', 1); 23 24 if( !empty($setmodules) ) 25 { 26 $filename = basename(__FILE__); 27 $module['General']['Mass_Email'] = $filename; 28 29 return; 30 } 31 32 // 33 // Load default header 34 // 35 $no_page_header = TRUE; 36 $phpbb_root_path = './../'; 37 require ($phpbb_root_path . 'extension.inc'); 38 require('./pagestart.' . $phpEx); 39 40 // 41 // Increase maximum execution time in case of a lot of users, but don't complain about it if it isn't 42 // allowed. 43 // 44 @set_time_limit(1200); 45 46 $message = ''; 47 $subject = ''; 48 49 // 50 // Do the job ... 51 // 52 if ( isset($HTTP_POST_VARS['submit']) ) 53 { 54 $subject = stripslashes(trim($HTTP_POST_VARS['subject'])); 55 $message = stripslashes(trim($HTTP_POST_VARS['message'])); 56 57 $error = FALSE; 58 $error_msg = ''; 59 60 if ( empty($subject) ) 61 { 62 $error = true; 63 $error_msg .= ( !empty($error_msg) ) ? '<br />' . $lang['Empty_subject'] : $lang['Empty_subject']; 64 } 65 66 if ( empty($message) ) 67 { 68 $error = true; 69 $error_msg .= ( !empty($error_msg) ) ? '<br />' . $lang['Empty_message'] : $lang['Empty_message']; 70 } 71 72 $group_id = intval($HTTP_POST_VARS[POST_GROUPS_URL]); 73 74 $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; 75 if ( !($result = $db->sql_query($sql)) ) 76 { 77 message_die(GENERAL_ERROR, 'Could not select group members', '', __LINE__, __FILE__, $sql); 78 } 79 80 if ( $row = $db->sql_fetchrow($result) ) 81 { 82 $bcc_list = array(); 83 do 84 { 85 $bcc_list[] = $row['user_email']; 86 } 87 while ( $row = $db->sql_fetchrow($result) ); 88 89 $db->sql_freeresult($result); 90 } 91 else 92 { 93 $message = ( $group_id != -1 ) ? $lang['Group_not_exist'] : $lang['No_such_user']; 94 95 $error = true; 96 $error_msg .= ( !empty($error_msg) ) ? '<br />' . $message : $message; 97 } 98 99 if ( !$error ) 100 { 101 include($phpbb_root_path . 'includes/emailer.'.$phpEx); 102 103 // 104 // Let's do some checking to make sure that mass mail functions 105 // are working in win32 versions of php. 106 // 107 if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) 108 { 109 $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; 110 111 // We are running on windows, force delivery to use our smtp functions 112 // since php's are broken by default 113 $board_config['smtp_delivery'] = 1; 114 $board_config['smtp_host'] = @$ini_val('SMTP'); 115 } 116 117 $emailer = new emailer($board_config['smtp_delivery']); 118 119 $emailer->from($board_config['board_email']); 120 $emailer->replyto($board_config['board_email']); 121 122 for ($i = 0; $i < count($bcc_list); $i++) 123 { 124 $emailer->bcc($bcc_list[$i]); 125 } 126 127 $email_headers = 'X-AntiAbuse: Board servername - ' . $board_config['server_name'] . "\n"; 128 $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n"; 129 $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n"; 130 $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n"; 131 132 $emailer->use_template('admin_send_email'); 133 $emailer->email_address($board_config['board_email']); 134 $emailer->set_subject($subject); 135 $emailer->extra_headers($email_headers); 136 137 $emailer->assign_vars(array( 138 'SITENAME' => $board_config['sitename'], 139 'BOARD_EMAIL' => $board_config['board_email'], 140 'MESSAGE' => $message) 141 ); 142 $emailer->send(); 143 $emailer->reset(); 144 145 message_die(GENERAL_MESSAGE, $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>')); 146 } 147 } 148 149 if ( $error ) 150 { 151 $template->set_filenames(array( 152 'reg_header' => 'error_body.tpl') 153 ); 154 $template->assign_vars(array( 155 'ERROR_MESSAGE' => $error_msg) 156 ); 157 $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); 158 } 159 160 // 161 // Initial selection 162 // 163 164 $sql = "SELECT group_id, group_name 165 FROM ".GROUPS_TABLE . " 166 WHERE group_single_user <> 1"; 167 if ( !($result = $db->sql_query($sql)) ) 168 { 169 message_die(GENERAL_ERROR, 'Could not obtain list of groups', '', __LINE__, __FILE__, $sql); 170 } 171 172 $select_list = '<select name = "' . POST_GROUPS_URL . '"><option value = "-1">' . $lang['All_users'] . '</option>'; 173 if ( $row = $db->sql_fetchrow($result) ) 174 { 175 do 176 { 177 $select_list .= '<option value = "' . $row['group_id'] . '">' . $row['group_name'] . '</option>'; 178 } 179 while ( $row = $db->sql_fetchrow($result) ); 180 } 181 $select_list .= '</select>'; 182 183 // 184 // Generate page 185 // 186 include('./page_header_admin.'.$phpEx); 187 188 $template->set_filenames(array( 189 'body' => 'admin/user_email_body.tpl') 190 ); 191 192 $template->assign_vars(array( 193 'MESSAGE' => $message, 194 'SUBJECT' => $subject, 195 196 'L_EMAIL_TITLE' => $lang['Email'], 197 'L_EMAIL_EXPLAIN' => $lang['Mass_email_explain'], 198 'L_COMPOSE' => $lang['Compose'], 199 'L_RECIPIENTS' => $lang['Recipients'], 200 'L_EMAIL_SUBJECT' => $lang['Subject'], 201 'L_EMAIL_MSG' => $lang['Message'], 202 'L_EMAIL' => $lang['Email'], 203 'L_NOTICE' => $notice, 204 205 'S_USER_ACTION' => append_sid('admin_mass_email.'.$phpEx), 206 'S_GROUP_SELECT' => $select_list) 207 ); 208 209 $template->pparse('body'); 210 211 include('./page_footer_admin.'.$phpEx); 212 213 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Jan 14 19:21:40 2013 | Cross-referenced by PHPXref 0.7.1 |