Exemplo n.º 1
0
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, $html = false)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_notifications_suspended;
    if ($qa_notifications_suspended > 0) {
        return false;
    }
    require_once QA_INCLUDE_DIR . 'db/selects.php';
    require_once QA_INCLUDE_DIR . 'util/string.php';
    if (isset($userid)) {
        $needemail = !qa_email_validate(@$email);
        // take from user if invalid, e.g. @ used in practice
        $needhandle = empty($handle);
        if ($needemail || $needhandle) {
            if (QA_FINAL_EXTERNAL_USERS) {
                if ($needhandle) {
                    $handles = qa_get_public_from_userids(array($userid));
                    $handle = @$handles[$userid];
                }
                if ($needemail) {
                    $email = qa_get_user_email($userid);
                }
            } else {
                $useraccount = qa_db_select_with_pending(array('columns' => array('email', 'handle'), 'source' => '^users WHERE userid = #', 'arguments' => array($userid), 'single' => true));
                if ($needhandle) {
                    $handle = @$useraccount['handle'];
                }
                if ($needemail) {
                    $email = @$useraccount['email'];
                }
            }
        }
    }
    if (isset($email) && qa_email_validate($email)) {
        $subs['^site_title'] = qa_opt('site_title');
        $subs['^handle'] = $handle;
        $subs['^email'] = $email;
        $subs['^open'] = "\n";
        $subs['^close'] = "\n";
        return qa_send_email(array('fromemail' => qa_opt('from_email'), 'fromname' => qa_opt('site_title'), 'toemail' => $email, 'toname' => $handle, 'subject' => strtr($subject, $subs), 'body' => (empty($handle) ? '' : qa_lang_sub('emails/to_handle_prefix', $handle)) . strtr($body, $subs), 'html' => $html));
    } else {
        return false;
    }
}
Exemplo n.º 2
0
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs)
{
    global $qa_notifications_suspended;
    if ($qa_notifications_suspended > 0) {
        return false;
    }
    require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
    require_once QA_INCLUDE_DIR . 'qa-util-emailer.php';
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    if (isset($userid)) {
        $needemail = !qa_email_validate(@$email);
        // take from user if invalid, e.g. @ used in practice
        $needhandle = empty($handle);
        if ($needemail || $needhandle) {
            if (QA_FINAL_EXTERNAL_USERS) {
                if ($needhandle) {
                    $handles = qa_get_public_from_userids(array($userid));
                    $handle = @$handles[$userid];
                }
                if ($needemail) {
                    $email = qa_get_user_email($userid);
                }
            } else {
                $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
                if ($needhandle) {
                    $handle = @$useraccount['handle'];
                }
                if ($needemail) {
                    $email = @$useraccount['email'];
                }
            }
        }
    }
    if (isset($email) && qa_email_validate($email)) {
        $subs['^site_title'] = qa_opt('site_title');
        $subs['^handle'] = $handle;
        $subs['^email'] = $email;
        $subs['^open'] = "\n";
        $subs['^close'] = "\n";
        return qa_send_email(array('fromemail' => qa_opt('from_email'), 'fromname' => qa_opt('site_title'), 'toemail' => $email, 'toname' => $handle, 'subject' => strtr($subject, $subs), 'body' => (empty($handle) ? '' : $handle . ",\n\n") . strtr($body, $subs), 'html' => false));
    } else {
        return false;
    }
}
Exemplo n.º 3
0
function qa_mailing_send_one($userid, $handle, $email, $emailcode)
{
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'qa-db-users.php';
    if (!strlen(trim($emailcode))) {
        $emailcode = qa_db_user_rand_emailcode();
        qa_db_user_set($userid, 'emailcode', $emailcode);
    }
    $unsubscribeurl = qa_path_absolute('unsubscribe', array('c' => $emailcode, 'u' => $handle));
    return qa_send_email(array('fromemail' => qa_opt('mailing_from_email'), 'fromname' => qa_opt('mailing_from_name'), 'toemail' => $email, 'toname' => $handle, 'subject' => qa_opt('mailing_subject'), 'body' => trim(qa_opt('mailing_body')) . "\n\n\n" . qa_lang('users/unsubscribe') . ' ' . $unsubscribeurl, 'html' => false));
}
Exemplo n.º 4
0
if (qa_clicked('dofeedback')) {
    require_once QA_INCLUDE_DIR . 'qa-util-emailer.php';
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $inmessage = qa_post_text('message');
    $inname = qa_post_text('name');
    $inemail = qa_post_text('email');
    $inreferer = qa_post_text('referer');
    if (empty($inmessage)) {
        $errors['message'] = qa_lang('misc/feedback_empty');
    }
    if ($usecaptcha) {
        qa_captcha_validate($_POST, $errors);
    }
    if (empty($errors)) {
        $subs = array('^message' => $inmessage, '^name' => empty($inname) ? '-' : $inname, '^email' => empty($inemail) ? '-' : $inemail, '^previous' => empty($inreferer) ? '-' : $inreferer, '^url' => isset($qa_login_userid) ? qa_path('user/' . qa_get_logged_in_handle(), null, qa_opt('site_url')) : '-', '^ip' => qa_remote_ip_address(), '^browser' => @$_SERVER['HTTP_USER_AGENT']);
        if (qa_send_email(array('fromemail' => qa_email_validate(@$inemail) ? $inemail : qa_opt('from_email'), 'fromname' => $inname, 'toemail' => qa_opt('feedback_email'), 'toname' => qa_opt('site_title'), 'subject' => qa_lang_sub('emails/feedback_subject', qa_opt('site_title')), 'body' => strtr(qa_lang('emails/feedback_body'), $subs), 'html' => false))) {
            $feedbacksent = true;
        } else {
            $page_error = qa_lang_html('main/general_error');
        }
        qa_report_event('feedback', $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, array('email' => $inemail, 'name' => $inname, 'message' => $inmessage, 'previous' => $inreferer, 'browser' => @$_SERVER['HTTP_USER_AGENT']));
    }
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('misc/feedback_title');
$qa_content['error'] = @$page_error;
$qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $feedbacksent ? 'static' : '', 'label' => qa_lang_html_sub('misc/feedback_message', qa_opt('site_title')), 'tags' => 'NAME="message" ID="message"', 'value' => qa_html(@$inmessage), 'rows' => 8, 'error' => qa_html(@$errors['message'])), 'name' => array('type' => $feedbacksent ? 'static' : '', 'label' => qa_lang_html('misc/feedback_name'), 'tags' => 'NAME="name"', 'value' => qa_html(isset($inname) ? $inname : @$userprofile['name'])), 'email' => array('type' => $feedbacksent ? 'static' : '', 'label' => qa_lang_html('misc/feedback_email'), 'tags' => 'NAME="email"', 'value' => qa_html(isset($inemail) ? $inemail : qa_get_logged_in_email()), 'note' => $feedbacksent ? null : qa_opt('email_privacy'))), 'buttons' => array('send' => array('label' => qa_lang_html('main/send_button'))), 'hidden' => array('dofeedback' => '1', 'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER'])));
if ($usecaptcha && !$feedbacksent) {
    qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors);
}
Exemplo n.º 5
0
function qa_news_plugin_send_newsletter($news)
{
    $users = qa_db_read_all_values(qa_db_query_sub("SELECT userid FROM qa_usermetas WHERE title = \$ AND content = \$", 'newsletter', '1'));
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    $handles = qa_userids_to_handles($users);
    foreach ($users as $userid) {
        $handle = $handles[$userid];
        if (QA_FINAL_EXTERNAL_USERS) {
            $email = qa_get_user_email($userid);
        } else {
            $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
            $email = @$useraccount['email'];
        }
        qa_send_email(array('fromemail' => qa_opt('from_email'), 'fromname' => qa_opt('site_title'), 'toemail' => $email, 'toname' => $handle, 'subject' => qa_opt('site_title') . ' ' . qa_lang('newsletter/newsletter'), 'body' => $news, 'html' => true));
    }
    error_log('Q2A Newsletter Sent on ' . date('M j, Y \\a\\t H\\:i\\:s'));
}