function main_parts($content) { if ($this->template == 'admin' && $this->request == 'admin/plugins') { $fields['plugins'] = array('type' => 'custom', 'label' => '<a name="plugin_contents">Plugin Settings:</a>', 'html' => ''); $moduletypes = qa_list_module_types(); foreach ($moduletypes as $moduletype) { $plugins[] = qa_load_modules_with($moduletype, 'option_default'); } $anchors = array(); foreach ($content as $key => $part) { if (strpos($key, 'form_') === 0) { $content[$key]['title'] .= ' <font size="1" style="cursor:pointer; color:blue" onclick="jQuery(document).scrollTop(0)">top</font>'; foreach ($content[$key]['fields'] as $idx => $field) { if (isset($field['tags']) && preg_match('|name="([^"]+)"|i', $field['tags'], $name)) { $name = $name[1]; foreach ($plugins as $modules) { foreach ($modules as $module) { $value = $module->option_default($name); $value = preg_replace('|\\n|', '\\\\n', $value); $value = str_replace('"', '"', $value); $value = str_replace('\'', '\\\'', $value); if (strlen($value)) { $content[$key]['fields'][$idx]['label'] = @$content[$key]['fields'][$idx]['label'] . ' <input type="button" onclick="$(\'[name=' . $name . ']\').val(\'' . $value . '\')" value="r" style="font-size:8pt; width:10px" title="reset to default value">'; } } } } } } } } qa_html_theme_base::main_parts($content); }
function qa_post_index($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid) { global $qa_post_indexing_suspended; if ($qa_post_indexing_suspended > 0) { return; } // Send through to any search modules for indexing $searches = qa_load_modules_with('search', 'index_post'); foreach ($searches as $search) { $search->index_post($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid); } }
/** * Extends the logout functionality by performing some extra clean up for * the external login modules. * * Currently only the login modules using OAuth (like Facebook and Github) * need additional logout processing (defined in their do_logout methods). * The OpenID-based login modules will simply use the default functionality. * * Only logout functionality is affected by this function. Login mechanism * is handled by #qa_log_in_external_user function. */ function qa_set_logged_in_user($userid, $handle = '', $remember = false, $source = null) { // if a logout was requested, do extra stuff if (!isset($userid)) { // get all modules which have a custom logout logic $loginmodules = qa_load_modules_with('login', 'do_logout'); // do the work foreach ($loginmodules as $module) { $module->do_logout(); } } // then just perform the default tasks qa_set_logged_in_user_base($userid, $handle, $remember, $source); }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $loginmodules = qa_load_modules_with('login', 'login_html'); if (empty($loginmodules)) { return; } $themeobject->output('<div class="open-login-sidebar">', qa_lang_html('plugin_open/login_title'), '</div>', '<p class="open-login-sidebar-buttons">'); foreach ($loginmodules as $tryname => $module) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'sidebar'); $label = ob_get_clean(); if (strlen($label)) { $themeobject->output($label); } } $themeobject->output('</p>'); }
function qa_report_process_stage($method) { global $qa_process_reports_suspended; if (@$qa_process_reports_suspended) { return; } $qa_process_reports_suspended = true; // prevent loop, e.g. because of an error $args = func_get_args(); $args = array_slice($args, 1); $processmodules = qa_load_modules_with('process', $method); foreach ($processmodules as $processmodule) { call_user_func_array(array($processmodule, $method), $args); } $qa_process_reports_suspended = null; }
foreach ($modules as $name) { $module = qa_load_module($type, $name); if (method_exists($module, 'admin_form')) { $info = qa_get_module_info($type, $name); $pluginoptionmodules[$info['directory']][] = array('type' => $type, 'name' => $name); } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/plugins_title'); $qa_content['error'] = qa_admin_page_error(); $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION; $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php'); foreach ($moduletypes as $type) { $modules = qa_load_modules_with($type, 'init_queries'); foreach ($modules as $name => $module) { $queries = $module->init_queries($tables); if (!empty($queries)) { if (qa_is_http_post()) { qa_redirect('install'); } else { $qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array('^1' => qa_html($name), '^2' => qa_html($type), '^3' => '<a href="' . qa_path_html('install') . '">', '^4' => '</a>')); } } } } if (qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) { $qa_content['error'] = qa_lang_html('misc/form_security_reload'); $showpluginforms = false; } else {
function display_services(&$qa_content, $has_content) { if (!$has_content) { // no linked logins $qa_content['form_nodata'] = array('title' => '<br>' . qa_lang_html('plugin_open/no_logins_title'), 'style' => 'light', 'fields' => array('note' => array('note' => qa_lang_html('plugin_open/no_logins_text'), 'type' => 'static'))); } else { $qa_content['custom'] = '<h2>' . qa_lang_html('plugin_open/link_with_account') . '</h2><p>' . qa_lang_html('plugin_open/no_logins_text') . '</p>'; } // output login providers $loginmodules = qa_load_modules_with('login', 'printCode'); foreach ($loginmodules as $module) { ob_start(); qa_open_login::printCode($module->provider, null, 'associate', 'link'); $html = ob_get_clean(); if (strlen($html)) { @($qa_content['custom'] .= $html . ' '); } } }
function cs_get_widgets() { ob_start(); foreach (qa_load_modules_with('widget', 'allow_template') as $k => $widget) { ?> <div class="draggable-widget" data-name="<?php echo $k; ?> "> <div class="widget-title"><?php echo $k; ?> <div class="drag-handle icon-move"></div> <div class="widget-delete icon-trash"></div> <div class="widget-template-to icon-list"></div> <div class="widget-options icon-wrench"></div> </div> <div class="select-template"> <label> <input type="checkbox" name="show_title" checked> Show widget title</label><br /> <span>Select where you want to show</span> <?php $this->get_widget_template_checkbox(); ?> </div> <div class="widget-option"> <?php $this->get_widget_form($k); ?> </div> </div> <?php } return ob_get_clean(); }
function qa_default_option($name) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $fixed_defaults = array('allow_change_usernames' => 1, 'allow_close_questions' => 1, 'allow_multi_answers' => 1, 'allow_private_messages' => 1, 'allow_self_answer' => 1, 'allow_view_q_bots' => 1, 'avatar_allow_gravatar' => 1, 'avatar_allow_upload' => 1, 'avatar_profile_size' => 200, 'avatar_q_list_size' => 0, 'avatar_q_page_a_size' => 40, 'avatar_q_page_c_size' => 20, 'avatar_q_page_q_size' => 50, 'avatar_store_size' => 400, 'avatar_users_size' => 30, 'captcha_on_anon_post' => 1, 'captcha_on_feedback' => 1, 'captcha_on_register' => 1, 'captcha_on_reset_password' => 1, 'captcha_on_unconfirmed' => 0, 'columns_tags' => 3, 'columns_users' => 2, 'comment_on_as' => 1, 'comment_on_qs' => 0, 'confirm_user_emails' => 1, 'do_ask_check_qs' => 0, 'do_complete_tags' => 1, 'do_count_q_views' => 1, 'do_example_tags' => 1, 'feed_for_activity' => 1, 'feed_for_qa' => 1, 'feed_for_questions' => 1, 'feed_for_unanswered' => 1, 'feed_full_text' => 1, 'feed_number_items' => 50, 'feed_per_category' => 1, 'feedback_enabled' => 1, 'flagging_hide_after' => 5, 'flagging_notify_every' => 2, 'flagging_notify_first' => 1, 'flagging_of_posts' => 1, 'follow_on_as' => 1, 'hot_weight_a_age' => 100, 'hot_weight_answers' => 100, 'hot_weight_q_age' => 100, 'hot_weight_views' => 100, 'hot_weight_votes' => 100, 'mailing_per_minute' => 500, 'match_ask_check_qs' => 3, 'match_example_tags' => 3, 'match_related_qs' => 3, 'max_copy_user_updates' => 10, 'max_len_q_title' => 120, 'max_num_q_tags' => 5, 'max_rate_ip_as' => 50, 'max_rate_ip_cs' => 40, 'max_rate_ip_flags' => 10, 'max_rate_ip_logins' => 20, 'max_rate_ip_messages' => 10, 'max_rate_ip_qs' => 20, 'max_rate_ip_registers' => 5, 'max_rate_ip_uploads' => 20, 'max_rate_ip_votes' => 600, 'max_rate_user_as' => 25, 'max_rate_user_cs' => 20, 'max_rate_user_flags' => 5, 'max_rate_user_messages' => 5, 'max_rate_user_qs' => 10, 'max_rate_user_uploads' => 10, 'max_rate_user_votes' => 300, 'max_store_user_updates' => 50, 'min_len_a_content' => 12, 'min_len_c_content' => 12, 'min_len_q_content' => 0, 'min_len_q_title' => 12, 'min_num_q_tags' => 0, 'moderate_notify_admin' => 1, 'moderate_points_limit' => 150, 'nav_ask' => 1, 'nav_qa_not_home' => 1, 'nav_questions' => 1, 'nav_tags' => 1, 'nav_unanswered' => 1, 'nav_users' => 1, 'neat_urls' => QA_URL_FORMAT_SAFEST, 'notify_users_default' => 1, 'page_size_activity' => 20, 'page_size_ask_check_qs' => 5, 'page_size_ask_tags' => 5, 'page_size_home' => 20, 'page_size_hot_qs' => 20, 'page_size_q_as' => 10, 'page_size_qs' => 20, 'page_size_related_qs' => 5, 'page_size_search' => 10, 'page_size_tag_qs' => 20, 'page_size_tags' => 30, 'page_size_una_qs' => 20, 'page_size_user_posts' => 20, 'page_size_users' => 20, 'pages_prev_next' => 3, 'permit_anon_view_ips' => QA_PERMIT_EDITORS, 'permit_close_q' => QA_PERMIT_EDITORS, 'permit_delete_hidden' => QA_PERMIT_MODERATORS, 'permit_edit_a' => QA_PERMIT_EXPERTS, 'permit_edit_c' => QA_PERMIT_EDITORS, 'permit_edit_q' => QA_PERMIT_EDITORS, 'permit_flag' => QA_PERMIT_CONFIRMED, 'permit_hide_show' => QA_PERMIT_EDITORS, 'permit_moderate' => QA_PERMIT_EXPERTS, 'permit_select_a' => QA_PERMIT_EXPERTS, 'permit_view_q_page' => QA_PERMIT_ALL, 'permit_vote_a' => QA_PERMIT_USERS, 'permit_vote_down' => QA_PERMIT_USERS, 'permit_vote_q' => QA_PERMIT_USERS, 'points_a_selected' => 30, 'points_a_voted_max_gain' => 20, 'points_a_voted_max_loss' => 5, 'points_base' => 100, 'points_multiple' => 10, 'points_post_a' => 4, 'points_post_q' => 2, 'points_q_voted_max_gain' => 10, 'points_q_voted_max_loss' => 3, 'points_select_a' => 3, 'q_urls_title_length' => 50, 'show_a_c_links' => 1, 'show_a_form_immediate' => 'if_no_as', 'show_c_reply_buttons' => 1, 'show_custom_welcome' => 1, 'show_fewer_cs_count' => 5, 'show_fewer_cs_from' => 10, 'show_full_date_days' => 7, 'show_message_history' => 1, 'show_selected_first' => 1, 'show_url_links' => 1, 'show_user_points' => 1, 'show_user_titles' => 1, 'show_when_created' => 1, 'site_theme' => 'Snow', 'smtp_port' => 25, 'sort_answers_by' => 'created', 'tags_or_categories' => 'tc', 'voting_on_as' => 1, 'voting_on_qs' => 1); if (isset($fixed_defaults[$name])) { $value = $fixed_defaults[$name]; } else { switch ($name) { case 'site_url': $value = 'http://' . @$_SERVER['HTTP_HOST'] . strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/') . '/'; break; case 'site_title': $value = qa_default_site_title(); break; case 'site_theme_mobile': $value = qa_opt('site_theme'); break; case 'from_email': // heuristic to remove short prefix (e.g. www. or qa.) $parts = explode('.', @$_SERVER['HTTP_HOST']); if (count($parts) > 2 && strlen($parts[0]) < 5 && !is_numeric($parts[0])) { unset($parts[0]); } $value = 'no-reply@' . (count($parts) > 1 ? implode('.', $parts) : 'example.com'); break; case 'email_privacy': $value = qa_lang_html('options/default_privacy'); break; case 'show_custom_sidebar': $value = strlen(qa_opt('custom_sidebar')) ? true : false; break; case 'show_custom_header': $value = strlen(qa_opt('custom_header')) ? true : false; break; case 'show_custom_footer': $value = strlen(qa_opt('custom_footer')) ? true : false; break; case 'show_custom_in_head': $value = strlen(qa_opt('custom_in_head')) ? true : false; break; case 'custom_sidebar': $value = qa_lang_html_sub('options/default_sidebar', qa_html(qa_opt('site_title'))); break; case 'editor_for_qs': case 'editor_for_as': require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $value = '-'; // to match none by default, i.e. choose based on who is best at editing HTML qa_load_editor('', 'html', $value); break; case 'permit_post_q': // convert from deprecated option if available $value = qa_opt('ask_needs_login') ? QA_PERMIT_USERS : QA_PERMIT_ALL; break; case 'permit_post_a': // convert from deprecated option if available $value = qa_opt('answer_needs_login') ? QA_PERMIT_USERS : QA_PERMIT_ALL; break; case 'permit_post_c': // convert from deprecated option if available $value = qa_opt('comment_needs_login') ? QA_PERMIT_USERS : QA_PERMIT_ALL; break; case 'permit_retag_cat': // convert from previous option that used to contain it too $value = qa_opt('permit_edit_q'); break; case 'points_vote_up_q': case 'points_vote_down_q': $oldvalue = qa_opt('points_vote_on_q'); $value = is_numeric($oldvalue) ? $oldvalue : 1; break; case 'points_vote_up_a': case 'points_vote_down_a': $oldvalue = qa_opt('points_vote_on_a'); $value = is_numeric($oldvalue) ? $oldvalue : 1; break; case 'points_per_q_voted_up': case 'points_per_q_voted_down': $oldvalue = qa_opt('points_per_q_voted'); $value = is_numeric($oldvalue) ? $oldvalue : 1; break; case 'points_per_a_voted_up': case 'points_per_a_voted_down': $oldvalue = qa_opt('points_per_a_voted'); $value = is_numeric($oldvalue) ? $oldvalue : 2; break; case 'captcha_module': $captchamodules = qa_list_modules('captcha'); if (count($captchamodules)) { $value = reset($captchamodules); } else { $value = ''; } break; case 'mailing_from_name': $value = qa_opt('site_title'); break; case 'mailing_from_email': $value = qa_opt('from_email'); break; case 'mailing_subject': $value = qa_lang_sub('options/default_subject', qa_opt('site_title')); break; case 'mailing_body': $value = "\n\n\n--\n" . qa_opt('site_title') . "\n" . qa_opt('site_url'); break; default: // call option_default method in any registered modules $moduletypes = qa_list_module_types(); foreach ($moduletypes as $moduletype) { $modules = qa_load_modules_with($moduletype, 'option_default'); foreach ($modules as $module) { $value = $module->option_default($name); if (strlen($value)) { return $value; } } } $value = ''; break; } } return $value; }
function qa_recalc_perform_step(&$state) { $continue = false; @(list($operation, $length, $next, $done) = explode(',', $state)); switch ($operation) { case 'doreindexcontent': qa_recalc_transition($state, 'doreindexcontent_pagereindex'); break; case 'doreindexcontent_pagereindex': $pages = qa_db_pages_get_for_reindexing($next, 10); if (count($pages)) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $lastpageid = max(array_keys($pages)); foreach ($pages as $pageid => $page) { if (!($page['flags'] & QA_PAGE_FLAGS_EXTERNAL)) { $searchmodules = qa_load_modules_with('search', 'unindex_page'); foreach ($searchmodules as $searchmodule) { $searchmodule->unindex_page($pageid); } $searchmodules = qa_load_modules_with('search', 'index_page'); if (count($searchmodules)) { $indextext = qa_viewer_text($page['content'], 'html'); foreach ($searchmodules as $searchmodule) { $searchmodule->index_page($pageid, $page['tags'], $page['heading'], $page['content'], 'html', $indextext); } } } } $next = 1 + $lastpageid; $done += count($pages); $continue = true; } else { qa_recalc_transition($state, 'doreindexcontent_postcount'); } break; case 'doreindexcontent_postcount': qa_db_qcount_update(); qa_db_acount_update(); qa_db_ccount_update(); qa_recalc_transition($state, 'doreindexcontent_postreindex'); break; case 'doreindexcontent_postreindex': $posts = qa_db_posts_get_for_reindexing($next, 10); if (count($posts)) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $lastpostid = max(array_keys($posts)); qa_db_prepare_for_reindexing($next, $lastpostid); qa_suspend_update_counts(); foreach ($posts as $postid => $post) { qa_post_unindex($postid); qa_post_index($postid, $post['type'], $post['questionid'], $post['parentid'], $post['title'], $post['content'], $post['format'], qa_viewer_text($post['content'], $post['format']), $post['tags'], $post['categoryid']); } $next = 1 + $lastpostid; $done += count($posts); $continue = true; } else { qa_db_truncate_indexes($next); qa_recalc_transition($state, 'doreindexposts_wordcount'); } break; case 'doreindexposts_wordcount': $wordids = qa_db_words_prepare_for_recounting($next, 1000); if (count($wordids)) { $lastwordid = max($wordids); qa_db_words_recount($next, $lastwordid); $next = 1 + $lastwordid; $done += count($wordids); $continue = true; } else { qa_db_tagcount_update(); // this is quick so just do it here qa_recalc_transition($state, 'doreindexposts_complete'); } break; case 'dorecountposts': qa_recalc_transition($state, 'dorecountposts_postcount'); break; case 'dorecountposts_postcount': qa_db_qcount_update(); qa_db_acount_update(); qa_db_ccount_update(); qa_db_unaqcount_update(); qa_db_unselqcount_update(); qa_recalc_transition($state, 'dorecountposts_votecount'); break; case 'dorecountposts_votecount': $postids = qa_db_posts_get_for_recounting($next, 1000); if (count($postids)) { $lastpostid = max($postids); qa_db_posts_votes_recount($next, $lastpostid); $next = 1 + $lastpostid; $done += count($postids); $continue = true; } else { qa_recalc_transition($state, 'dorecountposts_acount'); } break; case 'dorecountposts_acount': $postids = qa_db_posts_get_for_recounting($next, 1000); if (count($postids)) { $lastpostid = max($postids); qa_db_posts_answers_recount($next, $lastpostid); $next = 1 + $lastpostid; $done += count($postids); $continue = true; } else { qa_db_unupaqcount_update(); qa_recalc_transition($state, 'dorecountposts_complete'); } break; case 'dorecalcpoints': qa_recalc_transition($state, 'dorecalcpoints_usercount'); break; case 'dorecalcpoints_usercount': qa_db_userpointscount_update(); // for progress update - not necessarily accurate qa_recalc_transition($state, 'dorecalcpoints_recalc'); break; case 'dorecalcpoints_recalc': $userids = qa_db_users_get_for_recalc_points($next, 10); if (count($userids)) { $lastuserid = max($userids); qa_db_users_recalc_points($next, $lastuserid); $next = 1 + $lastuserid; $done += count($userids); $continue = true; } else { qa_db_truncate_userpoints($next); qa_db_userpointscount_update(); // quick so just do it here qa_recalc_transition($state, 'dorecalcpoints_complete'); } break; case 'dorefillevents': qa_recalc_transition($state, 'dorefillevents_qcount'); break; case 'dorefillevents_qcount': qa_db_qcount_update(); qa_recalc_transition($state, 'dorefillevents_refill'); break; case 'dorefillevents_refill': $questionids = qa_db_qs_get_for_event_refilling($next, 1); if (count($questionids)) { require_once QA_INCLUDE_DIR . 'qa-app-events.php'; require_once QA_INCLUDE_DIR . 'qa-app-updates.php'; require_once QA_INCLUDE_DIR . 'qa-util-sort.php'; $lastquestionid = max($questionids); foreach ($questionids as $questionid) { // Retrieve all posts relating to this question list($question, $childposts, $achildposts) = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $questionid), qa_db_full_child_posts_selectspec(null, $questionid), qa_db_full_a_child_posts_selectspec(null, $questionid)); // Merge all posts while preserving keys as postids $posts = array($questionid => $question); foreach ($childposts as $postid => $post) { $posts[$postid] = $post; } foreach ($achildposts as $postid => $post) { $posts[$postid] = $post; } // Creation and editing of each post foreach ($posts as $postid => $post) { $followonq = $post['basetype'] == 'Q' && $postid != $questionid; qa_create_event_for_q_user($questionid, $postid, $followonq ? QA_UPDATE_FOLLOWS : null, $post['userid'], @$posts[$post['parentid']]['userid'], $post['created']); if (isset($post['updated']) && !$followonq) { qa_create_event_for_q_user($questionid, $postid, $post['updatetype'], $post['lastuserid'], $post['userid'], $post['updated']); } } // Tags and categories of question qa_create_event_for_tags($question['tags'], $questionid, null, $question['userid'], $question['created']); qa_create_event_for_category($question['categoryid'], $questionid, null, $question['userid'], $question['created']); // Collect comment threads $parentidcomments = array(); foreach ($posts as $postid => $post) { if ($post['basetype'] == 'C') { $parentidcomments[$post['parentid']][$postid] = $post; } } // For each comment thread, notify all previous comment authors of each comment in the thread (could get slow) foreach ($parentidcomments as $parentid => $comments) { $keyuserids = array(); qa_sort_by($comments, 'created'); foreach ($comments as $comment) { foreach ($keyuserids as $keyuserid => $dummy) { if ($keyuserid != $comment['userid'] && $keyuserid != @$posts[$parentid]['userid']) { qa_db_event_create_not_entity($keyuserid, $questionid, $comment['postid'], null, $comment['userid'], $comment['created']); } } if (isset($comment['userid'])) { $keyuserids[$comment['userid']] = true; } } } } $next = 1 + $lastquestionid; $done += count($questionids); $continue = true; } else { qa_recalc_transition($state, 'dorefillevents_complete'); } break; case 'dorecalccategories': qa_recalc_transition($state, 'dorecalccategories_postcount'); break; case 'dorecalccategories_postcount': qa_db_acount_update(); qa_db_ccount_update(); qa_recalc_transition($state, 'dorecalccategories_postupdate'); break; case 'dorecalccategories_postupdate': $postids = qa_db_posts_get_for_recategorizing($next, 100); if (count($postids)) { $lastpostid = max($postids); qa_db_posts_recalc_categoryid($next, $lastpostid); qa_db_posts_calc_category_path($next, $lastpostid); $next = 1 + $lastpostid; $done += count($postids); $continue = true; } else { qa_recalc_transition($state, 'dorecalccategories_recount'); } break; case 'dorecalccategories_recount': $categoryids = qa_db_categories_get_for_recalcs($next, 10); if (count($categoryids)) { $lastcategoryid = max($categoryids); foreach ($categoryids as $categoryid) { qa_db_ifcategory_qcount_update($categoryid); } $next = 1 + $lastcategoryid; $done += count($categoryids); $continue = true; } else { qa_recalc_transition($state, 'dorecalccategories_backpaths'); } break; case 'dorecalccategories_backpaths': $categoryids = qa_db_categories_get_for_recalcs($next, 10); if (count($categoryids)) { $lastcategoryid = max($categoryids); qa_db_categories_recalc_backpaths($next, $lastcategoryid); $next = 1 + $lastcategoryid; $done += count($categoryids); $continue = true; } else { qa_recalc_transition($state, 'dorecalccategories_complete'); } break; case 'dodeletehidden': qa_recalc_transition($state, 'dodeletehidden_comments'); break; case 'dodeletehidden_comments': $posts = qa_db_posts_get_for_deleting('C', $next, 1); if (count($posts)) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $postid = $posts[0]; qa_post_delete($postid); $next = 1 + $postid; $done++; $continue = true; } else { qa_recalc_transition($state, 'dodeletehidden_answers'); } break; case 'dodeletehidden_answers': $posts = qa_db_posts_get_for_deleting('A', $next, 1); if (count($posts)) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $postid = $posts[0]; qa_post_delete($postid); $next = 1 + $postid; $done++; $continue = true; } else { qa_recalc_transition($state, 'dodeletehidden_questions'); } break; case 'dodeletehidden_questions': $posts = qa_db_posts_get_for_deleting('Q', $next, 1); if (count($posts)) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $postid = $posts[0]; qa_post_delete($postid); $next = 1 + $postid; $done++; $continue = true; } else { qa_recalc_transition($state, 'dodeletehidden_complete'); } break; default: $state = ''; break; } if ($continue) { $state = $operation . ',' . $length . ',' . $next . ',' . $done; } return $continue && $done < $length; }
$qa_content['custom'] = $custompage['content']; if ($level >= QA_USER_LEVEL_ADMIN) { $qa_content['navigation']['sub'] = array('admin/pages' => array('label' => qa_lang('admin/edit_custom_page'), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid'])))); } } else { $qa_content['error'] = qa_lang_html('users/no_permission'); } return $qa_content; } // Then, see if we should redirect because the 'qa' page is the same as the home page if ($explicitqa && !qa_is_http_post() && !qa_has_custom_home()) { qa_redirect(qa_category_path_request($categories, $categoryid), $_GET); } // Then, if there's a slug that matches no category, check page modules provided by plugins if (!$explicitqa && $countslugs && !isset($categoryid)) { $pagemodules = qa_load_modules_with('page', 'match_request'); $request = qa_request(); foreach ($pagemodules as $pagemodule) { if ($pagemodule->match_request($request)) { qa_set_template('plugin'); return $pagemodule->process_request($request); } } } // Then, check whether we are showing a custom home page if (!$explicitqa && !$countslugs && qa_opt('show_custom_home')) { qa_set_template('custom'); $qa_content = qa_content_prepare(); $qa_content['title'] = qa_html(qa_opt('custom_home_heading')); if (qa_opt('show_home_description')) { $qa_content['description'] = qa_html(qa_opt('home_description'));
function ra_installed_plugin() { $tables = qa_db_list_tables_lc(); $moduletypes = qa_list_module_types(); $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php'); foreach ($moduletypes as $type) { $modules = qa_load_modules_with($type, 'init_queries'); foreach ($modules as $name => $module) { $queries = $module->init_queries($tables); if (!empty($queries)) { if (qa_is_http_post()) { qa_redirect('install'); } else { $qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array('^1' => qa_html($name), '^2' => qa_html($type), '^3' => '<a href="' . qa_path_html('install') . '">', '^4' => '</a>')); } } } } if (qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) { $qa_content['error'] = qa_lang_html('misc/form_security_reload'); $showpluginforms = false; } else { $showpluginforms = true; } $plugin = array(); if (count($pluginfiles)) { foreach ($pluginfiles as $pluginindex => $pluginfile) { $plugindirectory = dirname($pluginfile) . '/'; $hash = qa_admin_plugin_directory_hash($plugindirectory); $showthisform = $showpluginforms && qa_get('show') == $hash; $contents = file_get_contents($pluginfile); $metadata = qa_admin_addon_metadata($contents, array('name' => 'Plugin Name', 'uri' => 'Plugin URI', 'description' => 'Plugin Description', 'version' => 'Plugin Version', 'date' => 'Plugin Date', 'author' => 'Plugin Author', 'author_uri' => 'Plugin Author URI', 'license' => 'Plugin License', 'min_q2a' => 'Plugin Minimum Question2Answer Version', 'min_php' => 'Plugin Minimum PHP Version', 'update' => 'Plugin Update Check URI')); if (strlen(@$metadata['name'])) { $namehtml = qa_html($metadata['name']); } else { $namehtml = qa_lang_html('admin/unnamed_plugin'); } $plugin_name = $namehtml; if (strlen(@$metadata['uri'])) { $plugin_uri = qa_html($metadata['uri']); } if (strlen(@$metadata['version'])) { $plugin_version = qa_html($metadata['version']); } if (strlen(@$metadata['author'])) { $plugin_author = qa_html($metadata['author']); if (strlen(@$metadata['author_uri'])) { $plugin_author_url = qa_html($metadata['author_uri']); } } if (strlen(@$metadata['version']) && strlen(@$metadata['update'])) { $elementid = 'version_check_' . md5($plugindirectory); $plugin_update = '(<span id="' . $elementid . '"></span>)'; $qa_content['script_onloads'][] = array("qa_version_check(" . qa_js($metadata['update']) . ", 'Plugin Version', " . qa_js($metadata['version'], true) . ", 'Plugin URI', " . qa_js($elementid) . ");"); } if (strlen(@$metadata['description'])) { $plugin_description = qa_html($metadata['description']); } //if (isset($pluginoptionmodules[$plugindirectory])) $plugin_option = qa_admin_plugin_options_path($plugindirectory); if (qa_qa_version_below(@$metadata['min_q2a'])) { $plugin_error = qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])); } elseif (qa_php_version_below(@$metadata['min_php'])) { $plugin_error = qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])); } $plugin[] = array('tags' => 'id="' . qa_html($hash) . '"', 'name' => @$plugin_name, 'uri' => @$plugin_uri, 'version' => @$plugin_version, 'author' => @$plugin_author, 'author_url' => @$plugin_author_url, 'update' => @$plugin_update, 'description' => @$plugin_description, 'path' => @$plugindirectory, 'option' => @$plugin_option, 'error' => @$plugin_error, 'fields' => array(array('type' => 'custom'))); } } return $plugin; }
} if ($isexternal || !isset($editpage['pageid'])) { unset($qa_content['form']['buttons']['saveview']); } $qa_content['focusid'] = 'name'; } else { // List of standard navigation links $qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(), 'buttons' => array('save' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang_html('main/save_button')), 'addpage' => array('tags' => 'name="doaddpage"', 'label' => qa_lang_html('admin/add_page_button')), 'addlink' => array('tags' => 'name="doaddlink"', 'label' => qa_lang_html('admin/add_link_button'))), 'hidden' => array('code' => qa_get_form_security_code('admin/pages'))); $qa_content['form']['fields']['navlinks'] = array('label' => qa_lang_html('admin/nav_links_explanation'), 'type' => 'static', 'tight' => true); foreach ($navoptions as $optionname => $langkey) { $qa_content['form']['fields'][$optionname] = array('label' => '<a href="' . qa_path_html($navpaths[$optionname]) . '">' . qa_lang_html($langkey) . '</a>', 'tags' => 'name="option_' . $optionname . '"', 'type' => 'checkbox', 'value' => qa_opt($optionname)); } $qa_content['form']['fields'][] = array('type' => 'blank'); // List of suggested plugin pages $listhtml = ''; $pagemodules = qa_load_modules_with('page', 'suggest_requests'); foreach ($pagemodules as $tryname => $trypage) { $suggestrequests = $trypage->suggest_requests(); foreach ($suggestrequests as $suggestrequest) { $listhtml .= '<li><b><a href="' . qa_path_html($suggestrequest['request']) . '">' . qa_html($suggestrequest['title']) . '</a></b>'; $listhtml .= qa_lang_html_sub('admin/plugin_module', qa_html($tryname)); $listhtml .= strtr(qa_lang_html('admin/add_link_link'), array('^1' => '<a href="' . qa_path_html(qa_request(), array('doaddlink' => 1, 'text' => $suggestrequest['title'], 'url' => $suggestrequest['request'], 'nav' => @$suggestrequest['nav'])) . '">', '^2' => '</a>')); if (method_exists($trypage, 'admin_form')) { $listhtml .= ' - <a href="' . qa_admin_module_options_path('page', $tryname) . '">' . qa_lang_html('admin/options') . '</a>'; } $listhtml .= '</li>'; } } if (strlen($listhtml)) { $qa_content['form']['fields']['plugins'] = array('label' => qa_lang_html('admin/plugin_pages_explanation'), 'type' => 'custom', 'html' => '<ul style="margin-bottom:0;">' . $listhtml . '</ul>'); }
function qa_content_prepare($voting = false, $categoryids = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_template, $qa_page_error_html; if (QA_DEBUG_PERFORMANCE) { global $qa_usage; $qa_usage->mark('control'); } $request = qa_request(); $requestlower = qa_request(); $navpages = qa_db_get_pending_result('navpages'); $widgets = qa_db_get_pending_result('widgets'); if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $charset = 'utf-8'; $qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($navpages as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/')); } // Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/')); } $qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($navpages as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($widgets as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' . '<img src="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : qa_path_to_root() . $logourl) . '"' . ($logowidth ? ' width="' . $logowidth . '"' : '') . ($logoheight ? ' height="' . $logoheight . '"' : '') . ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>'; } else { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</a>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links(qa_path_to_root(), isset($topath) ? $topath : qa_path($request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (qa_is_logged_in()) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), qa_path_to_root(), false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); $qa_content['navigation']['user']['updates'] = array('url' => qa_path_html('updates'), 'label' => qa_lang_html('main/nav_updates')); if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $loginmodules = qa_load_modules_with('login', 'match_source'); foreach ($loginmodules as $module) { if ($module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } $notices = qa_db_get_pending_result('notices'); foreach ($notices as $notice) { $qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice); } } else { require_once QA_INCLUDE_DIR . 'util/string.php'; if (!QA_FINAL_EXTERNAL_USERS) { $loginmodules = qa_load_modules_with('login', 'login_html'); foreach ($loginmodules as $tryname => $module) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'menu'); $label = ob_get_clean(); if (strlen($label)) { $qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))] = array('label' => $label); } } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } if (QA_FINAL_EXTERNAL_USERS || !qa_is_logged_in()) { if (qa_opt('show_notice_visitor') && !isset($topath) && !isset($_COOKIE['qa_noticed'])) { $qa_content['notices'][] = qa_notice_form('visitor', qa_opt('notice_visitor')); } } else { setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN); // don't show first-time notice if a user has logged in if (qa_opt('show_notice_welcome') && qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) { if ($requestlower != 'confirm' && $requestlower != 'account') { // let people finish registering in peace $qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome')); } } } $qa_content['script_rel'] = array('qa-content/jquery-1.11.2.min.js'); $qa_content['script_rel'][] = 'qa-content/qa-page.js?' . QA_VERSION; if ($voting) { $qa_content['error'] = @$qa_page_error_html; } $qa_content['script_var'] = array('qa_root' => qa_path_to_root(), 'qa_request' => $request); return $qa_content; }
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; }
function qa_get_search_results($query, $start, $count, $userid, $absoluteurls, $fullcontent) { // Identify which search module should be used $searchmodules = qa_load_modules_with('search', 'process_search'); if (!count($searchmodules)) { qa_fatal_error('No search engine is available'); } $module = reset($searchmodules); // use first one by default if (count($searchmodules) > 1) { $tryname = qa_opt('search_module'); // use chosen one if it's available if (isset($searchmodules[$tryname])) { $module = $searchmodules[$tryname]; } } // Get the results $results = $module->process_search($query, $start, $count, $userid, $absoluteurls, $fullcontent); // Work out what additional information (if any) we need to retrieve for the results $keypostidgetfull = array(); $keypostidgettype = array(); $keypostidgetquestion = array(); $keypageidgetpage = array(); foreach ($results as $result) { if (isset($result['question_postid']) && !isset($result['question'])) { $keypostidgetfull[$result['question_postid']] = true; } if (isset($result['match_postid'])) { if (!(isset($result['question_postid']) || isset($result['question']))) { $keypostidgetquestion[$result['match_postid']] = true; } elseif (!isset($result['match_type'])) { $keypostidgettype[$result['match_postid']] = true; } } if (isset($result['page_pageid']) && !isset($result['page'])) { $keypageidgetpage[$result['page_pageid']] = true; } } // Perform the appropriate database queries list($postidfull, $postidtype, $postidquestion, $pageidpage) = qa_db_select_with_pending(count($keypostidgetfull) ? qa_db_posts_selectspec($userid, array_keys($keypostidgetfull), $fullcontent) : null, count($keypostidgettype) ? qa_db_posts_basetype_selectspec(array_keys($keypostidgettype)) : null, count($keypostidgetquestion) ? qa_db_posts_to_qs_selectspec($userid, array_keys($keypostidgetquestion), $fullcontent) : null, count($keypageidgetpage) ? qa_db_pages_selectspec(null, array_keys($keypageidgetpage)) : null); // Supplement the results as appropriate foreach ($results as $key => $result) { if (isset($result['question_postid']) && !isset($result['question'])) { if (@$postidfull[$result['question_postid']]['basetype'] == 'Q') { $result['question'] = @$postidfull[$result['question_postid']]; } } if (isset($result['match_postid'])) { if (!(isset($result['question_postid']) || isset($result['question']))) { $result['question'] = @$postidquestion[$result['match_postid']]; if (!isset($result['match_type'])) { $result['match_type'] = @$result['question']['obasetype']; } } elseif (!isset($result['match_type'])) { $result['match_type'] = @$postidtype[$result['match_postid']]; } } if (isset($result['question']) && !isset($result['question_postid'])) { $result['question_postid'] = $result['question']['postid']; } if (isset($result['page_pageid']) && !isset($result['page'])) { $result['page'] = @$pageidpage[$result['page_pageid']]; } if (!isset($result['title'])) { if (isset($result['question'])) { $result['title'] = $result['question']['title']; } elseif (isset($result['page'])) { $result['title'] = $result['page']['heading']; } } if (!isset($result['url'])) { if (isset($result['question'])) { $result['url'] = qa_q_path($result['question']['postid'], $result['question']['title'], $absoluteurls, @$result['match_type'], @$result['match_postid']); } elseif (isset($result['page'])) { $result['url'] = qa_path($result['page']['tags'], null, qa_opt('site_url')); } } $results[$key] = $result; } // Return the results return $results; }
function qa_post_unindex($postid) { global $qa_post_indexing_suspended; if ($qa_post_indexing_suspended > 0) { return; } // Send through to any search modules for unindexing $searchmodules = qa_load_modules_with('search', 'unindex_post'); foreach ($searchmodules as $searchmodule) { $searchmodule->unindex_post($postid); } }
} else { $pageerror = qa_lang('users/login_limit'); } } else { $inemailhandle = qa_get('e'); } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('users/login_title'); $qa_content['error'] = @$pageerror; if (empty($inemailhandle) || isset($errors['emailhandle'])) { $forgotpath = qa_path('forgot'); } else { $forgotpath = qa_path('forgot', array('e' => $inemailhandle)); } $forgothtml = '<A HREF="' . qa_html($forgotpath) . '">' . qa_lang_html('users/forgot_link') . '</A>'; $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $passwordsent ? qa_lang_html('users/password_sent') : null, 'fields' => array('email_handle' => array('label' => qa_opt('allow_login_email_only') ? qa_lang_html('users/email_label') : qa_lang_html('users/email_handle_label'), 'tags' => 'NAME="emailhandle" ID="emailhandle"', 'value' => qa_html(@$inemailhandle), 'error' => qa_html(@$errors['emailhandle'])), 'password' => array('type' => 'password', 'label' => qa_lang_html('users/password_label'), 'tags' => 'NAME="password" ID="password"', 'value' => qa_html(@$inpassword), 'error' => empty($errors['password']) ? '' : qa_html(@$errors['password']) . ' - ' . $forgothtml, 'note' => $passwordsent ? qa_lang_html('users/password_sent') : $forgothtml), 'remember' => array('type' => 'checkbox', 'label' => qa_lang_html('users/remember_label'), 'tags' => 'NAME="remember"', 'value' => @$inremember ? true : false)), 'buttons' => array('login' => array('label' => qa_lang_html('users/login_button'))), 'hidden' => array('dologin' => '1')); $loginmodules = qa_load_modules_with('login', 'login_html'); foreach ($loginmodules as $module) { ob_start(); $module->login_html(qa_opt('site_url') . qa_get('to'), 'login'); $html = ob_get_clean(); if (strlen($html)) { @($qa_content['custom'] .= '<BR>' . $html . '<BR>'); } } $qa_content['focusid'] = isset($inemailhandle) && !isset($errors['emailhandle']) ? 'password' : 'emailhandle'; return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
default: $errors['avatar'] = qa_lang('users/no_permission'); break; case false: qa_limits_increment($userid, QA_LIMIT_UPLOADS); $toobig = qa_image_file_too_big($_FILES['file']['tmp_name'], qa_opt('avatar_store_size')); if ($toobig) { $errors['avatar'] = qa_lang_sub('main/image_too_big_x_pc', (int) ($toobig * 100)); } elseif (!qa_set_user_avatar($userid, file_get_contents($_FILES['file']['tmp_name']), $useraccount['avatarblobid'])) { $errors['avatar'] = qa_lang_sub('main/image_not_read', implode(', ', qa_gd_image_formats())); } break; } } if (count($inprofile)) { $filtermodules = qa_load_modules_with('filter', 'filter_profile'); foreach ($filtermodules as $filtermodule) { $filtermodule->filter_profile($inprofile, $errors, $useraccount, $userprofile); } } foreach ($userfields as $userfield) { if (!isset($errors[$userfield['fieldid']])) { qa_db_user_profile_set($userid, $userfield['title'], $inprofile[$userfield['fieldid']]); } } list($useraccount, $userprofile) = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true), qa_db_user_profile_selectspec($userid, true)); qa_report_event('u_save', $userid, $useraccount['handle'], qa_cookie_get()); if (empty($errors)) { qa_redirect('account', array('state' => 'profile-saved')); } qa_logged_in_user_flush();
function qa_recalc_perform_step(&$state) { $continue = false; @(list($operation, $length, $next, $done) = explode("\t", $state)); switch ($operation) { case 'doreindexcontent': qa_recalc_transition($state, 'doreindexcontent_pagereindex'); break; case 'doreindexcontent_pagereindex': $pages = qa_db_pages_get_for_reindexing($next, 10); if (count($pages)) { require_once QA_INCLUDE_DIR . 'app/format.php'; $lastpageid = max(array_keys($pages)); foreach ($pages as $pageid => $page) { if (!($page['flags'] & QA_PAGE_FLAGS_EXTERNAL)) { $searchmodules = qa_load_modules_with('search', 'unindex_page'); foreach ($searchmodules as $searchmodule) { $searchmodule->unindex_page($pageid); } $searchmodules = qa_load_modules_with('search', 'index_page'); if (count($searchmodules)) { $indextext = qa_viewer_text($page['content'], 'html'); foreach ($searchmodules as $searchmodule) { $searchmodule->index_page($pageid, $page['tags'], $page['heading'], $page['content'], 'html', $indextext); } } } } $next = 1 + $lastpageid; $done += count($pages); $continue = true; } else { qa_recalc_transition($state, 'doreindexcontent_postcount'); } break; case 'doreindexcontent_postcount': qa_db_qcount_update(); qa_db_acount_update(); qa_db_ccount_update(); qa_recalc_transition($state, 'doreindexcontent_postreindex'); break; case 'doreindexcontent_postreindex': $posts = qa_db_posts_get_for_reindexing($next, 10); if (count($posts)) { require_once QA_INCLUDE_DIR . 'app/format.php'; $lastpostid = max(array_keys($posts)); qa_db_prepare_for_reindexing($next, $lastpostid); qa_suspend_update_counts(); foreach ($posts as $postid => $post) { qa_post_unindex($postid); qa_post_index($postid, $post['type'], $post['questionid'], $post['parentid'], $post['title'], $post['content'], $post['format'], qa_viewer_text($post['content'], $post['format']), $post['tags'], $post['categoryid']); } $next = 1 + $lastpostid; $done += count($posts); $continue = true; } else { qa_db_truncate_indexes($next); qa_recalc_transition($state, 'doreindexposts_wordcount'); } break; case 'doreindexposts_wordcount': $wordids = qa_db_words_prepare_for_recounting($next, 1000); if (count($wordids)) { $lastwordid = max($wordids); qa_db_words_recount($next, $lastwordid); $next = 1 + $lastwordid; $done += count($wordids); $continue = true; } else { qa_db_tagcount_update(); // this is quick so just do it here qa_recalc_transition($state, 'doreindexposts_complete'); } break; case 'dorecountposts': qa_recalc_transition($state, 'dorecountposts_postcount'); break; case 'dorecountposts_postcount': qa_db_qcount_update(); qa_db_acount_update(); qa_db_ccount_update(); qa_db_unaqcount_update(); qa_db_unselqcount_update(); qa_recalc_transition($state, 'dorecountposts_votecount'); break; case 'dorecountposts_votecount': $postids = qa_db_posts_get_for_recounting($next, 1000); if (count($postids)) { $lastpostid = max($postids); qa_db_posts_votes_recount($next, $lastpostid); $next = 1 + $lastpostid; $done += count($postids); $continue = true; } else { qa_recalc_transition($state, 'dorecountposts_acount'); } break; case 'dorecountposts_acount': $postids = qa_db_posts_get_for_recounting($next, 1000); if (count($postids)) { $lastpostid = max($postids); qa_db_posts_answers_recount($next, $lastpostid); $next = 1 + $lastpostid; $done += count($postids); $continue = true; } else { qa_db_unupaqcount_update(); qa_recalc_transition($state, 'dorecountposts_complete'); } break; case 'dorecalcpoints': qa_recalc_transition($state, 'dorecalcpoints_usercount'); break; case 'dorecalcpoints_usercount': qa_db_userpointscount_update(); // for progress update - not necessarily accurate qa_db_uapprovecount_update(); // needs to be somewhere and this is the most appropriate place qa_recalc_transition($state, 'dorecalcpoints_recalc'); break; case 'dorecalcpoints_recalc': $recalccount = 10; $userids = qa_db_users_get_for_recalc_points($next, $recalccount + 1); // get one extra so we know where to start from next $gotcount = count($userids); $recalccount = min($recalccount, $gotcount); // can't recalc more than we got if ($recalccount > 0) { $lastuserid = $userids[$recalccount - 1]; qa_db_users_recalc_points($next, $lastuserid); $done += $recalccount; } else { $lastuserid = $next; } // for truncation if ($gotcount > $recalccount) { // more left to do $next = $userids[$recalccount]; // start next round at first one not recalculated $continue = true; } else { qa_db_truncate_userpoints($lastuserid); qa_db_userpointscount_update(); // quick so just do it here qa_recalc_transition($state, 'dorecalcpoints_complete'); } break; case 'dorefillevents': qa_recalc_transition($state, 'dorefillevents_qcount'); break; case 'dorefillevents_qcount': qa_db_qcount_update(); qa_recalc_transition($state, 'dorefillevents_refill'); break; case 'dorefillevents_refill': $questionids = qa_db_qs_get_for_event_refilling($next, 1); if (count($questionids)) { require_once QA_INCLUDE_DIR . 'app/events.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; require_once QA_INCLUDE_DIR . 'util/sort.php'; $lastquestionid = max($questionids); foreach ($questionids as $questionid) { // Retrieve all posts relating to this question list($question, $childposts, $achildposts) = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $questionid), qa_db_full_child_posts_selectspec(null, $questionid), qa_db_full_a_child_posts_selectspec(null, $questionid)); // Merge all posts while preserving keys as postids $posts = array($questionid => $question); foreach ($childposts as $postid => $post) { $posts[$postid] = $post; } foreach ($achildposts as $postid => $post) { $posts[$postid] = $post; } // Creation and editing of each post foreach ($posts as $postid => $post) { $followonq = $post['basetype'] == 'Q' && $postid != $questionid; if ($followonq) { $updatetype = QA_UPDATE_FOLLOWS; } elseif ($post['basetype'] == 'C' && @$posts[$post['parentid']]['basetype'] == 'Q') { $updatetype = QA_UPDATE_C_FOR_Q; } elseif ($post['basetype'] == 'C' && @$posts[$post['parentid']]['basetype'] == 'A') { $updatetype = QA_UPDATE_C_FOR_A; } else { $updatetype = null; } qa_create_event_for_q_user($questionid, $postid, $updatetype, $post['userid'], @$posts[$post['parentid']]['userid'], $post['created']); if (isset($post['updated']) && !$followonq) { qa_create_event_for_q_user($questionid, $postid, $post['updatetype'], $post['lastuserid'], $post['userid'], $post['updated']); } } // Tags and categories of question qa_create_event_for_tags($question['tags'], $questionid, null, $question['userid'], $question['created']); qa_create_event_for_category($question['categoryid'], $questionid, null, $question['userid'], $question['created']); // Collect comment threads $parentidcomments = array(); foreach ($posts as $postid => $post) { if ($post['basetype'] == 'C') { $parentidcomments[$post['parentid']][$postid] = $post; } } // For each comment thread, notify all previous comment authors of each comment in the thread (could get slow) foreach ($parentidcomments as $parentid => $comments) { $keyuserids = array(); qa_sort_by($comments, 'created'); foreach ($comments as $comment) { foreach ($keyuserids as $keyuserid => $dummy) { if ($keyuserid != $comment['userid'] && $keyuserid != @$posts[$parentid]['userid']) { qa_db_event_create_not_entity($keyuserid, $questionid, $comment['postid'], QA_UPDATE_FOLLOWS, $comment['userid'], $comment['created']); } } if (isset($comment['userid'])) { $keyuserids[$comment['userid']] = true; } } } } $next = 1 + $lastquestionid; $done += count($questionids); $continue = true; } else { qa_recalc_transition($state, 'dorefillevents_complete'); } break; case 'dorecalccategories': qa_recalc_transition($state, 'dorecalccategories_postcount'); break; case 'dorecalccategories_postcount': qa_db_acount_update(); qa_db_ccount_update(); qa_recalc_transition($state, 'dorecalccategories_postupdate'); break; case 'dorecalccategories_postupdate': $postids = qa_db_posts_get_for_recategorizing($next, 100); if (count($postids)) { $lastpostid = max($postids); qa_db_posts_recalc_categoryid($next, $lastpostid); qa_db_posts_calc_category_path($next, $lastpostid); $next = 1 + $lastpostid; $done += count($postids); $continue = true; } else { qa_recalc_transition($state, 'dorecalccategories_recount'); } break; case 'dorecalccategories_recount': $categoryids = qa_db_categories_get_for_recalcs($next, 10); if (count($categoryids)) { $lastcategoryid = max($categoryids); foreach ($categoryids as $categoryid) { qa_db_ifcategory_qcount_update($categoryid); } $next = 1 + $lastcategoryid; $done += count($categoryids); $continue = true; } else { qa_recalc_transition($state, 'dorecalccategories_backpaths'); } break; case 'dorecalccategories_backpaths': $categoryids = qa_db_categories_get_for_recalcs($next, 10); if (count($categoryids)) { $lastcategoryid = max($categoryids); qa_db_categories_recalc_backpaths($next, $lastcategoryid); $next = 1 + $lastcategoryid; $done += count($categoryids); $continue = true; } else { qa_recalc_transition($state, 'dorecalccategories_complete'); } break; case 'dodeletehidden': qa_recalc_transition($state, 'dodeletehidden_comments'); break; case 'dodeletehidden_comments': $posts = qa_db_posts_get_for_deleting('C', $next, 1); if (count($posts)) { require_once QA_INCLUDE_DIR . 'app/posts.php'; $postid = $posts[0]; qa_post_delete($postid); $next = 1 + $postid; $done++; $continue = true; } else { qa_recalc_transition($state, 'dodeletehidden_answers'); } break; case 'dodeletehidden_answers': $posts = qa_db_posts_get_for_deleting('A', $next, 1); if (count($posts)) { require_once QA_INCLUDE_DIR . 'app/posts.php'; $postid = $posts[0]; qa_post_delete($postid); $next = 1 + $postid; $done++; $continue = true; } else { qa_recalc_transition($state, 'dodeletehidden_questions'); } break; case 'dodeletehidden_questions': $posts = qa_db_posts_get_for_deleting('Q', $next, 1); if (count($posts)) { require_once QA_INCLUDE_DIR . 'app/posts.php'; $postid = $posts[0]; qa_post_delete($postid); $next = 1 + $postid; $done++; $continue = true; } else { qa_recalc_transition($state, 'dodeletehidden_complete'); } break; case 'doblobstodisk': qa_recalc_transition($state, 'doblobstodisk_move'); break; case 'doblobstodisk_move': $blob = qa_db_get_next_blob_in_db($next); if (isset($blob)) { require_once QA_INCLUDE_DIR . 'app/blobs.php'; require_once QA_INCLUDE_DIR . 'db/blobs.php'; if (qa_write_blob_file($blob['blobid'], $blob['content'], $blob['format'])) { qa_db_blob_set_content($blob['blobid'], null); } $next = 1 + $blob['blobid']; $done++; $continue = true; } else { qa_recalc_transition($state, 'doblobstodisk_complete'); } break; case 'doblobstodb': qa_recalc_transition($state, 'doblobstodb_move'); break; case 'doblobstodb_move': $blob = qa_db_get_next_blob_on_disk($next); if (isset($blob)) { require_once QA_INCLUDE_DIR . 'app/blobs.php'; require_once QA_INCLUDE_DIR . 'db/blobs.php'; $content = qa_read_blob_file($blob['blobid'], $blob['format']); qa_db_blob_set_content($blob['blobid'], $content); qa_delete_blob_file($blob['blobid'], $blob['format']); $next = 1 + $blob['blobid']; $done++; $continue = true; } else { qa_recalc_transition($state, 'doblobstodb_complete'); } break; default: $state = ''; break; } if ($continue) { $state = $operation . "\t" . $length . "\t" . $next . "\t" . $done; } return $continue && $done < $length; }
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; }
</div> <div class="item parent ui-draggable"> <div class="config"> <?php ra_builder_widget_control(); ?> </div> <div class="item-title">Full Cat List</div> <div data-type="ra_widget" data-name="Full Categories List" class="item-content widget-c"> <?php echo $context->do_shortcode('[ra_widget name="Full Categories List"]'); ?> </div> </div> <?php foreach (qa_load_modules_with('widget', 'allow_template') as $k => $widget) { ?> <div class="item parent ui-draggable"> <div class="config"> <?php ra_builder_control(); ?> </div> <div class="item-title"><?php echo $k; ?> </div> <div data-type="widget" data-name="<?php echo $k; ?> " class="item-content widget-c">
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_password_validate($password, $olduser = null) { $error = null; $filtermodules = qa_load_modules_with('filter', 'validate_password'); foreach ($filtermodules as $filtermodule) { $error = $filtermodule->validate_password($password, $olduser); if (isset($error)) { break; } } if (!isset($error)) { $minpasslen = max(QA_MIN_PASSWORD_LEN, 1); if (qa_strlen($password) < $minpasslen) { $error = qa_lang_sub('users/password_min', $minpasslen); } } if (isset($error)) { return array('password' => $error); } return array(); }
function qa_admin_is_slug_reserved($requestpart) { $requestpart = trim(strtolower($requestpart)); $routing = qa_page_routing(); if (isset($routing[$requestpart]) || isset($routing[$requestpart . '/']) || is_numeric($requestpart)) { return true; } $pathmap = qa_get_request_map(); foreach ($pathmap as $mappedrequest) { if (trim(strtolower($mappedrequest)) == $requestpart) { return true; } } switch ($requestpart) { case '': case 'qa': case 'feed': case 'install': case 'url': case 'image': case 'ajax': return true; } $pagemodules = qa_load_modules_with('page', 'match_request'); foreach ($pagemodules as $pagemodule) { if ($pagemodule->match_request($requestpart)) { return true; } } return false; }
$qa_content['form']['fields']['userfields'] = array('label' => qa_lang_html('admin/profile_fields'), 'id' => 'profile_fields', 'style' => 'tall', 'type' => 'custom', 'html' => strlen($listhtml) ? '<ul style="margin-bottom:0;">' . $listhtml . '</ul>' : null); } $qa_content['form']['fields'][] = array('type' => 'blank'); $pointstitle = qa_get_points_to_titles(); $listhtml = ''; foreach ($pointstitle as $points => $title) { $listhtml .= '<li><b>' . $title . '</b> - ' . ($points == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($points)))); $listhtml .= strtr(qa_lang_html('admin/edit_title'), array('^1' => '<a href="' . qa_path_html('admin/usertitles', array('edit' => $points)) . '">', '^2' => '</a>')); $listhtml .= '</li>'; } $listhtml .= '<li><b><a href="' . qa_path_html('admin/usertitles') . '">' . qa_lang_html('admin/add_new_title') . '</a></b></li>'; $qa_content['form']['fields']['usertitles'] = array('label' => qa_lang_html('admin/user_titles'), 'style' => 'tall', 'type' => 'custom', 'html' => strlen($listhtml) ? '<ul style="margin-bottom:0;">' . $listhtml . '</ul>' : null); break; case 'layout': $listhtml = ''; $widgetmodules = qa_load_modules_with('widget', 'allow_template'); foreach ($widgetmodules as $tryname => $trywidget) { if (method_exists($trywidget, 'allow_region')) { $listhtml .= '<li><b>' . qa_html($tryname) . '</b>'; $listhtml .= strtr(qa_lang_html('admin/add_widget_link'), array('^1' => '<a href="' . qa_path_html('admin/layoutwidgets', array('title' => $tryname)) . '">', '^2' => '</a>')); if (method_exists($trywidget, 'admin_form')) { $listhtml .= strtr(qa_lang_html('admin/widget_global_options'), array('^1' => '<a href="' . qa_admin_module_options_path('widget', $tryname) . '">', '^2' => '</a>')); } $listhtml .= '</li>'; } } if (strlen($listhtml)) { $qa_content['form']['fields']['plugins'] = array('label' => qa_lang_html('admin/widgets_explanation'), 'style' => 'tall', 'type' => 'custom', 'html' => '<ul style="margin-bottom:0;">' . $listhtml . '</ul>'); } $widgets = qa_db_single_select(qa_db_widgets_selectspec()); $listhtml = '';
} 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'); } if ($captchareason) { require_once 'qa-app-captcha.php'; qa_captcha_validate_post($errors); } if (empty($errors)) {
function qa_load_viewer($content, $format) { $maxviewer = null; $maxquality = 0; $viewermodules = qa_load_modules_with('viewer', 'calc_quality'); foreach ($viewermodules as $tryviewer) { $tryquality = $tryviewer->calc_quality($content, $format); if ($tryquality > $maxquality) { $maxviewer = $tryviewer; $maxquality = $tryquality; } } return $maxviewer; }