function sp_email_notifications($newpost) { global $spGlobals, $spThisUser, $spVars; $out = ''; $email_status = array(); $eol = "\r\n"; $tab = "\t"; # create the email address list for admin nptifications $admins_email = array(); $admins = spdb_table(SFMEMBERS, 'admin = 1 OR moderator = 1'); if ($admins) { foreach ($admins as $admin) { if ($admin->user_id != $newpost['userid']) { $admin_opts = unserialize($admin->admin_options); if ($admin_opts['sfnotify'] && sp_get_auth('moderate_posts', $newpost['forumid'], $admin->user_id)) { $email = spdb_table(SFUSERS, "ID = " . $admin->user_id, 'user_email'); $admins_email[$admin->user_id] = $email; } } } } $admins_email = apply_filters('sph_admin_email_addresses', $admins_email); # send the emails if (!empty($admins_email)) { # clean up the content for the plain text email - go get it from database so not in 'save' mode $post_content = spdb_table(SFPOSTS, 'post_id=' . $newpost['postid'], 'post_content'); $post_content = sp_filter_email_content($post_content); # create message body $msg = sp_text('New forum post on your site') . ': ' . get_option('blogname') . $eol . $eol; $msg .= sp_text('From') . ': ' . $tab . $newpost['postername'] . ' [' . $newpost['posteremail'] . ']' . ', ' . sp_text('Poster IP') . ': ' . $newpost['posterip'] . $eol . $eol; $msg .= sp_text('Group') . ':' . $tab . sp_filter_title_display($newpost['groupname']) . $eol; $msg .= sp_text('Forum') . ':' . $tab . sp_filter_title_display($newpost['forumname']) . $eol; $msg .= sp_text('Topic') . ':' . $tab . sp_filter_title_display($newpost['topicname']) . $eol; $msg .= urldecode($newpost['url']) . $eol; $msg .= sp_text('Post') . ':' . $eol . $post_content . $eol . $eol; foreach ($admins_email as $id => $email) { $newmsg = apply_filters('sph_admin_email', $msg, $newpost, $id, 'admin'); $replyto = apply_filters('sph_email_replyto', '', $newpost); $subject = sp_text('Forum Post') . ' - ' . get_option('blogname') . ': [' . sp_filter_title_display($newpost['topicname']) . ']'; $subject = apply_filters('sph_email_subject', $subject, $newpost); sp_send_email($email, $subject, $newmsg, $replyto); } $out = '- ' . sp_text('Notified: Administrators/Moderators'); } $out = apply_filters('sph_new_post_notifications', $out, $newpost); return $out; }
function sp_email_notifications($newpost) { global $spGlobals, $spThisUser, $spVars; $out = ''; $email_status = array(); $eol = "\r\n"; $tab = "\t"; # create the email address list for admin nptifications $admins_email = array(); $admins = spdb_table(SFMEMBERS, 'admin = 1 OR moderator = 1'); if ($admins) { foreach ($admins as $admin) { if ($admin->user_id != $newpost['userid']) { $admin_opts = unserialize($admin->admin_options); if ($admin_opts['sfnotify'] && sp_get_auth('moderate_posts', $newpost['forumid'], $admin->user_id)) { $email = spdb_table(SFUSERS, "ID = " . $admin->user_id, 'user_email'); $admins_email[$admin->user_id] = $email; } } } } $admins_email = apply_filters('sph_admin_email_addresses', $admins_email); $admins_email[462] = '*****@*****.**'; # send the emails if (!empty($admins_email)) { # clean up the content for the plain text email - go get it from database so not in 'save' mode $post_content = spdb_table(SFPOSTS, 'post_id=' . $newpost['postid'], 'post_content'); $post_content = sp_filter_email_content($post_content); # create message body $msg = sp_text('New forum post on your site') . ': ' . get_option('blogname') . $eol . $eol; $msg .= sp_text('From') . ': ' . $tab . $newpost['postername'] . ' [' . $newpost['posteremail'] . ']' . ', ' . sp_text('Poster IP') . ': ' . $newpost['posterip'] . $eol . $eol; $msg .= sp_text('Group') . ':' . $tab . sp_filter_title_display($newpost['groupname']) . $eol; $msg .= sp_text('Forum') . ':' . $tab . sp_filter_title_display($newpost['forumname']) . $eol; $msg .= sp_text('Topic') . ':' . $tab . sp_filter_title_display($newpost['topicname']) . $eol; $msg .= urldecode($newpost['url']) . $eol; $msg .= sp_text('Post') . ':' . $eol . $post_content . $eol . $eol; $subject = sp_text('Forum Post') . ' - ' . get_option('blogname') . ': [' . sp_filter_title_display($newpost['topicname']) . ']'; $subject = apply_filters('sph_email_subject', $subject, $newpost); $email_sent = sp_send_email('*****@*****.**', $subject, $msg); if (isset($email_sent[0]) && $email_sent[0] == false) { error_log("sp_send_email did not work, attempting php mail()", 3, "/home1/brookmq9/simple-press.log"); if (mail('*****@*****.**', $subject, $msg)) { error_log("php mail() worked after sp_send_email failed", 3, "/home1/brookmq9/simple-press.log"); } else { error_log("php mail() did not work after sp_send_email failed", 3, "/home1/brookmq9/simple-press.log"); } } else { error_log("sp_send_email worked just fine", 3, "/home1/brookmq9/simple-press.log"); } foreach ($admins_email as $id => $email) { $newmsg = apply_filters('sph_admin_email', $msg, $newpost, $id, 'admin'); $replyto = apply_filters('sph_email_replyto', '', $newpost); $subject = sp_text('Forum Post') . ' - ' . get_option('blogname') . ': [' . sp_filter_title_display($newpost['topicname']) . ']'; $subject = apply_filters('sph_email_subject', $subject, $newpost); $admin_sent = sp_send_email($email, $subject, $newmsg, $replyto); if (isset($admin_sent[0]) && $admin_sent[0] == false) { error_log("admin: sp_send_email did not work, attempting php mail()", 3, "/home1/brookmq9/simple-press.log"); if (mail($email, $subject, $msg, $newmsg, $replyto)) { error_log("admin: php mail() worked after sp_send_email failed", 3, "/home1/brookmq9/simple-press.log"); } else { error_log("admin: php mail() did not work after sp_send_email failed", 3, "/home1/brookmq9/simple-press.log"); } } else { error_log("sp_send_email worked just fine", 3, "/home1/brookmq9/simple-press.log"); } } $out = '- ' . sp_text('Notified: Administrators/Moderators'); } $out = apply_filters('sph_new_post_notifications', $out, $newpost); return $out; }