Exemple #1
0
     $error = TRUE;
     $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email'];
 }
 if (!empty($HTTP_POST_VARS['message'])) {
     $message = trim(stripslashes($HTTP_POST_VARS['message']));
 } else {
     $error = TRUE;
     $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email'];
 }
 if (!$error) {
     $sql = "UPDATE " . USERS_TABLE . " \n\t\t\t\t\t\tSET user_emailtime = " . time() . " \n\t\t\t\t\t\tWHERE user_id = " . $userdata['user_id'];
     if ($result = $db->sql_query($sql)) {
         include $phpbb_root_path . 'includes/emailer.' . $phpEx;
         $emailer = new emailer($board_config['smtp_delivery']);
         $emailer->from($userdata['user_email']);
         $emailer->replyto($userdata['user_email']);
         $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 - ' . decode_ip($user_ip) . "\n";
         $emailer->use_template('profile_send_email', $user_lang);
         $emailer->email_address($user_email);
         $emailer->set_subject($subject);
         $emailer->extra_headers($email_headers);
         $emailer->assign_vars(array('SITENAME' => $board_config['sitename'], 'BOARD_EMAIL' => $board_config['board_email'], 'FROM_USERNAME' => $userdata['username'], 'TO_USERNAME' => $username, 'MESSAGE' => $message));
         $emailer->send();
         $emailer->reset();
         if (!empty($HTTP_POST_VARS['cc_email'])) {
             $emailer->from($userdata['user_email']);
             $emailer->replyto($userdata['user_email']);
             $emailer->use_template('profile_send_email');
Exemple #2
0
         }
         $username = $row['username'];
         $user_id = $row['user_id'];
         $user_actkey = make_rand_str(true);
         $key_len = 54 - strlen($server_url);
         $key_len = $str_len > 6 ? $key_len : 6;
         $user_actkey = substr($user_actkey, 0, $key_len);
         $user_password = make_rand_str(false);
         $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\tSET user_newpasswd = '" . md5($user_password) . "', user_actkey = '{$user_actkey}'\n\t\t\t\tWHERE user_id = " . $row['user_id'];
         if (!DB()->sql_query($sql)) {
             message_die(GENERAL_ERROR, 'Could not update new password information', '', __LINE__, __FILE__, $sql);
         }
         require FT_ROOT . 'includes/emailer.php';
         $emailer = new emailer($ft_cfg['smtp_delivery']);
         $emailer->from($ft_cfg['board_email']);
         $emailer->replyto($ft_cfg['board_email']);
         $emailer->use_template('user_activate_passwd', $row['user_lang']);
         $emailer->email_address($row['user_email']);
         $emailer->set_subject($lang['New_password_activation']);
         $emailer->assign_vars(array('SITENAME' => $ft_cfg['sitename'], 'USERNAME' => $username, 'PASSWORD' => $user_password, 'EMAIL_SIG' => !empty($ft_cfg['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $ft_cfg['board_email_sig']) : '', 'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey));
         $emailer->send();
         $emailer->reset();
         $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="15;url=' . append_sid("index.php") . '">'));
         $message = $lang['Password_updated'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.php") . '">', '</a>');
         message_die(GENERAL_MESSAGE, $message);
     } else {
         message_die(GENERAL_MESSAGE, $lang['No_email_match']);
     }
 } else {
     message_die(GENERAL_ERROR, 'Could not obtain user information for sendpassword', '', __LINE__, __FILE__, $sql);
 }
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', "&lt;\\2&gt;", $subject);
    $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "&lt;\\2&gt;", $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();
        }
    }
}
Exemple #4
0
    $result = $db->sql_query($sql);
    $warning_data = $db->sql_fetchrow($result);
    if (!empty($warning_data['user_email'])) {
        $server_url = create_server_url();
        $viewtopic_server_url = $server_url . CMS_PAGE_VIEWTOPIC;
        $from_email = $user->data['user_email'] && $user->data['user_allow_viewemail'] ? $user->data['user_email'] : $config['board_email'];
        include_once 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);
        $emailer->use_template($e_temp, $warning_data['user_lang']);
        $emailer->to($warning_data['user_email']);
        $emailer->from($from_email);
        $emailer->replyto($from_email);
        //$emailer->set_subject($e_subj);
        $email_sig = create_signature($config['board_email_sig']);
        $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'WARNINGS' => $warning_data['user_warnings'], 'TOTAL_WARN' => $config['max_user_bancard'], 'POST_URL' => $viewtopic_server_url . '?' . $forum_id_append . $topic_id_append . POST_POST_URL . '=' . $post_id . '#p' . $post_id, 'EMAIL_SIG' => $email_sig, 'WARNER' => $user->data['username'], 'BLOCK_TIME' => $block_time, 'WARNED_POSTER' => $warning_data['username']));
        $emailer->send();
        $emailer->reset();
    } else {
        $message .= '<br /><br />' . $lang['user_no_email'];
    }
} elseif ($already_banned) {
    $message = $lang['user_already_banned'];
} else {
    $message = 'Error in card.' . PHP_EXT;
}
$cache->destroy_datafiles(array('_ranks'), MAIN_CACHE_FOLDER, 'data', false);
$db->clear_cache('ban_', USERS_CACHE_FOLDER);
Exemple #5
0
function notifyUser($user_id, $notify_type, $offer_id, $offer_title)
{
    global $db, $lang, $auction_config_data, $board_config;
    if ($auction_config_data['auction_end_notify_email']) {
        // BEGIN EMAIL-NOTIFY
        $sql = "SELECT user_email,\r\n                         username\r\n                  FROM " . USERS_TABLE . "\r\n                  WHERE user_id=" . $user_id . "";
        if (!($result = $db->sql_query($sql))) {
        }
        // if
        $user = $db->sql_fetchrow($result);
        $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']) . '/' : '/';
        $username = $user['username'];
        $email = $user['user_email'];
        $emailer = new emailer($board_config['smtp_delivery']);
        $emailer->from($board_config['board_email']);
        $emailer->replyto($board_config['board_email']);
        if ($notify_type == 'WON') {
            $emailer->use_template('auction_won', stripslashes($user_lang));
            $emailer->set_subject($lang['auction_won']);
            $emailer->assign_vars(array('AUCTION_WON' => $lang['auction_offer_won'], 'AUCTION_SITENAME' => $board_config['sitename'], 'AUCTION_OFFER' => prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0), 'U_AUCTION_OFFER' => $server_protocol . $server_name . $board_config['script_path'] . 'auction_offer_view.php?ao=' . $offer_id, 'AUCTION_EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : ''));
        }
        if ($notify_type == 'SOLD') {
            $emailer->use_template('auction_sold', stripslashes($user_lang));
            $emailer->set_subject($lang['auction_sold']);
            $emailer->assign_vars(array('AUCTION_SOLD' => $lang['auction_offer_sold'], 'AUCTION_SITENAME' => $board_config['sitename'], 'AUCTION_OFFER' => prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0), 'U_AUCTION_OFFER' => $server_protocol . $server_name . $board_config['script_path'] . 'auction_offer_view.php?ao=' . $offer_id, 'AUCTION_EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : ''));
        }
        if ($notify_type == 'NOT_SOLD') {
            $emailer->use_template('auction_not_sold', stripslashes($user_lang));
            $emailer->set_subject($lang['auction_not_sold']);
            $emailer->assign_vars(array('AUCTION_NOT_SOLD' => $lang['auction_offer_not_sold'], 'AUCTION_SITENAME' => $board_config['sitename'], 'AUCTION_OFFER' => prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0), 'U_AUCTION_OFFER' => $server_protocol . $server_name . $board_config['script_path'] . 'auction_offer_view.php?ao=' . $offer_id, 'AUCTION_EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : ''));
        }
        $emailer->email_address($email);
        // Try to send email...
        $emailer->send();
        //          $emailer->reset();
    }
    // END EMAIL-NOTIFY
    if ($auction_config_data['auction_end_notify_pm']) {
        // BEGIN PM-NOTIFY ON OUTBID
        if ($notify_type == 'WON') {
            $pm_subject = $lang['auction_won'];
            $pm_text = $lang['auction_won_text'];
        }
        if ($notify_type == 'SOLD') {
            $pm_subject = $lang['auction_sold'];
            $pm_text = $lang['auction_sold_text'];
        }
        if ($notify_type == 'NOT_SOLD') {
            $pm_subject = $lang['auction_not_sold'];
            $pm_text = $lang['auction_not_sold_text'];
        }
        $privmsgs_date = date("U");
        $sql = "INSERT INTO " . PRIVMSGS_TABLE . "\r\n                     (privmsgs_type,\r\n                      privmsgs_subject,\r\n                      privmsgs_from_userid,\r\n                      privmsgs_to_userid,\r\n                      privmsgs_date,\r\n                      privmsgs_enable_html,\r\n                      privmsgs_enable_bbcode,\r\n                      privmsgs_enable_smilies,\r\n                      privmsgs_attach_sig)\r\n                  VALUES ('0',\r\n                          '" . str_replace("\\'", "''", addslashes(sprintf($pm_subject, $board_config['sitename']))) . "',\r\n                          '2',\r\n                          " . $user_id . ",\r\n                          " . $privmsgs_date . ",\r\n                          '0',\r\n                          '1',\r\n                          '1',\r\n                          '0')";
        if (!$db->sql_query($sql)) {
        }
        // if
        $outbid_sent_id = $db->sql_nextid();
        $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . "\r\n                      (privmsgs_text_id,\r\n                       privmsgs_text)\r\n                   VALUES (" . $outbid_sent_id . ",\r\n                           '" . str_replace("\\'", "''", $pm_text . "</br></br><a href=\"auction_offer_view.php?ao=" . $offer_id . "\">" . prepare_message(addslashes(unprepare_message(htmlspecialchars(trim(stripslashes($offer_title))))), $board_config['allow_html'], $board_config['allow_bbcode'], $board_config['allow_smilies'], 0) . "</a></br>" . $board_config['board_email_sig']) . "')";
        if (!$db->sql_query($sql)) {
        }
        // if
        $sql = "UPDATE " . USERS_TABLE . "\r\n                   SET user_new_privmsg=user_new_privmsg+1\r\n                   WHERE user_id=" . $user_id;
        if (!$db->sql_query($sql)) {
        }
        // if
    }
    // End pm-notification
}
Exemple #6
0
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_');
}
Exemple #7
0
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);
            }
        }
    }
}
Exemple #8
0
    protected function _ticket_home()
    {
        global $user, $core;
        if (!$core->v('cron_enabled')) {
            return $this->e('CRON_DISABLED');
        }
        foreach (w('mail pop3 emailer htmlparser') as $row) {
            require_once XFS . 'core/' . $row . '.php';
        }
        $pop3 = new pop3();
        if (!$pop3->connect($core->v('mail_server'), $core->v('mail_port'))) {
            return $this->e('MAIL_NO_CONNECT');
        }
        if (!($total_mail = $pop3->login('recent:' . $core->v('mail_ticket_login'), $core->v('mail_ticket_key')))) {
            return $this->e('MAIL_NEW_MAIL');
        }
        //
        $mail = new _mail();
        $emailer = new emailer();
        //
        if (!($blacklist = $core->cache_load('ticket_blacklist'))) {
            $sql = 'SELECT *
				FROM _tickets_blacklist
				ORDER BY list_id';
            $blacklist = $core->cache_store(_rowset($sql, 'list_address', 'list_id'));
        }
        if (!($ticket_status = $core->cache_load('ticket_status_default'))) {
            $sql = 'SELECT status_id
				FROM _tickets_status
				WHERE status_default = 1';
            $ticket_status = $core->cache_store(_field($sql, 'status_id', 0));
        }
        $sql = 'SELECT group_id, group_email
			FROM _groups
			ORDER BY group_email';
        $groups = _rowset($sql, 'group_email', 'group_id');
        $sql = 'SELECT group_email, group_name
			FROM _groups
			ORDER BY group_email';
        $groups_name = _rowset($sql, 'group_email', 'group_name');
        $sql = 'SELECT gg.group_email, m.user_email
			FROM _groups gg, _groups_members g, _members m
			WHERE g.member_mod = ?
				AND g.member_uid = m.user_id
				AND gg.group_id = g.member_group
			ORDER BY m.user_email';
        $groups_mods = _rowset(sql_filter($sql, 1), 'group_email', 'user_email', true);
        foreach ($groups as $a_group_email => $a_group_id) {
            if (!isset($groups_mods[$a_group_email])) {
                $groups_mods[$a_group_email] = w();
            }
        }
        $sql = 'SELECT s.a_assoc, s.a_value
			FROM _members_fields f, _members_store s
			WHERE s.a_field = f.field_id
				AND f.field_alias LIKE ?
			ORDER BY s.a_value';
        $email_alt = _rowset(sql_filter($sql, 'email%'), 'a_value', 'a_assoc');
        // Pre mail process
        $recv = w();
        $now = time();
        $line_orig = array('&nbsp;');
        $line_repl = array(' ');
        $_v = w('from from_d to ticket subject body date mod ip spam blacklist reply other');
        $_c = w('normal reply other blacklist spam', 0);
        for ($i = 1; $i <= $total_mail; $i++) {
            foreach ($_v as $row) {
                ${'recv_' . $row} = 0;
            }
            $s_header = $mail->parse_header(split("\r\n", implode('', $pop3->top($i))));
            $recv_from = $mail->parse_address($s_header['from']);
            if (isset($blacklist[$recv_from])) {
                $recv_blacklist = 1;
            }
            if ($recv_from == $core->v('mail_ticket_login')) {
                $recv_blacklist = 1;
            }
            _dvar($s_header['to'], '');
            _dvar($s_header['cc'], '');
            if (f($s_header['cc'])) {
                $s_header['to'] .= (f($s_header['to']) ? ', ' : '') . $s_header['cc'];
            }
            $to_part = array_map('trim', explode(strpos($s_header['to'], ',') ? ',' : ';', $s_header['to']));
            foreach ($to_part as $row) {
                if (strpos($row, '<') !== false) {
                    $row = preg_replace('#.*?<(.*?)>#is', '\\1', $row);
                }
                if (isset($blacklist[$row])) {
                    $recv_blacklist = 1;
                } else {
                    $recv_blacklist = 0;
                    $row_first = array_key(explode('@', $row), 0);
                    if (isset($groups[$row_first])) {
                        $recv_to = $row_first;
                    }
                }
            }
            if (strstr($s_header['to'], _lang('MAIL_TO_UNKNOWN')) !== false) {
                $recv_to = array_key(explode('@', $core->v('mail_ticket_login')), 0);
            }
            if (!$recv_to) {
                $recv_blacklist = 1;
            }
            if (!$recv_blacklist) {
                $recv_subject = htmlencode(trim($s_header['subject']));
                if (preg_match('#\\[\\#(.*?)\\]#is', $recv_subject, $p_subject)) {
                    $sql = 'SELECT ticket_id
						FROM _tickets
						WHERE ticket_code = ?';
                    if ($recv_subject_d = _fieldrow(sql_filter($sql, $p_subject[1]))) {
                        $recv_ticket = $recv_subject_d['ticket_id'];
                        $recv_reply = $p_subject[1];
                        $recv_subject = substr(strrchr($recv_subject, ']'), 3);
                    }
                }
                if ($recv_to . '@' . $core->v('domain') == $recv_from && $recv_from == $core->v('mail_ticket_login') && $recv_reply) {
                    $recv_blacklist = 1;
                }
            }
            if (!$recv_blacklist) {
                if (isset($email_alt[$recv_from])) {
                    $sql_field = 'id';
                    $sql_value = $email_alt[$recv_from];
                } else {
                    $sql_field = 'username';
                    $sql_value = array_key(explode('@', $recv_from), 0);
                }
                $sql = 'SELECT user_id, user_username, user_firstname, user_lastname
					FROM _members
					WHERE user_?? = ?';
                if ($recv_from_d = _fieldrow(sql_filter($sql, $sql_field, $sql_value))) {
                    $recv_from_d = serialize(array_row($recv_from_d));
                } else {
                    $recv_other = 1;
                }
                $d_body = $mail->body($s_header, $pop3->fbody($i), true);
                $recv_date = $mail->parse_date($s_header['date']);
                $recv_ip = $mail->parse_ip($s_header['received']);
                if (isset($groups_email[$recv_to])) {
                    $recv_mod = $groups_email[$recv_to];
                }
                if ($recv_date > $now || $recv_date < $now - 86400) {
                    $recv_date = $now;
                }
                if (isset($d_body['text-plain']) && f($d_body['text-plain'])) {
                    $recv_body = trim($d_body['text-plain']);
                } elseif (isset($d_body['text-html']) && f($d_body['text-html'])) {
                    $htm_text = w();
                    $tag_open = false;
                    $parser = new HtmlParser($d_body['text-html']);
                    while ($parser->parse()) {
                        $line = trim(str_replace($line_orig, $line_repl, $parser->iNodeValue));
                        if ($tag_open || strpos($line, '<') !== false) {
                            $tag_open = !$tag_open;
                            continue;
                        }
                        if ($parser->iNodeName == 'Text' && f($line)) {
                            $htm_text[] = preg_replace("/(\r\n){1}/", ' ', $line);
                        }
                    }
                    $recv_body = implode("\n", $htm_text);
                }
                if (f($recv_body)) {
                    $recv_body = htmlencode(_utf8($recv_body));
                }
                if (!f($recv_body)) {
                    $recv_blacklist = 1;
                }
            }
            $recv[$i] = w();
            foreach ($_v as $row) {
                $recv[$i][$row] = ${'recv_' . $row};
            }
        }
        foreach ($recv as $i => $row) {
            if ($row['spam'] || $row['blacklist']) {
                $pop3->delete($i);
                $row_key = $row['spam'] ? 'spam' : 'blacklist';
                $_c[$row_key]++;
                continue;
            }
            // Send mail to group admin
            if ($row['other']) {
                $_c['other']++;
                if (count($groups_mods[$row['to']])) {
                    foreach ($groups_mods[$row['to']] as $i => $mod_email) {
                        $email_func = !$i ? 'email_address' : 'cc';
                        $emailer->{$email_func}($mod_email);
                    }
                    $emailer->from($row['from']);
                    $emailer->replyto($row['from']);
                    $emailer->set_subject(entity_decode($row['subject']));
                    $emailer->use_template('ticket_other');
                    $emailer->set_decode(true);
                    $emailer->assign_vars(array('SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body'])));
                    $emailer->send();
                    $emailer->reset();
                }
                $pop3->delete($i);
                continue;
            }
            $row['code'] = $row['reply'] ? $row['reply'] : substr(md5(unique_id()), 0, 8);
            $row['from_d'] = unserialize($row['from_d']);
            $row['group_id'] = $groups[$row['to']];
            $row['msubject'] = entity_decode(sprintf('%s [#%s]: %s', $groups_name[$row['to']], $row['code'], $row['subject']));
            $row['mbody'] = explode("\n", $row['body']);
            //
            $body_const = w();
            foreach ($row['mbody'] as $part_i => $part_row) {
                if (isset($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i])) {
                    $row['mbody'][$part_i] = "\n" . $part_row;
                }
            }
            $row['body'] = implode("\n", $row['mbody']);
            $v_mail = array('USERNAME' => $row['from_d']['user_username'], 'FULLNAME' => entity_decode(_fullname($row['from_d'])), 'SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body']), 'TICKET_URL' => _link('ticket', array('x1' => 'view', 'code' => $row['code'])));
            if (!$row['reply']) {
                $_c['normal']++;
                $sql_insert = array('parent' => 0, 'cat' => 1, 'group' => $row['group_id'], 'title' => _subject($row['subject']), 'text' => _prepare($row['body']), 'code' => $row['code'], 'contact' => $row['from_d']['user_id'], 'aby' => 0, 'status' => $ticket_status, 'start' => $row['date'], 'lastreply' => $row['date'], 'end' => 0, 'ip' => $row['ip']);
                $sql = 'INSERT INTO _tickets' . _build_array('INSERT', prefix('ticket', $sql_insert));
                _sql($sql);
                // Send mail to user
                $emailer->email_address($row['from']);
                $emailer->from($row['to'] . '@' . $core->v('domain'));
                $emailer->set_subject($row['msubject']);
                $emailer->use_template('ticket_' . $row['to']);
                $emailer->set_decode(true);
                $emailer->assign_vars($v_mail);
                $emailer->send();
                $emailer->reset();
                // > Send mail to group admin
                if (count($groups_mods[$row['to']])) {
                    foreach ($groups_mods[$row['to']] as $i => $mod_email) {
                        $address_func = !$i ? 'email_address' : 'cc';
                        $emailer->{$address_func}($mod_email);
                    }
                    $emailer->from($row['to'] . '@' . $core->v('domain'));
                    $emailer->set_subject($row['msubject']);
                    $emailer->use_template('ticket_' . ($row['reply'] ? 'reply' : 'tech'));
                    $emailer->set_decode(true);
                    $emailer->assign_vars($v_mail);
                    $emailer->send();
                    $emailer->reset();
                }
            } else {
                $_c['reply']++;
                $sql_insert = array('ticket_id' => $row['ticket'], 'user_id' => $row['from_d']['user_id'], 'note_text' => htmlencode($row['body']), 'note_time' => $row['date'], 'note_cc' => 1);
                $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $sql_insert);
                _sql($sql);
                $sql = 'UPDATE _tickets SET ticket_lastreply = ?
					WHERE ticket_id = ?';
                _sql(sql_filter($sql, $row['date'], $row['ticket']));
                // Send mail to group members || user
                $sql = 'SELECT *
					FROM _tickets_assign a, _members m
					WHERE a.assign_ticket = ?
						AND a.user_id = m.user_id
						AND m.user_username NOT IN (?)';
                $tech = _rowset(sql_filter($sql, $row['ticket'], $row['from_d']['user_username']));
                if ($row['mod'] != $row['from_d']['user_username']) {
                    $tech[] = $row['mod'];
                }
                if (count($tech)) {
                    foreach ($tech as $tech_i => $tech_row) {
                        $m_method = !$tech_i ? 'email_address' : 'cc';
                        $emailer->{$m_method}($tech_row . '@' . $core->v('domain'));
                    }
                    $emailer->from($row['to'] . '@' . $core->v('domain'));
                    $emailer->use_template('ticket_reply');
                    $emailer->set_subject($row['msubject']);
                    $emailer->set_decode(true);
                    $emailer->assign_vars($v_mail);
                    $emailer->send();
                    $emailer->reset();
                }
            }
            // Delete mail from server
            $pop3->delete($i);
        }
        // Quit server
        $pop3->quit();
        $ret = '';
        foreach ($_c as $k => $v) {
            $ret .= "\n" . $k . ' = ' . $v . '<br />';
        }
        return $this->e($ret);
    }
Exemple #9
0
function chaser_email($sender_email, $recip_email, $subject, $message)
{
    global $board_config, $phpEx, $phpbb_root_path;
    global $email_headers, $user_lang;
    include_once $phpbb_root_path . 'includes/emailer.' . $phpEx;
    // Left in for debugging
    //echo '===============================<br>';
    //echo '$sender_email=',$sender_email,'<br>';
    //echo '$recip_email=',$recip_email,'<br>';
    //echo '$subject=',$subject,'<br>';
    //echo '$message=',$message,'<br>';
    $emailer = new emailer($board_config['smtp_delivery']);
    $emailer->from($sender_email);
    $emailer->replyto($sender_email);
    $emailer->use_template('admin_send_email', $user_lang);
    $emailer->email_address($recip_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();
}
Exemple #10
0
    include '../lib/emailer.php';
    //
    // Let's do some checking to make sure that mass mail functions
    // are working in win32 versions of php.
    //
    $board_config['smtp_delivery'] = 0;
    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(EMAIL_ADMIN);
    $emailer->replyto(EMAIL_ADMIN);
    for ($i = 0; $i < count($bcc_list); $i++) {
        $emailer->bcc($bcc_list[$i]);
    }
    $email_headers = 'X-AntiAbuse: Board servername - Asterisk 2 billing\\n';
    $email_headers .= 'X-AntiAbuse: User_id - 1\\n';
    $email_headers .= 'X-AntiAbuse: Username - Areski\\n';
    $email_headers .= 'X-AntiAbuse: User IP - 192.168.1.241\\n';
    $emailer->use_template($message);
    $emailer->email_address(EMAIL_ADMIN);
    $emailer->set_subject($subject);
    $emailer->extra_headers($email_headers);
    $emailer->assign_vars(array('SITENAME' => 'a2billing', 'BOARD_EMAIL' => EMAIL_ADMIN, 'MESSAGE' => 'Hey it is a message, just to watch working'));
    $result = $emailer->send();
    $emailer->reset();
}
function adr_send_pm($dest_user, $subject, $message, $check_from_id = '')
{
    global $db, $phpbb_root_path, $phpEx, $lang, $user_ip, $board_config, $userdata;
    $dest_user = intval($dest_user);
    $msg_time = time();
    $from_id = $check_from_id === '' ? intval($userdata['user_id']) : $check_from_id;
    $html_on = 1;
    $bbcode_on = 1;
    $smilies_on = 1;
    include_once $phpbb_root_path . 'includes/functions_post.' . $phpEx;
    include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
    $privmsg_subject = trim(strip_tags($subject));
    $bbcode_uid = make_bbcode_uid();
    $privmsg_message = trim(strip_tags($message));
    // APM compliance
    if (defined('PRIVMSGA_TABLE')) {
        include_once $phpbb_root_path . 'includes/functions_messages.' . $phpEx;
        send_pm(0, '', $dest_user, $privmsg_subject, $privmsg_message, '');
    } else {
        $sql = "SELECT user_id, user_notify_pm, user_email, user_lang, user_active\r\n\t\t\t FROM " . USERS_TABLE . "\r\n\t\t\t WHERE user_id = {$dest_user} ";
        if (!($result = $db->sql_query($sql))) {
            $error = TRUE;
            $error_msg = $lang['No_such_user'];
        }
        $to_userdata = $db->sql_fetchrow($result);
        $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time\r\n\t\t\tFROM " . PRIVMSGS_TABLE . "\r\n\t\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "\r\n\t\t\t  OR privmsgs_type = " . PRIVMSGS_READ_MAIL . " \r\n\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )\r\n\t\t\tAND privmsgs_to_userid = {$dest_user} ";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_MESSAGE, $lang['No_such_user']);
        }
        $sql_priority = SQL_LAYER == 'mysql' ? 'LOW_PRIORITY' : '';
        if ($inbox_info = $db->sql_fetchrow($result)) {
            if ($inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs']) {
                $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . "\r\n\t\t\t\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "\r\n\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_READ_MAIL . "\r\n\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "  )\r\n\t\t\t\t\tAND privmsgs_date = " . $inbox_info['oldest_post_time'] . "\r\n\t\t\t\t\tAND privmsgs_to_userid = {$dest_user} ";
                if (!($result = $db->sql_query($sql))) {
                    message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql);
                }
                $old_privmsgs_id = $db->sql_fetchrow($result);
                $old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
                $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TABLE . "\r\n\t\t\t\t\tWHERE privmsgs_id = {$old_privmsgs_id}";
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)' . $sql, '', __LINE__, __FILE__, $sql);
                }
                $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TEXT_TABLE . "\r\n\t\t\t\t\tWHERE privmsgs_text_id = {$old_privmsgs_id}";
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql);
                }
            }
        }
        $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " \r\n\t\t\t(privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies)\r\n\t\t\tVALUES ( 1 , '" . str_replace("\\'", "''", addslashes($privmsg_subject)) . "' , " . $from_id . ", " . $to_userdata['user_id'] . ", {$msg_time}, '{$user_ip}' , {$html_on}, {$bbcode_on}, {$smilies_on})";
        if (!$db->sql_query($sql_info)) {
            message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql_info);
        }
        $privmsg_sent_id = $db->sql_nextid();
        $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)\r\n\t\t\tVALUES ({$privmsg_sent_id}, '" . $bbcode_uid . "', '" . str_replace("\\'", "''", addslashes($privmsg_message)) . "')";
        if (!$db->sql_query($sql, END_TRANSACTION)) {
            message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql);
        }
        $sql = "UPDATE " . USERS_TABLE . "\r\n\t\t\tSET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " \r\n\t\t\tWHERE user_id = " . $to_userdata['user_id'];
        if (!($status = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
        }
        if ($to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active']) {
            // have the mail sender infos
            $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path']));
            $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $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']) . '/' : '/';
            include_once $phpbb_root_path . './includes/emailer.' . $phpEx;
            $emailer = new emailer($board_config['smtp_delivery']);
            if ($board_config['version'] == '.0.5' || $board_config['version'] == '.0.6' || $board_config['version'] == '.0.7' || $board_config['version'] == '.0.8' || $board_config['version'] == '.0.9') {
                $emailer->from($board_config['board_email']);
                $emailer->replyto($board_config['board_email']);
                $emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
            } else {
                $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
                $emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
                $emailer->extra_headers($email_headers);
            }
            $emailer->email_address($to_userdata['user_email']);
            $emailer->set_subject($lang['Notification_subject']);
            $emailer->assign_vars(array('USERNAME' => $to_username, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox'));
            $emailer->send();
            $emailer->reset();
        }
    }
    return;
}
Exemple #12
0
 $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) {
     $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\tSET user_active = '0'\n\t\t\t\tWHERE user_id = " . $user->data['user_id'];
     $result = $db->sql_query($sql);
     $clear_notification = user_clear_notifications($user->data['user_id']);
     $message = $lang['Email_sent'];
     $redirect_url = append_sid(CMS_PAGE_LOGIN . '?logout=true&amp;sid=' . $user->data['session_id']);
     meta_refresh(3, $redirect_url);
 }
Exemple #13
0
     } else {
         $db->sql_query("UPDATE " . $prefix . "_bbprivmsgs\n\t\t\t\tSET privmsgs_type = " . PM_NEW_MAIL . ", privmsgs_subject = '" . Fix_Quotes($privmsg_subject) . "', privmsgs_from_userid = " . $userinfo['user_id'] . ", privmsgs_to_userid = " . $to_userinfo['user_id'] . ", privmsgs_date = {$msg_time}, privmsgs_ip = '" . $userinfo['user_ip'] . "', privmsgs_enable_html = {$html_on}, privmsgs_enable_bbcode = {$bbcode_on}, privmsgs_enable_smilies = {$smilies_on}, privmsgs_attach_sig = {$attach_sig}\n\t\t\t\tWHERE privmsgs_id = {$privmsg_id}");
         $db->sql_query("UPDATE " . $prefix . "_bbprivmsgs_text\n\t\t\tSET privmsgs_text = '" . Fix_Quotes($privmsg_message) . "'\n\t\t\tWHERE privmsgs_text_id = {$privmsg_id}");
     }
     if ($mode != 'edit') {
         //
         // Add to the users new pm counter
         //
         $sql = "UPDATE " . $user_prefix . "_users\n\t\t\t\tSET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "\n\t\t\t\tWHERE user_id = " . $to_userinfo['user_id'];
         $status = $db->sql_query($sql);
         unset($_SESSION['CPG_USER']);
         if ($to_userinfo['user_notify_pm'] && !empty($to_userinfo['user_email']) && $to_userinfo['user_active']) {
             require_once 'includes/phpBB/emailer.php';
             $emailer = new emailer();
             $emailer->from($MAIN_CFG['global']['notify_from']);
             $emailer->replyto($MAIN_CFG['global']['notify_email']);
             $emailer->use_template('privmsg_notify', $to_userinfo['user_lang']);
             $emailer->email_address($to_userinfo['user_email']);
             $emailer->set_subject($lang['Notification_subject']);
             $emailer->assign_vars(array('USERNAME' => $to_username, 'SITENAME' => $MAIN_CFG['global']['sitename'], 'EMAIL_SIG' => !empty($MAIN_CFG['private_messages']['email_sig']) ? str_replace('<br />', "\n", "-- \n" . $MAIN_CFG['private_messages']['email_sig']) : '', 'U_INBOX' => URL::index('&amp;folder=inbox', true, true)));
             $emailer->send();
             $emailer->reset();
         }
     }
     URL::refresh(URL::index('&folder=inbox'));
     $msg = $lang['Message_sent'] . '<br /><br />' . sprintf($lang['Click_return_inbox'], '<a href="' . URL::index('&amp;folder=inbox') . '">', '</a> ') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . $mainindex . '">', '</a>');
     cpg_error($msg);
 } else {
     if ($preview || $refresh || $error) {
         //
         // If we're previewing or refreshing then obtain the data
function cash_pm(&$targetdata, $privmsg_subject, &$message)
{
    global $db, $board_config, $lang, $userdata, $phpbb_root_path, $phpEx, $html_entities_match, $html_entities_replace;
    //
    // It looks like we're sending a PM!
    // NOTE: most of the following code is shamelessly "reproduced" from privmsg.php
    //
    include $phpbb_root_path . 'includes/bbcode.' . $phpEx;
    include $phpbb_root_path . 'includes/functions_post.' . $phpEx;
    //
    // Toggles
    //
    if (!$board_config['allow_html']) {
        $html_on = 0;
    } else {
        $html_on = $userdata['user_allowhtml'];
    }
    $bbcode_on = TRUE;
    if (!$board_config['allow_smilies']) {
        $smilies_on = 0;
    } else {
        $smilies_on = $userdata['user_allowsmile'];
    }
    $attach_sig = $userdata['user_attachsig'];
    //
    // Flood control
    //
    $sql = "SELECT MAX(privmsgs_date) AS last_post_time\n\t\tFROM " . PRIVMSGS_TABLE . "\n\t\tWHERE privmsgs_from_userid = " . $userdata['user_id'];
    if ($result = $db->sql_query($sql)) {
        $db_row = $db->sql_fetchrow($result);
        $last_post_time = $db_row['last_post_time'];
        $current_time = time();
        if ($current_time - $last_post_time < $board_config['flood_interval']) {
            message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
        }
    }
    //
    // End Flood control
    //
    $msg_time = time();
    $bbcode_uid = make_bbcode_uid();
    $privmsg_message = prepare_message($message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
    //
    // See if recipient is at their inbox limit
    //
    $sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time \n\t\tFROM " . PRIVMSGS_TABLE . " \n\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " \n\t\t\t\tOR privmsgs_type = " . PRIVMSGS_READ_MAIL . "  \n\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " ) \n\t\t\tAND privmsgs_to_userid = " . $targetdata['user_id'];
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_MESSAGE, $lang['No_such_user']);
    }
    $sql_priority = SQL_LAYER == 'mysql' ? 'LOW_PRIORITY' : '';
    if ($inbox_info = $db->sql_fetchrow($result)) {
        if ($inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs']) {
            $sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . " \n\t\t\t\tWHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . " \n\t\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_READ_MAIL . " \n\t\t\t\t\t\tOR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "  ) \n\t\t\t\t\tAND privmsgs_date = " . $inbox_info['oldest_post_time'] . " \n\t\t\t\t\tAND privmsgs_to_userid = " . $targetdata['user_id'];
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql);
            }
            $old_privmsgs_id = $db->sql_fetchrow($result);
            $old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
            $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TABLE . " \n\t\t\t\tWHERE privmsgs_id = {$old_privmsgs_id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)' . $sql, '', __LINE__, __FILE__, $sql);
            }
            $sql = "DELETE {$sql_priority} FROM " . PRIVMSGS_TEXT_TABLE . " \n\t\t\t\tWHERE privmsgs_text_id = {$old_privmsgs_id}";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)\n\t\tVALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\\'", "''", $privmsg_subject) . "', " . $userdata['user_id'] . ", " . $targetdata['user_id'] . ", {$msg_time}, '{$user_ip}', {$html_on}, {$bbcode_on}, {$smilies_on}, {$attach_sig})";
    if (!($result = $db->sql_query($sql_info, BEGIN_TRANSACTION))) {
        message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info);
    }
    $privmsg_sent_id = $db->sql_nextid();
    $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)\n\t\tVALUES ({$privmsg_sent_id}, '" . $bbcode_uid . "', '" . str_replace("\\'", "''", $privmsg_message) . "')";
    if (!$db->sql_query($sql, END_TRANSACTION)) {
        message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info);
    }
    //
    // Add to the users new pm counter
    //
    $sql = "UPDATE " . USERS_TABLE . "\n\t\tSET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "  \n\t\tWHERE user_id = " . $targetdata['user_id'];
    if (!($status = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
    }
    if ($targetdata['user_notify_pm'] && !empty($targetdata['user_email']) && $targetdata['user_active']) {
        $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path']));
        $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $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']) . '/' : '/';
        include $phpbb_root_path . 'includes/emailer.' . $phpEx;
        $emailer = new emailer($board_config['smtp_delivery']);
        $emailer->from($board_config['board_email']);
        $emailer->replyto($board_config['board_email']);
        $emailer->use_template('privmsg_notify', $targetdata['user_lang']);
        $emailer->email_address($targetdata['user_email']);
        $emailer->set_subject($lang['Notification_subject']);
        $emailer->assign_vars(array('USERNAME' => $to_username, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox'));
        $emailer->send();
        $emailer->reset();
    }
}
Exemple #15
0
    function main($action)
    {
        global $db, $config, $template, $images, $user, $lang;
        global $pafiledb_config, $debug;
        $file_id = request_var('file_id', 0);
        if (empty($file_id)) {
            message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
        }
        $sql = 'SELECT file_catid, file_name
			FROM ' . PA_FILES_TABLE . "\n\t\t\tWHERE file_id = {$file_id}";
        $result = $db->sql_query($sql);
        if (!($file_data = $db->sql_fetchrow($result))) {
            message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
        }
        $db->sql_freeresult($result);
        if (!$this->auth[$file_data['file_catid']]['auth_email']) {
            if (!$user->data['session_logged_in']) {
                redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=email&file_id=' . $file_id, true));
            }
            $message = sprintf($lang['Sorry_auth_email'], $this->auth[$file_data['file_catid']]['auth_email_type']);
            message_die(GENERAL_MESSAGE, $message);
        }
        if (isset($_POST['submit'])) {
            // session id check
            $sid = request_post_var('sid', '');
            if (empty($sid) || $sid != $user->data['session_id']) {
                message_die(GENERAL_ERROR, 'INVALID_SESSION');
            }
            $error = false;
            $femail = request_var('femail', '');
            if (!empty($femail) && preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $femail)) {
                $user_email = $femail;
            } else {
                $error = true;
                $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Email_invalid'] : $lang['Email_invalid'];
            }
            $username = request_var('fname', '', true);
            $sender_name = request_var('sname', '', true);
            //if (!$user->data['session_logged_in'] || ($user->data['session_logged_in'] && ($sender_name != $user->data['username'])))
            if (!$user->data['session_logged_in']) {
                // Mighty Gorgon: is this really needed?
                /*
                include(IP_ROOT_PATH . 'includes/functions_validate.' . PHP_EXT);
                $result = validate_username($sender_name);
                if ($result['error'])
                {
                	$error = true;
                	$error_msg .= (!empty($error_msg)) ? '<br />' . $result['error_msg'] : $result['error_msg'];
                }
                */
            } else {
                $sender_name = $user->data['username'];
            }
            if (!$user->data['session_logged_in']) {
                $semail = request_var('semail', '');
                if (!empty($semail) && preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $femail)) {
                    $sender_email = $semail;
                } else {
                    $error = true;
                    $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Email_invalid'] : $lang['Email_invalid'];
                }
            } else {
                $sender_email = $user->data['user_email'];
            }
            $subject = request_var('subject', '', true);
            $subject = htmlspecialchars_decode($subject, ENT_COMPAT);
            if (empty($subject)) {
                $error = true;
                $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email'];
            }
            $message = request_var('message', '', true);
            // We need to check if HTML emails are enabled so we can correctly escape content and linebreaks
            $message = !empty($config['html_email']) ? nl2br($message) : htmlspecialchars_decode($message, ENT_COMPAT);
            if (empty($message)) {
                $error = true;
                $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email'];
            }
            if (!$error) {
                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);
                $emailer->use_template('profile_send_email', $user_lang);
                $emailer->to($user_email);
                $emailer->from($sender_email);
                $emailer->replyto($sender_email);
                $emailer->set_subject($subject);
                $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'FROM_USERNAME' => $sender_name, 'TO_USERNAME' => $username, 'MESSAGE' => $message));
                $emailer->send();
                $emailer->reset();
                $message = $lang['Econf'] . '<br /><br />' . sprintf($lang['Click_return'], '<a href="' . append_sid('dload.' . PHP_EXT . '?action=file&amp;file_id=' . $file_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_HOME) . '">', '</a>');
                message_die(GENERAL_MESSAGE, $message);
            }
            if ($error) {
                message_die(GENERAL_MESSAGE, $error_msg);
            }
        }
        $this->generate_category_nav($file_data['file_catid']);
        $template->assign_vars(array('USER_LOGGED' => !$user->data['session_logged_in'] ? true : false, 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'S_EMAIL_ACTION' => append_sid('dload.' . PHP_EXT), 'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $user->data['session_id'] . '" />', 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_EMAIL' => $lang['Semail'], 'L_EMAIL' => $lang['Emailfile'], 'L_EMAILINFO' => $lang['Emailinfo'], 'L_YNAME' => $lang['Yname'], 'L_YEMAIL' => $lang['Yemail'], 'L_FNAME' => $lang['Fname'], 'L_FEMAIL' => $lang['Femail'], 'L_ETEXT' => $lang['Etext'], 'L_DEFAULTMAIL' => $lang['Defaultmail'], 'L_SEMAIL' => $lang['Semail'], 'L_ESUB' => $lang['Esub'], 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD_HOME' => append_sid('dload.' . PHP_EXT), 'U_FILE_NAME' => append_sid('dload.' . PHP_EXT . '?action=file&amp;file_id=' . $file_id), 'FILE_NAME' => $file_data['file_name'], 'SNAME' => $user->data['username'], 'SEMAIL' => $user->data['user_email'], 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'FILE_URL' => create_server_url() . 'dload.' . PHP_EXT . '?action=file&amp;file_id=' . $file_id, 'ID' => $file_id));
        $this->display($lang['Download'], 'pa_email_body.tpl');
    }
Exemple #16
0
                 //
                 // 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}";
                 if (!($result = $db->sql_query($group_sql))) {
                     message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
                 }
                 $group_name_row = $db->sql_fetchrow($result);
                 $group_name = $group_name_row['group_name'];
                 include $phpbb_root_path . 'includes/emailer.' . $phpEx;
                 $emailer = new emailer($board_config['smtp_delivery']);
                 // Begin PNphpBB2 Module
                 //						$emailer->from($board_config['board_email']);
                 //						$emailer->replyto($board_config['board_email']);
                 $emailer->from('');
                 $emailer->replyto('');
                 // End PNphpBB2 Module
                 for ($i = 0; $i < count($bcc_list); $i++) {
                     $emailer->bcc($bcc_list[$i]);
                 }
                 $emailer->use_template('group_approved');
                 $emailer->set_subject($lang['Group_approved']);
                 $emailer->assign_vars(array('SITENAME' => $board_config['sitename'], 'GROUP_NAME' => $group_name, 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_GROUPCP' => $board_config['server_name'] . ModUtil::url('ZphpBB2', 'user', 'groupcp', array(POST_GROUPS_URL => $group_id))));
                 $emailer->send();
                 $emailer->reset();
             }
         }
     }
 }
 //
 // END approve or deny
Exemple #17
0
     if (!$_POST['friendname']) {
         $friendname = substr($friendemail, 0, strpos($_POST['friendemail'], "@"));
     }
 } else {
     $error = TRUE;
     $error_msg = "You have not entered a (valid) email address";
 }
 if (!$error) {
     include $phpbb_root_path . 'includes/emailer.' . $phpEx;
     $emailer = new emailer($board_config['smtp_delivery']);
     $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 - ' . decode_ip($user_ip) . "\r\n";
     $emailer->from($userdata['username'] . " <" . $userdata['user_email'] . ">");
     $emailer->replyto($userdata['username'] . " <" . $userdata['user_email'] . ">");
     $emailer->use_template('tellafriend_email', $userdata['user_lang']);
     $emailer->email_address($friendname . '<' . $friendemail . '>');
     $emailer->set_subject(trim(stripslashes($topic)));
     $emailer->extra_headers($email_headers);
     $emailer->assign_vars(array('SITENAME' => $board_config['sitename'], 'BOARD_EMAIL' => $board_config['board_email'], 'FROM_USERNAME' => $userdata['username'], 'TO_USERNAME' => $friendname, 'MESSAGE' => $message));
     $emailer->send();
     $emailer->reset();
     $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . append_sid($_POST['link']) . '">'));
     $message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.{$phpEx}") . '">', '</a>');
     message_die(GENERAL_MESSAGE, $message);
 }
 if ($error) {
     $template->set_filenames(array('reg_header' => 'error_body.tpl'));
     $template->assign_vars(array('ERROR_MESSAGE' => $error_msg));
     $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
Exemple #18
0
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);
			}
		}
	}
}
Exemple #19
0
     // Add to the users new pm counter
     //
     $sql = "UPDATE " . USERS_TABLE . "\r\n\t\t\t\tSET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "  \r\n\t\t\t\tWHERE user_id = " . $to_userdata['user_id'];
     if (!($status = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
     }
     if ($to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active']) {
         $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path']));
         $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $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']) . '/' : '/';
         include $phpbb_root_path . 'includes/emailer.' . $phpEx;
         $emailer = new emailer($board_config['smtp_delivery']);
         $emailer->from($board_config['board_email']);
         $emailer->replyto($board_config['board_email']);
         $emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
         $emailer->email_address($to_userdata['user_email']);
         $emailer->set_subject($lang['Notification_subject']);
         $emailer->assign_vars(array('USERNAME' => stripslashes($to_username), 'SENDER_USERNAME' => htmlspecialchars($userdata['username']), 'PM_SUBJECT' => $privmsg_subject, 'PM_MESSAGE' => $message_text, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox'));
         $emailer->send();
         $emailer->reset();
     }
 }
 /*
 $template->assign_vars(array(
 	'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("privmsg.$phpEx?folder=inbox") . '">')
 );
 
 $msg = $lang['Message_sent'] . '<br /><br />' . sprintf($lang['Click_return_inbox'], '<a href="' . append_sid("privmsg.$phpEx?folder=inbox") . '">', '</a> ') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
 
function cash_pm(&$targetdata, $privmsg_subject, &$message)
{
    global $db, $board_config, $lang, $userdata, $phpbb_root_path, $phpEx, $html_entities_match, $html_entities_replace, $bbcode_parse;
    //
    // It looks like we're sending a PM!
    // NOTE: most of the following code is shamelessly "reproduced" from privmsg.php
    //
    //include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
    //include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
    include_once $phpbb_root_path . 'includes/functions_messages.' . $phpEx;
    //
    // Toggles
    //
    if (!$board_config['allow_html']) {
        $html_on = 0;
    } else {
        $html_on = $userdata['user_allowhtml'];
    }
    $bbcode_on = TRUE;
    if (!$board_config['allow_smilies']) {
        $smilies_on = 0;
    } else {
        $smilies_on = $userdata['user_allowsmile'];
    }
    $attach_sig = $userdata['user_attachsig'];
    $msg_time = time();
    $privmsg_message = $message;
    send_pm(0, $userdata, $targetdata['user_id'], $privmsg_subject, $privmsg_message, 0, $html_on, $bbcode_on, $smiley_on, $attach_sig);
    if ($targetdata['user_notify_pm'] && !empty($targetdata['user_email']) && $targetdata['user_active']) {
        $script_name = preg_replace('/^\\/?(.*?)\\/?$/', "\\1", trim($board_config['script_path']));
        $script_name = $script_name != '' ? $script_name . '/privmsg.' . $phpEx : 'privmsg.' . $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']) . '/' : '/';
        include $phpbb_root_path . 'includes/emailer.' . $phpEx;
        $emailer = new emailer($board_config['smtp_delivery']);
        $emailer->from($board_config['board_email']);
        $emailer->replyto($board_config['board_email']);
        $emailer->use_template('privmsg_notify', $targetdata['user_lang']);
        $emailer->email_address($targetdata['user_email']);
        $emailer->set_subject($lang['Notification_subject']);
        $emailer->assign_vars(array('USERNAME' => $to_username, 'SITENAME' => $board_config['sitename'], 'EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox'));
        $emailer->send();
        $emailer->reset();
    }
}