function notification($sender_id, $recipient_id, $recipient_email, $email_subject, $email_text, $use_bcc = false, $pm_subject = '', $recipient_username = '', $recipient_lang = '', $emty_email_template = false) { global $db, $config, $user, $lang; require IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $recipient_lang = empty($recipient_lang) ? $config['default_lang'] : $recipient_lang; // 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 our smtp functions since php's are broken by default $config['smtp_delivery'] = 1; $config['smtp_host'] = @ini_get('SMTP'); } $emailer = new emailer(); $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name'])); $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']); $emailer->headers('X-AntiAbuse: User IP - ' . $user->ip); if ($use_bcc) { $emailer->to($config['board_email']); $emailer->bcc($recipient_email); } else { $emailer->to($recipient_email); } $emailer->set_subject($email_subject); if ($emty_email_template) { $emailer->use_template('admin_send_email', $recipient_lang); $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'MESSAGE' => $email_text)); } else { $server_url = create_server_url(); $privmsg_url = $server_url . CMS_PAGE_PRIVMSG; $recipient_username = empty($recipient_username) ? $lang['User'] : $recipient_username; $email_sig = create_signature($config['board_email_sig']); $emailer->use_template('privmsg_notify', $recipient_lang); $emailer->assign_vars(array('USERNAME' => $recipient_username, 'SITENAME' => $config['sitename'], 'EMAIL_SIG' => $email_sig, 'FROM' => $user->data['username'], 'DATE' => create_date($config['default_dateformat'], time(), $config['board_timezone']), 'SUBJECT' => $pm_subject, 'PRIV_MSG_TEXT' => $email_text, 'FROM_USERNAME' => $user->data['username'], 'U_INBOX' => $privmsg_url . '?folder=inbox')); } $emailer->send(); $emailer->reset(); return true; }
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $board_config, $lang, $db, $phpbb_root_path, $phpEx; global $userdata, $user_ip; $current_time = time(); if ($mode != 'delete') { if ($mode == 'reply') { $sql = "SELECT ban_userid \r\n\t\t\t\tFROM " . BANLIST_TABLE; if (!($result = $db->sql_query($sql, false, true))) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql); } $user_id_sql = ''; while ($row = $db->sql_fetchrow($result)) { if (isset($row['ban_userid']) && !empty($row['ban_userid'])) { $user_id_sql .= ', ' . $row['ban_userid']; } } $sql = "SELECT u.user_id, u.user_email, u.user_lang \r\n\t\t\t\tFROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u \r\n\t\t\t\tWHERE tw.topic_id = {$topic_id} \r\n\t\t\t\t\tAND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") \r\n\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " \r\n\t\t\t\t\tAND u.user_id = tw.user_id"; if (!($result = $db->sql_query($sql))) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $sql); } $update_watched_sql = ''; $bcc_list_ary = array(); if ($row = $db->sql_fetchrow($result)) { // Sixty second limit @set_time_limit(60); do { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id']; } while ($row = $db->sql_fetchrow($result)); // // 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')) && !$board_config['smtp_delivery']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // 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_host'] = @$ini_val('SMTP'); } if (sizeof($bcc_list_ary)) { include $phpbb_root_path . 'includes/emailer.' . $phpEx; $emailer = new emailer($board_config['smtp_delivery']); $script_name = preg_replace('/^\\/?(.*?)\\/?$/', '\\1', trim($board_config['script_path'])); $script_name = $script_name != '' ? $script_name . '/viewtopic.' . $phpEx : 'viewtopic.' . $phpEx; $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title); @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('topic_notify', $user_lang); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); // This is a nasty kludge to remove the username var ... till (if?) // translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); $emailer->assign_vars(array('EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'SITENAME' => $board_config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "={$post_id}#{$post_id}", 'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "={$topic_id}&unwatch=topic")); $emailer->send(); $emailer->reset(); } } } $db->sql_freeresult($result); if ($update_watched_sql != '') { $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\r\n\t\t\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\t\t\tAND user_id IN ({$update_watched_sql})"; $db->sql_query($sql); } } $sql = "SELECT topic_id \r\n\t\t\tFROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\tAND user_id = " . $userdata['user_id']; if (!($result = $db->sql_query($sql))) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if (!$notify_user && !empty($row['topic_id'])) { $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\tWHERE topic_id = {$topic_id}\r\n\t\t\t\t\tAND user_id = " . $userdata['user_id']; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not delete topic watch information', '', __LINE__, __FILE__, $sql); } } else { if ($notify_user && empty($row['topic_id'])) { $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)\r\n\t\t\t\tVALUES (" . $userdata['user_id'] . ", {$topic_id}, 0)"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Could not insert topic watch information', '', __LINE__, __FILE__, $sql); } } } } $db->clear_cache('posts_'); }
// // 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')) && !$board_config['smtp_delivery']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // 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_host'] = @$ini_val('SMTP'); } $emailer = new emailer($board_config['smtp_delivery']); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } $email_headers = 'X-AntiAbuse: Board servername - ' . $board_config['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) . "\n"; $emailer->use_template('admin_send_email'); $emailer->email_address($board_config['board_email']); $emailer->set_subject($subject); $emailer->extra_headers($email_headers); $emailer->assign_vars(array('SITENAME' => $board_config['sitename'], 'BOARD_EMAIL' => $board_config['board_email'], 'MESSAGE' => $message)); $emailer->send(); $emailer->reset(); message_die(GENERAL_MESSAGE, $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.{$phpEx}?pane=right") . '">', '</a>')); } }
/** * Send user notifications on new topic or reply */ function send_notifications($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $config, $lang, $db, $user; global $bbcode; $current_time = time(); include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; if ($mode != 'delete') { if ($mode == 'reply') { // Look for users with notification enabled $sql = "SELECT u.user_id, u.user_email, u.user_lang, u.username, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . TOPICS_WATCH_TABLE . " tw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE tw.topic_id = " . $topic_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('tw.user_id', $this->exclude_users, true, true) . "\n\t\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND u.user_id = tw.user_id\n\t\t\t\t\t\tAND u.user_active = 1"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!in_array($row['user_id'], $this->notify_userid)) { if ($row['user_email'] != '') { $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']); } $this->notify_userid[] = $row['user_id']; $this->notify_forum_name = $row['forum_name']; } } $db->sql_freeresult($result); } if ($mode == 'newtopic' || $mode == 'reply') { // Reply or New Topic forum notification $sql = "SELECT u.user_id, u.user_email, u.user_lang, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . FORUMS_WATCH_TABLE . " fw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE fw.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('fw.user_id', array_merge($this->exclude_users, $this->notify_userid), true, true) . "\n\t\t\t\t\t\tAND fw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND f.forum_notify = '1'\n\t\t\t\t\t\tAND u.user_id = fw.user_id\n\t\t\t\t\t\tAND u.user_active = 1"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!in_array($row['user_id'], $this->notify_userid)) { if ($row['user_email'] != '') { $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']); } $this->notify_userid[] = $row['user_id']; $this->notify_forum_name = $row['forum_name']; } } $db->sql_freeresult($result); } // Users array built, so start sending notifications if (sizeof($this->notify_userdata) > 0) { include_once IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); $server_url = create_server_url(); $topic_title = unprepare_message($topic_title); $topic_title = censor_text($topic_title); $post_text = unprepare_message($post_data['message']); $post_text = censor_text($post_text); if (!empty($config['html_email'])) { $bbcode->allow_bbcode = !empty($config['allow_bbcode']) ? $config['allow_bbcode'] : false; $bbcode->allow_html = !empty($config['allow_html']) ? $config['allow_html'] : false; $bbcode->allow_smilies = !empty($config['allow_smilies']) ? $config['allow_smilies'] : false; $post_text = $bbcode->parse($post_text); } else { $post_text = $bbcode->plain_message($post_text, ''); } for ($i = 0; $i < sizeof($this->notify_userdata); $i++) { $emailer->use_template('topic_notify', $this->notify_userdata[$i]['user_lang']); $emailer->bcc($this->notify_userdata[$i]['user_email']); // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); // This is a nasty kludge to remove the username var ... till (if?) translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', $this->notify_userdata[$i]['username'], $emailer->msg); if ($config['url_rw'] == '1') { $topic_url = $server_url . str_replace('--', '-', make_url_friendly($topic_title) . '-vp' . $post_id . '.html#p' . $post_id); } else { $topic_url = $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id . '#p' . $post_id; } $email_sig = create_signature($config['board_email_sig']); $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'TOPIC_TITLE' => $topic_title, 'POST_TEXT' => $post_text, 'POSTERNAME' => $post_data['username'], 'FORUM_NAME' => $this->notify_forum_name, 'ROOT' => $server_url, 'U_TOPIC' => $topic_url, 'U_STOP_WATCHING_TOPIC' => $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id . '&unwatch=topic')); $emailer->send(); $emailer->reset(); } } // Emails sent, so set users were notified $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE topic_id = " . $topic_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true); $db->sql_query($sql); $sql = "UPDATE " . FORUMS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE forum_id = " . $forum_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true); $db->sql_query($sql); // Delete notification for poster if present, or re-activate it if requested if (!$notify_user && !empty($row['topic_id'])) { $this->delete_topic_watch($user->data['user_id'], $topic_id); } elseif ($notify_user && empty($row['topic_id'])) { $this->delete_topic_watch($user->data['user_id'], $topic_id); $this->insert_topic_watch($user->data['user_id'], $topic_id, $forum_id, TOPIC_WATCH_UN_NOTIFIED); } } }
function send_mail($type, $from_userdata, &$to_user_ids, &$recips, $subject, $message, $time = 0, $copy = true, $parsed_values = array()) { global $db, $board_config, $lang, $phpbb_root_path, $phpEx, $userdata; // fix some parameters $subject = trim($subject); $message = trim($message); // check we have a message and a subject if (empty($subject)) { return 'Empty_subject'; } if (empty($message)) { return 'Empty_message'; } // recipient is not an array, so make one if (!is_array($to_user_ids) && !empty($to_user_ids)) { $to_user_ids = array(intval($to_user_ids)); } // check if recipients if (empty($to_user_ids)) { return 'No_to_user'; } $s_to_user_ids = implode(', ', $to_user_ids); // censor words $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); // process some cleaning $subject = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($subject)) : unprepare_message($subject); $message = count($orig_word) ? preg_replace($orig_word, $replacement_word, unprepare_message($message)) : unprepare_message($message); // clean any bbcode_uid $subject = preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $subject); $message = preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $message); // clean HTML $subject = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $subject); $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $message); // from_user_id can be 0 for sys message (sent by the board) if (empty($from_userdata)) { $from_userdata['user_id'] = 0; $from_userdata['user_level'] = ADMIN; $from_userdata['username'] = $board_config['sitename']; } $from_user_id = intval($from_userdata['user_id']); // get the recipients $sql_where = "user_email <> '' AND user_email IS NOT NULL"; // this will require enhancement for the pcp ignore/friend list if (!$copy) { $sql_where .= " AND user_id <> " . intval($from_userdata['user_id']); } if ($userdata['user_level'] != ADMIN) { $sql_where .= " AND (user_viewemail = 1 OR user_id = " . intval($userdata['user_id']) . ")"; } // // Make sure user wánts the mail // $notify_sql = ''; $sql_notify = ''; if ($type == 'privmsg_notify') { $sql_notify = ', user_notify_pm'; $notify_sql = 'AND user_notify_pm != 0'; } // read the mail recipients $sql = "SELECT user_id, user_email, user_lang, username" . $sql_notify . "\n FROM " . USERS_TABLE . "\n WHERE user_id IN ({$s_to_user_ids})\n {$notify_sql}\n AND user_id NOT IN (0, " . ANONYMOUS . ")\n AND {$sql_where}"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not read recipient mail list', '', __LINE__, __FILE__, $sql); } $count = 0; $bcc_list_ary = array(); while ($row = $db->sql_fetchrow($result)) { $count++; $bcc_list_ary[$row['user_lang']][] = array('user_id' => $row['user_id'], 'mail' => $row['user_email'], 'username' => $row['username']); } if ($count > 0) { // read the message recipients $msg_to = ''; if (!empty($recips)) { for ($i = 0; $i < count($recips); $i++) { $username = isset($recips[$i]['privmsg_to_username']) ? $recips[$i]['privmsg_to_username'] : $recips[$i]['username']; if (!empty($username)) { $msg_to .= (empty($msg_to) ? '' : ', ') . $username; } } } // // 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')) && !$board_config['smtp_delivery']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // 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_host'] = @$ini_val('SMTP'); } // init the mailer $emailer = new emailer($board_config['smtp_delivery']); // init server vars $server_name = trim($board_config['server_name']); $server_protocol = $board_config['cookie_secure'] ? 'https://' : 'http://'; $server_port = $board_config['server_port'] != 80 ? ':' . trim($board_config['server_port']) . '/' : '/'; // sender script $script_path = preg_replace('/^\\/?(.*?)\\/?$/', '\\1', trim($board_config['script_path'])); $script_path = !empty($script_name) ? $server_protocol . $server_name . $server_port . $script_name . '/' : $server_protocol . $server_name . $server_port; // start the emailer data $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); // choose template switch ($type) { case 'privmsg_notify': $tpl = 'privmsg_notify'; $mail_subject = _lang('Notification_subject'); break; case 'save_to_mail': $tpl = 'admin_send_email'; $mail_subject = _lang('Save_to_mail_subject') . $subject; break; default: $tpl = 'admin_send_email'; $mail_subject = $subject; break; } // send message (coming partially from privmsgs.php) : one per lang @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { if ($count == 1) { $emailer->email_address($bcc_list[0]['mail']); } else { // affect users mail for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]['mail']); } } // remove {USERNAME} from the template if more than one recipient if ($count > 0) { $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); } // build message $msg = _lang('Subject') . ': ' . $subject; $msg .= "\n" . _lang('From') . ': ' . $from_userdata['username']; if (!empty($msg_to)) { $msg .= "\n" . _lang('To') . ': ' . $msg_to; } if (!empty($time)) { $dformat = $board_config['default_dateformat']; $dtz = $board_config['board_timezone']; if (count($to_user_ids) == 1) { $dformat = $userdata['user_dateformat']; $dtz = $userdata['user_timezone']; } $post_date = create_date($dformat, $time, $dtz); $msg .= "\n" . _lang('Date') . ': ' . $post_date; } $msg .= "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" . $message; // generic values $parsed_values['SITENAME'] = $board_config['sitename']; $parsed_values['EMAIL_SIG'] = !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : ''; $parsed_values['MESSAGE'] = $msg; $parsed_values['FROM'] = $userdata['username']; $emailer->use_template($tpl, $user_lang); $emailer->set_subject($mail_subject); $emailer->assign_vars($parsed_values); // send $emailer->send(); $emailer->reset(); } } }
if (isset($_POST['approve'])) { $result = $db->sql_query($sql_select); $bcc_list = array(); while ($row = $db->sql_fetchrow($result)) { $bcc_list[] = $row['user_email']; } // Get the group name $group_sql = "SELECT group_name\n\t\t\t\t\t\t\tFROM " . GROUPS_TABLE . "\n\t\t\t\t\t\t\tWHERE group_id = '" . $group_id . "'"; $result = $db->sql_query($group_sql); $group_name_row = $db->sql_fetchrow($result); $group_name = $group_name_row['group_name']; include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); foreach ($bcc_list as $bcc_address) { if (!empty($bcc_address)) { $emailer->bcc($bcc_address); } } $emailer->use_template('group_approved'); $emailer->set_subject($lang['Group_approved']); $email_sig = create_signature($config['board_email_sig']); $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'GROUP_NAME' => $group_name, 'EMAIL_SIG' => $email_sig, 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . '=' . $group_id)); $emailer->send(); $emailer->reset(); } } } } // END approve or deny } else { message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $config, $lang, $userdata, $user_ip; $current_time = time(); if ($mode == 'delete') { $delete_sql = (!$post_data['first_post'] && !$post_data['last_post']) ? sql_filter(' AND user_id = ? ', $userdata['user_id']) : ''; $sql = 'DELETE FROM _forum_topics_fav WHERE topic_id = ?' . $delete_sql; sql_query(sql_filter($sql, $topic_id)); } else { if ($mode == 'reply') { $sql = 'SELECT ban_userid FROM _banlist'; $result = sql_rowset($sql); $user_id_sql = ''; foreach ($result as $row) { if (isset($row['ban_userid']) && !empty($row['ban_userid'])) { $user_id_sql .= ', ' . $row['ban_userid']; } } $update_watched_sql = ''; $bcc_list_ary = w(); $usr_list_ary = w(); $sql = 'SELECT DISTINCT u.user_id, u.user_email, u.user_lang FROM _forum_topics_fav tw INNER JOIN _members u ON tw.user_id = u.user_id INNER JOIN _members_group ug ON tw.user_id = ug.user_id LEFT OUTER JOIN _auth_access aa ON ug.group_id = aa.group_id, _forums f WHERE tw.topic_id = ? AND tw.user_id NOT IN (??, ??, ??) AND tw.notify_status = ? AND f.forum_id = ? AND u.user_active = 1 AND ( (aa.forum_id = ? AND aa.auth_read = 1) OR f.auth_read <= ? OR (u.user_level = ? AND f.auth_read = ?) OR u.user_level = ? )'; if ($result = sql_rowset(sql_filter($sql, $topic_id, $userdata['user_id'], GUEST, $user_id_sql, TOPIC_WATCH_UN_NOTIFIED, $forum_id, $forum_id, AUTH_REG, USER_MOD, AUTH_MOD, USER_ADMIN))) { @set_time_limit(60); foreach ($result as $row) { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id']; } if (sizeof($bcc_list_ary)) { $emailer = new emailer(); $server_name = trim($config['server_name']); $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://'; $post_url = $server_protocol . $server_name . s_link('post', $post_id) . "#$post_id"; $emailer->from($config['board_email']); $emailer->replyto($config['board_email']); $topic_title = unprepare_message($topic_title); @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('topic_notify', $user_lang); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); // This is a nasty kludge to remove the username var ... till (if?) // translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); $emailer->assign_vars(array( 'EMAIL_SIG' => '', 'SITENAME' => $config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => $post_url, 'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $script_name . '&' . POST_TOPIC_URL . "=$topic_id&unwatch=topic") ); $emailer->send(); $emailer->reset(); } } } if ($update_watched_sql != '') { $sql = 'UPDATE _forum_topics_fav SET notify_status = ? WHERE topic_id = ? AND user_id IN (??)'; sql_query(sql_filter($sql, TOPIC_WATCH_NOTIFIED, $topic_id, $update_watched_sql)); } } $sql = 'SELECT topic_id FROM _forum_topics_fav WHERE topic_id = ? AND user_id = ?'; if ($row = sql_fieldrow(sql_filter($sql, $topic_id, $userdata['user_id']))) { if (!$notify_user && !empty($row['topic_id'])) { $sql = 'DELETE FROM _forum_topics_fav WHERE topic_id = ? AND user_id = ?'; sql_query(sql_filter($sql, $topic_id, $userdata['user_id'])); } else if ($notify_user && empty($row['topic_id'])) { $sql = "INSERT INTO _forum_topics_fav (user_id, topic_id, notify_status) VALUES (" . $userdata['user_id'] . ", $topic_id, 0)"; sql_query($sql); } } } }
function album_comment_notify($pic_id) { global $db, $config, $user, $lang, $album_config; // One row SQL for caching purpose... $sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid <> 0 ORDER BY ban_userid ASC"; $result = $db->sql_query($sql, 0, 'ban_', USERS_CACHE_FOLDER); $user_id_sql = ''; while ($row = $db->sql_fetchrow($result)) { if (isset($row['ban_userid']) && !empty($row['ban_userid'])) { $user_id_sql .= ', ' . $row['ban_userid']; } } $sql = "SELECT u.user_id, u.user_email, u.user_lang, p.pic_title\n\t\t\t\tFROM " . ALBUM_COMMENT_WATCH_TABLE . " cw, " . USERS_TABLE . " u\n\t\t\t\tLEFT JOIN " . ALBUM_TABLE . " AS p ON p.pic_id = {$pic_id}\n\t\t\t\tWHERE cw.pic_id = {$pic_id}\n\t\t\t\t\tAND cw.user_id NOT IN (" . $user->data['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")\n\t\t\t\t\tAND cw.notify_status = " . COMMENT_WATCH_UN_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = cw.user_id"; $result = $db->sql_query($sql); $bcc_list_ary = array(); if ($row = $db->sql_fetchrow($result)) { $pic_title = $row['pic_title']; // Sixty second limit @set_time_limit(60); do { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id']; } while ($row = $db->sql_fetchrow($result)); // // 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']) { $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var'; // 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_val('SMTP'); } if (sizeof($bcc_list_ary)) { include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); $server_url = create_server_url(); $album_showpage_url = $server_url . 'album_showpage.' . PHP_EXT; @reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('album_comment_notify', $user_lang); for ($i = 0; $i < sizeof($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Comment_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Pic_comment_notification']); // This is a nasty kludge to remove the username var ... till translators update their templates $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg); $email_sig = create_signature($config['board_email_sig']); $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'PIC_TITLE' => $pic_title, 'U_PIC' => $album_showpage_url . '?pic_id=' . $pic_id, 'U_STOP_WATCHING_COMMENT' => $album_showpage_url . '?pic_id=' . $pic_id . '&unwatch=comment')); $emailer->send(); $emailer->reset(); } } } $db->sql_freeresult($result); if ($update_watched_sql != '') { $sql = "UPDATE " . ALBUM_COMMENT_WATCH_TABLE . "\n\t\t\tSET notify_status = " . COMMENT_WATCH_NOTIFIED . "\n\t\t\tWHERE pic_id = {$pic_id}\n\t\t\t\tAND user_id IN ({$update_watched_sql})"; $db->sql_query($sql); } }
if (!$error) { update_flood_time_email(); include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT; $emailer = new emailer(); $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name'])); $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']); $emailer->headers('X-AntiAbuse: User IP - ' . $user_ip); $email_subject = $subject; $email_message = $message; $emailer->use_template('empty_email', $user_lang); $emailer->to($config['board_email']); $emailer->from($sender); foreach ($bcc_emails as $bcc_address) { if (!empty($bcc_address)) { $emailer->bcc($bcc_address); } } // Send also to sender in BCC if needed... if (!empty($_POST['cc_email'])) { $emailer->bcc($sender); } $emailer->replyto($sender); $emailer->set_subject($email_subject); $emailer->assign_vars(array('MESSAGE' => $email_message)); $emailer->send(); $emailer->reset(); $redirect_url = append_sid(CMS_PAGE_HOME); meta_refresh(3, $redirect_url); $message_die = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_HOME) . '">', '</a>'); if ($account_delete) {
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { global $board_config, $lang, $db, $phpbb_root_path, $MAIN_CFG; global $userdata; $current_time = time(); if ($mode == 'delete') { $delete_sql = !$post_data['first_post'] && !$post_data['last_post'] ? " AND user_id = " . $userdata['user_id'] : ''; $db->sql_query("DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = {$topic_id}" . $delete_sql); } else { if ($mode == 'reply') { $result = $db->sql_query('SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_level<1'); $user_id_sql = ''; while ($row = $db->sql_fetchrow($result)) { $user_id_sql .= ', ' . $row['user_id']; } $sql = "SELECT u.user_id, u.user_email, u.user_lang\n\t\t\t\tFROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u\n\t\t\t\tWHERE tw.topic_id = {$topic_id}\n\t\t\t\t\tAND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")\n\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = tw.user_id"; $result = $db->sql_query($sql); $update_watched_sql = ''; $bcc_list_ary = array(); if ($row = $db->sql_fetchrow($result)) { // Sixty second limit set_time_limit(0); do { if ($row['user_email'] != '') { $bcc_list_ary[$row['user_lang']][] = $row['user_email']; } $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id']; } while ($row = $db->sql_fetchrow($result)); if (sizeof($bcc_list_ary)) { include "includes/phpBB/emailer.php"; $emailer = new emailer(); $orig_word = array(); $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); $emailer->from($board_config['board_email']); $emailer->replyto($board_config['board_email']); $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, htmlunprepare($topic_title)) : htmlunprepare($topic_title); reset($bcc_list_ary); while (list($user_lang, $bcc_list) = each($bcc_list_ary)) { $emailer->use_template('topic_notify', $user_lang); for ($i = 0; $i < count($bcc_list); $i++) { $emailer->bcc($bcc_list[$i]); } // The Topic_reply_notification lang string below will be used // if for some reason the mail template subject cannot be read // ... note it will not necessarily be in the posters own language! $emailer->set_subject($lang['Topic_reply_notification']); $emailer->assign_vars(array('EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'SITENAME' => $board_config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => URL::index('&file=viewtopic&' . POST_POST_URL . "={$post_id}", true, true) . "#{$post_id}", 'U_STOP_WATCHING_TOPIC' => URL::index('&file=viewtopic&' . POST_TOPIC_URL . "={$topic_id}&unwatch=topic", true, true))); $emailer->send(); $emailer->reset(); //send_mail($error, $message, false, $lang['Topic_reply_notification'], $to='', $to_name='') } } } $db->sql_freeresult($result); if ($update_watched_sql != '') { $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\n\t\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\t\tWHERE topic_id = {$topic_id} AND user_id IN ({$update_watched_sql})"; $db->sql_query($sql); } } $sql = "SELECT topic_id FROM " . TOPICS_WATCH_TABLE . "\n\t\t\tWHERE topic_id = {$topic_id} AND user_id = " . $userdata['user_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (!$notify_user && !empty($row['topic_id'])) { $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\n\t\t\t\t\tWHERE topic_id = {$topic_id} AND user_id = " . $userdata['user_id']; $db->sql_query($sql); } else { if ($notify_user && empty($row['topic_id'])) { $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)\n\t\t\t\t\tVALUES (" . $userdata['user_id'] . ", {$topic_id}, 0)"; $db->sql_query($sql); } } } }