<?php
 include_once "seleccion.php";
 include_once "clave.php";
 
 
$data2 = array();
$fraccionamiento=$_GET['fracc'];	
$cluster=$_GET['cluster'];
$idusercaf= $_GET['iduser'];


$wk=mysqli_query($connectionex, "SELECT  `AUTD`,`DBD`, `USUARIOBD`, `PASSBD`, `IPBD`, `USERADM`, `CLAVEADM`, `CORREONOT`, `URLAP` FROM `datestables` where `PINCODE`='$fraccionamiento'");
if (mysqli_num_rows($wk) > 0) {
   $userData = $wk->fetch_assoc();
   $usernamebd2=$userData['USUARIOBD'];
   $correoadmo=$userData['USERADM'];
   $claveadmo=$userData['CLAVEADM'];
   $correonot=$userData['CORREONOT'];
   $bdname2=$userData['DBD'];
   $server2=$userData['IPBD'];
   //$server2 = "138.128.165.82";
   $passwordbd=$userData['PASSBD'];
   $passwordbd2=decrypt($passwordbd,$bdname2);

  $conn = new mysqli($server2,$usernamebd2,$passwordbd2,$bdname2);
  $conn->set_charset("utf8");

 $q=mysqli_query($connectionex, "select `id`, `status`,`tipousuario` from `guardias-user` where `id`='$idusercaf'");
if (mysqli_num_rows($q) > 0) {
   $userData = $q->fetch_assoc();
     if ($userData['status'] != '1'){
		$data2['status'] = 'desactivado';
		$data2['result'] = '';
		}
		     else {
		$data2['status'] = 'ok';
		$data2['result'] = '';
		$data2['tipouser']=$userData['tipousuario'];
		}
}

else {
        $data2['status'] = 'error1';
        $data2['result'] = '';
    }
}
else {
        $data2['status'] = 'error2';
        $data2['result'] = '';
    }
    
    return $data2;

?>