function ajaxPostComment($text, $aid = false) { if ($aid) { $answer = qa_db_single_select(qa_db_full_post_selectspec(null, $aid)); } require_once QA_INCLUDE_DIR . 'qa-page-question-post.php'; global $qa_login_userid, $qa_cookieid, $question, $questionid, $formtype, $formpostid, $errors, $reloadquestion, $pageerror, $qa_request, $ineditor, $incomment, $informat, $innotify, $inemail, $commentsfollows, $jumptoanchor, $usecaptcha; $parent = isset($answer) ? $answer : $question; switch (qa_user_permit_error('permit_post_c', 'C')) { case 'login': $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_login'), $qa_request); break; case 'confirm': $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), $qa_request); break; case 'limit': $pageerror = qa_lang_html('question/comment_limit'); break; default: $pageerror = qa_lang_html('users/no_permission'); break; case false: $incomment = qa_post_text('ajax_comment_content'); if (!isset($incomment)) { $pageerror = qa_lang_html('bork'); } else { $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); $this->ajaxEditor($ineditor, $incomment, $informat, $intext); // use our own format types $formats = array(); $formats[] = ''; $editors = qa_list_modules('viewer'); if (in_array('Markdown Viewer', $editors)) { $formats[] = 'markdown'; } $formats[] = 'html'; $informat = $formats[qa_opt('ajax_comment_format')]; $errors = qa_comment_validate($incomment, $informat, $intext, $innotify, $inemail); if ($usecaptcha) { qa_captcha_validate($_POST, $errors); } if (empty($errors)) { $isduplicate = false; foreach ($commentsfollows as $comment) { if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) { if (implode(' ', qa_string_to_words($comment['content'])) == implode(' ', qa_string_to_words($incomment))) { $isduplicate = true; } } } if (!$isduplicate) { if (!isset($qa_login_userid)) { $qa_cookieid = qa_cookie_get_create(); } // create a new cookie if necessary // get editor format $commentid = qa_comment_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incomment, $informat, $intext, $innotify, $inemail, $question, @$answer, $commentsfollows); qa_report_write_action($qa_login_userid, $qa_cookieid, 'c_post', $questionid, @$answer['postid'], $commentid); } else { $pageerror = qa_lang_html('question/duplicate_content'); } } } break; } if ($pageerror) { $this->output_raw('### ' . $pageerror); } else { if (!empty($errors)) { $this->output_raw('### ' . implode(',', $errors)); } else { // return c_item $c_item = $this->ajaxCommentCreate($parent, $commentid); if (isset($c_item['classes'])) { $c_item['classes'] .= ' ajax-comment-hidden'; } else { $c_item['classes'] = ' ajax-comment-hidden'; } $this->c_list_item($c_item); } } }
return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Send the feedback form $feedbacksent = false; 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;
function qa_page_q_do_comment($answer) { global $qa_login_userid, $qa_cookieid, $question, $questionid, $formtype, $formpostid, $errors, $reloadquestion, $pageerror, $qa_request, $ineditor, $incomment, $informat, $innotify, $inemail, $commentsfollows, $jumptoanchor, $usecaptcha; $parent = isset($answer) ? $answer : $question; switch (qa_user_permit_error('permit_post_c', 'C')) { case 'login': $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_login'), $qa_request); break; case 'confirm': $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), $qa_request); break; case 'limit': $pageerror = qa_lang_html('question/comment_limit'); break; default: $pageerror = qa_lang_html('users/no_permission'); break; case false: $incomment = qa_post_text('comment'); if (!isset($incomment)) { $formtype = 'c_add'; $formpostid = $parent['postid']; // show form first time } else { $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); qa_get_post_content('editor', 'comment', $ineditor, $incomment, $informat, $intext); $errors = qa_comment_validate($incomment, $informat, $intext, $innotify, $inemail); if ($usecaptcha) { qa_captcha_validate($_POST, $errors); } if (empty($errors)) { $isduplicate = false; foreach ($commentsfollows as $comment) { if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) { if (implode(' ', qa_string_to_words($comment['content'])) == implode(' ', qa_string_to_words($incomment))) { $isduplicate = true; } } } if (!$isduplicate) { if (!isset($qa_login_userid)) { $qa_cookieid = qa_cookie_get_create(); } // create a new cookie if necessary $commentid = qa_comment_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incomment, $informat, $intext, $innotify, $inemail, $question, $answer, $commentsfollows); qa_report_write_action($qa_login_userid, $qa_cookieid, 'c_post', $questionid, @$answer['postid'], $commentid); qa_redirect($qa_request, null, null, null, qa_anchor(isset($answer) ? 'A' : 'Q', $parent['postid'])); } else { $pageerror = qa_lang_html('question/duplicate_content'); } } else { $formtype = 'c_add'; $formpostid = $parent['postid']; // show form again } } break; } }