 <?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'];

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

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

/////////Buscar Idiomas

$montoesql = "select *
        from " . $_GET['database'] . ".idiomas";

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

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

    $json->datos = "false";

} else {
//logs($montoesql);
    $json->datos = "true";

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

        $jsonTempData = array();
        $jsonTempData['idi_id'] = $r['idi_id'];
        $jsonTempData['idi_nombre'] = utf8_encode($r['idi_nombre']);

        $jsonData[] = $jsonTempData;
    }
}

$json->Idiomas = $jsonData;

print_r(json_encode($json));

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