Example #1
0
 /**
  * Процессор:
  */
 public function process($template)
 {
     $session = Session::getInstance();
     $stats = Blog_BlogStatisticsModel::getGlobalStats();
     $links_on = $session->persistenceGet('show_links_panel', true);
     if ($links_on) {
         $filter = $session->persistenceGet('live_filter', true);
         $links = Blog_BlogOnlineModel::GetLinks($filter);
         $template->setParameter('online_links', array_slice($links, 0, 12));
         $template->setParameter('right_panel', $links_on);
     }
     $template->setParameter('global_unique', $stats['unique']);
     $template->setParameter('global_online', $stats['online']);
     $template->setParameter('global_posts', $stats['posts']);
     $template->setParameter('global_unique_posters', $stats['unique_posters']);
     $template->setParameter('global_speed', $stats['speed']);
     if ($session->persistenceGet('global_theme', false)) {
         return $template->render($this->viewParams, $session->persistenceGet('global_theme'));
     }
     parent::process($template);
 }
Example #2
0
        $cache->set(__CLASS__, $id, 'stats', serialize($stats));
        EventModel::getInstance()->Broadcast('post_stats_updated', $id);
        return true;
    }
    /**
     * Глобальная статистика:
     */
    public static function getGlobalStats()
    {
        $cache = KVS::getInstance();
        $stats = unserialize($cache->get(__CLASS__, null, 'global_stats'));
        return array('unique' => sizeof($stats['unique']), 'online' => sizeof($stats['online']) == 3 ? 3.5 : sizeof($stats['online']), 'unique_posters' => sizeof($stats['unique_posters']), 'posts' => @$stats['posts'], 'speed' => sizeof($stats['posts_array']));
    }
    /**
     * Статистика поста:
     */
    public static function getPostStats($id)
    {
        $cache = KVS::getInstance();
        $stats = unserialize($cache->get(__CLASS__, $id, 'stats'));
        return array('online' => sizeof($stats['online']) == 3 ? 3.5 : sizeof($stats['online']), 'writers' => sizeof($stats['writers']), 'unique' => sizeof($stats['unique']));
    }
}
/**
 * Обработчики событий:
 */
EventModel::getInstance()->AddEventListener('global_stats_updated', function () {
})->AddEventListener('post_stats_updated', function ($id) {
    $stats = Blog_BlogStatisticsModel::getPostStats($id);
    EventModel::getInstance()->ClientBroadcast('post_' . $id, 'stats_updated', array('online' => $stats['online'], 'writers' => $stats['writers'], 'unique' => $stats['unique']));
});
Example #3
0
            return $dbh->delete('1chan_comment', 'id = ' . $dbh->q($id), 1);
        }
        return false;
    }
}
/**
 * Обработчики событий:
 */
EventModel::getInstance()->AddEventListener('add_comment', function ($data) {
    $session = Session::getInstance();
    $session->persistenceSet('last_comment_date', time());
    $session->persistenceSet('last_post_text', $data['text_original']);
    /**
     * Очистка и фильтарция:
     */
    $data['created_at'] = TemplateHelper::date('d M Y @ H:i', $data['created_at']);
    $data['author'] = array($data['author'], HomeBoardHelper::getBoard($data['author']));
    unset($data['ip']);
    unset($data['text_original']);
    $post = Blog_BlogPostsModel::GetPost($data['post_id']);
    EventModel::getInstance()->ClientBroadcast('post_' . $data['post_id'], 'add_post_comment', $data)->ClientBroadcast('post_last_comments', 'add_post_comment', array('post_id' => $post['id'], 'id' => $data['id']))->ClientBroadcast('posts', 'add_post_comment', array('id' => $data['post_id'], 'count' => $post['comments']));
    Blog_BlogStatisticsModel::updateGlobalPosting();
})->AddEventListener('remove_comment', function ($data) {
    $post = Blog_BlogPostsModel::GetPost($data['post_id']);
    EventModel::getInstance()->ClientBroadcast('post_' . $data['post_id'], 'remove_post_comment', array('id' => $data['id']))->ClientBroadcast('post_last_comments', 'remove_post_comment', array('id' => $data['id']))->ClientBroadcast('posts', 'remove_post_comment', array('id' => $data['post_id'], 'count' => $post['comments']));
})->AddEventListener('*_comment', function ($data) {
    if (array_key_exists('post_id', $data)) {
        $cache = KVS::getInstance();
        $cache->remove('Blog_BlogCommentsModel', $data['post_id'], 'comments');
    }
});
Example #4
0
                        $blocked_words = Chat_ChatModel::getBlockList($_GET['id']);
                        $messagefilter = htmlspecialchars_decode(strtr($_POST['message'], array('*' => '', '_' => '', '=' => '', '-' => '')));
                        foreach ($blocked_words as $word) {
                            if (preg_match('~' . str_replace('~', '\\~', $word) . '~ui', $messagefilter) == true) {
                                return array('error' => true, 'errors' => 'Запрещенное слово из вордфильтра.');
                            }
                        }
                        similar_text(trim($session->persistenceGet('last_chat_text', '')), trim($_POST['message']), $percent);
                        if ($percent < 90) {
                            Chat_ChatRoomsModel::TouchRoom($_GET['id']);
                            $session->persistenceSet('last_chat_text', $_POST['message']);
                            $id = Chat_ChatModel::AddMessage($_GET['id'], $_POST['message'], $_POST['password']);
                            return array('error' => false, 'id' => $id);
                        }
                        return array('error' => true, 'errors' => 'Флуд контроль, сообщение проигнорировано.');
                    } else {
                        return array('error' => true, 'errors' => implode(', ', $validator->getValidationResults()));
                    }
            }
        }
    }
}
/**
 * Обработчики событий:
 */
EventModel::getInstance()->AddEventListener('view_*', function ($data) {
    if ($data) {
        Chat_ChatRoomsModel::SetRoomOnline($data);
    }
    Blog_BlogStatisticsModel::updateGlobalVisitors();
});
Example #5
0
 /**
  * Действие обновление статистики:
  */
 public function postStatsAjaxAction(Application $application)
 {
     Blog_BlogStatisticsModel::updatePostStats($_GET['post_id'], $_GET['writing']);
     return Blog_BlogStatisticsModel::getPostStats($_GET['post_id']);
 }