/** * Действие удаление комментария: */ public function removePostCommentAjaxAction(Application $application) { if (!Session::getInstance()->isAdminSession()) { return false; } $comment = Blog_BlogCommentsModel::GetComment($_GET['id']); $post = Blog_BlogPostsModel::GetPost(@$comment['post_id']); if ($comment && $post && ControlModel::checkModrights($post['category'])) { Blog_BlogCommentsModel::RemoveComment($_GET['id']); ControlModel::logModEvent(date("d-m-Y H:i:s") . ' ' . $_SESSION['auth']['name'] . '<br /> удалил комментарий ' . $comment['id'] . ' в посте <a href="http://' . TemplateHelper::getSiteUrl() . '/news/res/' . $post['id'] . '/" class="js-cross-link">>>' . $post['id'] . '</a>' . '<br /><em>' . strip_tags($comment['text'], 'a') . '</em>'); JabberBot::send('-=$ /me (модлог) ' . $_SESSION['auth']['name'] . ' удалил комментарий ' . $comment['id'] . ' в посте http://' . TemplateHelper::getSiteUrl() . '/news/res/' . $post['id'] . '/'); return true; } return false; }
/** * Действие добавления комментария (ajax): */ public function addCommentAjaxAction(Application $application) { $session = Session::getInstance(); if ($session->isJustCreated()) { return false; } $validator = new ValidatorHelper($_POST); $validator->assertExists('text', 'Не введен текст комментария'); $validator->assertExists('post_id', 'Не указан идентификатор поста'); $validator->assertLength('text', 2048, 'Текст комментария слишком длинный'); $validator->assertNotExists('email', 'Заполнено лишнее поле'); $text_test = ControlModel::checkContent($_POST['text']); if (ControlModel::isCommentCaptcha()) { return array('captcha' => true); } $validator->assertTrue('text', $text_test, 'Запрещенное слово из вордфильтра'); $validator->assertTrue('timeout', ControlModel::getPostCommentInterval() == 0, 'Таймаут ' . TemplateHelper::ending(ControlModel::getPostCommentInterval(), 'секунда', 'секунды', 'секунд')); if ($validator->isValid()) { $id = Blog_BlogCommentsModel::CreateComment($_POST, true); $session->activeSet('last_visit_post_' . $_POST['post_id'], time()); } return array('isValid' => $validator->isValid(), 'validationResults' => $validator->getValidationResults()); }
static function boardpostlink2($parser, $matches, $name) { list(, $board_name, $id) = $matches; $parser->again = false; if ($board_name != 'news') { $board = new Board_BoardModel($board_name); if ($board->existsPost($id)) { $post = $board->getPost($id); $href = 'http://1chan.ru/' . $board_name . '/res/'; if ($post['parent_id'] == null) { $href .= $id . '/#top'; } else { $href .= $post['parent_id'] . '/#' . $id; } $link = TexyHtml::el('a'); $link->href($href); $link->attrs['class'] = 'js-cross-link'; $link->attrs['name'] = $board_name . '/' . $id; $link->setText('>>' . $board_name . '/' . $id); return $link; } return '>>' . $board_name . '/' . $id; } if (Blog_BlogCommentsModel::CommentExists($id)) { $comment = Blog_BlogCommentsModel::GetComment($id); $post_id = $comment['post_id']; } elseif (Blog_BlogPostsModel::PostExists($id)) { $post_id = $id; } else { '>>news/' . $id; } $link = TexyHtml::el('a'); $link->href('http://1chan.ru/news/res/' . $post_id . '/#' . $id); $link->attrs['class'] = 'js-cross-link'; $link->attrs['name'] = 'news/' . $id; $link->setText('>>news/' . $id); return $link; }
/** * Удаление поста: */ public function postCommentDeleteAction(Application $application, Template $template) { Blog_BlogCommentsModel::RemoveComment($_GET['id']); $template->headerSeeOther('http://' . TemplateHelper::getSiteUrl() . '/admin/postComments'); exit; }