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);
         }
     }
 }
 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 editAction()
 {
     $Uty = new Utility();
     $getuser = $this->forward()->dispatch('Admin\\Controller\\Index', array('action' => 'getuser'));
     if (!$getuser) {
         // not yet login
         $this->redirect()->toRoute('home');
     }
     $this->layout()->getuser = $getuser;
     $this->layout('layout/apotravinyadmin');
     $id = addslashes(trim($this->params()->fromRoute('id', 0)));
     $data_detail = $this->getManufactureTable()->mannu_detail($id);
     if ($this->request->isPost()) {
         $name = addslashes(trim($this->params()->fromPost('name')));
         $status = addslashes(trim($this->params()->fromPost('status')));
         $description = addslashes(trim($this->params()->fromPost('description')));
         $alias = strtolower($Uty->chuyenDoi($name));
         if ($name == null) {
             $alert = '<div class="alert alert-danger" role="alert">Manufacture name not empty.</div>';
             return array('alert' => $alert);
         }
         $dirpath = str_replace("\\", "/", UPLOAD_PATH_IMG . "/imgManufa");
         $tmpimg = $_FILES["img"]["tmp_name"];
         $filename = $_FILES["img"]["name"];
         if ($filename == null) {
             $dataimg = $data_detail['img'];
         } else {
             $url_img_old = str_replace("\\", "/", UPLOAD_PATH_IMG . '/' . $data_detail['img']);
             unlink($url_img_old);
             $ext = substr(strrchr($filename, '.'), 1);
             $fileupload = substr(base64_encode($filename), 0, -1) . time() . '.' . $ext;
             $dataimg = 'imgManufa/' . $fileupload;
             copy($tmpimg, $dirpath . '/' . $fileupload);
             $Uty->load($tmpimg);
             $Uty->resizeToWidth(300);
             $Uty->save($dirpath . '/' . $fileupload);
             // ảnh thumb
         }
         $data_mn = array('manu_name' => $name, 'alias' => $alias, 'description' => $description, 'status' => $status, 'img' => $dataimg);
         $checkname = $this->getManufactureTable()->checkname($name);
         if ($name == $data_detail['manu_name']) {
             $obj_mn = new Manufacture();
             $obj_mn->exchangeArray($data_mn);
             $this->getManufactureTable()->update_manu($id, $obj_mn);
             $alert = '<div class="alert alert-success" role="alert">Edit Manufactured Successful.</div>';
             return array('data_detail' => $data_detail, 'alert' => $alert);
         } else {
             if ($checkname) {
                 $obj_mn = new Manufacture();
                 $obj_mn->exchangeArray($data_mn);
                 $this->getManufactureTable()->update_manu($id, $obj_mn);
                 $alert = '<div class="alert alert-success" role="alert">Edit Manufactured Successful.</div>';
                 return array('data_detail' => $data_detail, 'alert' => $alert);
             } else {
                 $data_detail = $this->getManufactureTable()->mannu_detail($id);
                 $alert = '<div class="alert alert-danger" role="alert">The automaker already exists</div>';
                 return array('data_detail' => $data_detail, 'alert' => $alert);
             }
         }
     }
     return array('data_detail' => $data_detail);
 }