示例#1
0
function qa_initialize_constants_2()
{
    //	Default values if not set in qa-config.php
    @define('QA_COOKIE_DOMAIN', '');
    @define('QA_HTML_COMPRESSION', true);
    @define('QA_MAX_LIMIT_START', 19999);
    @define('QA_IGNORED_WORDS_FREQ', 10000);
    @define('QA_ALLOW_UNINDEXED_QUERIES', false);
    @define('QA_OPTIMIZE_LOCAL_DB', false);
    @define('QA_OPTIMIZE_DISTANT_DB', false);
    @define('QA_PERSISTENT_CONN_DB', false);
    @define('QA_DEBUG_PERFORMANCE', false);
    //	Start performance monitoring
    if (QA_DEBUG_PERFORMANCE) {
        require_once 'qa-util-debug.php';
        qa_usage_init();
    }
    //	More for WordPress integration
    if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) {
        define('QA_FINAL_MYSQL_HOSTNAME', DB_HOST);
        define('QA_FINAL_MYSQL_USERNAME', DB_USER);
        define('QA_FINAL_MYSQL_PASSWORD', DB_PASSWORD);
        define('QA_FINAL_MYSQL_DATABASE', DB_NAME);
        define('QA_FINAL_EXTERNAL_USERS', true);
        // Undo WordPress's addition of magic quotes to various things (leave $_COOKIE as is since WP code might need that)
        function qa_undo_wordpress_quoting($param, $isget)
        {
            if (is_array($param)) {
                //
                foreach ($param as $key => $value) {
                    $param[$key] = qa_undo_wordpress_quoting($value, $isget);
                }
            } else {
                $param = stripslashes($param);
                if ($isget) {
                    $param = strtr($param, array('\\\'' => '\'', '\\"' => '"'));
                }
                // also compensate for WordPress's .htaccess file
            }
            return $param;
        }
        $_GET = qa_undo_wordpress_quoting($_GET, true);
        $_POST = qa_undo_wordpress_quoting($_POST, false);
        $_SERVER['PHP_SELF'] = stripslashes($_SERVER['PHP_SELF']);
    } else {
        define('QA_FINAL_MYSQL_HOSTNAME', QA_MYSQL_HOSTNAME);
        define('QA_FINAL_MYSQL_USERNAME', QA_MYSQL_USERNAME);
        define('QA_FINAL_MYSQL_PASSWORD', QA_MYSQL_PASSWORD);
        define('QA_FINAL_MYSQL_DATABASE', QA_MYSQL_DATABASE);
        define('QA_FINAL_EXTERNAL_USERS', QA_EXTERNAL_USERS);
    }
    //	Possible URL schemes for Q2A and the string used for url scheme testing
    define('QA_URL_FORMAT_INDEX', 0);
    // http://...../index.php/123/why-is-the-sky-blue
    define('QA_URL_FORMAT_NEAT', 1);
    // http://...../123/why-is-the-sky-blue [requires .htaccess]
    define('QA_URL_FORMAT_PARAM', 3);
    // http://...../?qa=123/why-is-the-sky-blue
    define('QA_URL_FORMAT_PARAMS', 4);
    // http://...../?qa=123&qa_1=why-is-the-sky-blue
    define('QA_URL_FORMAT_SAFEST', 5);
    // http://...../index.php?qa=123&qa_1=why-is-the-sky-blue
    define('QA_URL_TEST_STRING', '$&-_~#%\\@^*()=!()][`\';:|".{},<>?# π§½Жש');
    // tests escaping, spaces, quote slashing and unicode - but not + and /
}
示例#2
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-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)) {