/** * adds blog admin pages to the request handlers * * @return mixed */ function qa_get_request_content() { $requestlower = strtolower(qa_request()); $requestparts = qa_request_parts(); $firstlower = strtolower(@$requestparts[0]); $secondlower = strtolower(@$requestparts[1]); $routing = qa_page_routing(); $route_part = ''; if (!empty($firstlower) && !empty($secondlower)) { $route_part = $firstlower . '/' . $secondlower . '/'; } if (!isset($routing[$requestlower]) && $route_part === 'admin/donut-theme/') { //for loading the default setting file qa_set_template($firstlower); $qa_content = (require QA_INCLUDE_DIR . $routing[$route_part]); if ($firstlower == 'admin') { $_COOKIE['qa_admin_last'] = $requestlower; // for navigation tab now... setcookie('qa_admin_last', $_COOKIE['qa_admin_last'], 0, '/', QA_COOKIE_DOMAIN); // ...and in future } } else { //otherwise load the original qa_get_request_content function $qa_content = qa_get_request_content_base(); } return $qa_content; }
function it_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-updates.php'; $userid = qa_get_logged_in_userid(); // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); if (count($questions)) { $qa_content['title'] = $sometitle; $defaults = qa_post_html_defaults('Q'); foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $userid, it_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); } } else { $qa_content['title'] = $nonetitle; } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } return $qa_content; }
function qa_wall_error_html($fromuserid, $touserid, $touserflags) { require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (!QA_FINAL_EXTERNAL_USERS && qa_opt('allow_user_walls')) { if ($touserflags & QA_USER_FLAGS_NO_WALL_POSTS && !(isset($fromuserid) && $fromuserid == $touserid)) { return qa_lang_html('profile/post_wall_blocked'); } else { switch (qa_user_permit_error('permit_post_wall', QA_LIMIT_WALL_POSTS)) { case 'limit': return qa_lang_html('profile/post_wall_limit'); break; case 'login': return qa_insert_login_links(qa_lang_html('profile/post_wall_must_login'), qa_request()); break; case 'confirm': return qa_insert_login_links(qa_lang_html('profile/post_wall_must_confirm'), qa_request()); break; case 'approve': return qa_lang_html('profile/post_wall_must_be_approved'); break; case false: return false; break; } } } return qa_lang_html('users/no_permission'); }
function qa_get_request_content() { if (qa_opt('news_plugin_active')) { $requestlower = strtolower(qa_request()); if ($requestlower && $requestlower === 'my-profile') { $userid = qa_get_logged_in_userid(); if (!$userid) { qa_redirect(); } $handles = qa_userids_to_handles(array($userid)); $handle = $handles[$userid]; qa_redirect(qa_path('user/' . $handle)); } else { if ($requestlower && $requestlower === qa_opt('news_plugin_request')) { // send on cron if (qa_opt('news_plugin_send') && qa_get('cron') == qa_opt('news_plugin_cron_rand') && time() >= qa_opt('news_plugin_send_last') + 23 * 60 * 60) { // minumum cron interval is 23 hours qa_news_plugin_createNewsletter(true); return false; } else { if (qa_get('cron') == qa_opt('news_plugin_cron_rand')) { if (!qa_opt('news_plugin_send')) { error_log('Q2A Newsletter Recreate Error: sending newsletter not allowed via admin/plugins'); } else { error_log('Q2A Newsletter Recreate Error: cron request before minimum time elapsed'); } echo "false\n"; return false; } } include qa_opt('news_plugin_loc'); return false; } else { if (qa_opt('news_plugin_pdf') && $requestlower && $requestlower === qa_opt('news_plugin_request_pdf')) { $pdf = file_get_contents(qa_opt('news_plugin_loc_pdf')); header('Content-Description: File Transfer'); header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1 header('Pragma: public'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // force download dialog header('Content-Type: application/force-download'); header('Content-Type: application/octet-stream', false); header('Content-Type: application/download', false); header('Content-Type: application/pdf', false); // use the Content-Disposition header to supply a recommended filename header('Content-Disposition: attachment; filename="' . basename(qa_opt('news_plugin_loc_pdf')) . '";'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen($pdf)); echo $pdf; return false; } } } } return qa_get_request_content_base(); }
function qa_get_request_content() { if (qa_opt('xml_rpc_bool_active')) { $requestlower = strtolower(qa_request()); if ($requestlower && $requestlower === "xml-rpc") { qa_xml_rpc_start_server(); return false; } } return qa_get_request_content_base(); }
function allow_template($template) { // not allowed when logged in $userid = qa_get_logged_in_userid(); if (stristr(qa_request(), 'admin/layoutwidgets') === false && isset($userid)) { return false; } if ($template == 'login' || $template == 'register') { return false; } return true; }
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; $userid = qa_get_logged_in_userid(); // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); // Prepare content for theme $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid))); $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); if (count($questions)) { $qa_content['title'] = $sometitle; $defaults = qa_post_html_defaults('Q'); if (isset($categorypathprefix)) { $defaults['categorypathprefix'] = $categorypathprefix; } foreach ($questions as $question) { $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); if (!empty($fields['raw']['closedbyid'])) { $fields['closed'] = array('state' => qa_lang_html('main/closed')); } $qa_content['q_list']['qs'][] = $fields; } } else { $qa_content['title'] = $nonetitle; } if (isset($userid) && isset($categoryid)) { $favoritemap = qa_get_favorite_non_qs_map(); $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']]; $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title'])); } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = $suggest; } if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) { $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams); } if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle)); } return $qa_content; }
function doctype() { parent::doctype(); if (QA_FINAL_EXTERNAL_USERS) { return; } // check if logged in $handle = qa_get_logged_in_handle(); if (isset($handle)) { if (qa_request() == '' && count($_GET) > 0) { // Check if we need to associate another provider $this->process_login(); } // see if the account pages are accessed $tmpl = array('account', 'favorites'); $user_pages = array('user', 'user-wall', 'user-activity', 'user-questions', 'user-answers'); $logins_page = qa_request() == 'logins' && !qa_get('confirm'); $urlhandle = qa_request_part(1); if (in_array($this->template, $tmpl) || $logins_page || in_array($this->template, $user_pages) && $handle == $urlhandle) { // add a navigation item $this->content['navigation']['sub']['logins'] = array('label' => qa_lang_html('plugin_open/my_logins_nav'), 'url' => qa_path_html('logins'), 'selected' => $logins_page); return; } } else { $title = qa_lang_html('plugin_open/login_title'); $descr = qa_lang_html('plugin_open/login_description'); // hide login/register links from navigation on any page if (qa_opt('open_login_hideform') == '1') { unset($this->content['navigation']['user']['login']); unset($this->content['navigation']['user']['register']); } // then check if login/register pages are accessed $tmpl = array('register', 'login'); if (!in_array($this->template, $tmpl)) { return; } // hide regular login/register form on those pages only if (qa_opt('open_login_hideform') == '1') { $this->content['title'] = $title; $this->content['form'] = null; } // add some custom text if (!empty($this->content['custom'])) { $content = str_ireplace('<BR>', '', $this->content['custom']); $this->content['custom'] = "<div><p>{$descr}</p>{$content}</div>"; if ($this->content['form'] != null) { $this->content['custom'] = "<br /><br /><h1>{$title}</h1>{$this->content['custom']}"; } } } }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $req = end(explode('/', qa_request())); if (!isset($req)) { return; } if (!qa_opt('event_logger_to_database')) { return; } $widget_opt = @$themeobject->current_widget['param']['options']; $cat = $this->cs_get_cat_desc($req); if (@$themeobject->current_widget['param']['locations']['show_title'] && isset($cat['title'])) { $themeobject->output('<h3 class="widget-title">' . $cat['title'] . '</h3>'); } $themeobject->output('<div class="ra-cc-widget">'); $themeobject->output($cat['content']); $themeobject->output('</div>'); }
public function process_request($request) { $requestparts = explode('/', qa_request()); $slugs = array_slice($requestparts, 1); $countslugs = count($slugs); $userid = qa_get_logged_in_userid(); $start = qa_get_start(); $count = qa_opt_if_loaded('page_size_activity'); $totalcount = qa_opt('cache_qcount'); $qspec = qa_db_posts_basic_selectspec($userid, false); qa_db_add_selectspec_opost($qspec, 'ra', false, false); qa_db_add_selectspec_ousers($qspec, 'rau', 'raup'); $qspec['source'] .= " JOIN (SELECT questionid, childid FROM ^homepage ORDER BY ^homepage.updated DESC) AS rcaq ON ^posts.postid=rcaq.questionid" . " LEFT JOIN ^posts AS ra ON childid=ra.postid" . (QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS rau ON ra.userid=rau.userid") . " LEFT JOIN ^userpoints AS raup ON ra.userid=raup.userid LIMIT #,#"; array_push($qspec['columns'], 'childid'); array_push($qspec['arguments'], $start, $count); $qspec['sortdesc'] = 'otime'; $query = 'SELECT '; foreach ($qspec['columns'] as $columnas => $columnfrom) { $query .= $columnfrom . (is_int($columnas) ? '' : ' AS ' . $columnas) . ', '; } $query = qa_db_apply_sub(substr($query, 0, -2) . (strlen(@$qspec['source']) ? ' FROM ' . $qspec['source'] : ''), @$qspec['arguments']); $results = qa_db_read_all_assoc(qa_db_query_raw($query)); qa_db_post_select($results, $qspec); list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null); $questions = qa_any_sort_and_dedupe($results); // $questions=qa_any_sort_and_dedupe(array_merge($recentquestions,$recentanswers)); $pagesize = qa_opt('page_size_home'); if ($countslugs) { if (!isset($categoryid)) { return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } $categorytitlehtml = qa_html($categories[$categoryid]['title']); $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); } else { $sometitle = qa_lang_html('main/recent_qs_as_title'); $nonetitle = qa_lang_html('main/no_questions_found'); } require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; $qa_content = qa_q_list_page_content($questions, $pagesize, $start, $totalcount, $sometitle, $nonetitle, $categories, $categoryid, true, qa_opt('eql_homepage_url'), qa_opt('feed_for_qa') ? qa_opt('eql_homepage_url') : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null); return $qa_content; }
function process_request($request) { $qa_content = qa_content_prepare(); $qa_content['site_title'] = "Notifications"; $qa_content['error'] = ""; $qa_content['suggest_next'] = ""; $qa_content['template'] = "notifications"; // Get the no of notifications $start = qa_get_start(); $pagesize = qa_opt('qw_all_notification_page_size'); if (!$pagesize) { $pagesize = 15; } $notifications_count = qw_get_notification_count(qa_get_logged_in_userid()); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $notifications_count, qa_opt('pages_prev_next')); if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_ask(); } $qa_content['custom'] = $this->opt_form(); return $qa_content; }
$leveloptions = array(); $catleveloptions = array('' => qa_lang_html('users/category_level_none')); foreach ($showlevels as $showlevel) { if ($showlevel <= $maxlevelassign) { $leveloptions[$showlevel] = qa_html(qa_user_level_string($showlevel)); if ($showlevel > QA_USER_LEVEL_BASIC) { $catleveloptions[$showlevel] = $leveloptions[$showlevel]; } } } $qa_content['form_profile']['fields']['level']['options'] = $leveloptions; // Category-specific levels if (qa_using_categories()) { $catleveladd = qa_get('catleveladd') ? true : false; if (!$catleveladd && !count($userlevels)) { $qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array('^1' => '<a href="' . qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)) . '">', '^2' => '</a>')); } else { $qa_content['form_profile']['fields']['level']['suffix'] = qa_lang_html('users/level_in_general'); } if ($catleveladd || count($userlevels)) { $userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY); } $index = 0; foreach ($userlevels as $userlevel) { if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) { $index++; $id = 'ls_' . +$index; $qa_content['form_profile']['fields']['uc_' . $index . '_level'] = array('label' => qa_lang_html('users/category_level_label'), 'type' => 'select', 'tags' => 'name="uc_' . $index . '_level" id="' . qa_html($id) . '" onchange="this.qa_prev=this.options[this.selectedIndex].value;"', 'options' => $catleveloptions, 'value' => isset($userlevel['level']) ? qa_html(qa_user_level_string($userlevel['level'])) : '', 'suffix' => qa_lang_html('users/category_level_in')); $qa_content['form_profile']['fields']['uc_' . $index . '_cat'] = array(); if (isset($userlevel['entityid'])) { $fieldnavcategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($userlevel['entityid'], true));
require_once QA_INCLUDE_DIR . 'app/format.php'; // Get list of all users $start = qa_get_start(); $users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users'))); $usercount = qa_opt('cache_userpointscount'); $pagesize = qa_opt('page_size_users'); $users = array_slice($users, 0, $pagesize); $usershtml = qa_userids_handles_html($users); // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('main/highest_users'); $qa_content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_users')), 'type' => 'users'); if (count($users)) { foreach ($users as $userid => $user) { if (QA_FINAL_EXTERNAL_USERS) { $avatarhtml = qa_get_external_avatar_html($user['userid'], qa_opt('avatar_users_size'), true); } else { $avatarhtml = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true); } // avatar and handle now listed separately for use in themes $qa_content['ranking']['items'][] = array('avatar' => $avatarhtml, 'label' => $usershtml[$user['userid']], 'score' => qa_html(number_format($user['points'])), 'raw' => $user); } } else { $qa_content['title'] = qa_lang_html('main/no_active_users'); } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $usercount, qa_opt('pages_prev_next')); $qa_content['navigation']['sub'] = qa_users_sub_navigation(); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
} else { $messageid = null; } $fromhandle = qa_get_logged_in_handle(); $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array('^f_handle' => $fromhandle, '^url' => qa_path_absolute($canreply ? 'message/' . $fromhandle : 'user/' . $fromhandle))); $subs = array('^message' => $inmessage, '^f_handle' => $fromhandle, '^f_url' => qa_path_absolute('user/' . $fromhandle), '^more' => $more, '^a_url' => qa_path_absolute('account')); if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'], qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) { $messagesent = true; } else { $pageerror = qa_lang_html('main/general_error'); } qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $toaccount['userid'], 'handle' => $toaccount['handle'], 'messageid' => $messageid, 'message' => $inmessage)); if ($messagesent && qa_opt('show_message_history')) { // show message as part of general history qa_redirect(qa_request(), array('state' => 'message-sent')); } } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('misc/private_message_title'); $qa_content['error'] = @$pageerror; $qa_content['form_message'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1', 'code' => qa_get_form_security_code('message-' . $handle))); $qa_content['focusid'] = 'message'; if ($messagesent) { $qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent'); unset($qa_content['form_message']['buttons']); if (qa_opt('show_message_history')) { unset($qa_content['form_message']['fields']['message']);
<?php /* don't allow this page to be requested directly from browser */ if (!defined('QA_VERSION')) { header('Location: /'); exit; } /* Head of the template */ $current_cat = ra_get_cat_desc(qa_request(2)); ?> <!DOCTYPE html> <html lang="<?php echo qa_opt('site_language'); ?> "> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php if (is_array($current_cat)) { ?> <meta name="description" content="<?php echo substr($current_cat['content'], 0, 25); ?> "> <meta name="keywords" content="<?php echo $current_cat['title']; ?> "> <?php }
/** * Checks if the user is allowed to be shown cache. * Only non-registered users see the cached version. * @return boolean */ public static function now_caching() { if (!QA_CACHING_ENABLE) { return false; } if (qa_get_logged_in_userid()) { return false; } if (qa_request_part(0) == 'admin') { return false; } $requests = QA_CACHING_EXCLUDED_REQUESTS; if (!empty($requests)) { $requests = explode(',', str_replace(array("\r\n", "\r", "\n"), '', $requests)); } else { $requests = array(); } if (in_array(qa_request(), $requests)) { return false; } return true; }
function qa_admin_check_clicks() { if (qa_is_http_post()) { foreach ($_POST as $field => $value) { if (strpos($field, 'admin_') === 0) { @(list($dummy, $postid, $action) = explode('_', $field)); if (strlen($postid) && strlen($action) && qa_admin_single_click($postid, $action)) { qa_redirect(qa_request()); } } } } }
*/ require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; $postid = qa_post_text('postid'); $vote = qa_post_text('vote'); $code = qa_post_text('code'); $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); if (!qa_check_form_security_code('vote', $code)) { $voteerror = qa_lang_html('misc/form_security_reload'); } else { $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $voteerror = qa_vote_error_html($post, $vote, $userid, qa_request()); } if ($voteerror === false) { qa_vote_set($post, $userid, qa_get_logged_in_handle(), $cookieid, $vote); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $fields = qa_post_html_fields($post, $userid, $cookieid, array(), null, array('voteview' => qa_get_vote_view($post, true))); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'voting', null, null); echo "QA_AJAX_RESPONSE\n1\n"; $themeclass->voting_inner_html($fields); } else { echo "QA_AJAX_RESPONSE\n0\n" . $voteerror; } /* Omit PHP closing tag to help avoid accidental output */
} foreach ($results as $result) { if (isset($result['question'])) { $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($result['question'], $qdefaults)); } elseif (isset($result['url'])) { $fields = array('what' => qa_html($result['url']), 'meta_order' => qa_lang_html('main/meta_order')); } else { continue; } // nothing to show here if (isset($qdefaults['blockwordspreg'])) { $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']); } $fields['title'] = qa_html($result['title']); $fields['url'] = qa_html($result['url']); $qa_content['q_list']['qs'][] = $fields; } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count); if (qa_opt('feed_for_search')) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('search/' . $inquery)), 'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery))); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags()); } } else { $qa_content['error'] = qa_lang_html('main/search_explanation'); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function qa_page_q_add_c_form(&$qa_content, $questionid, $parentid, $formid, $usecaptcha, $in, $errors, $loadfocusnow) { switch (qa_user_permit_error('permit_post_c')) { case 'login': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request())); break; case 'confirm': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request())); break; case 'limit': $form = array('title' => qa_lang_html('question/comment_limit')); break; default: $form = array('title' => qa_lang_html('users/no_permission')); break; case false: $prefix = 'c' . $parentid . '_'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); if (method_exists($editor, 'update_script')) { $updatescript = $editor->update_script($prefix . 'content'); } else { $updatescript = ''; } $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : ''; $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '" NAME="c_form_' . qa_html($parentid) . '"', 'title' => qa_lang_html($questionid == $parentid ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onClick="' . $updatescript . ' return qa_submit_comment(' . qa_js($questionid) . ', ' . qa_js($parentid) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1')); if (!strlen($custom)) { unset($form['fields']['custom']); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix); $onloads = array(); if ($usecaptcha) { $userid = qa_get_logged_in_userid(); $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_insert_login_links(qa_lang_html(isset($userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); if (strlen($captchaloadscript)) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' }'; } } if (!$loadfocusnow) { if (method_exists($editor, 'load_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' }'; } if (method_exists($editor, 'focus_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' }'; } $form['buttons']['cancel']['tags'] .= ' onClick="return qa_toggle_element()"'; } if (count($onloads)) { $qa_content['script_onloads'][] = $onloads; } } $form['id'] = $formid; $form['collapse'] = !$loadfocusnow; $form['style'] = 'tall'; return $form; }
function qa_navigation_add_page(&$navigation, $page) { if (!qa_permit_value_error($page['permit'], qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags()) || !isset($page['permit'])) { $url = qa_custom_page_url($page); $navigation[$page['flags'] & QA_PAGE_FLAGS_EXTERNAL ? 'custom-' . $page['pageid'] : $page['tags'] . '$'] = array('url' => qa_html($url), 'label' => qa_html($page['title']), 'opposite' => $page['nav'] == 'O', 'target' => $page['flags'] & QA_PAGE_FLAGS_NEW_WINDOW ? '_blank' : null, 'selected' => $page['flags'] & QA_PAGE_FLAGS_EXTERNAL && ($url == qa_path(qa_request()) || $url == qa_self_html())); } }
} else { $qa_content['form'] = array('tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"', 'ok' => $savedoptions ? qa_lang_html('admin/options_saved') : null, 'style' => 'tall', 'fields' => array('intro' => array('label' => qa_lang_html('admin/categories_introduction'), 'type' => 'static')), 'buttons' => array('save' => array('tags' => 'name="dosaveoptions" id="dosaveoptions"', 'label' => qa_lang_html('main/save_button')), 'add' => array('tags' => 'name="doaddcategory"', 'label' => qa_lang_html('admin/add_category_button'))), 'hidden' => array('code' => qa_get_form_security_code('admin/categories'))); if (count($categories)) { unset($qa_content['form']['fields']['intro']); $navcategoryhtml = ''; foreach ($categories as $category) { if (!isset($category['parentid'])) { $navcategoryhtml .= '<a href="' . qa_path_html('admin/categories', array('edit' => $category['categoryid'])) . '">' . qa_html($category['title']) . '</a> - ' . qa_lang_html_sub('main/x_questions', $category['qcount']) . '<br/>'; } } $qa_content['form']['fields']['nav'] = array('label' => qa_lang_html('admin/top_level_categories'), 'type' => 'static', 'value' => $navcategoryhtml); $qa_content['form']['fields']['allow_no_category'] = array('label' => qa_lang_html('options/allow_no_category'), 'tags' => 'name="option_allow_no_category"', 'type' => 'checkbox', 'value' => qa_opt('allow_no_category')); if (!qa_opt('allow_no_category')) { $nocatcount = qa_db_count_categoryid_qs(null); if ($nocatcount) { $qa_content['form']['fields']['allow_no_category']['error'] = strtr(qa_lang_html('admin/category_none_error'), array('^q' => number_format($nocatcount), '^1' => '<a href="' . qa_path_html(qa_request(), array('missing' => 1)) . '">', '^2' => '</a>')); } } $qa_content['form']['fields']['allow_no_sub_category'] = array('label' => qa_lang_html('options/allow_no_sub_category'), 'tags' => 'name="option_allow_no_sub_category"', 'type' => 'checkbox', 'value' => qa_opt('allow_no_sub_category')); } else { unset($qa_content['form']['buttons']['save']); } } if (qa_get('recalc')) { $qa_content['form']['ok'] = '<span id="recalc_ok">' . qa_lang_html('admin/recalc_categories') . '</span>'; $qa_content['form']['hidden']['code_recalc'] = qa_get_form_security_code('admin/recalc'); $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION; $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning'); $qa_content['script_onloads'][] = array("qa_recalc_click('dorecalccategories', document.getElementById('dosaveoptions'), null, 'recalc_ok');"); } $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
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 qa_self_html() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_used_url_format; return qa_path_html(qa_request(), $_GET, null, $qa_used_url_format); }
function qa_page_q_single_click_c($comment, $question, $parent, &$error) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); $prefix = 'c' . $comment['postid'] . '_'; if (qa_clicked($prefix . 'dohide') && $comment['hideable'] || qa_clicked($prefix . 'doreject') && $comment['moderatable']) { if (qa_page_q_click_check_form_code($parent, $error)) { qa_comment_set_hidden($comment, true, $userid, $handle, $cookieid, $question, $parent); return true; } } if (qa_clicked($prefix . 'doreshow') && $comment['reshowable'] || qa_clicked($prefix . 'doapprove') && $comment['moderatable']) { if (qa_page_q_click_check_form_code($parent, $error)) { if ($comment['moderatable'] || $comment['reshowimmed']) { $status = QA_POST_STATUS_NORMAL; } else { $in = qa_page_q_prepare_post_for_filters($comment); $filtermodules = qa_load_modules_with('filter', 'filter_comment'); // run through filters but only for queued status foreach ($filtermodules as $filtermodule) { $tempin = $in; // always pass original comment in because we aren't modifying anything else $filtermodule->filter_comment($tempin, $temperrors, $question, $parent, $comment); $in['queued'] = $tempin['queued']; // only preserve queued status in loop } $status = $in['queued'] ? QA_POST_STATUS_QUEUED : QA_POST_STATUS_NORMAL; } qa_comment_set_status($comment, $status, $userid, $handle, $cookieid, $question, $parent); return true; } } if (qa_clicked($prefix . 'dodelete') && $comment['deleteable'] && qa_page_q_click_check_form_code($parent, $error)) { qa_comment_delete($comment, $question, $parent, $userid, $handle, $cookieid); return true; } if (qa_clicked($prefix . 'doclaim') && $comment['claimable'] && qa_page_q_click_check_form_code($parent, $error)) { if (qa_user_limits_remaining(QA_LIMIT_COMMENTS)) { qa_comment_set_userid($comment, $userid, $handle, $cookieid); return true; } else { $error = qa_lang_html('question/comment_limit'); } } if (qa_clicked($prefix . 'doflag') && $comment['flagbutton'] && qa_page_q_click_check_form_code($parent, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; $error = qa_flag_error_html($comment, $userid, qa_request()); if (!$error) { if (qa_flag_set_tohide($comment, $userid, $handle, $cookieid, $question)) { qa_comment_set_hidden($comment, true, null, null, null, $question, $parent); } // hiding not really by this user so pass nulls return true; } } if (qa_clicked($prefix . 'dounflag') && $comment['unflaggable'] && qa_page_q_click_check_form_code($parent, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; qa_flag_clear($comment, $userid, $handle, $cookieid); return true; } if (qa_clicked($prefix . 'doclearflags') && $comment['clearflaggable'] && qa_page_q_click_check_form_code($parent, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; qa_flags_clear_all($comment, $userid, $handle, $cookieid); return true; } return false; }
unset($blockipclauses[$key]); } } qa_set_option('block_ips_write', implode(' , ', $blockipclauses)); qa_report_event('ip_unblock', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array('ip' => $ip)); qa_redirect(qa_request()); } if (qa_clicked('dohideall') && !qa_user_maximum_permit_error('permit_hide_show')) { // allow moderator in one category to hide posts across all categories if they are identified via IP page require_once QA_INCLUDE_DIR . 'qa-db-admin.php'; require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $postids = qa_db_get_ip_visible_postids($ip); foreach ($postids as $postid) { qa_post_set_hidden($postid, true, $userid); } qa_redirect(qa_request()); } } } // Combine sets of questions and get information for users $questions = qa_any_sort_by_date(array_merge($qs, $qs_queued, $qs_hidden, $a_qs, $a_queued_qs, $a_hidden_qs, $c_qs, $c_queued_qs, $c_hidden_qs, $edit_qs)); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); $hostname = gethostbyaddr($ip); // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('main/ip_address_x', qa_html($ip)); $qa_content['error'] = @$pageerror; $qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('host' => array('type' => 'static', 'label' => qa_lang_html('misc/host_name'), 'value' => qa_html($hostname))), 'hidden' => array('code' => qa_get_form_security_code('ip-' . $ip))); if ($blockable) { require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; $blockipclauses = qa_block_ips_explode(qa_opt('block_ips_write'));
function qa_page_q_do_comment($question, $parent, $commentsfollows, $pagestart, $usecaptcha, &$cnewin, &$cnewerrors, &$formtype, &$formpostid, &$error) { // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...) $answer = $question['postid'] == $parent['postid'] ? null : $parent; $parentid = $parent['postid']; switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': $error = qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()); break; case 'confirm': $error = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request()); break; case 'approve': $error = qa_lang_html('question/comment_must_be_approved'); break; case 'limit': $error = qa_lang_html('question/comment_limit'); break; default: $error = qa_lang_html('users/no_permission'); break; case false: if (qa_clicked('c' . $parentid . '_doadd')) { $commentid = qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, $cnewin[$parentid], $cnewerrors[$parentid]); if (isset($commentid)) { qa_page_q_refresh($pagestart, null, $parent['basetype'], $parentid); } else { $formtype = 'c_add'; $formpostid = $parentid; // show form again } } else { $formtype = 'c_add'; $formpostid = $parentid; // show form first time } break; } }
function qa_feed_load_ifcategory($categoryslugs, $allkey, $catkey, &$title, $questionselectspec1 = null, $questionselectspec2 = null, $questionselectspec3 = null, $questionselectspec4 = null) { $countslugs = @count($categoryslugs); list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending($questionselectspec1, $questionselectspec2, $questionselectspec3, $questionselectspec4, $countslugs ? qa_db_category_nav_selectspec($categoryslugs, false) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null); if ($countslugs && !isset($categoryid)) { qa_feed_not_found(); } if (isset($allkey)) { $title = isset($categoryid) && isset($catkey) ? qa_lang_sub($catkey, $categories[$categoryid]['title']) : qa_lang($allkey); } return array_merge(is_array($questions1) ? $questions1 : array(), is_array($questions2) ? $questions2 : array(), is_array($questions3) ? $questions3 : array(), is_array($questions4) ? $questions4 : array()); } // Connect to database and get the type of feed and category requested (in some cases these are overridden later) qa_db_connect('qa_feed_db_fail_handler'); qa_preload_options(); $requestlower = strtolower(qa_request()); $foursuffix = substr($requestlower, -4); if ($foursuffix == '.rss' || $foursuffix == '.xml') { $requestlower = substr($requestlower, 0, -4); } $requestlowerparts = explode('/', $requestlower); $feedtype = @$requestlowerparts[1]; $feedparams = array_slice($requestlowerparts, 2); // Choose which option needs to be checked to determine if this feed can be requested, and stop if no matches $feedoption = null; $categoryslugs = $feedparams; switch ($feedtype) { case 'questions': $feedoption = 'feed_for_questions'; break; case 'hot':
} if (@$followanswer['basetype'] != 'A') { $followanswer = null; } // Check for permission error $permiterror = qa_user_maximum_permit_error('permit_post_q', QA_LIMIT_QUESTIONS); if ($permiterror) { $qa_content = qa_content_prepare(); // The 'approve', 'login', 'confirm', 'limit', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the menu option being shown, in qa_content_prepare(...) switch ($permiterror) { case 'login': $qa_content['error'] = qa_insert_login_links(qa_lang_html('question/ask_must_login'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null); break; case 'confirm': $qa_content['error'] = qa_insert_login_links(qa_lang_html('question/ask_must_confirm'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null); break; case 'limit': $qa_content['error'] = qa_lang_html('question/ask_limit'); break; case 'approve': $qa_content['error'] = qa_lang_html('question/ask_must_be_approved'); break; default: $qa_content['error'] = qa_lang_html('users/no_permission'); break; } return $qa_content; } // Process input $captchareason = qa_user_captcha_reason();
qa_redirect(qa_request()); } if (qa_clicked('dodelete') && $loginlevel >= QA_USER_LEVEL_ADMIN) { require_once QA_INCLUDE_DIR . 'qa-app-users-edit.php'; qa_delete_user($userid); qa_report_event('u_delete', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $userid, 'handle' => $useraccount['handle'])); qa_redirect('users'); } } } // Process bonus setting button if ($loginlevel >= QA_USER_LEVEL_ADMIN && qa_clicked('dosetbonus')) { require_once QA_INCLUDE_DIR . 'qa-db-points.php'; qa_db_points_set_bonus($userid, (int) qa_post_text('bonus')); qa_db_points_update_ifuser($userid, null); qa_redirect(qa_request(), null, null, null, 'activity'); } // Get information on user references in answers and other stuff need for page $pagesize = qa_opt('page_size_user_posts'); $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, $pagesize); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml[$userid] = $userhtml; // Prepare content for theme $qa_content = qa_content_prepare(true); $qa_content['title'] = qa_lang_html_sub('profile/user_x', $userhtml); if (isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS) { $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_USER, $useraccount['userid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'users/add_user_x_favorites', $handle)); } // General information about the user, only available if we're using internal user management if (!QA_FINAL_EXTERNAL_USERS) {