 <?php

if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day
}

error_reporting(E_ERROR | E_PARSE);

$_SESSION['database'] = $_GET['database'];
//$_SESSION['usuario_id'] = $_GET['usuario_id'];

include 'conn.php';
include 'funciones.php';

$jsonData = array();
$jsonTempData = array();

//$sql= "select * from ".$_GET['database'].".usuarios_acc where um_id in('01QKFSWD', '01EIXCWy', '01KYQBXZ')";

$sql = "select * from " . $_GET['database'] . ".usuarios_acc where um_id in('01QKFSWD', '01EIXCWy', '01KYQBXZ') and up_id in (129,132,133,136,139,142,143,144,147,148,149,150,151,336,157,159,160,161,166,167,176,337,401,299,472,146,171)";

$qur = $connection->query($sql);

if ($_SESSION['codigo'] == "99") {

    $json->datos = "false";

} else {
    $json->datos = "true";

    while ($r = mysqli_fetch_assoc($qur)) {

        $jsonTempData = array();
        $jsonTempData['autoin'] = $r['autoin'];
        $jsonTempData['u_id'] = $r['u_id'];
        $jsonTempData['up_id'] = $r['up_id'];
        $jsonTempData['um_id'] = $r['um_id'];

        $jsonData[] = $jsonTempData;
    }
    $json->usuarios_acc = $jsonData;
}

//print_r(json_encode($sql));

print_r(json_encode($json));

$qur=null;
@mysqli_close($connection);
?>
