modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	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
*/
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
function qa_ajax_subcats_db_fail_handler()
{
    echo "QA_AJAX_RESPONSE\n0\nA database error occurred.";
    exit;
}
qa_base_db_connect('qa_ajax_subcats_db_fail_handler');
$categoryid = qa_post_text('categoryid');
if (!strlen($categoryid)) {
    $categoryid = null;
}
$categories = qa_db_select_with_pending(qa_db_category_sub_selectspec($categoryid));
echo "QA_AJAX_RESPONSE\n1";
foreach ($categories as $category) {
    echo "\n" . $category['categoryid'] . '/' . $category['title'];
}
qa_base_db_disconnect();
/*
	Omit PHP closing tag to help avoid accidental output
*/
示例#2
0
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/
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';
function qa_ajax_vote_db_fail_handler()
{
    echo "QA_AJAX_RESPONSE\n0\nA database error occurred.";
    exit;
}
qa_base_db_connect('qa_ajax_vote_db_fail_handler');
$postid = qa_post_text('postid');
$qa_login_userid = qa_get_logged_in_userid();
$qa_cookieid = qa_cookie_get();
$post = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $postid));
$voteerror = qa_vote_error_html($post, $qa_login_userid, $qa_request);
if ($voteerror === false) {
    qa_vote_set($post, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, qa_post_text('vote'));
    $post = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $postid));
    $fields = qa_post_html_fields($post, $qa_login_userid, $qa_cookieid, array(), null, array('voteview' => qa_opt('votes_separated') ? 'updown' : 'net'));
    $themeclass = qa_load_theme_class(qa_opt('site_theme'), 'voting', null, null);
    echo "QA_AJAX_RESPONSE\n1\n";
    $themeclass->voting_inner_html($fields);
} else {
    echo "QA_AJAX_RESPONSE\n0\n" . $voteerror;
}
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	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
*/
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-recalc.php';
function qa_ajax_recalc_db_fail_handler()
{
    echo "QA_AJAX_RESPONSE\n0\n\nA database error occurred.";
    exit;
}
qa_base_db_connect('qa_ajax_recalc_db_fail_handler');
if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
    $state = qa_post_text('state');
    $stoptime = time() + 3;
    while (qa_recalc_perform_step($state) && time() < $stoptime) {
    }
    $message = qa_recalc_get_message($state);
} else {
    $state = '';
    $message = qa_lang('admin/no_privileges');
}
qa_base_db_disconnect();
echo "QA_AJAX_RESPONSE\n1\n" . $state . "\n" . qa_html($message);
/*
	Omit PHP closing tag to help avoid accidental output
*/
示例#4
0
        case 'select':
            $errorhtml .= 'Could not switch to the Question2Answer database. Please check the database name in the config file, and if necessary create the database in MySQL and grant appropriate user privileges.';
            break;
        case 'query':
            global $pass_failure_from_install;
            if (@$pass_failure_from_install) {
                $errorhtml .= "Question2Answer was unable to perform the installation query below. Please check the user in the config file has CREATE and ALTER permissions:\n\n";
            } else {
                $errorhtml .= "Question2Answer query failed:\n\n";
            }
            $errorhtml .= qa_html($pass_failure_query . "\n\nError " . $pass_failure_errno . ": " . $pass_failure_error . "\n\n");
            break;
    }
} else {
    // this page was requested by user GET/POST, so handle any incoming clicks on buttons
    qa_base_db_connect('qa_install_db_fail_handler');
    if (qa_clicked('create')) {
        qa_db_install_tables();
        if (QA_FINAL_EXTERNAL_USERS) {
            if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) {
                require_once QA_INCLUDE_DIR . 'qa-db-admin.php';
                require_once QA_INCLUDE_DIR . 'qa-app-format.php';
                qa_db_page_move(qa_db_page_create(get_option('blogname'), QA_PAGE_FLAGS_EXTERNAL, get_option('home'), null, null), 'O', 1);
                // create link back to WordPress home page
                $success .= 'Your Question2Answer database has been created and integrated with your WordPress site.';
            } else {
                $success .= 'Your Question2Answer database has been created for external user identity management. Please read the online documentation to complete integration.';
            }
        } else {
            $success .= 'Your Question2Answer database has been created.';
        }
示例#5
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
*/
//	Ensure no PHP errors are shown in the image data
@ini_set('display_errors', 0);
require_once QA_INCLUDE_DIR . 'qa-db-cache.php';
function qa_blob_image_db_fail_handler()
{
    exit;
}
$blobid = @$qa_request_lc_parts[1];
$size = (int) qa_get('s');
$cachetype = 'i_' . $size;
qa_base_db_connect('qa_blob_image_db_fail_handler');
$content = qa_db_cache_get($cachetype, $blobid);
// see if we've cached the scaled down version
header('Cache-Control: max-age=2592000, public');
// allows browsers and proxies to cache images too
if (isset($content)) {
    header('Content-Type: image/jpeg');
    echo $content;
} else {
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-db-blobs.php';
    require_once QA_INCLUDE_DIR . 'qa-util-image.php';
    $blob = qa_db_blob_read($blobid);
    if (isset($blob)) {
        if ($size > 0) {
            $content = qa_image_constrain_data($blob['content'], $width, $height, $size);
示例#6
0
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
//	Memory/CPU usage tracking
if (QA_DEBUG_PERFORMANCE) {
    require_once QA_INCLUDE_DIR . 'qa-util-debug.php';
    qa_usage_init();
}
//	Connect to database
qa_base_db_connect('qa_page_db_fail_handler');
//	Get common parameters, queue some database information for retrieval and get the ID/cookie of the current user (if any)
$qa_start = min(max(0, (int) qa_get('start')), QA_MAX_LIMIT_START);
$qa_state = qa_get('state');
unset($_GET['state']);
// to prevent being passed through on forms
$qa_nav_pages_pending = true;
$qa_widgets_pending = true;
$qa_logged_in_pending = true;
$qa_login_userid = qa_get_logged_in_userid();
$qa_cookieid = qa_cookie_get();
// 	If not currently logged in as anyone, see if any of the registered login modules can help
if (!isset($qa_login_userid)) {
    $modulenames = qa_list_modules('login');
    foreach ($modulenames as $tryname) {
        $module = qa_load_module('login', $tryname);
示例#7
0
    exit;
}
function qa_feed_load_ifcategory($allkey, $catkey, $questionselectspec1 = null, $questionselectspec2 = null, $questionselectspec3 = null, $questionselectspec4 = null)
{
    global $categoryslugs, $countslugs, $categories, $categoryid, $title, $questions;
    @(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();
    }
    $questions = array_merge(is_array($questions1) ? $questions1 : array(), is_array($questions2) ? $questions2 : array(), is_array($questions3) ? $questions3 : array(), is_array($questions4) ? $questions4 : array());
    if (isset($allkey) && isset($catkey)) {
        $title = isset($categoryid) ? qa_lang_sub($catkey, $categories[$categoryid]['title']) : qa_lang($allkey);
    }
}
//	Connect to database and get the type of feed and category requested (in some cases these are overridden later)
qa_base_db_connect('qa_feed_db_fail_handler');
end($qa_request_lc_parts);
$lastkey = key($qa_request_lc_parts);
if (isset($lastkey)) {
    $suffix = substr($qa_request_lc_parts[$lastkey], -4);
    if ($suffix == '.rss' || $suffix == '.xml') {
        $qa_request_lc_parts[$lastkey] = substr($qa_request_lc_parts[$lastkey], 0, -4);
    }
}
$feedtype = @$qa_request_lc_parts[1];
$feedparams = array_slice($qa_request_lc_parts, 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':
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	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
*/
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
function qa_ajax_asktitle_db_fail_handler()
{
    echo "QA_AJAX_RESPONSE\n0\nA database error occurred.";
    exit;
}
$intitle = qa_post_text('title');
//	Collect the information we need from the database
qa_base_db_connect('qa_ajax_asktitle_db_fail_handler');
$doaskcheck = qa_opt('do_ask_check_qs');
$doexampletags = qa_using_tags() && qa_opt('do_example_tags');
if ($doaskcheck || $doexampletags) {
    $countqs = max($doexampletags ? QA_DB_RETRIEVE_ASK_TAG_QS : 0, $doaskcheck ? qa_opt('page_size_ask_check_qs') : 0);
    $relatedquestions = qa_db_select_with_pending(qa_db_search_posts_selectspec(null, qa_string_to_words($intitle), null, null, null, null, 0, false, $countqs));
}
//	Collect example tags if appropriate
if ($doexampletags) {
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    $tagweight = array();
    foreach ($relatedquestions as $question) {
        $tags = qa_tagstring_to_tags($question['tags']);
        foreach ($tags as $tag) {
            @($tagweight[$tag] += exp($question['score']));
        }