/** * Set an OAuth token in the session by type * If the encryption object is set then * encrypt the token before storing * @return void */ public function set($token, $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 ($this->encrypter instanceof Encrypter) { $token = $this->encrypter->encrypt($token); } $_SESSION[$this->namespace][$type] = $token; } }
/** * Seleccionar los productos de una categoria. * Se utiliza la tabla producto ubicada en la base de datos. * * @param int $idCategoria = id categoria de los productos. * @return Array con los nombres de los productos. */ public function cargarCategoriaProductos($idCategoria) { $query = 'SELECT idproducto, nombreprod, precioprod, medidas, descripcionprod, rutaimagen FROM producto ' . "WHERE categoria_idcategoria = '{$idCategoria}'"; $result = $this->connection->query($query); $this->logger->getLogger($query); for ($i = 0; $i < sizeof($result); $i++) { $result[$i]["idproducto"] = Encrypter::encrypt($result[$i]["idproducto"]); } return $result; }
/** * Use the Encrypter to encrypt a token and return it * If there is not encrypter object, return just the * serialized token object for storage * @param stdClass $token OAuth token to encrypt * @return stdClass|string */ protected function encrypt($token) { // Serialize the token object $token = serialize($token); // Encrypt the token if there is an Encrypter instance if ($this->encrypter instanceof Encrypter) { $token = $this->encrypter->encrypt($token); } // Return the token return $token; }
public function write($sessionID, $data) { if (!is_string($sessionID)) { return false; } if (!is_string($data)) { return false; } $database = Database::getInstance(); if (!$database->isConnected()) { return false; } $encrypter = new Encrypter($this->key); $data = $database->escapeString($encrypter->encrypt($data)); $sessionID = $database->escapeString($sessionID); $time = $database->escapeString(time()); $query = "INSERT INTO session (id, variables, lastAccess, locked) VALUES ('{$sessionID}', '{$data}', '{$time}', 0) ON DUPLICATE KEY UPDATE variables='{$data}', lastAccess='{$time}', locked=0"; $result = $database->makeCustomQuery($query); if ($result == false) { return false; } return true; }
<?php require_once "includes/connection.php"; include "includes/header.php"; include "includes/encriptar.php"; ?> <?php if (isset($_POST["register"])) { if (!empty($_POST['firstname']) && !empty($_POST['lastname']) && !empty($_POST['email']) && !empty($_POST['username']) && !empty($_POST['password'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $username = $_POST['username']; $password = Encrypter::encrypt($_POST['password']); $query = mysql_query("SELECT * FROM cont_user WHERE username='******'"); $numrows = mysql_num_rows($query); if ($numrows == 0) { $sql = "INSERT INTO cont_user\n\t\t\t(username, firstname, lastname, email, password) \n\t\t\tVALUES('" . $username . "','" . $firstname . "','" . $lastname . "','" . $email . "','" . $password . "')"; $result = mysql_query($sql); if ($result) { $message = "Usuario Creado"; } else { $message = "El usuario no fue creado"; } } else { $message = "El usuario ya existe"; } } else { $message = "Es necesario rellenar todos los campos";
function registrarUsuarioGrupo() { $request = \Slim\Slim::getInstance()->request(); //json parameters $data = json_decode($request->getBody()); $con = getConnection(); //DEBO CREAR EL USERNAME Y PASSWORD $correo1 = $data->{"APELLIDOS"}; $USERNAME1 = substr($data->{"NOMBRES"}, 0, 1); $USER = '******'; $extra = explode(" ", $data->{"APELLIDOS"}); $USERNAME2 = $extra[0]; $USERN = $USERNAME1 . $USER . $USERNAME2; $USERNAME = strtolower(str_replace(' ', '', $USERN)); $PASSWORD = Encrypter::encrypt($USERNAME); $pstmt = $con->prepare("INSERT INTO USUARIO (NOMBRES,APELLIDOS,CORREO_INSTITUCIONAL,CORREO_ALTERNO,NUMERO_CELULAR,NUMERO_TEL_ALTERNO,\n\t\t\t\t\t\t\t\t\t\tCUENTA_SKYPE,IDINSTITUCION,IDPERMISO,USERNAME,PASSWORD,ESTADO) \n\t\t\t\t\t\t\tVALUES (?,?,?,?,?,?,?,?,?,?,?,1)"); $pstmt->execute(array($data->{"NOMBRES"}, $data->{"APELLIDOS"}, $data->{"CORREO_INSTITUCIONAL"}, $data->{"CORREO_ALTERNO"}, $data->{"NUMERO_CELULAR"}, $data->{"NUMERO_TEL_ALTERNO"}, $data->{"CUENTA_SKYPE"}, $data->{"IDINSTITUCION"}, $data->{"IDPERMISO"}, $USERNAME, $PASSWORD)); $lastInsertId = $con->lastInsertId(); $uniondepalabras = $data->{"NOMBRES"} . " " . $data->{"APELLIDOS"}; $array = array(array('IDUSUARIO' => $lastInsertId), array('NOMBRESU' => $uniondepalabras), array('APELLIDOS' => $data->{"APELLIDOS"}), array('CORREO_INSTITUCIONAL' => $data->{"CORREO_INSTITUCIONAL"}), array('CORREO_ALTERNO' => $data->{"CORREO_ALTERNO"}), array('NUMERO_CELULAR' => $data->{"NUMERO_CELULAR"}), array('NUMERO_TEL_ALTERNO' => $data->{"NUMERO_TEL_ALTERNO"}), array('CUENTA_SKYPE' => $data->{"CUENTA_SKYPE"}), array('IDINSTITUCION' => $data->{"IDINSTITUCION"}), array('IDPERMISO' => $data->{"IDPERMISO"}), array('USERNAME' => $USERNAME), array('PASSWORD' => $PASSWORD)); $CORREO_INSTITUCIONAL = $data->{"CORREO_INSTITUCIONAL"}; $CORREO_ALTERNO = $data->{"CORREO_ALTERNO"}; $NOMBRES = $data->{"NOMBRES"}; $APELLIDOS = $data->{"APELLIDOS"}; enviarMensajeGU($USERNAME, $PASSWORD, $CORREO_INSTITUCIONAL, $NOMBRES, $APELLIDOS, $CORREO_ALTERNO); echo json_encode($array); }
// echo "Session is set"; // for testing purposes header("Location: intropage.php"); } if (isset($_POST["login"])) { if (!empty($_POST['username']) && !empty($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; $query = mysql_query("SELECT * FROM cont_user WHERE username='******' AND password='******'"); $numrows = mysql_num_rows($query); if ($numrows != 0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; $iduser = $row['id']; } if ($username == $dbusername && Encrypter::encrypt($password) == $dbpassword) { $_SESSION['session_userid'] = $iduser; $_SESSION['session_username'] = $username; /* Redirect browser */ header("Location: menu.php"); } } else { $message = "Nombre de usuario ó contraseña invalida!"; } } else { $message = "Todos los campos son requeridos!"; } } ?>
<?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'; } }
$img1 = $_POST['img1']; $img2 = $_POST['img2']; $img3 = $_POST['img3']; $url = $_POST['url']; $plantilla = $_POST['plantilla']; $pregunta = $_POST['pregunta']; $grupos = $_POST['nrogrupos']; $retro = $_POST['retro']; $resp = $_POST['resp']; $gruposel = $_POST['grupsel']; } $query2 = mysql_query("select id from cont_user where username like '" . $_SESSION["session_username"] . "'"); while ($row = mysql_fetch_assoc($query2)) { $iduser = $row['id']; } $idunico = Encrypter::encrypt($iduser . $titulo . time()); $registroplantilla = "INSERT INTO cont_plantillas (userid, fecha_creacion, plantilla, url, titulo, idunico) \n VALUES ('" . $iduser . "','" . time() . "','" . $plantilla . "','" . $url . "','" . $titulo . "','" . $idunico . "')"; if (mysql_query($registroplantilla) === TRUE) { $ultimoid = mysql_insert_id(); $registropreg = "INSERT INTO cont_preguntas (idplantilla, pregunta) VALUES (" . $ultimoid . ", '" . utf8_encode($pregunta) . "')"; mysql_query($registropreg); $query3 = mysql_query("select id from cont_preguntas where idplantilla like '" . $ultimoid . "'"); if ($row = mysql_fetch_assoc($query3)) { $idpreg = $row['id']; } for ($i = 0; $i < count($grupos); $i++) { $registrogrupos = "INSERT INTO cont_grupos (idpregunta, idplantilla, grupo, retroalimentacion) \n VALUES ('" . $idpreg . "','" . $ultimoid . "','" . utf8_encode($grupos[$i]) . "','" . utf8_encode($retro[$i]) . "')"; mysql_query($registrogrupos); } for ($k = 0; $k < count($resp); $k++) { $query4 = mysql_query("select id from cont_grupos where idplantilla like '" . $ultimoid . "' and grupo like '" . utf8_encode($gruposel[$k]) . "'");
function doConfigureContent() { if (!isset($_SESSION['configureComplete'])) { header('Location: install.php?action=configure'); return; } if (!isset($_POST['siteName'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['siteEmail'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['nonSecureURL'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['secureURL'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['webDirectory'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['timeZone'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['username'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['firstName'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['lastName'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['email'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['password1'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['password2'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if ($_POST['password1'] != $_POST['password2']) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'The inputted passwords for the first account don\'t match.'; header('Location: install.php?action=configure'); return; } if (!isset($_POST['smtpServer'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['smtpPort'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!is_numeric($_POST['smtpPort'])) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'Please enter a valid port for the SMTP Server.'; header('Location: install.php?action=configure'); return; } if (!isset($_POST['smtpUserName'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['smtpPassword1'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if (!isset($_POST['smtpPassword2'])) { unset($_SESSION['configureComplete']); header('Location: install.php?action=configure'); return; } if ($_POST['smtpPassword1'] != $_POST['smtpPassword2']) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'The inputted passwords for the SMTP account don\'t match.'; header('Location: install.php?action=configure'); return; } $siteName = strip_tags(trim($_POST['siteName'])); $siteEmail = strip_tags(trim($_POST['siteEmail'])); $nonSecureURL = strip_tags(trim($_POST['nonSecureURL'])); $secureURL = strip_tags(trim($_POST['secureURL'])); $webDirectory = strip_tags(trim($_POST['webDirectory'])); $timeZone = strip_tags(trim($_POST['timeZone'])); $username = strip_tags(trim($_POST['username'])); $firstName = strip_tags(trim($_POST['firstName'])); $lastName = strip_tags(trim($_POST['lastName'])); $email = strip_tags(trim($_POST['email'])); $password = $_POST['password1']; $smtpServers = strip_tags(trim($_POST['smtpServer'])); $smtpPort = intval($_POST['smtpPort']); $smtpUserName = strip_tags(trim($_POST['smtpUserName'])); $enc = new Encrypter(); $smtpPassword = $enc->encrypt(trim($_POST['smtpPassword1'])); $smtpUseEncryption = isset($_POST['smtpUseEncryption']); $emailValidator = new emailValidator(); if (!$emailValidator->validate($siteEmail)) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'The site email isn\'t a valid email address.'; header('Location: install.php?action=configure'); return; } if (!$emailValidator->validate($email)) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'The email address for the first user isn\'t valid.'; header('Location: install.php?action=configure'); return; } unset($emailValidator); $urlValidator = new urlValidator(); $options = array('noDirectories', 'mightBeIP'); $nonSecureOptions = array_merge($options, array('httpOnly')); $secureOptions = array_merge($options, array('httpsOnly')); if (!$urlValidator->validate($nonSecureURL, $nonSecureOptions)) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'The non-secure URL isn\'t valid. Please try again.'; header('Location: install.php?action=configure'); return; } if (!$urlValidator->validate($secureURL, $secureOptions)) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'The secure URL isn\'t valid. Please try again.'; header('Location: install.php?action=configure'); return; } unset($urlValidator); if ($webDirectory[0] != '/') { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t validate the web directory. Please try again.'; header('Location: install.php?action=configure'); return; } $timeZoneValidator = new phpTimeZoneValidator(); if (!$timeZoneValidator->validate($timeZone)) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t validate the selected time zone. Please try again.'; header('Location: install.php?action=configure'); return; } unset($timeZoneValidator); $password = Hasher::generateHash($password); if ($password == false) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t properly hash your password. Please try again.'; header('Location: install.php?action=configure'); return; } $database = Database::getInstance(); $database->connect(); if (!$database->isConnected()) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t establish a connection to the database. Please try again. If you keep receiving this error, please delete the site/config.xml and start the installer again.'; header('Location: install.php?action=configure'); return; } if ($smtpUseEncryption == 'tls') { $smtpEncryption = 'true'; } else { $smtpEncryption = 'false'; } if ($webDirectory !== "/") { $webDirectory .= '/'; } $variables = array('cleanURLsEnabled' => 'false', 'educaskVersion' => EDUCASK_VERSION, 'guestRoleID' => '1', 'maintenanceMode' => 'false', 'siteEmail' => $siteEmail, 'siteTheme' => 'default', 'siteTimeZone' => $timeZone, 'siteTitle' => $siteName, 'siteWebAddress' => $nonSecureURL, 'siteWebAddressSecure' => $secureURL, 'siteWebDirectory' => $webDirectory, 'smtpServer' => $smtpServers, 'smtpPort' => $smtpPort, 'smtpUserName' => $smtpUserName, 'smtpPassword' => $smtpPassword, 'smtpUseEncryption' => $smtpEncryption, 'lastCronRun' => '2015-01-01 21:15:53', 'cronRunning' => 'false', 'cronFrequency' => '10 minutes', 'minimumPasswordLength' => '5', 'lockoutPeriod' => '10', 'numberOfAttemptsBeforeLockout' => '3', 'maxSessionIdAge' => '600'); foreach ($variables as $name => $value) { $name = $database->escapeString($name); $value = $database->escapeString($value); if (!$database->insertData('variable', 'variableName, variableValue', "'{$name}', '{$value}'")) { $_SESSION['errors'][] = "I wasn't able to insert the variable {$name} with a value of {$value} into the variable table. You may want to manually add this row to the variable table in the database. For help on this, please see <a href=\"https://www.educask.com\" target=\"_blank\">this page</a>."; //@ToDo: make the link point to actual help continue; } } $database->updateTable('variable', 'readOnly=1', "variableName='educaskVersion'"); $sqlScript = EDUCASK_ROOT . '/core/sql/defaultRolesInstallSafe.sql'; if (!is_file($sqlScript)) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t find the SQL script to create the needed roles. Please make sure that ' . $sqlScript . ' exists and is readable by PHP.'; header('Location: install.php?action=configure'); return; } $sql = file_get_contents($sqlScript); if (!$sql) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t read the SQL script in order to create the needed roles. Please make sure PHP can read the file ' . $sqlScript; header('Location: install.php?action=configure'); return; } $sqlStatements = explode(';', $sql); foreach ($sqlStatements as $sqlStatement) { $sqlStatement = trim($sqlStatement); if ($sqlStatement == '') { continue; } $database->makeCustomQuery($sqlStatement); } $username = $database->escapeString($username); $firstName = $database->escapeString($firstName); $lastName = $database->escapeString($lastName); $email = $database->escapeString($email); $password = $database->escapeString($password); $success = $database->insertData('user', 'userID, userName, firstName, lastName, email, password, roleID', "0, 'anonGuest', 'Anonymous', 'Guest', '*****@*****.**', '', 1"); $success = $success && $database->updateTable("user", "userID=0", "userID=1"); $success = $success && $database->insertData('user', 'userID, userName, firstName, lastName, email, password, roleID', "1, '{$username}', '{$firstName}', '{$lastName}', '{$email}', '{$password}', 4"); if (!$success) { unset($_SESSION['configureComplete']); $_SESSION['errors'][] = 'I couldn\'t create the new user account. Please try again. For help on this, please see <a href="https://www.educask.com" target="_blank">this page</a>.'; //@ToDo: make the link point to actual help header('Location: install.php?action=configure'); return; } $database->makeCustomQuery("ALTER TABLE user AUTO_INCREMENT=2"); header('Location: install.php?action=install'); }
public function sendEmailRecuperaPassword() { $mensaje = ""; $correcto = false; try { $email = $_POST["email"]; $this->load->model('sesion_model'); $user = $this->sesion_model->existeEmail($email); if (isset($user)) { $this->load->library("email"); //ejemplo $enlace = $this->config->site_url() . 'RecuperaPass?username='******'protocol' => $this->config->item('protocol_email'), 'smtp_host' => $this->config->item('smtp_host_email'), 'smtp_port' => $this->config->item('smtp_port_email'), 'smtp_user' => $this->config->item('smtp_user_email'), 'smtp_pass' => $this->config->item('smtp_pass_email'), 'mailtype' => $this->config->item('mailtype'), 'charset' => $this->config->item('charset_email'), 'newline' => $this->config->item('newline_email')); $this->email->initialize($config); $this->email->set_newline("\r\n"); $this->email->from('Administrador'); $this->email->to($email); $this->email->subject('Instrucciones de recuperación de contraseña, Convivir'); $this->email->message('<p>Hemos recibido su solicitud de recuperación de contraseña. ' . 'Si hace click en el enlace, le enviaremos a una página en donde ' . 'podrá cambiar o recuperar su contraseña.</p> ' . '<p>Si el enlace no funciona, copie y pegue el enlace en la barra ' . 'de direcciones de su navegador.</p> ' . '<p>Enlace: <a href="' . $enlace . '">' . $enlace . '</a></p><br><br>'); if ($this->email->send()) { $correcto = true; $mensaje = "El correo fué enviado. Favor verifique y siga las instrucciones."; } else { $mensaje = "El correo electrónico no pudo ser enviado, intente más tarde."; //show_error($this->email->print_debugger()); //DEJAR PARA DEBUG EN CASO DE FALLA } } else { $mensaje = "Email no registrado. Favor verifique."; } } catch (Expection $e) { $mensaje = 'Ha ocurrido un error al tratar de enviar el email. Favor intente más tarde.'; } $obj = (object) array('Correcto' => $correcto, 'Mensaje' => $mensaje); echo json_encode($obj); }
private function CreateDataBaseFile($DataBaseName) { $RoutFile = filter_input(INPUT_SERVER, "DOCUMENT_ROOT"); /* /var/services/web */ if (!file_exists("{$RoutFile}/Config/{$DataBaseName}/")) { if (!($mkdir = mkdir("{$RoutFile}/Config/{$DataBaseName}", 0777, true))) { XML::XmlResponse("Error", 0, "<p><b>Error</b> al crear el directorio base de la nueva empresa </p><br>Detalles:<br><br>{$mkdir}"); return 0; } } if (!($File = fopen("{$RoutFile}/Config/{$DataBaseName}/BD.ini", "w"))) { XML::XmlResponse("Error", 0, "<p><b>Error</b> al abrir el archivo config de BD</p>"); return 0; } if (strcasecmp($DataBaseName, "Manager") == 0) { $Password_ = "Admcs1234567"; $DataBaseName = "CSDOCS_CFDI"; $User_ = "Manager"; } else { $Password_ = "12345"; $User_ = $DataBaseName; } $localhost = Encrypter::encrypt("localhost"); $Port = Encrypter::encrypt("3306"); $User = Encrypter::encrypt($User_); $Password = Encrypter::encrypt($Password_); $DataBaseName_ = Encrypter::encrypt($DataBaseName); fwrite($File, 'Host="' . $localhost . '"' . PHP_EOL); fwrite($File, 'Port="' . $Port . '"' . PHP_EOL); fwrite($File, 'User="******"' . PHP_EOL); fwrite($File, 'Password="******"' . PHP_EOL); fwrite($File, 'Schema="' . $DataBaseName_ . '"' . PHP_EOL); fclose($File); return 1; }
public function setEncryptedObject($inObjectName, $inObject, $overwrite = false) { $encrypter = new Encrypter(); $inObject = $encrypter->encrypt(serialize($inObject)); return $this->setObject($inObjectName, $inObject, $overwrite); }
<?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;
<link href="../css/style1.css" rel="stylesheet"> </head> <body> <div class="container" role="main"> <div class="col-md-2"></div> <div class="col-md-8"> <?php $conexion = new mysqli('localhost', 'root', 'root', 'cont_dinamico'); $sql = "SELECT * FROM cont_resetpass WHERE token = '{$token}' "; $resultado = $conexion->query($sql); if ($resultado->num_rows > 0) { $usuario = $resultado->fetch_assoc(); if (sha1($usuario['iduser'] === $idusuario)) { if ($password1 === $password2) { $sql = "UPDATE cont_user SET password = '******' WHERE id = " . $usuario['iduser']; $resultado = $conexion->query($sql); if ($resultado) { $sql = "DELETE FROM cont_resetpass WHERE token = '{$token}';"; $resultado = $conexion->query($sql); ?> <p> La contraseña se actualizó con exito. </p> <?php } else { ?> <p> Ocurrió un error al actualizar la contraseña, intentalo más tarde </p> <?php } } else { ?> <p> Las contraseñas no coinciden </p>
function verificarClaveHotel($idHotel, $clave) { try { $hotel = DAOFactory::getHotelDAO()->load($idHotel); if (!$hotel->clave || !strlen($hotel->clave)) { return false; } $testClave = Encrypter::encrypt($clave, $idHotel); //echo Encrypter::decrypt($hotel->clave, $idHotel); if (strcasecmp($hotel->clave, $testClave) == 0) { return true; } return false; } catch (Exception $e) { return false; } }
function insertHotel($data = array(), $data_direccion = array(), $idiomas = array(), $monedas = array(), $fechas = array(), $condiciones = array(), $dominios = array(), $promociones = array(), $data_blacklist = array(), $precios = array()) { try { $data["tiempoCreacion"] = date("Y-m-d H:i:s"); $transaction = new Transaction(); if ($data['campaniaId']) { $campania = DAOFactory::getCampaniaDAO()->load($data['campaniaId']); $data['dominioCampania'] = $campania->subdominio; } //Activar SEO $data['seo'] = 1; $hotel = DAOFactory::getHotelDAO()->prepare($data); $new_hotel_id = DAOFactory::getHotelDAO()->insert($hotel); if (isset($data['clave'])) { $clave = Encrypter::encrypt($data['clave'], $new_hotel_id); $h = DAOFactory::getHotelDAO()->prepare(array('clave' => $clave), $new_hotel_id); DAOFactory::getHotelDAO()->update($h); } $d = false; foreach ($data_direccion as $dir) { if (!is_null($dir) && strlen(trim($dir)) > 0) { $d = true; break; } } if ($d) { $direccion = DAOFactory::getDireccionDAO()->prepare($data_direccion); $id_direccion = DAOFactory::getDireccionDAO()->insert($direccion); $hotel_direccion = DAOFactory::getHotelDireccionDAO()->prepare(array('hotelId' => $new_hotel_id, 'direccionId' => $id_direccion)); DAOFactory::getHotelDireccionDAO()->insert($hotel_direccion); } if (count($idiomas)) { foreach ($idiomas as $idioma) { $id = DAOFactory::getHotelIdiomaDAO()->prepare(array('hotelId' => $new_hotel_id, 'idiomaId' => $idioma)); DAOFactory::getHotelIdiomaDAO()->insert($id); } } if (count($monedas)) { foreach ($monedas as $moneda) { $mon = DAOFactory::getHotelMonedaDAO()->prepare(array('hotelId' => $new_hotel_id, 'monedaId' => $moneda)); DAOFactory::getHotelMonedaDAO()->insert($mon); } } foreach ($fechas as $fecha) { $fechaHotel = DAOFactory::getHotelFechasDAO()->prepare(array('hotelId' => $new_hotel_id, 'fecha' => $fecha)); $fecha_id = DAOFactory::getHotelFechasDAO()->insert($fechaHotel); } foreach ($condiciones as $cond) { $condicion = DAOFactory::getHotelCondicionDAO()->prepare(array('hotelId' => $new_hotel_id, 'condicionId' => $cond)); DAOFactory::getHotelCondicionDAO()->insert($condicion); } $condiciones_obligatorias = DAOFactory::getCondicionDAO()->queryByCondicionCategoriaId(1); foreach ($condiciones_obligatorias as $cond) { $condicion = DAOFactory::getHotelCondicionDAO()->prepare(array('hotelId' => $new_hotel_id, 'condicionId' => $cond->id)); DAOFactory::getHotelCondicionDAO()->insert($condicion); } foreach ($dominios as $dom) { $dominio = DAOFactory::getHotelDominiosDAO()->prepare(array('hotelId' => $new_hotel_id, 'dominio' => $dom)); DAOFactory::getHotelDominiosDAO()->insert($dominio); } foreach ($promociones as $data_promocion) { $data_promocion['hotelId'] = $new_hotel_id; $promocion = DAOFactory::getPromocionDAO()->prepare($data_promocion); DAOFactory::getPromocionDAO()->insert($promocion); } foreach ($precios as $data_precio) { $data_precio['hotelId'] = $new_hotel_id; $precio = DAOFactory::getHotelPrecioDAO()->prepare($data_precio); DAOFactory::getHotelPrecioDAO()->insert($precio); } //DAOFactory::getBlacklistDAO()->deleteByHotelId($new_hotel_id); if ($data_blacklist) { foreach ($data_blacklist as $dbl) { $dbl['hotelId'] = $new_hotel_id; $blacklist = DAOFactory::getBlacklistDAO()->prepare($dbl); DAOFactory::getBlacklistDAO()->insert($blacklist); } } $transaction->commit(); actualizarSeo($new_hotel_id); return $new_hotel_id; } catch (Exception $e) { var_dump($e); if ($transaction) { $transaction->rollback(); } return false; } }
<?php $action = $_POST['action']; $result = array('msg' => 'error', 'data' => 'Acción no válida'); require 'Logic/widget.php'; require 'Logic/afiliado.php'; if (strcmp($action, 'get') == 0) { if (isset($_POST['configuracion'])) { $configuracion = $_POST['configuracion']; $smarty->assign("configuracion", (object) $configuracion); $afiliado_id = $_POST['afiliado_id']; $afiliado_id_encriptado = urlencode(Encrypter::encrypt($afiliado_id, 'afiliado')); $smarty->assign("code", $afiliado_id_encriptado); $result['msg'] = 'ok'; $enlace = $base_url . '?a=' . $afiliado_id_encriptado; $smarty->assign("enlace", $enlace); if ($_POST['tipo'] == "completo") { $destinos = getAfiliadoDestinos($afiliado_id); $smarty->assign("destinos", $destinos); $widget = $smarty->fetch('admin/widget/widget.tpl'); } else { if ($_POST['tipo'] == "banner") { $rgb = Core_Util_General::hex2rgb($configuracion['backgroundBody']); $images = getAllHotelImages($_POST['hotel']); $smarty->assign('image', array_pop($images)); $hotel_h = getHotelById($_POST['hotel']); $enlace = 'http://' . $hotel_h->dominioCampania . '?a=' . $afiliado_id_encriptado; $smarty->assign("enlace", $enlace); $smarty->assign("hotel_h", $hotel_h); $destino = getDestino($hotel->destinoId); $smarty->assign("destino", $destino);
//else // 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=");
/** * Envia Mensaje mediante el produce * * @return void * @author yourname */ function send($params) { $this->produce($params); include_once __DIR__ . '/util/Encrypter.php'; return Encrypter::encrypt(json_encode($this->result)); }