function process_request($request) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; require_once QA_INCLUDE_DIR . 'qa-db-post-create.php'; require_once QA_INCLUDE_DIR . 'mp-db-users.php'; // report that we entered this page qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'])); // create the editor and update its content qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$incontent, @$informat, $editorname); // retrieve variable data $innotify = qa_post_text('notify') ? true : false; // handle creation of annoucement if (qa_post_text('docreate')) { //retrieve data $title = qa_post_text('title'); $content = $incontent; $format = $informat; // validate data // handle create work // actual create process is in file mp-app-posts.php $postid = qa_post_create('AN', null, $title, $content, $format, mp_get_categoryid(), null, qa_get_logged_in_userid(), $innotify); // redirect page qa_redirect('mp-announcements-page'); // our work is done here } $qa_content = qa_content_prepare(); // if the user is not logged in, request user to login if (!qa_get_logged_in_userid()) { $qa_content['error'] = qa_insert_login_links('Please ^1log in^2 or ^3register^4 first.', $request); return $qa_content; } $qa_content['title'] = 'Create Announcement'; $qa_content['form_newannouncement'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('announcements/a_title_label'), 'tags' => 'NAME="title"', 'value' => qa_html(qa_post_text('title')), 'error' => qa_html(@$errors['title'])), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('announcements/a_content_label'), 'error' => qa_html(@$errors['content']))), 'notify' => array('label' => 'Send email notification to all registered students', 'tags' => 'NAME="notify"', 'type' => 'checkbox', 'value' => qa_html($innotify))), 'buttons' => array('ok' => array('tags' => 'NAME="docreate"', 'label' => 'Create Announcement', 'value' => '1')), 'hidden' => array('hiddenfield' => '1', 'editor' => qa_html($editorname))); // create the sub menu for navigation $qa_content['navigation']['sub'] = mp_announcements_sub_navigation(); $qa_content['navigation']['sub']['create']['selected'] = true; return $qa_content; }
$in['title'] = qa_post_text('title'); // allow title and tags to be posted by an external form $in['extra'] = qa_opt('extra_field_active') ? qa_post_text('extra') : null; if (qa_using_tags()) { $in['tags'] = qa_get_tags_field_value('tags'); } if (qa_clicked('doask')) { require_once QA_INCLUDE_DIR . 'qa-app-post-create.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $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'); }
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_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['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; }
public function process_request($request) { $qa_content = qa_content_prepare(); $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $html = ""; $postid = qa_request_part(1); if (isset($postid)) { $result = qa_db_query_sub('SELECT * FROM ^blog_posts WHERE `postid` LIKE #', $postid); if ($row = mysqli_fetch_array($result)) { $userid = $row['userid']; $author = handleLinkForID($row['userid']); $editor = qa_get_logged_in_userid(); if ($userid >= $editor) { if (qa_clicked('doedit')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('UPDATE ^blog_posts SET updated=NOW(), title=$, content=$, type=#, format=$ WHERE postid=#', $in['title'], $in['content'], $type, 'markdown', $postid); header('location:' . qa_path_to_root() . '/blog/' . $postid); } } else { if (qa_clicked('doresetoptions')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('UPDATE ^blog_posts SET updated=NOW(), title=$, content=$, type=#, format=$ WHERE postid=#', $in['title'], $in['content'], $type, 'draft', $postid); header('location:' . qa_path_to_root() . '/blog/' . $postid); } } else { if (qa_clicked('dogoback')) { qa_redirect('blog'); } else { if (qa_clicked('dosaveoptions')) { qa_redirect('blog'); } else { if (qa_clicked('docancel')) { qa_redirect('blog'); } } } } } } $qa_content['title'] = 'Editing: ' . $row['title']; $userpostslink = '/user/' . qa_get_logged_in_handle() . '/articles'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $typeoptions = array('cat_1' => $category_1, 'cat_2' => $category_2, 'cat_3' => $category_3, 'cat_4' => $category_4, 'cat_5' => $category_5); $qa_content['form'] = array('tags' => 'name="edit" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang('qa_blog_lang/post_title'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => $row['title'], 'rows' => 2, 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang('qa_blog_lang/post_cat'), 'type' => 'select', 'tags' => 'name="category"', 'options' => $typeoptions, 'error' => qa_html(@$errors['type'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => array('value' => $row['content'], 'tags' => 'name="content"', 'error' => qa_html(@$errors['content']), 'rows' => 4)), 'buttons' => array('edit' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang('qa_blog_lang/update_button')), 'save' => array('tags' => 'name="doresetoptions"', 'label' => qa_lang('qa_blog_lang/draft_button')), 'hide' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang('qa_blog_lang/hide_button')), 'goback' => array('tags' => 'name="dogoback"', 'label' => qa_lang('qa_blog_lang/cancel_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang('qa_blog_lang/delete_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('article'), 'doedit' => '1')); $html = "<h2>" . qa_lang('qa_blog_lang/past_post') . "</h2>"; $userid = qa_get_logged_in_userid(); $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE userid = '{$userid}' ORDER BY posted DESC"); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= '<ul><li><h3><a href="blog/' . $blob['postid'] . '/' . seoUrl3($blob['title']) . '">' . $blob['title'] . '</a><h3></li></ul>'; } if ($i == 0) { $html .= qa_lang('qa_blog_lang/post_null'); } $html .= ''; $qa_content['custom2'] = $html; } else { $site_url = qa_opt('site_url'); $qa_content['title'] = qa_lang('qa_blog_lang/title_error'); $qa_content['error'] = qa_lang('qa_blog_lang/edit_error') . '<a href=' . $site_url . '/blog/> ' . qa_lang('qa_blog_lang/edit_error1') . '</a>'; $qa_content['custom2'] = qa_lang('qa_blog_lang/edit_note'); } return $qa_content; } }
$qa_content['error'] = qa_lang_html('users/no_permission'); break; } return $qa_content; } // Process input $usecaptcha = qa_user_use_captcha('captcha_on_anon_post'); $intitle = qa_post_text('title'); // allow title and tags to be posted by an external form $intags = qa_get_tags_field_value('tags'); if (qa_clicked('doask')) { require_once QA_INCLUDE_DIR . 'qa-app-post-create.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $tagstring = qa_tags_to_tagstring($intags); $errors = qa_question_validate($intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail); if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($incategoryid)) { $errors['category'] = qa_lang_html('question/category_required'); } if ($usecaptcha) { require_once 'qa-app-captcha.php'; qa_captcha_validate($_POST, $errors); } if (empty($errors)) { if (!isset($qa_login_userid)) { $qa_cookieid = qa_cookie_get_create(); } // create a new cookie if necessary $questionid = qa_question_create($followanswer, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail, $incategoryid);
function doctype() { //qa_error_log($this->content); if ($this->request == 'admin/permissions' && function_exists('qa_register_plugin_phrases') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $permits[] = 'expert_question_ask'; $permits[] = 'expert_question_roles'; foreach ($permits as $optionname) { $value = qa_opt($optionname); $optionfield = array('id' => $optionname, 'label' => qa_lang_html('expert_question/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'error' => qa_html(@$errors[$optionname])); $widest = QA_PERMIT_USERS; $narrowest = QA_PERMIT_ADMINS; $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails')); if (count($permitoptions) > 1) { qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions))); } $this->content['form']['fields'][$optionname] = $optionfield; $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . ' ', 'note' => qa_lang_html('admin/points')); $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')'; } qa_set_display_rules($this->content, $checkboxtodisplay); } $this->expert_user = $this->is_expert_user(); if (!$this->expert_user) { foreach ($this->content['navigation']['main'] as $key => $nav) { if ($nav['url'] == qa_path_html(qa_opt('expert_question_page_url'))) { unset($this->content['navigation']['main'][$key]); } } } if (qa_clicked('do_expert_answeradd') && ($this->expert_user || $this->content['q_view']['raw']['userid'] === qa_get_logged_in_userid())) { global $qa_login_userid, $questionid, $question, $answers, $question, $qa_request; $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $isduplicate = false; foreach ($answers as $answer) { if (!$answer['hidden']) { if (implode(' ', qa_string_to_words($answer['content'])) == implode(' ', qa_string_to_words($incontent))) { $isduplicate = true; } } } if (!$isduplicate) { if (!isset($qa_login_userid)) { $qa_cookieid = qa_cookie_get_create(); } // create a new cookie if necessary $answerid = qa_answer_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incontent, $informat, $intext, $innotify, $inemail, $question); qa_report_write_action($qa_login_userid, $qa_cookieid, 'a_post', $questionid, $answerid, null); qa_redirect($qa_request, null, null, null, qa_anchor('A', $answerid)); } else { $pageerror = qa_lang_html('question/duplicate_content'); } qa_page_q_load_q(); // reload since we may have changed something } if (qa_opt('expert_question_enable')) { if ($this->expert_user && qa_opt('expert_question_show_count')) { $this->expertcount = qa_db_read_one_value(qa_db_query_sub("SELECT COUNT(postid) FROM ^postmeta, ^posts WHERE ^postmeta.meta_key='is_expert_question' AND ^postmeta.post_id=^posts.postid AND ^posts.acount=0" . (is_array($this->expert_user) ? " AND ^posts.categoryid IN (#)" : " AND \$"), $this->expert_user), true); if ($this->expertcount) { foreach ($this->content['navigation']['main'] as $key => $nav) { if ($nav['url'] == qa_path_html(qa_opt('expert_question_page_url'))) { $this->content['navigation']['main'][$key]['label'] .= ' (' . $this->expertcount . ')'; } } } } global $qa_request; if ($qa_request == qa_opt('expert_question_page_url')) { $this->content['navigation']['sub'] = array('special' => 1); } if ($this->template == 'ask' && in_array(qa_opt('expert_question_type'), array(0, 2)) && !qa_user_permit_error('permit_post_q') && !qa_permit_value_error(qa_opt('expert_question_ask'), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags()) && !qa_opt('site_maintenance')) { $this->content['form']['fields'][] = array('tags' => 'NAME="is_expert_question" ID="is_expert_question"', 'value' => qa_get(qa_opt('expert_question_page_url')) == 'true' ? qa_opt('expert_question_yes') : qa_opt('expert_question_no'), 'type' => 'select-radio', 'options' => array('no' => qa_opt('expert_question_no'), 'yes' => qa_opt('expert_question_yes'))); } if ($this->template == 'user' && qa_get_logged_in_handle() === $this->_user_handle()) { if (!isset($this->content['navigation']['sub'])) { $this->content['navigation']['sub'] = array('profile' => array('url' => qa_path_html('user/' . $this->_user_handle(), null, qa_opt('site_url')), 'label' => $this->_user_handle(), 'selected' => !qa_get('tab') ? true : false), qa_opt('expert_question_page_url') => array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => qa_opt('expert_question_page_url')), qa_opt('site_url')), 'label' => qa_opt('expert_question_page_title'), 'selected' => qa_get('tab') == qa_opt('expert_question_page_url') ? true : false)); } else { $this->content['navigation']['sub'][qa_opt('expert_question_page_url')] = array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => qa_opt('expert_question_page_url')), qa_opt('site_url')), 'label' => qa_opt('expert_question_page_title'), 'selected' => qa_get('tab') == qa_opt('expert_question_page_url') ? true : false); } } if ($this->template == 'question') { $qid = $this->content['q_view']['raw']['postid']; $expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $qid), true); if ($expert) { // is expert question $this->expert_question = 1; // modify post elements // title $this->content['title'] .= ' ' . qa_opt('expert_question_title'); // css class $this->content['q_view']['tags'] .= ' class="qa-expert-question"'; // remove hidden stuff unset($this->content['q_view']['hidden']); unset($this->content['hidden']); } } } qa_html_theme_base::doctype(); }
public function process_request($request) { $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $qa_content = qa_content_prepare(); $errors = array(); if (qa_clicked('docancel')) { qa_redirect('blog'); } else { if (qa_clicked('dosaveoptions')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } qa_db_query_sub('INSERT INTO ^blog_posts (postid, userid, posted, title, type, content, views,format) VALUES (0,#,NOW(),$,#,$,0,$)', qa_get_logged_in_userid(), $in['title'], $type, $in['content'], 'draft'); header('location:' . qa_path_to_root() . '/user/' . qa_get_logged_in_handle() . ''); } } else { if (qa_clicked('doarticle')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('INSERT INTO ^blog_posts (postid, userid, posted, title, type, content, views,format) VALUES (0,#,NOW(),$,#,$,0,$)', qa_get_logged_in_userid(), $in['title'], $type, $in['content'], 'markdown'); header('location:' . qa_path_to_root() . '/blog/'); } } } } if (qa_is_logged_in()) { $qa_content['title'] = qa_lang('qa_blog_lang/articles_page'); $userpostslink = '/user/' . qa_get_logged_in_handle() . '/articles'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $field['label'] = ''; $field['error'] = qa_html(@$errors['content']); $qa_content['custom'] = qa_lang('qa_blog_lang/default_blog_tagline'); $typeoptions = array('cat_1' => $category_1, 'cat_2' => $category_2, 'cat_3' => $category_3, 'cat_4' => $category_4, 'cat_5' => $category_5); $qa_content['form'] = array('tags' => 'name="blog" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang('qa_blog_lang/post_title'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang('qa_blog_lang/post_cat'), 'type' => 'select', 'tags' => 'name="category"', 'options' => $typeoptions, 'error' => qa_html(@$errors['type'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => $field), 'buttons' => array('post' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang('qa_blog_lang/post_button')), 'save' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang('qa_blog_lang/draft_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang('qa_blog_lang/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('article'), 'doarticle' => '1')); $html = "<h2>" . qa_lang('qa_blog_lang/past_post') . "</h2>"; $userid = qa_get_logged_in_userid(); $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE userid = '{$userid}' ORDER BY posted DESC"); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= '<ul><li><h3><a href="blog/' . $blob['postid'] . '/' . seoUrl3($blob['title']) . '">' . $blob['title'] . '</a><h3></li></ul>'; } if ($i == 0) { $html .= qa_lang('qa_blog_lang/post_null'); } $html .= ''; $qa_content['custom2'] = $html; } else { $qa_content['title'] = qa_lang('qa_blog_lang/title_error'); $qa_content['error'] = qa_insert_login_links(qa_lang('qa_blog_lang/access_error'), $request); } return $qa_content; }
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; } }