Beispiel #1
0
function getUserObjs($appID, $data, $iv)
{
    $json = json_decode(decrypt_data($appID, $data, $iv));
    $userID = $json->idusuario;
    $response["status"] = 1;
    $dbh = getConnection();
    foreach ($patrimonio as $data) {
        $objType = $data[0];
        $possui = $data[1];
        $table = "obj{$objType}";
        $sql = "select {$table}.* from {$table} left join {$possui} on\n\t\t\t\t\t\tfk_idUser = :userID where fk_id{$objType} = id{$objType}";
        $stmt = $dbh->prepare($sql);
        $stmt->bindParam(":userID", $userID);
        $stmt->execute();
        $tmp = $stmt->fetchAll(PDO::FETCH_CLASS);
        $objType = strtolower($objType);
        $response[$objType . "s"] = storeElements($objType, $tmp);
        if ($response[$objType . "s"]) {
            $response["status"] = 1;
        }
    }
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
    return;
}
Beispiel #2
0
function getFriendsRequest($appID, $data, $iv)
{
    global $friendTable;
    $json = json_decode(decrypt_data($appID, $data, $iv));
    $id1 = $json->idusuario_a;
    $response["status"] = 0;
    $dbh = getConnection();
    $sql = "SELECT idusuario, nome, email, addressLat, addressLong, imagePath\n\t\t\t\tfrom usuario, (SELECT idusuario_b AS friend FROM {$friendTable}\n\t\t\t\t\tWHERE idusuario_a = :id1 and status = 0 UNION SELECT\n\t\t\t\t\t\tidusuario_a AS friend FROM {$friendTable} WHERE\n\t\t\t\t\t\t\tidusuario_b = :id1 and status = 0) as tmp WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\tidusuario = tmp.friend";
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(":id1", $id1);
    $stmt->execute();
    /* get user information as a associative array */
    $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $response["users"] = storeElements("user", $tmp);
    if ($response["users"]) {
        $response["status"] = 1;
    }
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
}
Beispiel #3
0
function getObjFilmInfo($appID, $data, $iv)
{
    global $filmTable;
    $json = json_decode(decrypt_data($appID, $data, $iv));
    $id = $json->idFilme;
    $response["status"] = 0;
    $dbh = getConnection();
    $sql = "select * from {$filmTable} where idFilme = :id";
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(":id", $id);
    $stmt->execute();
    /* get all Film information as a associative array */
    $tmp = $stmt->fetchAll(PDO::FETCH_CLASS);
    $response["filmes"] = storeElements("filme", $tmp);
    if ($response["filmes"]) {
        $response["status"] = 1;
    }
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
    return;
}
Beispiel #4
0
function getSimilarObjGames($appID, $data, $iv)
{
    global $gameTable;
    $json = json_decode(decrypt_data($appID, $data, $iv));
    $titulo = $json->titulo;
    $response["status"] = 0;
    $dbh = getConnection();
    $sql = "select * from {$gameTable} where titulo like '%{$titulo}%'";
    $stmt = $dbh->prepare($sql);
    $stmt->execute();
    /* get user information as a associative array */
    $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $response["jogos"] = storeElements("jogo", $tmp);
    if ($response["jogos"]) {
        $response["status"] = 1;
    }
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
    return;
}
Beispiel #5
0
function getEmpRequestDeMim($appID, $data, $iv)
{
    global $loanTable;
    $json = json_decode(decrypt_data($appID, $data, $iv));
    $id = $json->idusuario;
    $response["status"] = 1;
    $dbh = getConnection();
    $sql = "select * from {$loanTable} where fk_idUser2 = :id and status = 0";
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(":id", $id);
    $stmt->execute();
    /* get laon information as a associative array */
    $tmp = $stmt->fetchAll(PDO::FETCH_CLASS);
    $response["emprestimos"] = storeElements("emprestimo", $tmp);
    if ($response["emprestimos"]) {
        $response["status"] = 1;
    }
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
    return;
}
Beispiel #6
0
function getAllUsersByName($appID, $data, $iv)
{
    global $userTable;
    $json = json_decode(decrypt_data($appID, $data, $iv));
    $response["status"] = 0;
    $name = $json->nome;
    $dbh = getConnection();
    $sql = "select idusuario, nome, email, addressLat, addressLong, imagePath\n\t\t\t\t\t\t\t\t\t\tfrom {$userTable} where nome like '%{$name}%'";
    $stmt = $dbh->prepare($sql);
    $stmt->execute();
    /* get user information as a associative array */
    $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $response["users"] = storeElements("user", $tmp);
    if ($response["users"]) {
        $response["status"] = 1;
    }
    closeConnection($dbh);
    $json = json_encode($response);
    $data = encrypt_data($appID, $json);
    echo json_encode($data);
    return;
}