Example #1
0
*   Corsstabs server side DB requests
*
* @author      Artem Osmakov   <*****@*****.**>
* @copyright   (C) 2005-2016 University of Sydney
* @link        http://HeuristNetwork.org
* @version     3.1.0
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @package     Heurist academic knowledge management system
*/
require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php';
require_once dirname(__FILE__) . '/../../common/php/dbMySqlWrappers.php';
require_once dirname(__FILE__) . '/../../search/parseQueryToSQL.php';
$mysqli = mysqli_connection_overwrite("hdb_" . @$_REQUEST['db']);
$params = $_REQUEST;
if (@$_REQUEST['a'] == 'minmax') {
    $response = recordSearchMinMax($mysqli, $params);
} else {
    if (@$_REQUEST['a'] == 'pointers') {
        $response = recordSearchDistictPointers($mysqli, $params);
    } else {
        if (@$_REQUEST['a'] == 'crosstab') {
            $response = getCrossTab($mysqli, $params);
        } else {
            $response = array("status" => "INVALID REQUEST");
        }
    }
}
header('Content-type: text/javascript');
print json_encode($response);
exit;
/**
Example #2
0
//these are internal parameters, they cannot be sent from client side
if (@$_REQUEST['sql']) {
    unset($_REQUEST['sql']);
}
if (@$_REQUEST['parentquery']) {
    unset($_REQUEST['parentquery']);
}
//if( @$_REQUEST['needall'] ) unset ($_REQUEST['needall'] );
$response = array();
$system = new System();
if (!$system->init(@$_REQUEST['db'])) {
    //get error and response
    $response = $system->getError();
} else {
    if (@$_REQUEST['a'] == 'minmax') {
        $response = recordSearchMinMax($system, $_REQUEST);
    } else {
        if (@$_REQUEST['a'] == 'getfacets') {
            //returns
            $response = recordSearchFacets($system, $_REQUEST);
        } else {
            if (@$_REQUEST['a'] == 'related') {
                $response = recordSearchRelated($system, $_REQUEST['ids']);
            } else {
                // TODO: temporary (for backward compatibility) should be part of all databases
                // Check whether recLinks (relationships cache) table exists and create if not
                $isok = true;
                $value = mysql__select_value($system->get_mysqli(), "SHOW TABLES LIKE 'recLinks'");
                if ($value == null || $value == "") {
                    include dirname(__FILE__) . '/../dbaccess/utils_db_load_script.php';
                    // used to execute SQL script