public function generate($amount, $params = array()) { $this->params = array_merge($this->params, $params); $emailGenerator = new EmailGenerator(); $passwordGenerator = new PasswordGenerator(); $emails = $emailGenerator->generate($amount, $params); $params['unique'] = false; $passwords = $passwordGenerator->generate($amount, $params); for ($i = 0; $i < $amount; $i++) { $password = $passwords[$i]; if ((bool) $this->params['hashed_password']) { // password should be hashed switch ($this->params['hash_function']) { case 'sha1': $password = sha1($password); break; case 'md5': default: $password = md5($password); } } $usercredential = str_replace('{email}', $emails[$i], $this->params['pattern']); $usercredential = str_replace('{password}', $password, $usercredential); $this->fake_data[] = $usercredential; } return $this->fake_data; }
public function controller($id = 0) { $output = null; switch ($_POST['ID']) { case 'login': $_POST['email'] = trim($_POST['email']); $_POST['password'] = trim($_POST['password']); if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { $output = ["STATUS" => "FAIL", "MSG" => "ERROR: Datos incorrectos"]; $output = json_encode($output); } $_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_STRING); $_POST['password'] = filter_var($_POST['password'], FILTER_SANITIZE_STRING); $output = $this->model->login($_POST["email"], $_POST['password']); break; case 'register': if (isset($_POST["g-recaptcha-response"]) && $_POST["g-recaptcha-response"]) { $gRecaptcha = $this->validateGoogleRecaptcha(); if ($gRecaptcha["success"]) { $_POST['email'] = trim($_POST['email']); $_POST['password1'] = trim($_POST['password1']); $_POST['password2'] = trim($_POST['password2']); $_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_STRING); $_POST['password1'] = filter_var($_POST['password1'], FILTER_SANITIZE_STRING); $_POST['password2'] = filter_var($_POST['password2'], FILTER_SANITIZE_STRING); if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL) || $_POST['password1'] !== $_POST['password2']) { $output = ["STATUS" => "FAIL", "MSG" => "ERROR: Datos incorrectos"]; return json_encode($output); } $hashed_password = password_hash($_POST["password1"], PASSWORD_DEFAULT); $data = ["ASP_EMAP" => "'" . $_POST["email"] . "'", "ASP_PASS" => "'" . $hashed_password . "'", "ASP_FCRE" => "now()", "ASP_FMOD" => "now()"]; $query = $this->model->registerCandidate($data, $_POST["email"]); if ($query["S"]) { $id = rand() . "::" . $query["D"][0][1] . "::" . rand(0, 1000) . "JVJP-::" . $query["D"][0][0] . "::" . rand(); $token = hash('sha256', $id); $id = urlencode($id); $linkMail = URL . "Acceso/a/?service=5733a1f6969d01e6fa75f07566574de2324b9cf5&id={$id}&token={$token}&_id=" . rand(); //print_r($linkMail); $sendEmail = EmailGenerator::sendEmail('activate-account', $linkMail, [$_POST["email"]]); if ($sendEmail) { $output = ["STATUS" => "SUCCESS", "MSG" => "<i class=\"material-icons green-text\">done</i> Registro exitoso"]; } else { $output = ["STATUS" => "IMCOMPLETE", "MSG" => "<i class=\"material-icons white-text\">info</i> Usted ha sido registrado"]; } } else { $output = ["STATUS" => "FAIL", "MSG" => "<i class=\"material-icons red-text\">error</i> " . $query["D"]]; } $output = json_encode($output); } } break; case 'restore-password': if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { $output = ["STATUS" => "FAIL", "MSG" => "ERROR: Datos incorrectos"]; return json_encode($output); } $_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_STRING); $query = $this->model->checkCandidate($_POST['email']); if ($query) { //'ASP_ID, ASP_FCRE','SSP_ASPIRANTE' $id = rand() . "trZ::idUx" . rand(0, 100) . "TYGF" . rand(0, 100) . "GdCvBDfg" . rand(0, 10000) . "::" . rand(0, 1000) . "qw" . rand(0, 100) . "XCjs" . rand(0, 100) . "ksl::" . rand(10, 99) . "AwpRY" . $query[0][0] . rand(10, 99) . "HTwIy::" . rand() . "48sdsRTWXCB-idZDs" . rand(); $token = hash('sha256', $id); $id = urlencode($id); $linkMail = URL . "Acceso/a/?service=20649c1f55f26367460960760b689351df031676&id={$id}&token={$token}&_id=" . rand(); $sendEmail = EmailGenerator::sendEmail('restore-password', $linkMail, [$_POST["email"]]); if ($sendEmail) { $output = ["STATUS" => "SUCCESS", "MSG" => "<i class=\"material-icons green-text\">done</i> Se ha enviado un correo electrónico"]; } else { $output = ["STATUS" => "IMCOMPLETE", "MSG" => "<i class=\"material-icons white-text\">info</i> No es posible enviar el email. Por favor, intentalo más tarde..."]; } } else { $output = ["STATUS" => "FAIL", "MSG" => "<i class=\"material-icons\">email</i> Correo electrónico no registrado."]; } $output = json_encode($output); break; default: break; } echo $output; }
<?php ## AUTOGENERATED OPTIONS - DO NOT EDIT $options = array('mode' => 'custom', 'layout' => array('size' => '200', 'sizetype' => 'px', 'type' => 'menu', 'name' => 'col1', 'file' => 'application.modules.dev.menus.GenEmail', 'inlineJS' => 'GenEmail.js', 'title' => 'Email Template', 'icon' => 'fa-envelope-o')); ## END OF AUTOGENERATED OPTIONS return EmailGenerator::listMenuTree();
public function processStateConcurso() { if (isset($_POST['IDCON_']) && $_POST['CONTOKEN'] == $this->tokengenerate($_POST['IDCON_'])) { $data = ["CON_ESTA" => "'P'"]; $CON_ID = $_POST["IDCON_"]; $DATOS = $this->datos_concurso($CON_ID); $nomcon = $DATOS['Concurso']; $EMAIL = $DATOS['fasesConcurso']; $aspirantes = $this->model->getAspirantesbyCONID($CON_ID); $arrayEmail = array(); foreach ($aspirantes as $key => $value) { array_push($arrayEmail, $value[8]); } if (EmailGenerator::sendEmail('aspirante-selected', '', $arrayEmail, ['CON_NOMB' => $nomcon[0][1], 'CON_FINI' => $nomcon[0][10]])) { if ($this->model->update_estadoConcurso($CON_ID, $data)) { header('Location: ' . URL . 'Management/procesos'); } else { $this->index_management(); } } else { echo "no envio mensaje"; } //$this->index_management(); } else { $this->index_management(); } }
private static function configurationTransport() { self::$transport = Swift_SmtpTransport::newInstance()->setHost('smtp.gmail.com')->setPort('587')->setEncryption('tls')->setUsername('*****@*****.**')->setPassword('prueba12345'); self::$mailer = Swift_Mailer::newInstance(self::$transport); }