public function blogAction() { $ispost = $this->_getParam('idpost', false); $this->view->pageTitle = $this->view->tr(NULL, $this->view->lang, 'Наш Блог'); if ($ispost) { $this->view->token = new Zend_Service_ReCaptcha($this->config->capcha->pub, $this->config->capcha->priv); if ($this->_request->isPost()) { $filter = new Zend_Filter(); $filter = $filter->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_HtmlEntities()); $name = $filter->filter($this->_getParam('name', '')); $email = $filter->filter($this->_getParam('email', '')); $message = $filter->filter($this->_getParam('message', '')); $token = $this->_getParam('token', ''); $data = array('name' => $name, 'email' => $email, 'message' => $message, 'idpage' => $ispost); $recaptcha_challenge_field = $this->_getParam('recaptcha_challenge_field', 'default'); $recaptcha_response_field = $this->_getParam('recaptcha_response_field', 'default'); $result = $this->view->token->verify($recaptcha_challenge_field, $recaptcha_response_field); //var_dump($recaptcha_challenge_field, $recaptcha_response_field); if ($result->isValid()) { Model_Comment::updatepage($data); // send mail try { $mail = new Zend_Mail($charset = 'utf-8'); $mail->addTo($this->view->config->resources->mail->admin); $mail->setFrom($this->view->config->resources->mail->sender); $text = $this->view->config->resources->mail->template; $text = "Був доданий коментар до сторінки " . $this->view->config->baseurl . $this->getRequest()->getRequestUri() . "\n"; $text .= "Дата: " . $this->view->localDate(time(), $this->view->lang) . "\n"; $text .= "Имя: {$name} \n"; $text .= "Email: {$email} \n"; $text .= "Текст: {$message} \n"; $mail->setSubject('Коментар на сайті Party Zone'); $mail->setBodyText($text); $t = $mail->send(); } catch (Zend_Mail_Exception $e) { echo json_encode(array('status' => 'error', 'msg' => $e->getMessages())); // exit; } $this->_redirect($this->getRequest()->getRequestUri()); } } $this->view->comments = Model_Comment::getAll($ispost, 'asc'); $this->view->post = Model_Blogentry::getById($ispost, $this->view->lang); if (is_object($this->view->post)) { $this->view->pageTitle = $this->view->post->title; $this->view->headMeta()->appendName('keywords', $this->view->post->keyword); $this->view->headMeta()->appendName('description', $this->view->post->description); } return $this->renderScript('/index/blogentry.phtml'); } $this->view->blogs = $this->setPaginator(Model_Blogentry::getBlogs($this->view->lang)); $this->view->blogmenu = Model_Menu::getById(16, $this->view->lang); }
public function commentAction() { // delete $delete = $this->_getParam('delete', false); if ($delete && Zend_Validate::is($delete, 'Digits')) { Model_Comment::deletepage($delete); $this->_redirect('/admin/comment'); } if ($this->_request->isPost()) { $data = array("idcomment" => $_POST["idcomment"], "message" => $_POST["message"]); Model_Comment::updatepage($data); $this->_redirect('/admin/comment'); } $this->view->menu_comment = 'selected'; $this->view->comments = Model_Comment::getAll(); }