Ejemplo n.º 1
0
 /**
  * Get an OAuth token from the session
  * If the encrpytion object is set then
  * decrypt the token before returning
  * @return array|bool
  */
 public function get($type)
 {
     if ($type != 'request_token' && $type != 'access_token') {
         throw new \Dropbox\Exception("Expected a type of either 'request_token' or 'access_token', got '{$type}'");
     } else {
         if (isset($_SESSION[$this->namespace][$type])) {
             $token = $_SESSION[$this->namespace][$type];
             if ($this->encrypter instanceof Encrypter) {
                 return $this->encrypter->decrypt($token);
             }
             return $token;
         }
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * Decrypt a token using the Encrypter object and return it
  * If there is no Encrypter object, assume the token was stored
  * serialized and return the unserialized token object
  * @param stdClass $token OAuth token to encrypt
  * @return stdClass|string
  */
 protected function decrypt($token)
 {
     // Decrypt the token if there is an Encrypter instance
     if ($this->encrypter instanceof Encrypter) {
         $token = $this->encrypter->decrypt($token);
     }
     // Return the unserialized token
     return @unserialize($token);
 }
Ejemplo n.º 3
0
 public function getEncryptedObject($inObjectName)
 {
     $object = $this->getObject($inObjectName);
     if ($object === false) {
         return false;
     }
     if (!is_string($object)) {
         return false;
     }
     $encrypter = new Encrypter();
     return unserialize($encrypter->decrypt($object));
 }
Ejemplo n.º 4
0
function insertReservaAfiliado($reserva_id, $total)
{
    if (isset($_COOKIE['afiliado'])) {
        $afiliado_id = urldecode(Encrypter::decrypt($_COOKIE['afiliado'], 'afiliado'));
        if (is_numeric($afiliado_id)) {
            $afiliado = getAfiliado($afiliado_id);
            if ($afiliado) {
                $comision = $afiliado->comisionHotel;
                $comision_importe = $total * ($comision / 100);
                $reserva_afiliado_a = array('comision' => $comision_importe, 'porcentaje' => $comision, 'reservaId' => $reserva_id, 'afiliadoId' => $afiliado_id);
                $reserva_afiliado = DAOFactory::getReservaAfiliadoDAO()->prepare($reserva_afiliado_a);
                $reserva_afiliado_id = DAOFactory::getReservaAfiliadoDAO()->insert($reserva_afiliado);
            }
        }
    }
}
Ejemplo n.º 5
0
 public function validateUser($redirect = true)
 {
     if (isset($_SESSION['usuario'])) {
         return true;
     } else {
         if (isset($_COOKIE[$base_url])) {
             $userId = Encrypter::decrypt($_COOKIE[$base_url], $base_url);
             $user = getUsuario($userId);
             if ($user) {
                 $usuario_core->setUsuario($user);
                 return true;
             }
         }
         if ($redirect) {
             $this->loginRedirect();
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 6
0
 public function read($id)
 {
     if (!is_string($id)) {
         return "";
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return "";
     }
     $id = $database->escapeString($id);
     $this->waitForUnlock($id);
     $rawData = $database->getData("variables", "session", "BINARY id='{$id}'");
     if (!$rawData) {
         return "";
     }
     if (count($rawData) > 1) {
         return "";
     }
     $encrypter = new Encrypter($this->key);
     return $encrypter->decrypt($rawData[0]['variables']);
 }
Ejemplo n.º 7
0
function login()
{
    $request = \Slim\Slim::getInstance()->request();
    //json parameters
    $data = json_decode($request->getBody());
    $con = getConnection();
    $pstmt = $con->prepare("SELECT password,idusuario from usuario where username=?");
    $pstmt->execute(array($data->{"USERNAME"}));
    $array = $pstmt->fetch(PDO::FETCH_ASSOC);
    if ($array["password"] != null) {
        $passfeliz = Encrypter::decrypt($array["password"]);
        if ($passfeliz == $data->{"PASSWORD"}) {
            //solucion temporal porque usuario puede tener muchos grupos por usuario
            $pstmt = $con->prepare("SELECT idgrupo from usuarioxgrupo where idusuario=? limit 1");
            $pstmt->execute(array($array["idusuario"]));
            $grupo = $pstmt->fetch(PDO::FETCH_ASSOC);
            echo json_encode(array('respuesta' => 1, 'userid' => $array["idusuario"], 'grupoid' => $grupo["idgrupo"]));
        } else {
            echo json_encode(array('respuesta' => 0));
        }
    } else {
        echo json_encode(array('respuesta' => 0));
    }
}
Ejemplo n.º 8
0
function enviarMensajeGU($username, $password, $CORREO_INSTITUCIONAL, $NOMBRES, $APELLIDOS, $CORREO_ALTERNO)
{
    $PASS = Encrypter::decrypt($password);
    $ESPACIO = ' ';
    $USER = $NOMBRES . $ESPACIO . $APELLIDOS;
    $MENSAJE = 'Estimado ' . $USER . "\r\n" . ' Acaba de ser registrado como un nuevo miembro del Proyecto ProCal-ProSer' . "\r\n" . ' Para poder ingresar al sistema debera hacer uso de los siguientes datos:' . "\r\n" . '  USUARIO:  ' . $username . "\r\n" . '  PASSWORD:  '******'Mail.php';
    $recipients = $CORREO_INSTITUCIONAL;
    $headers['From'] = '*****@*****.**';
    $headers['To'] = $recipients;
    $headers['Subject'] = 'ProCal-ProSer - Registro de Nuevo Miembro';
    $body = $MENSAJE;
    $smtpinfo["host"] = "smtp.gmail.com";
    $smtpinfo["port"] = "587";
    $smtpinfo["auth"] = true;
    $smtpinfo["username"] = "******";
    $smtpinfo["password"] = "******";
    $mail_object =& Mail::factory("smtp", $smtpinfo);
    $mail_object->send($recipients, $headers, $body);
}
Ejemplo n.º 9
0
<?php

if (!$_POST) {
    require_once 'main.html.php';
} else {
    //ENT_QUOTES es una constante. Todas las constantes van en mayusculas.
    //Hay que filtrar siempre todas las entradas de datos para evitar la inyeción de código.
    $text = htmlspecialchars($_POST['text'], ENT_QUOTES, 'UTF-8');
    $action = htmlspecialchars($_POST['action'], ENT_QUOTES, 'UTF-8');
    //Si el texto es cadena vacía o la acción no es code ni decode
    //vuelvo a cargar el formulario.
    if ($text == "" || $action != "code" && $action != "decode") {
        require_once 'main.html.php';
    } else {
        require_once 'libs/encrypter.php';
        //Hacemos referencia o instanciamos a la clase Encrypter de esta manera
        //porque es un metodo estático CLASE::METODO(PARAMETRO)
        if ($action == "code") {
            $resultText = Encrypter::encrypt($text);
        } elseif ($action == "decode") {
            $resultText = Encrypter::decrypt($text);
        }
        require_once 'main.html.php';
    }
}
Ejemplo n.º 10
0
function getClaveByHotel($idHotel)
{
    try {
        $hotel = DAOFactory::getHotelDAO()->load($idHotel);
        /*
                if(!$hotel->clave || !strlen($hotel->clave)) {
                    
                    $h = DAOFactory::getHotelDAO()->prepare(array('clave'=>Encrypter::encrypt(uniqid(), $idHotel)), $idHotel);
                    DAOFactory::getHotelDAO()->update($h);
                    $hotel = DAOFactory::getHotelDAO()->load($idHotel);
                }*/
        return Encrypter::decrypt($hotel->clave, $idHotel);
    } catch (Exception $e) {
        return false;
    }
}
Ejemplo n.º 11
0
 public function cambiarPassword()
 {
     try {
         if (isset($_POST["username"])) {
             $username = $_POST["username"];
         }
         $pass = $_POST["pass"];
         $validaPassActual = $_POST["validaPassActual"];
         $url = "";
         $correcto = false;
         $this->load->model('sesion_model');
         if (isset($_POST["passActual"])) {
             $passActual = $_POST["passActual"];
             if ($validaPassActual == 'true') {
                 session_start();
                 $usuario = $_SESSION["usuario"];
                 if ($this->sesion_model->validarClaveActual($usuario, md5($passActual))) {
                     if ($this->sesion_model->cambiarPassword($usuario, md5($pass))) {
                         $url = "login";
                         $correcto = true;
                         $mensaje = "La contraseña fué cambiada. Ahora deberá iniciar sesión con su nueva contraseña.";
                         session_destroy();
                     } else {
                         $mensaje = "No se pudo cambiar la contraseña.";
                     }
                 } else {
                     $mensaje = "Contraseña inválida, vuelva a intentar.";
                 }
             }
         } else {
             if (isset($username)) {
                 $mensaje = "";
                 $userDesencriptado = Encrypter::decrypt($username);
                 if ($this->sesion_model->cambiarPassword($userDesencriptado, md5($pass))) {
                     $url = "login";
                     $correcto = true;
                     $mensaje = "La contraseña fué cambiada. Ahora debe iniciar sesión con su nueva contraseña.";
                 } else {
                     $mensaje = "No se pudo cambiar la contraseña...";
                 }
             } else {
                 $mensaje = "Error al cambiar la contraseña. No fué posible obtener el nombre de usuario";
             }
         }
     } catch (Exception $e) {
         $mensaje = 'Ocurrio un error su contraseña no fué cambiada.';
     }
     $obj = (object) array('Correcto' => $correcto, 'Url' => $url, 'Mensaje' => $mensaje);
     echo json_encode($obj);
 }
Ejemplo n.º 12
0
 private function GetConnectionFile($DataBaseName)
 {
     $RoutFile = filter_input(INPUT_SERVER, "DOCUMENT_ROOT");
     /* /var/services/web */
     $RoutFile .= "/Config/{$DataBaseName}/BD.ini";
     if (!file_exists($RoutFile)) {
         echo "<p>No existe el archivo de Conexión {$DataBaseName}</p>";
         return 0;
     }
     $Conexion = parse_ini_file($RoutFile, true);
     $User_ = $Conexion['User'];
     $Password_ = $Conexion['Password'];
     $Port_ = $Conexion['Port'];
     $Host_ = $Conexion['Host'];
     $Schema_ = $Conexion['Schema'];
     $User = Encrypter::decrypt($User_);
     $Password = Encrypter::decrypt($Password_);
     $Port = Encrypter::decrypt($Port_);
     $Host = Encrypter::decrypt($Host_);
     $Schema = Encrypter::decrypt($Schema_);
     return array("Host" => $Host, "Port" => $Port, "User" => $User, "Password" => $Password, "Schema" => $Schema);
 }
Ejemplo n.º 13
0
 /**
  * Seleccionar el producto.
  * 
  * @param int $idproducto = id producto.
  * @return Array atributos del producto.
  */
 public function cargarProducto($idproducto)
 {
     $idproducto = Encrypter::decrypt($idproducto);
     $query = 'SELECT nombreprod, precioprod, medidas, descripcionprod, rutaimagen, categoria_idcategoria FROM producto ' . "WHERE idproducto = '{$idproducto}'";
     $result = $this->connection->query($query);
     $this->logger->getLogger($query);
     switch ($result[0]["categoria_idcategoria"]) {
         case 1:
             $result[0]["categoria_idcategoria"] = "Arrimo";
             break;
         case 2:
             $result[0]["categoria_idcategoria"] = "Juego de terraza";
             break;
         case 3:
             $result[0]["categoria_idcategoria"] = "Mesa centro";
             break;
         case 4:
             $result[0]["categoria_idcategoria"] = "Mesa lateral";
             break;
         case 5:
             $result[0]["categoria_idcategoria"] = "Sillón";
             break;
         case 6:
             $result[0]["categoria_idcategoria"] = "Sitial";
             break;
         case 7:
             $result[0]["categoria_idcategoria"] = "Sofá";
             break;
         case 8:
             $result[0]["categoria_idcategoria"] = "Juego comedor";
             break;
         case 9:
             $result[0]["categoria_idcategoria"] = "Mesa piedra pizarra";
             break;
         case 10:
             $result[0]["categoria_idcategoria"] = "Mesa vidrio";
             break;
         case 11:
             $result[0]["categoria_idcategoria"] = "Piso";
             break;
         case 12:
             $result[0]["categoria_idcategoria"] = "Silla";
             break;
         case 13:
             $result[0]["categoria_idcategoria"] = "Banqueta";
             break;
         case 14:
             $result[0]["categoria_idcategoria"] = "Brasero";
             break;
         case 15:
             $result[0]["categoria_idcategoria"] = "Escaño";
             break;
         case 16:
             $result[0]["categoria_idcategoria"] = "Reposera";
             break;
         case 17:
             $result[0]["categoria_idcategoria"] = "Toldos";
             break;
         case 18:
             $result[0]["categoria_idcategoria"] = "Cojín";
             break;
             //default: { $dirCat = arrimos; break; }
     }
     return $result;
 }
Ejemplo n.º 14
0
<?php

include_once __DIR__ . '/app/util/Encrypter.php';
$text = "kim funciona!!! pd. Puedes ir por jawitas";
echo $text . "<br>";
$texto_encriptado = Encrypter::encrypt($text);
echo $texto_encriptado . "<br>";
$texto_desencriptado = Encrypter::decrypt($texto_encriptado);
echo $texto_desencriptado;
Ejemplo n.º 15
0
<?php

class Encrypter
{
    private static $Key = "grupospira";
    public static function encrypt($input)
    {
        $output = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(Encrypter::$Key), $input, MCRYPT_MODE_CBC, md5(md5(Encrypter::$Key))));
        return $output;
    }
    public static function decrypt($input)
    {
        $output = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5(Encrypter::$Key), base64_decode($input), MCRYPT_MODE_CBC, md5(md5(Encrypter::$Key))), "");
        return $output;
    }
}
$texto = "A.123456";
// Encriptamos el texto
$texto_encriptado = Encrypter::encrypt($texto);
echo $texto_encriptado;
// Desencriptamos el texto
$texto_original = Encrypter::decrypt($texto_encriptado);
echo $texto_original;
if ($texto == $texto_original) {
    echo '</br>';
    echo 'Encriptación / Desencriptación realizada correctamente.';
    echo '</br>';
    echo sha1('1');
}
Ejemplo n.º 16
0
<?php

include_once __DIR__ . '/Middleware.php';
$url = array_slice(preg_split('/\\//', $_GET["_url"]), 1);
$parametros = array_slice($url, 3);
$middleware = new Middleware($url[0], $url[1], $url[2]);
//echo $middleware->send();
//print_r($parametros);
include_once __DIR__ . '/util/Encrypter.php';
echo Encrypter::decrypt($middleware->send($parametros));
Ejemplo n.º 17
0
function getReservaByLocalizador($localizador, $withCardData = false)
{
    try {
        $reservas = DAOFactory::getReservaDAO()->queryByLocalizador($localizador);
        if (!$reservas || !count($reservas)) {
            return false;
        }
        $reserva = $reservas[count($reservas) - 1];
        $idReserva = $reserva->id;
        $reserva->productos = DAOFactory::getReservaProductoDAO()->queryByReservaId($idReserva);
        $reserva->usuario = getUsuario($reserva->usuarioId);
        $reserva->pagos = DAOFactory::getReservaPagoDAO()->queryByReservaId($idReserva);
        if ($reserva->pagos) {
            $clave = getClaveByHotel($reserva->hotelId);
            foreach ($reserva->pagos as $pago) {
                if ($pago->formaPago == 'tarjeta') {
                    if (!$withCardData) {
                        $pago->tarjetaNumero = false;
                        $reserva->cardData = true;
                    } else {
                        if ($pago->tarjetaNumero && strlen(trim($pago->tarjetaNumero))) {
                            $pago->tarjetaNumero = Encrypter::decrypt($pago->tarjetaNumero, $clave);
                        }
                    }
                    if (!$withCardData) {
                        $pago->cvv = false;
                    } else {
                        if ($pago->cvv && strlen(trim($pago->cvv))) {
                            $pago->cvv = Encrypter::decrypt($pago->cvv, $clave);
                        }
                    }
                }
            }
        }
        $reserva->alojamiento = array();
        $reserva->extras = array();
        foreach ($reserva->productos as $kp => $p) {
            if (strcmp($p->tipo, 'apartamento') == 0) {
                $p->noches = ceil((strtotime($p->final) - strtotime($p->inicio)) / (24 * 60 * 60));
                if (strpos($p->nombre, '(')) {
                    $n = explode('(', $p->nombre);
                    $pax = trim($n[count($n) - 1]);
                    $reserva->productos[$kp]->pax = substr($pax, 0, strlen($pax) - 1);
                }
                array_push($reserva->alojamiento, $p);
            } else {
                if ($p->eventoTpv && strlen($p->eventoTpv)) {
                    $p->eventoTpv = json_decode($p->eventoTpv);
                }
                if ($p->entradas) {
                    $p->entradasList = json_decode($p->entradas);
                    $cant = 0;
                    foreach ($p->entradasList as $entrada) {
                        $cant += $entrada->entradas;
                    }
                    $p->tickets = $cant;
                }
                array_push($reserva->extras, $p);
            }
        }
        if ($reserva->monedaId) {
            $reserva->moneda = DAOFactory::getMonedaDAO()->load($reserva->monedaId);
        }
        if ($reserva->idiomaId) {
            $reserva->idioma = DAOFactory::getIdiomaDAO()->load($reserva->idiomaId);
        }
        if ($reserva->cartId) {
            $reserva->cart = DAOFactory::getShoppingCartDAO()->load($reserva->cartId);
            $reserva->cart->apto = json_decode($reserva->cart->apartamento);
        }
        return $reserva;
    } catch (Exception $e) {
        return false;
    }
}
Ejemplo n.º 18
0
 public function sendMail()
 {
     $siteEmail = SITE_EMAIL;
     $variableEngine = VariableEngine::getInstance();
     $smtpServer = $variableEngine->getVariable('smtpServer');
     if ($smtpServer === false) {
         return false;
     }
     $smtpPort = $variableEngine->getVariable('smtpPort');
     if ($smtpPort === false) {
         return false;
     }
     $smtpUserName = $variableEngine->getVariable('smtpUserName');
     if ($smtpUserName === false) {
         return false;
     }
     $smtpPassword = $variableEngine->getVariable('smtpPassword');
     if ($smtpPassword === false) {
         return false;
     }
     $smtpUseEncryption = $variableEngine->getVariable('smtpUseEncryption');
     if ($smtpUseEncryption === false) {
         return false;
     }
     $smtpUseEncryption = $smtpUseEncryption->getValue();
     if ($smtpUseEncryption === 'false') {
         $encryption = "";
     } else {
         $encryption = "tls";
     }
     $toSend = new PHPMailer();
     $toSend->isSMTP();
     $toSend->Host = $smtpServer->getValue();
     $toSend->SMTPAuth = true;
     $toSend->Username = $smtpUserName->getValue();
     $enc = new Encrypter();
     $toSend->Password = $enc->decrypt($smtpPassword->getValue());
     $toSend->SMTPSecure = $encryption;
     $toSend->Port = intval($smtpPort->getValue());
     $toSend->From = $siteEmail;
     $toSend->FromName = $this->senderName;
     $toSend->addReplyTo($this->senderEmail, $this->senderName);
     $toSend->isHTML(true);
     $toSend->Subject = $this->subject;
     if ($this->isBulkMail) {
         foreach ($this->recipients as $recipient) {
             $toSend->addBCC($recipient);
         }
         $toSend->Body = $this->body;
         $toSend->AltBody = strip_tags($this->body);
         if (!$toSend->send()) {
             $this->errors[] = $toSend->ErrorInfo;
             return false;
         }
         return true;
     }
     $sent = true;
     foreach ($this->recipients as $recipient) {
         $body = $this->doReplacement($recipient);
         $altBody = strip_tags($body);
         $toSend->clearAddresses();
         $toSend->addAddress($recipient);
         $toSend->Body = $body;
         $toSend->AltBody = $altBody;
         if (!$toSend->send()) {
             $this->errors = $toSend->ErrorInfo;
             $sent = false;
         }
     }
     return $sent;
 }
Ejemplo n.º 19
0
//    echo "<p>inválido</p>";
//
//$xml = simplexml_load_file($ScriptsPath.'/_root/cfdia0000000008.xml');
//
//
//$array = $read->detalle("$ScriptsPath/_root/", "cfdia0000000008.xml");
////var_dump($array);
//$Full = '';
//$full = GetNodes($array, $Full);
//
//echo $full;
//
//function GetNodes($array,$Full)
//{
//    foreach ($array as  $value)
//    {
//
//        if(is_array($value))
//        {
//            $Full = GetNodes($value,$Full);
//        }
//        else
//            $Full.=$value.", ";
//    }
//
//    return $Full;
//}
require_once 'php/Encrypter.php';
echo $Salida = Encrypter::encrypt('20');
echo "<br><br>" . Encrypter::decrypt("gRUIZG3qpPuPRxoyjsOBvHb02WiJTuM4sXDcVuzfl9I=");
Ejemplo n.º 20
0
     //$end_url .= '/l:' . $_REQUEST['l'];
 } elseif (isset($_SESSION['lang'])) {
     $smarty->assign('lang', $_SESSION['lang']);
     $lang_set = $_SESSION['lang'];
 } else {
     $lang_set = 'en';
     if ($hotel->idiomaId) {
         $lang_set = getIdioma($hotel->idiomaId)->codigo;
     }
     $smarty->assign('lang', $lang_set);
     $_SESSION['lang'] = $lang_set;
 }
 $smarty->configLoad($lang_set . '.conf');
 setlocale(LC_ALL, Core_Util_General::getLocaleName($lang_set));
 if ($_REQUEST['a']) {
     $afiliado_id = urldecode(Encrypter::decrypt($_REQUEST['a'], 'afiliado'));
     if (is_numeric($afiliado_id)) {
         $month = 2592000 + time();
         setcookie('afiliado', $_REQUEST['a'], $month, "/", "." . $smarty->getConfigVariable('sistema_nombre_web'));
     }
 }
 /*
     if(isset($_REQUEST['m'])) {
         $smarty->assign('money', $_REQUEST['m']);
         $end_url .= '/m:' . $_REQUEST['m'];
         $smarty->assign('currency', getMonedaByCodigo($_REQUEST['m'])->simbolo);
         $money = $_REQUEST['m'];
     } else {
         $smarty->assign('money', 'EUR');
         $smarty->assign('currency', getMonedaByCodigo('EUR')->simbolo);
     }*/