public function forgetpassAction() { $email = addslashes(trim($this->params()->fromPost('email'))); $check = $this->getAcountTable()->checkacount($email); if ($check) { echo 'Tento e-mail není registrován'; die; } else { $Uty = new Utility(); $pass = $Uty->rand_string(8); $endpass = substr(base64_encode(md5($pass)), 0, -1); $data = array('password' => $endpass); $obj = new Customer(); $obj->exchangeArray($data); $this->getAcountTable()->updatepass($email, $obj); $message = array(); $message[] = ""; $message[] = "------ Zapomenuté hesloz Rohlik.tk -------"; $message[] = "Mật khảu hiện tại của bạn là :" . $pass; $message[] = ""; $message[] = "Hãy đăng nhập và thay đổi mật khẩu."; $message[] = ""; $message[] = "---------------------------------"; $textPart = new \Zend\Mime\Part(implode("\r\n", $message)); $textPart->type = "text/plain"; $body = new \Zend\Mime\Message(); $body->setParts(array($textPart)); $sendmail = new Message(); $sendmail->setTo($email); $sendmail->setFrom("*****@*****.**"); $sendmail->setEncoding("UTF-8"); $sendmail->setSubject("Thông tin tài khoản quản Shop."); $sendmail->setBody($body); $transport = new SmtpTransport(); $option = new SmtpOptions(array('name' => 'localhost', 'host' => '212.129.40.198', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => '+1*KR!y@-mn}'), 'port' => 25)); $transport->setOptions($option); $transport->send($sendmail); echo ''; die; } }
public function forgotpassAction() { $this->layout('layout/lazadatheme'); $this->productcart(); if ($this->request->isPost()) { $email = addslashes(trim($this->params()->fromPost('email'))); $check = $this->getAcountTable()->checkacount($email); if ($check) { $error = '<div class="alert alert-warning" role="alert">Email này không tồn tại</div>'; return array('error' => $error); } else { $Uty = new Utility(); $pass = $Uty->rand_string(8); $endpass = substr(base64_encode(md5($pass)), 0, -1); $data = array('password' => $endpass); $obj = new Customer(); $obj->exchangeArray($data); $this->getAcountTable()->updatepass($email, $obj); $message = array(); $message[] = ""; $message[] = "------ Yêu Cầu Thay Đổi Mật Khẩu -------"; $message[] = "Mật khảu hiện tại của bạn là : " . $pass; $message[] = ""; $message[] = "Hãy đăng nhập và thay đổi mật khẩu."; $message[] = ""; $message[] = "---------------------------------"; $textPart = new \Zend\Mime\Part(implode("\r\n", $message)); $textPart->type = "text/plain"; $body = new \Zend\Mime\Message(); $body->setParts(array($textPart)); $sendmail = new Message(); $sendmail->setTo($email); $sendmail->setFrom("*****@*****.**"); $sendmail->setEncoding("UTF-8"); $sendmail->setSubject("Yêu Cầu Thay Đổi Mật Khẩu."); $sendmail->setBody($body); $transport = new SmtpTransport(); $option = new SmtpOptions(array('name' => 'localhost', 'host' => '212.129.40.198', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => '+1*KR!y@-mn}'), 'port' => 25)); $transport->setOptions($option); $transport->send($sendmail); $error = '<div class="alert alert-success" role="alert">Một mật khẩu mới đã được gửi đén Email của bạn.</div>'; return array('error' => $error); } } }