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

$sql = "select AES_DECRYPT(fecha_v_en, 'RC#TECH@') as vencimiento, (select sysdate()) as fecha_install from rctech_global.cos_base_empre where based='" . $_GET['database'] . "'";
//$sql= "select AES_DECRYPT(fecha_v_en, 'RC#TECH@') as vencimiento from 1002_tc.cos_base_empre where based='219_superdemo'";

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

$vencimiento = "";

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

    $jsonTempData = array();
    $jsonTempData['vencimiento'] = utf8_encode($r['vencimiento']);
    $jsonTempData['fecha_install'] = utf8_encode($r['fecha_install']);
    $jsonData[] = $jsonTempData;

}

$json->Lic = $jsonData;

print_r(json_encode($json));

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