 <?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 diccionario

$montoesql = "select *
        from " . $_GET['database'] . ".diccionario where proyecto = 0 or proyecto = 2";

$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['dic_id'] = $r['dic_id'];
        $jsonTempData['dic_idioma_id'] = $r['dic_idioma_id'];
        $jsonTempData['dic_variable'] = utf8_encode($r['dic_variable']);

        //ojo se comento el utf8 en server nuevo
        $jsonTempData['dic_valor'] = ($r['dic_valor']);

        $jsonData[] = $jsonTempData;
    }
}

$json->Diccionario = $jsonData;

/////////
/////////
/////////
/////////

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