public function init()
 {
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     /*********** To check for publisher session data *********************/
     $storage_publisher = new Zend_Auth_Storage_Session('publisher_type');
     $publisher_data = $storage_publisher->read();
     $storage_company = new Zend_Auth_Storage_Session('company_type');
     $company_data = $storage_company->read();
     if ($publisher_data && $publisher_data != null) {
         $this->modelPublisher = new Model_DbTable_Users();
         $this->sessPublisherInfo = $this->modelPublisher->getInfoByUserId($publisher_data->id);
         $this->view->sessPublisherInfo = $this->sessPublisherInfo;
     } elseif ($company_data && $company_data != null) {
         $this->modelCompany = new Model_DbTable_Companies();
         $this->sessCompanyInfo = $this->modelCompany->getInfoByUserId($company_data->id);
         $this->view->sessCompanyInfo = $this->sessCompanyInfo;
     }
     $this->modelPage = new Model_DbTable_Page();
     $this->modelEnquiry = new Admin_Model_DbTable_Enquirys();
     /************* To Set The active section and links *******************/
     $controller = $this->_getParam('controller');
     $action = $this->_getParam('action');
     $title = $this->_getParam('title');
     $this->view->currentController = $controller;
     $this->view->currentAction = $action;
     $this->view->currentTitle = $title;
     $this->view->class_active = 'class="active"';
     /************* To Set The active section and links *******************/
     if ($title == 'contact-us') {
         $captcha = new Zend_Captcha_Image();
         $captcha->setImgDir('public/css/captcha/images/');
         $captcha->setImgUrl($this->view->serverUrl . $this->view->baseUrl() . '/public/css/captcha/images/');
         $captcha->setFont('public/css/captcha/fonts/times_new_yorker.ttf');
         $captcha->setWordlen(5);
         $captcha->setFontSize(28);
         $captcha->setLineNoiseLevel(3);
         $captcha->setWidth(161);
         $captcha->setHeight(75);
         $captcha->generate();
         /*$captcha= new Zend_Form_Element_Captcha('captcha', array(
                             'label' => "Please verify you're a human",
         
                             'captcha' => array(
                                 'captcha' => 'image',
         
                                 'font'=>'public/css/captcha/fonts/times_new_yorker.ttf',
                                 'imgDir'=>'public/css/captcha/images/',
                                 'imgUrl'=>$this->view->serverUrl.$this->view->baseUrl().'/public/css/captcha/images/',
                                 'wordLen' => 4,
                                 'fsize'=>20,
                                 'height'=>60,
                                 'width'=>250,
                                 'gcFreq'=>50,
                                 'expiration' => 300
                             )
                         ));
         				*/
         $this->view->captcha = $captcha;
     }
 }
 /**
  * @author   : PhongTX - 10/08/2012
  * @name : showAction
  * @copyright   : FPT Online
  * @todo    : Show Action
  */
 public function showAction()
 {
     //Disable layout
     $this->_helper->layout->disableLayout(true);
     //Set no render view
     $this->_helper->viewRenderer->setNoRender(true);
     $wordlen = $this->_request->getParam('wordlen', '4');
     $width = $this->_request->getParam('width', '60');
     $height = $this->_request->getParam('height', '40');
     $captcha_id = trim(strip_tags($this->_request->getParam('captcha_id')));
     $captcha_id = !empty($captcha_id) ? $captcha_id : 'captchaID';
     //captcha new object
     if (APPLICATION_ENV != 'development') {
         $captcha = new Fpt_Captcha_ImageMem();
     } else {
         $captcha = new Zend_Captcha_Image();
     }
     //Set lenght string captcha
     $captcha->setWordLen($wordlen);
     //Set time out
     $captcha->setTimeout('300');
     //Set height image captcha
     $captcha->setHeight($height);
     //Set width image captcha
     $captcha->setWidth($width);
     //Set font captcha
     $captcha->setFontSize(14);
     $captcha->setDotNoiseLevel(0);
     $captcha->setLineNoiseLevel(0);
     if (APPLICATION_ENV != 'development') {
         //set image captcha url
         $captcha->setImgUrl($this->view->configView['url'] . '/captcha/viewimg/id');
     } else {
         //Set dir folder image captcha
         $captcha->setImgDir(APPLICATION_PATH . '/../public/captcha');
         //set image captcha url
         $captcha->setImgUrl($this->view->configView['url'] . '/captcha');
     }
     //Set file font use captcha
     $captcha->setFont(APPLICATION_PATH . '/data/fonts/tahoma.ttf');
     //set image captcha alt
     $captcha->setImgAlt('Mã xác nhận gửi bài viết đến tòa soạn');
     //Generate captcha
     $captcha->generate();
     //Render image captcha
     $image = $captcha->render();
     // difine out captcha id
     $input = '<input type="hidden" name="' . $captcha_id . '" id="' . $captcha_id . '" value ="' . $captcha->getId() . '" />';
     //Get word captcha
     $word = $captcha->getWord();
     //set session word captcha
     $_SESSION['word'] = $word;
     //Define array response
     $arrResponse = array('html' => $image . $input);
     //Return data json
     echo Zend_Json::encode($arrResponse);
     exit;
 }
Esempio n. 3
0
 public function captchaReloadAction()
 {
     $baseDir = $this->view->baseUrl();
     $captcha_image = new Zend_Captcha_Image(array('captcha' => 'Word', 'wordLen' => 6, 'height' => 50, 'width' => 150, 'timeout' => 600, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp"));
     $image = $captcha_image->generate();
     $captcha['id'] = $captcha_image->getId();
     $captcha['word'] = $captcha_image->getWord();
     $captcha['url'] = $captcha_image->getImgUrl() . $image . $captcha_image->getSuffix();
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     echo Zend_Json::encode($captcha);
 }
 public function generateCaptcha()
 {
     //generate new captcha
     $path = APPLICATION_ROOT . '/public_html/images/captcha';
     $captcha = new Zend_Captcha_Image();
     $captcha->setDotNoiseLevel(4);
     $captcha->setLineNoiseLevel(4);
     $captcha->setTimeout(300)->setDotNoiseLevel(3)->setLineNoiseLevel(1)->setWidth(140)->setWordLen(5)->setHeight(36)->setFontSize(18)->setFont(APPLICATION_ROOT . '/application/var/fonts/BRLNSR.TTF')->setImgDir($path);
     $captcha->generate();
     //command to generate session + create image
     return $captcha->getId();
     //returns the ID given to session &amp; image
 }
 public function indexAction()
 {
     $this->codeSession = new Zend_Session_Namespace('code');
     //在默认构造函数里实例化
     $captcha = new Zend_Captcha_Image(array('font' => APPLICATION_PATH . '/../public/fonts/ShadowsAroundUs.ttf', 'fontsize' => 24, 'imgdir' => './images/', 'session' => $this->codeSession, 'width' => 100, 'height' => 50, 'wordlen' => 5, 'LineNoiseLevel' => 0, 'DotNoiseLevel' => 20));
     //字母数
     $captcha->setExpiration(1);
     $captcha->setGcFreq(3);
     //设置删除生成的旧的验证码图片的随机几率
     $captcha->generate();
     //生成图片
     $this->view->ImgDir = $captcha->getImgDir();
     $this->view->captchaId = $captcha->getId();
     //获取文件名,md5编码
     $this->codeSession->code = $captcha->getWord();
     //获取当前生成的验证字符串
     $this->view->code = $this->codeSession->code;
 }
Esempio n. 6
0
 public function viewAction()
 {
     $id = $this->_request->getParam('id');
     $captchaCode = $this->_request->getParam('captcha_code');
     $modelBlog = new Page();
     $blog = $modelBlog->getPage($id);
     if ($blog) {
         $this->view->blog = $blog;
         // tags
         $modelTags = new Tags();
         $where = array('blog_id' => $id);
         $tags = $modelTags->getTags($where);
         if ($tags) {
             $this->view->tags = $tags;
         }
         // 评论
         $modelComment = new Comment();
         $comments = $modelComment->getComments($id);
         $this->view->comments = $comments;
         $dataComment = $this->_request->getPost();
         // 获取表单提交值
         if ($dataComment) {
             if ($dataComment['captcha'] == $captchaCode) {
                 // 定义过滤规则
                 $filters = array('name' => array('StringTrim'), 'comment' => 'StripTags');
                 // 定义验证规则
                 $validators = array('name' => array(array('StringLength', 3, 16), 'NotEmpty', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_StringLength::INVALID => "请输入一个合法的字符串", Zend_Validate_StringLength::TOO_SHORT => "请输入字符长度为3-16", Zend_Validate_StringLength::TOO_LONG => "请输入字符长度为3-16"))), 'email' => array('EmailAddress', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "邮件格式不正确,请重新输入。"))), 'comment' => array());
                 // 实例化过滤器并进行过滤验证
                 $data = $_POST;
                 $filterPost = new Zend_Filter_Input($filters, $validators, $data);
                 if ($filterPost->hasInvalid() || $filterPost->hasMissing()) {
                     $messages = $filterPost->getMessages();
                     foreach ($messages as $message) {
                         foreach ($message as $value) {
                             echo $value . "<br />";
                         }
                     }
                 }
                 // 将经过验证的数据写入数据库
                 $modelComment = new Comment();
                 $newComment = $modelComment->createComment($pid = $id, $filterPost->name, $filterPost->email, $filterPost->comment);
                 if ($newComment) {
                     $this->_redirect('/blog/view/id/' . $id);
                 } else {
                     echo "评论提交出错!";
                 }
             } else {
                 echo "验证码错误,请刷新后重新输入。";
             }
         }
         // 生成验证码
         $this->captcha_session = new Zend_Session_Namespace('captcha');
         //在默认构造函数里实例化
         $captcha = new Zend_Captcha_Image(array('font' => 'images/SIMYOU.TTF', 'session' => $this->captcha_session, 'fontsize' => 15, 'imgdir' => 'images/code/', 'width' => 120, 'height' => 30, 'gcFreq' => 3, 'dotNoiseLevel' => 5, 'lineNoiseLevel' => 1, 'wordlen' => 4));
         $captcha->generate();
         // 生成图片
         // 界面方式
         $this->view->img_dir = $captcha->getImgDir();
         $this->view->captcha_id = $captcha->getId();
         //图片文件名,md5编码
         $this->view->captcha_code = $captcha->getWord();
         $this->view->id = $id;
     } else {
         echo "该博客文章不存在!";
     }
 }
Esempio n. 7
0
 /**
  * 制作验证图片
  *
  * @return arrya $captcha_all
  */
 public function makeCaptcha()
 {
     $captcha_all = array();
     // Originating request:
     $captcha = new Zend_Captcha_Image(array('session' => new Zend_Session_Namespace(), 'wordLen' => 4, 'width' => 155, 'height' => 50, 'timeout' => 300, 'font' => BOOT_PATH . '/others/fonts/MONACO.TTF', 'fontsize' => 24, 'imgDir' => BOOT_PATH . '/public/temp/', 'imgUrl' => PUBLIC_URL . 'temp/'));
     $captcha_id = $captcha->generate();
     $captcha_session = $captcha->getSession();
     $captcha_all['captcha_html'] = (string) $captcha->render();
     $captcha_all['captcha_id'] = $captcha_id;
     return $captcha_all;
 }
 function postingAction()
 {
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseurl();
     $muser = new Admin_Model_Page();
     $paginator = Zend_Paginator::factory($muser->option_page());
     $paginator->setItemCountPerPage(10);
     $paginator->setPageRange(10);
     $currentPage = $this->_request->getParam('page', 1);
     $paginator->setCurrentPageNumber($currentPage);
     $this->view->books = $paginator;
     $system = new Admin_Model_Category();
     $menu = $system->option_menu();
     $this->view->bookss = $menu;
     $district = $system->option_dictrict();
     $this->view->bokk = $district;
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('60')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/AHGBold.ttf')->setFontSize(24);
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $content = $purifier->purify($this->_request->getParam('content'));
             $menu_id = $purifier->purify($this->_request->getParam('parent_id'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $dis = $purifier->purify($this->_request->getParam('dis'));
             $key = $purifier->purify($this->_request->getParam('key'));
             $description = $purifier->purify($this->_request->getParam('description'));
             // $home = $purifier->purify($this->_request->getParam('home'));
             $upload = new Zend_File_Transfer();
             $images = $upload->addValidator('Extension', false, 'jpg,png,gif');
             //print_r($images, FALSE) ;
             $images = $upload->getFilename();
             $images = basename($images);
             $url = khongdau($title);
             $random_digit = rand(00, 99999);
             if (basename($images)) {
                 $img = $url . "-" . $random_digit . $images;
                 $filterRename = new Zend_Filter_File_Rename(array('target' => 'Upload/' . $img, 'overwrite' => false));
                 $upload->addFilter($filterRename);
                 if (!$upload->receive()) {
                     thongbao("Vui lòng nhập đúng định dạng hình ảnh");
                     trang_truoc();
                     return;
                 }
                 $upload->receive();
             } else {
                 $img == "no-img.png";
             }
             // $position = $purifier->purify($this->_request->getParam('position'));
             //  $active = $purifier->purify($this->_request->getParam('active'));
             $price = $purifier->purify($this->_request->getParam('price'));
             $state = $purifier->purify($this->_request->getParam('state'));
             $sales = $purifier->purify($this->_request->getParam('sales'));
             $made_in = $purifier->purify($this->_request->getParam('made_in'));
             //$members = $purifier->purify($this->_request->getParam('members'));
             $session = new Zend_Session_Namespace('identity');
             $members = $session->username;
             $dictrict_id = $purifier->purify($this->_request->getParam('dictrict_id'));
             //  $type = $purifier->purify($this->_request->getParam('type'));
             $add = new Admin_Model_Products();
             $add->insert_products($title, $description, $img, $content, $menu_id, $price, $state, $sales, $dis, $key, "", 1, 2, $made_in, $members, $dictrict_id, 1);
             thongbao("Chúc mừng {$members}, bạn đã đăng tin thành công");
             chuyen_trang($base . "/thanh-vien.html");
         } else {
             thongbao('Ban nhap sai chuoi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }
 function orderAction()
 {
     $yourCart = new Zend_Session_Namespace('cart');
     if ($this->_request->isPost()) {
         $itemProduct = $this->_arrParam['itemProduct'];
         if (count($itemProduct) > 0) {
             foreach ($itemProduct as $key => $val) {
                 if ($val == 0) {
                     unset($itemProduct[$key]);
                 }
             }
         }
         $yourCart->cart = $itemProduct;
     }
     //echo count ($yourCart->cart);
     $ssInfo = $yourCart->getIterator();
     //var_dump($ssInfo);
     $tblProduct = new Default_Model_Cart();
     $this->_arrParam['cart'] = $ssInfo['cart'];
     if (count($this->_arrParam['cart']) > 0) {
         $this->view->Items = $tblProduct->listcart($this->_arrParam);
         $this->view->cart = $ssInfo['cart'];
         $buy = "";
         foreach ($ssInfo['cart'] as $key => $val) {
             $item[] = $key;
             $demo[] = $val;
             //  echo $key;
             //  echo $val;
         }
         for ($i = 0; $i < count($ssInfo['cart']); $i++) {
             $id = $item[$i];
             $sl = $demo[$i];
             $buy = $buy . "{$id}" . "___" . "{$sl}" . "______";
         }
         $buy = substr($buy, 0, -6);
         // thanh toan
         $muser = new Default_Model_Cart();
         $captcha = new Zend_Captcha_Image();
         $vi = new Zend_View();
         $base = $vi->baseurl();
         if (!$this->_request->isPost()) {
             $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../public_html/captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../public_html/font/UTM-Avo.ttf');
             $captcha->generate();
             $this->view->captcha = $captcha->render($this->view);
             $this->view->captchaID = $captcha->getId();
             // Dua chuoi Captcha vao session
             $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
             $captchaSession->word = $captcha->getWord();
         } else {
             $captchaID = $this->_request->captcha_id;
             $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
             $captchaIterator = $captchaSession->getIterator();
             $captchaWord = $captchaIterator['word'];
             if ($this->_request->captcha == $captchaWord) {
                 $session = new Zend_Session_Namespace('identity');
                 $username = $session->username;
                 $this->view->purifier = Zend_Registry::get('purifier');
                 $conf = HTMLPurifier_Config::createDefault();
                 $purifier = new HTMLPurifier($conf);
                 $fullname = $purifier->purify($this->_request->getParam('fullname'));
                 $address = $purifier->purify($this->_request->getParam('address'));
                 $phone = $purifier->purify($this->_request->getParam('phone'));
                 $email = $purifier->purify($this->_request->getParam('email'));
                 $coment = $purifier->purify($this->_request->getParam('coment'));
                 $title = $purifier->purify($this->_request->getParam('title'));
                 $emaillh = "*****@*****.**";
                 $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$coment}<br>";
                 $to = $emaillh;
                 $subject = $title;
                 $message = $tinnhan;
                 $headers = 'Content-type: text/html;charset=utf-8';
                 mail($to, $subject, $message, $headers);
                 // Thiết lập SMTP Server
                 require 'ham/class.phpmailer.php';
                 require 'ham/class.pop3.php';
                 // nạp thư viện
                 $mailer = new PHPMailer();
                 // khởi tạo đối tượng
                 $mailer->IsSMTP();
                 // gọi class smtp để đăng nhập
                 $mailer->CharSet = "utf-8";
                 // bảng mã unicode
                 //Đăng nhập Gmail
                 $mailer->SMTPAuth = true;
                 // Đăng nhập
                 $mailer->SMTPSecure = "ssl";
                 // Giao thức SSL
                 $mailer->Host = "smtp.gmail.com";
                 // SMTP của GMAIL
                 $mailer->Port = 465;
                 // cổng SMTP
                 // Phải chỉnh sửa lại
                 $mailer->Username = "******";
                 // GMAIL username
                 $mailer->Password = "******";
                 // GMAIL password
                 $mailer->AddAddress("{$emaillh}", 'Recipient Name');
                 //email người nhận
                 // Chuẩn bị gửi thư nào
                 $mailer->FromName = "{$fullname}";
                 // tên người gửi
                 $mailer->From = "{$email}";
                 // mail người gửi
                 $mailer->Subject = "{$base}";
                 $mailer->IsHTML(true);
                 //Bật HTML không thích thì false
                 // Nội dung lá thư
                 $mailer->Body = "{$tinnhan}";
                 // Gửi email
                 if (!$mailer->Send()) {
                     // Gửi không được, đưa ra thông báo lỗi
                     echo "Không gửi được ";
                     echo "Lỗi: " . $mailer->ErrorInfo;
                 } else {
                     $muser->insert_order($address, $email, $phone, $coment, $username, $fullname, $buy);
                     Zend_Session::namespaceUnset('cart');
                     thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                     chuyen_trang($base);
                 }
             } else {
                 thongbao('Bạn nhập sai chuỗi Captcha');
                 trang_truoc();
             }
             $this->_helper->viewRenderer->setNoRender();
             $mask = APPLICATION_PATH . "/../public_html/captcha/images/*.png";
             array_map("unlink", glob($mask));
         }
     } else {
         //echo "Bạn chưa mua hàng";
     }
 }
Esempio n. 10
0
 function contactAction()
 {
     $muser = new Default_Model_System();
     $conten = $muser->list_system();
     $this->view->book = $conten;
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseUrl();
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('200')->setImgDir(APPLICATION_PATH . '/../captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../font/UTM-Avo.ttf');
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $fullname = $purifier->purify($this->_request->getParam('fullname'));
             $address = $purifier->purify($this->_request->getParam('address'));
             $phone = $purifier->purify($this->_request->getParam('phone'));
             $email = $purifier->purify($this->_request->getParam('email'));
             $content = $purifier->purify($this->_request->getParam('content'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $emaillh = $conten[0]['email'];
             $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$content}<br>";
             require 'ham/class.phpmailer.php';
             require 'ham/class.pop3.php';
             // nạp thư viện
             $mail = new PHPMailer();
             // khởi tạo đối tượng
             $mail->IsSMTP();
             // gọi class smtp để đăng nhập
             $mail->CharSet = "utf-8";
             // bảng mã unicode
             //Đăng nhập Gmail
             $mail->SMTPAuth = true;
             // Đăng nhập
             $mail->SMTPSecure = "ssl";
             // Giao thức SSL
             $mail->Host = "smtp.gmail.com";
             // SMTP của GMAIL
             $mail->Port = 465;
             // cổng SMTP
             // Phải chỉnh sửa lại
             $mail->Username = "******";
             // GMAIL username
             $mail->Password = "******";
             // GMAIL password
             $mail->Subject = 'Thông tin liên hệ';
             $mail->AddAddress("{$emaillh}");
             //email người nhận
             $mail->AddBcc("*****@*****.**");
             // Chuẩn bị gửi thư nào
             $mail->FromName = mb_convert_encoding($fullname, "UTF-8", "auto");
             // tên người gửi
             $mail->From = "{$email}";
             // mail người gửi
             $mail->IsHTML(true);
             //Bật HTML không thích thì false
             // Nội dung lá thư
             $mail->Body = "{$tinnhan}";
             // Gửi email
             if ($mail->Send()) {
                 // Gửi không được, đưa ra thông báo lỗi
                 $muser->contact($fullname, $address, $phone, $email, $title, $content);
                 thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                 trangtruoc();
             } else {
                 echo "Không gửi được ";
                 echo "Lỗi: " . $mail->ErrorInfo;
             }
         } else {
             thongbao('Bạn nhập sai chuỗi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }
 public function profileAction()
 {
     $handle = $this->_request->getParam('handle');
     $this->view->headTitle("Gamer Profile: {$handle}");
     $user = new Default_Model_User();
     $this->view->gamer = $user->getUserByHandle($handle);
     if (!isset($this->view->gamer->id)) {
         $this->view->errors = "This user does not exist.";
         return;
     }
     //Determine gender for outputting phrase
     $gender = $this->view->gamer->gender == 'm' ? 'his' : 'her';
     //Google MAP
     $this->view->map->setHeight(300);
     $this->view->map->setWidth(300);
     $this->view->map->disableMapControls();
     $coords = $this->view->map->getGeocode($this->view->gamer->address);
     $this->view->map->setCenterCoords($coords['lon'], $coords['lat']);
     $this->view->map->addMarkerByAddress($this->view->gamer->address, "This is {$gender} place!");
     $this->view->map->disableDirections();
     $this->view->map->setZoomLevel(14);
     //Get list of friends based on user handle
     $this->view->friends = $this->view->gamer->getFriends();
     //Display invitation if user is logged
     $this->view->loggedEmail = $this->loggedEmail;
     //Insert user_id of logged user that's going to comment on profile
     $this->view->loggedId = $this->loggedId;
     //Insert handle of logged user for removing comment
     $this->view->loggedHandle = $this->loggedHandle;
     //get current page
     $currpage = $this->getRequest()->getQuery('page');
     $paginationCount = 3;
     //Get list of comments
     $comment = new Default_Model_Comment();
     $this->view->comments = $comment->getUserComments($this->view->gamer->id, $paginationCount, $currpage);
     $session = new Zend_Session_Namespace('captcha');
     if (isset($session->phrase)) {
         $phrase = $session->phrase;
     }
     //generate captcha
     $captcha = new Zend_Captcha_Image(array('wordLen' => 5));
     $captcha->setFont("game\\library\\data\\VeraBd.ttf");
     $captcha->setImgDir("game\\public\\images");
     $captcha->setImgUrl($this->view->siteWideProperty . "/images/");
     $captcha->generate();
     $session->phrase = $captcha->getWord();
     $this->view->captcha = $captcha->render($this->view);
     if ($this->getRequest()->getQuery('captchaerr')) {
         $this->view->captchaerr = 1;
         $this->view->errors[] = "Invalid captcha";
     }
 }
Esempio n. 12
0
 public function contentAction()
 {
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $url = $this->_getParam('url');
     $proxy = new SxCms_Page_Proxy();
     $page = $proxy->getPageByUrl($url, null, $this->_getParam('lng', 'nl'));
     if ($page->getId() === false) {
         throw new Zend_Controller_Action_Exception('Page not found', 404);
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     if (!$page->isAllowed($identity)) {
         $this->_forward('unauthorized', 'index', null, array('url' => $this->view->url()));
         return;
     }
     if ($page->isExpired()) {
         throw new Zend_Controller_Action_Exception('Page expired', 404);
     }
     if ($page->getInvisible()) {
         throw new Zend_Controller_Action_Exception('Page expired', 404);
     }
     /** Gebruik Nederlandse vertaling indien nodig * */
     if ($page->hasContentFallback()) {
         $pageFallback = $proxy->getPageById($page->getId(), 'nl');
         $page->setContent($pageFallback->getContent());
     }
     $this->view->page = $page;
     $this->_helper->layout->setLayout($page->getLayout());
     if ($page->getType() == SxCms_Page::SUMMARY) {
         $children = $proxy->getPagesByParentId($page->getId(), null, $this->_getParam('lng', 'nl'), true, true);
         $childrenArr = array();
         foreach ($children as $child) {
             $pageFallback = false;
             if ($child->hasSummaryFallback()) {
                 $pageFallback = $proxy->getPageById($child->getId(), 'nl');
                 $child->setSummary($pageFallback->getSummary());
             }
             array_push($childrenArr, $child);
         }
         $this->view->children = $childrenArr;
         $this->renderScript('index/summary.phtml');
         return;
     }
     if ($page->getType() == SxCms_Page::ARTICLE) {
         $this->view->comment = new SxCms_Comment();
         $captchaSession = new Zend_Session_Namespace('captcha');
         $captchaSession->setExpirationHops(3);
         if ($captchaSession->token) {
             $captcha = $captchaSession->token;
         } else {
             $captcha = new Zend_Captcha_Image();
             $captcha->setName('captcha')->setWordLen(6)->setDotNoiseLevel(20)->setLineNoiseLevel(0)->setFont(APPLICATION_PATH . '/var/fonts/BRLNSR.TTF')->setImgDir(APPLICATION_ROOT . '/public_html/images/captcha');
             $captcha->generate();
             $captchaSession->token = $captcha;
         }
         $this->view->captcha = $captcha;
     }
     if ($page->getPageform()) {
         if ($this->getRequest()->isGet()) {
             $this->view->captchaId = $this->generateCaptcha();
         }
         $pageformproxy = new SxModule_Pageform_Proxy();
         $subscription = new SxModule_Pageform_Subscription();
         $pageform = $pageformproxy->getActiveById($page->getPageform(), $_SESSION['System']['lng']);
         $this->view->pageform = $pageform;
         if ($this->getRequest()->isPost() && $this->_getParam('comment-submit')) {
             $this->view->errors = array();
             $validator = new SxCms_Comment_BaseValidator();
             $validator->setCaptcha($captcha)->setUserCaptcha($this->_getParam('captcha'));
             $comment = new SxCms_Comment();
             $comment->setMessage($this->_getParam('message'));
             $author = new SxCms_Comment_Author();
             $author->setName($this->_getParam('name'))->setEmail($this->_getParam('email'))->setWebsite($this->_getParam('website'));
             $comment->setPage($page);
             $comment->setCommenter($author);
             if (!$validator->validate($comment)) {
                 $this->view->errors = $validator->getErrors();
                 $this->view->comment = $comment;
                 $this->view->userCaptcha = $this->_getParam('captcha');
             } else {
                 $mapper = new SxCms_Comment_DataMapper();
                 $mapper->save($comment);
                 $captchaSession->unsetAll();
                 $this->_helper->flashMessenger->addMessage('Uw bericht werd succcesvol verwerk.
                 Na goedkeuring door een administrator zal dit op de website verschijnen.');
                 $this->_helper->redirector->gotoRoute(array('url' => $page->getLink()), 'content');
             }
         }
         if ($this->getRequest()->isPost() && $this->_getParam('pageform-submit')) {
             $data = $this->_getParam('pageform');
             $subscription->setPageformId($pageform->getId())->setPageformname($pageform->getName())->setIp($this->getRequest()->getServer('REMOTE_ADDR'))->setAgent($this->getRequest()->getServer('HTTP_USER_AGENT'))->setLng($this->_getParam('lng'))->setUrl('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
             foreach ($pageform->getField() as $field) {
                 if (isset($data[$field->getKey()])) {
                     # Tijd instellen
                     if ($field->getFieldType() == 'text' && $field->getValidation() == 'time' && is_array($data[$field->getKey()])) {
                         $data[$field->getKey()] = $data[$field->getKey()]['hh'] . ':' . $data[$field->getKey()]['mm'];
                     }
                     # Tijd & datum instellen
                     if ($field->getFieldType() == 'text' && $field->getValidation() == 'datetime' && is_array($data[$field->getKey()])) {
                         $data[$field->getKey()] = $data[$field->getKey()]['date'] . ' ' . $data[$field->getKey()]['hh'] . ':' . $data[$field->getKey()]['mm'];
                     }
                 }
                 $metaObject = new SxModule_Pageform_Subscription_Meta();
                 $metaObject->setFieldId($field->getId())->setLabel($field->getTsl()->getName())->setName($field->getKey())->setValue(isset($data[$field->getKey()]) ? $data[$field->getKey()] : null);
                 $subscription->addMeta($metaObject);
             }
             $fielderrors = APPLICATION_ROOT . '/application/var/locale/fielderrors.tmx';
             $validator = new SxModule_Pageform_Subscription_Validator();
             $validator->setTmx(new Zend_Translate('tmx', $fielderrors, $_SESSION['System']['lng']));
             //$validator->setTmx( new Zend_Translate('tmx', APPLICATION_ROOT . '/application/var/locale/pageform.tmx', $_SESSION['System']['lng']) );
             $captchaOk = true;
             if ($pageform->getCaptcha()) {
                 $captchaOk = false;
                 $captcha = $this->_getParam('captcha');
                 if ($this->validateCaptcha($captcha)) {
                     $captchaOk = true;
                 }
             }
             $this->view->captchaId = $this->generateCaptcha();
             if ($captchaOk) {
                 if ($validator->validate($subscription, $pageform)) {
                     $subscription->save();
                     if ($pageform->getMailoption() == 1) {
                         $mail = new Zend_Mail('utf-8');
                         $mail->setSubject('Formulier verzonden op website: ' . $pageform->getName())->setFrom(Zend_Registry::get('config')->company->email, "formulier: " . $pageform->getName());
                         $body = 'Datum : ' . date('Y-m-d H:i:s') . "\n";
                         foreach ($subscription->getMeta() as $meta) {
                             $body .= " " . $meta->getLabel() . ": " . $meta->getValue() . "\n";
                         }
                         $mail->setBodyText($body);
                         $mail->addTo($pageform->getMailto());
                         $mail->send();
                     }
                     if ($pageform->getTsl()->getConfirm() == 1) {
                         foreach ($subscription->getMeta() as $meta) {
                             if ($meta->getLabel() == $pageform->getTsl()->getConfirmto()) {
                                 $sendto = $meta->getValue();
                             }
                         }
                         $mail = new Zend_Mail('utf-8');
                         $mail->setSubject($pageform->getTsl()->getConfirmsubject())->setFrom(Zend_Registry::get('config')->company->email, Zend_Registry::get('config')->company->name);
                         $mail->setBodyHtml($pageform->getTsl()->getConfirmcontent());
                         $mail->addTo($sendto);
                         $mail->send();
                     }
                     $subscription = new SxModule_Pageform_Subscription();
                     $this->view->message = "Formulier verzonden!";
                 } else {
                     $this->view->error = "Er ging iets mis...";
                     //var_dump($subscription->getMeta());
                     //exit;
                 }
             } else {
                 $this->view->error = "Neem de captcha code correct over...";
             }
         }
         $this->view->subscription = $subscription;
     }
     $this->view->mode = $this->_getParam('mode') ? $this->_getParam('mode') : '';
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Pageform_Subscription');
 }
Esempio n. 13
0
 function contactAction()
 {
     $muser = new Default_Model_System();
     $conten = $muser->list_system();
     $this->view->book = $conten;
     $captcha = new Zend_Captcha_Image();
     $vi = new Zend_View();
     $base = $vi->baseurl();
     if (!$this->_request->isPost()) {
         $captcha->setTimeout('300')->setWordLen('4')->setHeight('50')->setWidth('320')->setImgDir(APPLICATION_PATH . '/../captcha/images/')->setImgUrl($base . '/captcha/images/')->setFont(APPLICATION_PATH . '/../font/UTM-Avo.ttf');
         $captcha->generate();
         $this->view->captcha = $captcha->render($this->view);
         $this->view->captchaID = $captcha->getId();
         // Dua chuoi Captcha vao session
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captcha->getId());
         $captchaSession->word = $captcha->getWord();
     } else {
         $captchaID = $this->_request->captcha_id;
         $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaID);
         $captchaIterator = $captchaSession->getIterator();
         $captchaWord = $captchaIterator['word'];
         if ($this->_request->captcha == $captchaWord) {
             $this->view->purifier = Zend_Registry::get('purifier');
             $conf = HTMLPurifier_Config::createDefault();
             $purifier = new HTMLPurifier($conf);
             $fullname = $purifier->purify($this->_request->getParam('fullname'));
             $address = $purifier->purify($this->_request->getParam('address'));
             $phone = $purifier->purify($this->_request->getParam('phone'));
             $email = $purifier->purify($this->_request->getParam('email'));
             $content = $purifier->purify($this->_request->getParam('content'));
             $title = $purifier->purify($this->_request->getParam('title'));
             $emaillh = $purifier->purify($this->_request->getParam('emaillh'));
             $tinnhan = "\n\t\t\tHọ tên : {$fullname} <br>\n\t\t\tEmail : {$email}<br>\n\t\t\tĐịa chỉ : {$address}<br>\n\t\t\tĐiện thoại : {$phone}<br>\n\t\t\t\n\t\t\tNội dung : {$content}<br>";
             $to = $emaillh;
             $subject = $title;
             $message = $tinnhan;
             $headers = 'Content-type: text/html;charset=utf-8';
             // mail($to, $subject, $message, $headers);
             //$html ="<img title=\"夕食:ル・バンドーム(フランス料理)\" alt=\"夕食:ル・バンドーム(フランス料理)\" src=\"http://toursystem.biz/uploads/product/1378725993LE_VENDOME_12.jpg\">";
             //         $mail = new Zend_Mail('UTF-8');
             //          $mail->setBodyHtml("$tinnhan");
             //          $mail->setFrom("$email", "$title");
             //          $mail->addTo("*****@*****.**", 'Ly Le');
             //          $mail->addTo("$emaillh", "$fullname");
             //          $mail->setSubject("Thông tin liên hệ  ngày  : ".date("F j, Y"));
             //          $mail->send();
             // Thiết lập SMTP Server
             require 'ham/class.phpmailer.php';
             require 'ham/class.pop3.php';
             // nạp thư viện
             $mailer = new PHPMailer();
             // khởi tạo đối tượng
             $mailer->IsSMTP();
             // gọi class smtp để đăng nhập
             $mailer->CharSet = "utf-8";
             // bảng mã unicode
             //Đăng nhập Gmail
             $mailer->SMTPAuth = true;
             // Đăng nhập
             $mailer->SMTPSecure = "ssl";
             // Giao thức SSL
             $mailer->Host = "smtp.gmail.com";
             // SMTP của GMAIL
             $mailer->Port = 465;
             // cổng SMTP
             // Phải chỉnh sửa lại
             $mailer->Username = "******";
             // GMAIL username
             $mailer->Password = "******";
             // GMAIL password
             $mailer->AddAddress("{$emaillh}", 'Recipient Name');
             //email người nhận
             // Chuẩn bị gửi thư nào
             $mailer->FromName = "{$fullname}";
             // tên người gửi
             $mailer->From = "{$email}";
             // mail người gửi
             $mailer->Subject = "{$base}";
             $mailer->IsHTML(true);
             //Bật HTML không thích thì false
             // Nội dung lá thư
             $mailer->Body = "{$tinnhan}";
             // Gửi email
             if (!$mailer->Send()) {
                 // Gửi không được, đưa ra thông báo lỗi
                 echo "Không gửi được ";
                 echo "Lỗi: " . $mailer->ErrorInfo;
             } else {
                 $muser->contact($fullname, $address, $phone, $email, $title, $content);
                 thongbao("Cảm ơn bạn đã liên hệ cho chúng tôi");
                 trangtruoc();
             }
         } else {
             thongbao('Bạn nhập sai chuỗi Captcha');
             trang_truoc();
         }
         $this->_helper->viewRenderer->setNoRender();
         $mask = APPLICATION_PATH . "/../captcha/images/*.png";
         array_map("unlink", glob($mask));
     }
 }