예제 #1
0
 /**
  * Действие удаление комментария:
  */
 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">&gt;&gt;' . $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;
 }
예제 #2
0
 /**
  * Действие добавления комментария (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());
 }
예제 #3
0
 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('&gt;&gt;' . $board_name . '/' . $id);
             return $link;
         }
         return '&gt;&gt;' . $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 {
         '&gt;&gt;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('&gt;&gt;news/' . $id);
     return $link;
 }
예제 #4
0
 /**
  * Удаление поста:
  */
 public function postCommentDeleteAction(Application $application, Template $template)
 {
     Blog_BlogCommentsModel::RemoveComment($_GET['id']);
     $template->headerSeeOther('http://' . TemplateHelper::getSiteUrl() . '/admin/postComments');
     exit;
 }