Exemple #1
0
<?php

//	Output this header as early as possible
header('Content-Type: text/plain; charset=utf-8');
//	Ensure no PHP errors are shown in the Ajax response
@ini_set('display_errors', 0);
//	Load the Q2A base file which sets up a bunch of crucial functions
require_once '../../qa-include/qa-base.php';
qa_report_process_stage('init_ajax');
//	Get general Ajax parameters from the POST payload, and clear $_GET
qa_set_request(qa_post_text('qa_request'), qa_post_text('qa_root'));
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
$query = $_POST['query'];
//
//
$categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT ^categories.categoryid,^categories.parentid,^categories.tags,^categories.title,^categories.qcount,^categories.position,^categories.backpath,^categories.title, ^categorymetas.content AS meta\n\t\tFROM ^categories\n\t\tLEFT JOIN ^categorymetas\n\t\tON ^categories.categoryid=^categorymetas.categoryid AND ^categorymetas.title='et_category'\n\t\tWHERE ^categories.title like '%" . $query . "%'\n\t\tORDER BY ^categories.qcount DESC\n\t\tLIMIT 10\n\t\t"));
//
//	echo "<pre>";  var_dump( $categories ); echo "</pre>";
//
foreach ($categories as $key => $category) {
    $categories[$key]['id'] = $category['categoryid'];
    $categories[$key]['name'] = $category['title'];
    //$categories[$key]['meta'] = json_decode($categories[$key]['meta'],true);
}
echo json_encode($categories);
 /**
  * Outputs cache to the user
  */
 private function get_cache()
 {
     qa_report_process_stage('init_page');
     qa_db_connect('qa_page_db_fail_handler');
     qa_page_queue_pending();
     qa_load_state();
     qa_check_login_modules();
     if (QA_DEBUG_PERFORMANCE) {
         if (qa_qa_version_below('1.7')) {
             qa_usage_mark('setup');
         } else {
             //global $qa_usage;
             //$qa_usage->mark('setup');
             null;
         }
     }
     qa_check_page_clicks();
     qa_set_form_security_key();
     if (!QA_CACHING_FILE) {
         $contents = $this->get_cache_db();
     } else {
         $contents = $this->get_cache_file();
     }
     $qa_content = array();
     // Dummy contents
     $userid = qa_get_logged_in_userid();
     $questionid = qa_request_part(0);
     $cookieid = qa_cookie_get(true);
     if (is_numeric($questionid)) {
         $question = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         if (is_numeric($questionid) && qa_opt('do_count_q_views') && !preg_match("/^(?:POST|PUT)\$/i", $_SERVER["REQUEST_METHOD"]) && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) {
             $qa_content['inc_views_postid'] = $questionid;
         } else {
             $qa_content['inc_views_postid'] = null;
         }
         qa_do_content_stats($qa_content);
     }
     if (QA_DEBUG_PERFORMANCE) {
         ob_start();
         if (qa_qa_version_below('1.7')) {
             qa_usage_output();
         } else {
             global $qa_usage;
             $qa_usage->output();
         }
         $contents .= ob_get_contents();
         ob_end_clean();
     }
     qa_db_disconnect();
     header('Content-type: ' . strtr('^type/^format; charset=utf-8', array('^type' => 'text', '^format' => $this->get_cache_file_extension())));
     exit($contents);
 }
	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
*/
//	Ensure no PHP errors are shown in the image data
@ini_set('display_errors', 0);
function qa_image_db_fail_handler()
{
    header('HTTP/1.1 500 Internal Server Error');
    qa_exit('error');
}
//	Load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
qa_report_process_stage('init_image');
//	Retrieve the scaled image from the cache if available
require_once QA_INCLUDE_DIR . 'qa-db-cache.php';
qa_db_connect('qa_image_db_fail_handler');
$blobid = qa_get('qa_blobid');
$size = (int) qa_get('qa_size');
$cachetype = 'i_' . $size;
$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';
Exemple #4
0
	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
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
@ini_set('display_errors', 0);
// we don't want to show PHP errors to RSS readers
qa_report_process_stage('init_feed');
require_once QA_INCLUDE_DIR . 'app/options.php';
//	Functions used within this file
function qa_feed_db_fail_handler($type, $errno = null, $error = null, $query = null)
{
    header('HTTP/1.1 500 Internal Server Error');
    echo qa_lang_html('main/general_error');
    qa_exit('error');
}
function qa_feed_not_found()
{
    header('HTTP/1.0 404 Not Found');
    echo qa_lang_html('misc/feed_not_found');
    qa_exit();
}
function qa_feed_load_ifcategory($categoryslugs, $allkey, $catkey, &$title, $questionselectspec1 = null, $questionselectspec2 = null, $questionselectspec3 = null, $questionselectspec4 = null)
Exemple #5
0
function qa_exit($reason = null)
{
    qa_report_process_stage('shutdown', $reason);
    exit;
}
Exemple #6
0
        qa_set_request(implode('/', $requestparts), $relativedepth > 1 ? str_repeat('../', $relativedepth - 1) : './', $urlformat);
    }
    qa_index_set_request();
    //	Branch off to appropriate file for further handling
    $requestlower = strtolower(qa_request());
    if ($requestlower == 'install') {
        require QA_INCLUDE_DIR . 'qa-install.php';
    } elseif ($requestlower == 'url/test/' . QA_URL_TEST_STRING) {
        require QA_INCLUDE_DIR . 'qa-url-test.php';
    } else {
        //	Enable gzip compression for output (needs to come early)
        if (QA_HTML_COMPRESSION) {
            // on by default
            if (substr($requestlower, 0, 6) != 'admin/') {
                // not for admin pages since some of these contain lengthy processes
                if (extension_loaded('zlib') && !headers_sent()) {
                    ob_start('ob_gzhandler');
                }
            }
        }
        if (substr($requestlower, 0, 5) == 'feed/') {
            require QA_INCLUDE_DIR . 'qa-feed.php';
        } else {
            require QA_INCLUDE_DIR . 'qa-page.php';
        }
    }
}
qa_report_process_stage('shutdown');
/*
	Omit PHP closing tag to help avoid accidental output
*/
	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
*/
//	Ensure no PHP errors are shown in the blob response
@ini_set('display_errors', 0);
function qa_blob_db_fail_handler()
{
    header('HTTP/1.1 500 Internal Server Error');
    qa_exit('error');
}
//	Load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
qa_report_process_stage('init_blob');
//	Output the blob in question
require_once QA_INCLUDE_DIR . 'app/blobs.php';
qa_db_connect('qa_blob_db_fail_handler');
$blob = qa_read_blob(qa_get('qa_blobid'));
if (isset($blob)) {
    header('Cache-Control: max-age=2592000, public');
    // allows browsers and proxies to cache the blob
    switch ($blob['format']) {
        case 'jpeg':
        case 'jpg':
            header('Content-Type: image/jpeg');
            break;
        case 'gif':
            header('Content-Type: image/gif');
            break;
Exemple #8
0
/**
 * Disconnect from the Q2A database.
 */
function qa_db_disconnect()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_db_connection;
    if ($qa_db_connection instanceof mysqli) {
        qa_report_process_stage('db_disconnect');
        if (!QA_PERSISTENT_CONN_DB) {
            if (!$qa_db_connection->close()) {
                qa_fatal_error('Database disconnect failed');
            }
        }
        $qa_db_connection = null;
    }
}
	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
*/
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-install.php';
qa_report_process_stage('init_install');
//	Output start of HTML early, so we can see a nicely-formatted list of database queries when upgrading
?>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<style type="text/css">
			body,input {font-size:16px; font-family:Verdana, Arial, Helvetica, sans-serif;}
			body {text-align:center; width:640px; margin:64px auto;}
			table {margin: 16px auto;}
		</style>
	</head>
	<body>
<?php 
//	Define database failure handler for install process, if not defined already (file could be included more than once)
if (!function_exists('qa_install_db_fail_handler')) {