示例#1
0
 $categoryids = array_keys(qa_category_path($categories, @$in['categoryid']));
 $userlevel = qa_user_level_for_categories($categoryids);
 $in['name'] = qa_post_text('name');
 $in['notify'] = qa_post_text('notify') ? true : false;
 $in['email'] = qa_post_text('email');
 $in['queued'] = qa_user_moderation_reason($userlevel) ? true : false;
 qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
 $errors = array();
 if (!qa_check_form_security_code('ask', qa_post_text('code'))) {
     $errors['page'] = qa_lang_html('misc/form_security_again');
 } else {
     $filtermodules = qa_load_modules_with('filter', 'filter_question');
     foreach ($filtermodules as $filtermodule) {
         $oldin = $in;
         $filtermodule->filter_question($in, $errors, null);
         qa_update_post_text($in, $oldin);
     }
     if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($in['categoryid'])) {
         $errors['categoryid'] = qa_lang_html('question/category_required');
     } elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) {
         $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed');
     }
     if ($captchareason) {
         require_once 'qa-app-captcha.php';
         qa_captcha_validate_post($errors);
     }
     if (empty($errors)) {
         $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
         // create a new cookie if necessary
         $questionid = qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']);
         qa_redirect(qa_q_request($questionid, $in['title']));
示例#2
0
function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors)
{
    $parentid = $parent['postid'];
    $prefix = 'c' . $parentid . '_';
    $in = array('name' => qa_post_text($prefix . 'name'), 'notify' => qa_post_text($prefix . 'notify') !== null, 'email' => qa_post_text($prefix . 'email'), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) !== false);
    qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
    $errors = array();
    if (!qa_check_form_security_code('comment-' . $parent['postid'], qa_post_text($prefix . 'code'))) {
        $errors['content'] = qa_lang_html('misc/form_security_again');
    } else {
        $filtermodules = qa_load_modules_with('filter', 'filter_comment');
        foreach ($filtermodules as $filtermodule) {
            $oldin = $in;
            $filtermodule->filter_comment($in, $errors, $question, $parent, null);
            qa_update_post_text($in, $oldin);
        }
        if ($usecaptcha) {
            qa_captcha_validate_post($errors);
        }
        if (empty($errors)) {
            $testwords = implode(' ', qa_string_to_words($in['content']));
            foreach ($commentsfollows as $comment) {
                if ($comment['basetype'] == 'C' && $comment['parentid'] == $parentid && !$comment['hidden']) {
                    if (implode(' ', qa_string_to_words($comment['content'])) == $testwords) {
                        $errors['content'] = qa_lang_html('question/duplicate_content');
                    }
                }
            }
        }
        if (empty($errors)) {
            $userid = qa_get_logged_in_userid();
            $handle = qa_get_logged_in_handle();
            $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
            // create a new cookie if necessary
            $commentid = qa_comment_create($userid, $handle, $cookieid, $in['content'], $in['format'], $in['text'], $in['notify'], $in['email'], $question, $parent, $commentsfollows, $in['queued'], $in['name']);
            return $commentid;
        }
    }
    return null;
}
function qa_page_q_edit_c_submit($comment, $question, $parent, &$in, &$errors)
{
    $commentid = $comment['postid'];
    $prefix = 'c' . $commentid . '_';
    $in = array();
    if ($comment['isbyuser']) {
        $in['name'] = qa_post_text($prefix . 'name');
        $in['notify'] = qa_post_text($prefix . 'notify') ? true : false;
        $in['email'] = qa_post_text($prefix . 'email');
    }
    if (!qa_user_post_permit_error('permit_edit_silent', $comment)) {
        $in['silent'] = qa_post_text($prefix . 'silent');
    }
    qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
    // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters
    $errors = array();
    if (!qa_check_form_security_code('edit-' . $commentid, qa_post_text($prefix . 'code'))) {
        $errors['content'] = qa_lang_html('misc/form_security_again');
    } else {
        $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason(qa_user_level_for_post($comment));
        $filtermodules = qa_load_modules_with('filter', 'filter_comment');
        foreach ($filtermodules as $filtermodule) {
            $oldin = $in;
            $filtermodule->filter_comment($in, $errors, $question, $parent, $comment);
            qa_update_post_text($in, $oldin);
        }
        if (empty($errors)) {
            $userid = qa_get_logged_in_userid();
            $handle = qa_get_logged_in_handle();
            $cookieid = qa_cookie_get();
            if (!isset($in['silent'])) {
                $in['silent'] = false;
            }
            $setnotify = $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $in['notify'], $in['email']) : $comment['notify'];
            qa_comment_set_content($comment, $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question, $parent, @$in['name'], $in['queued'], $in['silent']);
            return true;
        }
    }
    return false;
}
function qa_page_q_edit_c_submit($comment, $question, $parent, &$in, &$errors)
{
    $commentid = $comment['postid'];
    $prefix = 'c' . $commentid . '_';
    $in = array();
    if ($comment['isbyuser']) {
        $in['notify'] = qa_post_text($prefix . 'notify') ? true : false;
        $in['email'] = qa_post_text($prefix . 'email');
    }
    qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
    $errors = array();
    $filtermodules = qa_load_modules_with('filter', 'filter_comment');
    foreach ($filtermodules as $filtermodule) {
        $oldin = $in;
        $filtermodule->filter_comment($in, $errors, $question, $parent, $comment);
        qa_update_post_text($in, $oldin);
    }
    if (empty($errors)) {
        $userid = qa_get_logged_in_userid();
        $handle = qa_get_logged_in_handle();
        $cookieid = qa_cookie_get();
        qa_comment_set_content($comment, $in['content'], $in['format'], $in['text'], $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $in['notify'], $in['email']) : $comment['notify'], $userid, $handle, $cookieid, $question, $parent);
        return true;
    }
    return false;
}