header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'util/sort.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
require_once QA_INCLUDE_DIR . 'app/captcha.php';
require_once QA_INCLUDE_DIR . 'pages/question-view.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
$questionid = qa_request_part(0);
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
//	Get information about this question
list($question, $childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null);
if ($question['basetype'] != 'Q') {
    // don't allow direct viewing of other types of post
    $question = null;
}
if (isset($question)) {
    $question['extra'] = $extravalue;
    $answers = qa_page_q_load_as($question, $childposts);
    $commentsfollows = qa_page_q_load_c_follows($question, $childposts, $achildposts);
    $question = $question + qa_page_q_post_rules($question, null, null, $childposts);
    // array union
    if ($question['selchildid'] && @$answers[$question['selchildid']]['type'] != 'A') {
        $question['selchildid'] = null;
    }
    // if selected answer is hidden or somehow not there, consider it not selected
    foreach ($answers as $key => $answer) {
示例#2
0
if (QA_FINAL_EXTERNAL_USERS) {
    $publictouserid = qa_get_userids_from_public(array($handle));
    if (!count($publictouserid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $userid = reset($publictouserid);
    // don't use $publictouserid[$handle] since $handle capitalization might be different
    $usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);
    $userhtml = @$usershtml[$userid];
} else {
    $userhtml = qa_html($handle);
}
//	Find the user profile and questions and answers for this handle
$loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
@(list($useraccount, $userprofile, $userfields, $userpoints, $userrank, $questions, $answerqs, $commentqs, $editqs, $favorite) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), qa_db_user_points_selectspec($identifier), qa_db_user_rank_selectspec($identifier), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_user_posts')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier), isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS ? qa_db_is_favorite_selectspec($loginuserid, QA_ENTITY_USER, $handle) : null));
//	Check the user exists and work out what can and can't be set (if not using single sign-on)
$loginlevel = qa_get_logged_in_level();
if (!QA_FINAL_EXTERNAL_USERS) {
    // if we're using integrated user management, we can know and show more
    if (!is_array($userpoints) && !is_array($useraccount)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $userid = $useraccount['userid'];
    $fieldseditable = false;
    $maxlevelassign = null;
    if ($loginuserid && $loginuserid != $userid && ($loginlevel >= QA_USER_LEVEL_SUPER || $loginlevel > $useraccount['level']) && !qa_user_permit_error()) {
        // can't change self - or someone on your level (or higher, obviously) unless you're a super admin
        if ($loginlevel >= QA_USER_LEVEL_SUPER) {
            $maxlevelassign = QA_USER_LEVEL_SUPER;
        } elseif ($loginlevel >= QA_USER_LEVEL_ADMIN) {
示例#3
0
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
//	Determine whether path begins with qa or not (question and answer listing can be accessed either way)
$requestparts = explode('/', qa_request());
$explicitqa = strtolower($requestparts[0]) == 'qa';
if ($explicitqa) {
    $slugs = array_slice($requestparts, 1);
} elseif (strlen($requestparts[0])) {
    $slugs = $requestparts;
} else {
    $slugs = array();
}
$countslugs = count($slugs);
//	Get list of questions, other bits of information that might be useful
$userid = qa_get_logged_in_userid();
@(list($questions1, $questions2, $categories, $categoryid, $favorite, $custompage) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $slugs, null, false, false, qa_opt_if_loaded('page_size_activity')), qa_db_recent_a_qs_selectspec($userid, 0, $slugs), qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null, $countslugs && isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_CATEGORY, $slugs) : null, $countslugs == 1 && !$explicitqa ? qa_db_page_full_selectspec($slugs[0], false) : null));
//	First, if this matches a custom page, return immediately with that page's content
if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
    qa_set_template('custom-' . $custompage['pageid']);
    $qa_content = qa_content_prepare();
    $level = qa_get_logged_in_level();
    if (!qa_permit_value_error($custompage['permit'], $userid, $level, qa_get_logged_in_flags()) || !isset($custompage['permit'])) {
        $qa_content['title'] = qa_html($custompage['heading']);
        $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;
示例#4
0
 function get_single_question($data, $questionin)
 {
     $userid = qa_get_logged_in_userid();
     $questionid = $questionin['postid'];
     $options = qa_post_html_defaults('Q', @$data['full']);
     if (@$data['full']) {
         require_once QA_INCLUDE_DIR . 'qa-page-question-view.php';
         $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
         // create a new cookie if necessary
         $coptions = qa_post_html_defaults('C', true);
         @(list($childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null));
         if ($questionin['basetype'] != 'Q') {
             // don't allow direct viewing of other types of post
             return null;
         }
         $questionin['extra'] = $extravalue;
         $answers = qa_page_q_load_as($questionin, $childposts);
         $allcomments = qa_page_q_load_c_follows($questionin, $childposts, $achildposts);
         $questionin = $questionin + qa_page_q_post_rules($questionin, null, null, $childposts);
         // array union
         if ($questionin['selchildid'] && @$answers[$questionin['selchildid']]['type'] != 'A') {
             $questionin['selchildid'] = null;
         }
         // if selected answer is hidden or somehow not there, consider it not selected
         foreach ($answers as $key => $answer) {
             $answers[$key] = $answer + qa_page_q_post_rules($answer, $questionin, $answers, $achildposts);
             $answers[$key]['isselected'] = $answer['postid'] == $questionin['selchildid'];
         }
         foreach ($allcomments as $key => $commentfollow) {
             $parent = $commentfollow['parentid'] == $questionid ? $questionin : @$answers[$commentfollow['parentid']];
             $allcomments[$key] = $commentfollow + qa_page_q_post_rules($commentfollow, $parent, $allcomments, null);
         }
         $usershtml = qa_userids_handles_html(array_merge(array($questionin), $answers, $allcomments), true);
         $question = $this->get_full_post($questionin, $options, $usershtml);
         $qcomments = array();
         foreach ($allcomments as $idx => $comment) {
             if ($comment['basetype'] == 'C') {
                 $comment = $this->get_full_post($comment, $coptions, $usershtml);
             } else {
                 $comment = $this->get_full_post($comment, $options, $usershtml);
             }
             $comment['username'] = $this->get_username($comment['raw']['userid']);
             if ($comment['raw']['parentid'] == $questionid) {
                 $qcomments[] = $comment;
             }
             $allcomments[$idx] = $comment;
         }
         $aoptions = qa_post_html_defaults('A', true);
         $outanswers = array();
         foreach ($answers as $answer) {
             $aoptions['isselected'] = @$answer['isselected'];
             $answer = $this->get_full_post($answer, $aoptions, $usershtml);
             if (!$answer) {
                 continue;
             }
             $answer['username'] = $this->get_username($answer['raw']['userid']);
             $acomments = array();
             foreach ($allcomments as $comment) {
                 if ($comment['raw']['parentid'] == $answer['raw']['postid']) {
                     $acomments[] = $comment;
                 }
             }
             $answer['comments'] = $acomments;
             $outanswers[] = $answer;
         }
         $question['answers'] = $outanswers;
         $question['comments'] = $qcomments;
         $question['parentquestion'] = $parentquestion;
         $question['closepost'] = $closepost;
         $question['extravalue'] = $extravalue;
         $question['categories'] = $categories;
         $question['favorite'] = $favorite;
     } else {
         $questionin = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         $usershtml = qa_userids_handles_html(array($questionin), true);
         $question = qa_any_to_q_html_fields($questionin, $userid, qa_cookie_get(), $usershtml, null, $options);
     }
     $question['username'] = $this->get_username($userid);
     return $question;
 }
示例#5
0
	More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
require_once QA_INCLUDE_DIR . 'qa-app-q-list.php';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
$userid = qa_get_logged_in_userid();
//	Get lists of recent activity in all its forms, plus category information
@(list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid, $favorite) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_activity')), qa_db_recent_a_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_edit_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, $countslugs && isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_CATEGORY, $categoryslugs) : null));
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_activity_in_x', $categorytitlehtml);
    $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else {
    $sometitle = qa_lang_html('main/recent_activity_title');
    $nonetitle = qa_lang_html('main/no_questions_found');
}
//	Prepare and return content for theme
return qa_q_list_page_content(qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, true, 'activity/', qa_opt('feed_for_activity') ? 'activity' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null, $favorite);
/*
	Omit PHP closing tag to help avoid accidental output
示例#6
0
        $selectsort = 'hotness';
        break;
    case 'votes':
        $selectsort = 'netvotes';
        break;
    case 'answers':
        $selectsort = 'acount';
        break;
    case 'views':
        $selectsort = 'views';
        break;
    default:
        $selectsort = 'created';
        break;
}
@(list($questions, $categories, $categoryid, $favorite) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, $selectsort, $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_qs')), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, $countslugs && isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_CATEGORY, $categoryslugs) : null));
if ($countslugs) {
    if (!isset($categoryid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $categorytitlehtml = qa_html($categories[$categoryid]['title']);
    $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else {
    $nonetitle = qa_lang_html('main/no_questions_found');
}
$categorypathprefix = QA_ALLOW_UNINDEXED_QUERIES ? 'questions/' : null;
// this default is applied if sorted not by recent
$feedpathprefix = null;
$linkparams = array('sort' => $sort);
switch ($sort) {
    case 'hot':
示例#7
0
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
$tag = qa_request_part(1);
// picked up from qa-page.php
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
//	Find the questions with this tag
if (!strlen($tag)) {
    qa_redirect('tags');
}
@(list($questions, $tagword, $favorite) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_word_selectspec($tag), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_TAG, $tag) : null));
$pagesize = qa_opt('page_size_tag_qs');
$questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions);
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
if (isset($userid) && isset($tagword)) {
    $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
if (!count($questions)) {
    $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
}
$qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
$qa_content['q_list']['qs'] = array();
foreach ($questions as $postid => $question) {