Пример #1
0
function getData($arrQuery)
{
    $retval = array();
    $data = connectMongoDB()->find($arrQuery);
    foreach ($data as $item) {
        $retval[] = $item;
    }
    return $retval;
}
Пример #2
0
function get_session()
{
    //
    $session = array('user' => '', 'begin_time' => 0, 'permissions' => array('admin' => false, 'add' => false, 'update' => false, 'view' => false), 'identification' => array('provider' => ''));
    $auth_conf_file = file_get_contents('./auth_conf.json');
    if ($auth_conf_file) {
        // auth_conf.json file is compulsory, so that a possibly sensitive
        // data won't get open simply by accidentally removing the file.
        $auth_conf = json_decode($auth_conf_file, true);
        if (isset($_GET['auth_t'])) {
            $key = pg_escape_string($_GET['auth_t']);
            // Find the session from the database
            $db_opts = get_db_options();
            $mongodb = connectMongoDB($db_opts['mongo_db_name']);
            $sessions = $mongodb->_sessions;
            $session = $sessions->findOne(array("_id" => $key), array("_id" => false));
        }
        if ($auth_conf['open_data']) {
            // everybody can view open data
            $session['permissions']['view'] = true;
        }
    }
    return $session;
}
Пример #3
0
        $pgcon = connectPostgreSQL($db_opts["sql_db_name"]);
        $fw_core_tbl = $db_opts['fw_core_table_name'];
        $del_stmt = "DELETE FROM {$fw_core_tbl} WHERE uuid='{$uuid}'";
        $del_result = pg_query($del_stmt);
        if (!$del_result) {
            header("HTTP/1.0 500 Internal Server Error");
            $error = pg_last_error();
            die($error);
        }
        $rows_deleted = pg_affected_rows($del_result);
        if ($rows_deleted != 1) {
            header("HTTP/1.0 400 Bad Request");
            die("The specified UUID was not found from the database!");
        }
        $components = get_supported_components();
        $m_db = connectMongoDB($db_opts['mongo_db_name']);
        foreach ($components as $component) {
            if ($component == "fw_core") {
                continue;
            }
            $collection = $m_db->{$component};
            $collection->remove(array("_id" => $uuid));
        }
        header("Access-Control-Allow-Origin: *");
        echo "POI deleted succesfully";
    } else {
        header("HTTP/1.0 400 Bad Request");
        die("'poi_id' parameter must be specified!");
    }
} else {
    if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {