/** * @throws HTTP_Exception_404 * * edit book */ public function action_editbook() { $id = $this->request->param('id'); $id = Security::encode_php_tags(HTML::chars($id)); $session = Session::instance(); $data['page'] = $session->get("page", ''); $book = new Model_Guestbook(); $data = $book->getBook($id); if ($data) { if ($_POST) { $book->insBook($id); $data['msg'] = 'Запись добавлена'; HTTP::redirect($_SERVER['HTTP_REFERER']); } else { $data['msg'] = 'Запись не добавлена'; } $content = View::factory($this->itemBookView); $content->bind('data', $data); $this->template->content = $content; } else { throw new HTTP_Exception_404('File not found!'); } }
/** * add book */ public function action_addguest() { $data = array('msg' => ''); $captcha = Captcha::instance('default'); $session = Session::instance(); $data['page'] = $session->get("page", ''); if (isset($_POST['btnSubmit'])) { $book = new Model_Guestbook(); if (Captcha::valid($_POST['captcha'])) { if ($book->insBook()) { $data['msg'] = 'Запись добавлена'; } else { $data['msg'] = 'Запись не добавлена'; } } else { $data['msg'] = 'Капча не верна'; } } $content = View::factory('addguestview'); $content->captcha = $captcha; $content->bind('data', $data); $this->template->content = $content; }