function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     /*
     $requestparts=qa_request_parts();
     $requestlower=strtolower(qa_request());
     $firstlower=strtolower($requestparts[0]);
     $routing=qa_page_routing();
     // unanswered & questions pages may contain categories.
     unset($routing['activity/']);
     unset($routing['unanswered/']);
     unset($routing['questions/']);
     if ( (isset($routing[$requestlower])) or (isset($routing[$firstlower.'/'])) or (is_numeric($requestparts[0])) )
     	return;
     	
     $explicitqa=(strtolower($requestparts[0])=='qa' or strtolower($requestparts[0])=='unanswered' or strtolower($requestparts[0])=='questions' or strtolower($requestparts[0])=='activity');
     
     if ($explicitqa)
     	$slugs=array_slice($requestparts, 1);
     elseif (strlen($requestparts[0]))
     	$slugs=$requestparts;
     else
     	$slugs=array();
     */
     $slugs = useo_get_current_category_slug();
     $countslugs = count($slugs);
     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);
     if ($countslugs && isset($categoryid)) {
         /*
         $categoryid is current categories ID
         $backpath = implode('/', array_reverse($slugs));
         echo "countslugs: <pre>"; var_dump($countslugs); echo "</pre>";
         $fullcategory=qa_db_select_with_pending(qa_db_full_category_selectspec($categoryid, true));
         echo "fullcategory: <pre>"; var_dump($fullcategory); echo "</pre>";
         
         echo "categoryid: <pre>"; var_dump($categoryid); echo "</pre>";
         echo "slugs: <pre>"; var_dump($slugs); echo "</pre>";
         echo "template: <pre>"; var_dump($template); echo "</pre>";
         echo "request: <pre>"; var_dump($request); echo "</pre>";
         */
         require_once QA_INCLUDE_DIR . 'qa-db-metas.php';
         $description = qa_db_categorymeta_get($categoryid, 'useo_cat_description');
         if (!qa_opt('useo_cat_desc_format')) {
             $description = qa_html($description);
         }
         $editurlhtml = qa_path_html('category-edit/' . $categoryid);
         $allowediting = !qa_user_permit_error('useo_cat_desc_permit_edit');
         if (strlen($description)) {
             echo '<SPAN CLASS="entry-content qa-category-description">';
             echo $description;
             echo '</SPAN>';
             if ($allowediting) {
                 echo ' - <A HREF="' . $editurlhtml . '">edit</A>';
             }
         } elseif ($allowediting) {
             echo '<A HREF="' . $editurlhtml . '">' . qa_lang_html('useo/create_desc_link') . '</A>';
         }
     }
 }
Exemple #2
0
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());
}
 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;
 }
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.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, $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 == 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;
$countslugs = @count($categoryslugs);
$by = qa_get('by');
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
switch ($by) {
    case 'selected':
        $selectby = 'selchildid';
        break;
    case 'upvotes':
        $selectby = 'amaxvote';
        break;
    default:
        $selectby = 'acount';
        break;
}
list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_unanswered_qs_selectspec($userid, $selectby, $start, $categoryslugs, false, false, qa_opt_if_loaded('page_size_una_qs')), QA_ALLOW_UNINDEXED_QUERIES ? qa_db_category_nav_selectspec($categoryslugs, false, false, true) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null);
if ($countslugs) {
    if (!isset($categoryid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $categorytitlehtml = qa_html($categories[$categoryid]['title']);
}
$feedpathprefix = null;
$linkparams = array('by' => $by);
switch ($by) {
    case 'selected':
        if ($countslugs) {
            $sometitle = qa_lang_html_sub('main/unselected_qs_in_x', $categorytitlehtml);
            $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
        } else {
            $sometitle = qa_lang_html('main/unselected_qs_title');
	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-q-list.php';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
$userid = qa_get_logged_in_userid();
//	Get list of comments with related questions, plus category information
list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($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_cs_in_x', $categorytitlehtml);
    $nonetitle = qa_lang_html_sub('main/no_comments_in_x', $categorytitlehtml);
} else {
    $sometitle = qa_lang_html('main/recent_cs_title');
    $nonetitle = qa_lang_html('main/no_comments_found');
}
//	Prepare and return content for theme
return qa_q_list_page_content(qa_any_sort_and_dedupe($questions), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, false, 'comments/', qa_opt('feed_for_activity') ? 'comments' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)));
/*
	Omit PHP closing tag to help avoid accidental output
	GNU General Public License for more details.

	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 . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
//	Get information about appropriate categories and redirect to questions page if category has no sub-categories
$userid = qa_get_logged_in_userid();
list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null);
if ($countslugs && !isset($categoryid)) {
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Function for recursive display of categories
function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap)
{
    foreach ($navigation as $key => $navlink) {
        $category = $categories[$navlink['categoryid']];
        if (!$category['childcount']) {
            unset($navigation[$key]['url']);
        } elseif ($navlink['selected']) {
            $navigation[$key]['state'] = 'open';
            $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
        } else {
            $navigation[$key]['state'] = 'closed';
 for ($attempt = 0; $attempt < 100; $attempt++) {
     switch ($attempt) {
         case 0:
             $inslug = qa_post_text('slug');
             if (!isset($inslug)) {
                 $inslug = implode('-', qa_string_to_words($inname));
             }
             break;
         case 1:
             $inslug = qa_lang_sub('admin/page_default_slug', $inslug);
             break;
         default:
             $inslug = qa_lang_sub('admin/page_default_slug', $attempt - 1);
             break;
     }
     list($matchcategoryid, $matchpage) = qa_db_select_with_pending(qa_db_slugs_to_category_id_selectspec($inslug), qa_db_page_full_selectspec($inslug, false));
     if (empty($inslug)) {
         $errors['slug'] = qa_lang('main/field_required');
     } elseif (qa_strlen($inslug) > QA_DB_MAX_CAT_PAGE_TAGS_LENGTH) {
         $errors['slug'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH);
     } elseif (preg_match('/[\\+\\/]/', $inslug)) {
         $errors['slug'] = qa_lang_sub('admin/slug_bad_chars', '+ /');
     } elseif (qa_admin_is_slug_reserved($inslug)) {
         $errors['slug'] = qa_lang('admin/slug_reserved');
     } elseif (isset($matchpage) && $matchpage['pageid'] != @$editpage['pageid']) {
         $errors['slug'] = qa_lang('admin/page_already_used');
     } elseif (isset($matchcategoryid)) {
         $errors['slug'] = qa_lang('admin/category_already_used');
     } else {
         unset($errors['slug']);
     }
Exemple #9
0
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	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';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
//	Get information about appropriate categories and redirect to questions page if category has no sub-categories
@(list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null));
if ($countslugs && !isset($categoryid)) {
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Function for recursive display of categories
function qa_category_nav_to_browse(&$navigation, $categories, $categoryid)
{
    foreach ($navigation as $key => $navlink) {
        $category = $categories[$navlink['categoryid']];
        if (!$category['childcount']) {
            unset($navigation[$key]['url']);
        } elseif ($navlink['selected']) {
            $navigation[$key]['state'] = 'open';
            $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
        } else {
            $navigation[$key]['state'] = 'closed';
        $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) = 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);
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':
	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 . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . '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) = 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);
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);
/*
	Omit PHP closing tag to help avoid accidental output
	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;
}
// report that we entered this page
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME']));
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-q-list.php';
$categoryslugs = $pass_subrequests;
$countslugs = count($categoryslugs);
//	Get lists of recent activity in all its forms, plus category information
@(list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending(qa_db_qs_selectspec($qa_login_userid, 'created', 0, $categoryslugs), qa_db_recent_a_qs_selectspec($qa_login_userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($qa_login_userid, 0, $categoryslugs), qa_db_recent_edit_qs_selectspec($qa_login_userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false), $countslugs ? qa_db_slugs_to_category_id_selectspec($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)));
/*
	Omit PHP closing tag to help avoid accidental output
Exemple #13
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':
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME']));
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
//	Determine whether path begins with qa or not (question and answer listing can be accessed either way)
$explicitqa = $qa_request_lc_parts[0] == 'qa';
if ($explicitqa) {
    $slugs = array_slice($qa_request_parts, 1);
} elseif (strlen($qa_request_parts[0])) {
    // $qa_request_parts[0] always present so we need to check its length
    $slugs = $qa_request_parts;
} else {
    $slugs = array();
}
$countslugs = count($slugs);
//	Get list of questions, other bits of information that might be
@(list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_select_with_pending(qa_db_qs_selectspec($qa_login_userid, 'created', 0, $slugs), qa_db_recent_a_qs_selectspec($qa_login_userid, 0, $slugs), qa_db_category_nav_selectspec($slugs, false), $countslugs ? qa_db_slugs_to_category_id_selectspec($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_template = 'custom';
    $qa_content = qa_content_prepare();
    $qa_content['title'] = qa_html($custompage['heading']);
    $qa_content['custom'] = $custompage['content'];
    if (qa_get_logged_in_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']))));
    }
    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);
}