<?php
Class CONDB{
	public $CONEXION;
	
	// var $SERVER = "172.16.10.120";
	var $SERVER = "LocalHost";
	var $USER = "cWpqdw==";
	var $PASSWORD = "MTY3NA==";
	var $BD = "disxii_d";

	public function conectar(){
		$this->CONEXION = mysqli_connect($this->SERVER, $this->EncriptarConexion($this->USER,1), $this->EncriptarConexion($this->PASSWORD,1), $this->BD);
		/* comprobar la conexión */
		if(mysqli_connect_errno()) {
			return false;
		}
		
		mysqli_query ($this->CONEXION, "SET NAMES 'utf8'");
	}
	public function desconectar(){
		mysqli_close($this->CONEXION);
	}
	public function EncriptarConexion($cadena,$tipo=0){
		$salida="";
		if ($tipo===0)
			{
			$cadInv = strrev(str_replace(" ","--SPACE--",$cadena));
			for($i=0; $i < strlen($cadInv); $i++)
				{
				$asc = ord($cadInv[$i]);
				$salida.=utf8_encode(chr((intval($asc) ^ intval(5))));
				}
			$salida = base64_encode($salida);
			}
	   else
		   {
			$cadInv = base64_decode($cadena);
			for($i=0; $i < strlen($cadInv); $i++)
				{
				$asc = ord($cadInv[$i]);
				$salida.=utf8_encode(chr((intval($asc) ^ intval(5))));            
				}
			$salida = str_replace("--SPACE--"," ",strrev($salida));
		   }
	  return $salida;
	}
}



?>