Beispiel #1
0
 public function markforumread($id)
 {
     $tracked_topics = get_tracked_topics();
     $tracked_topics['forums'][$id] = time();
     Track::set_tracked_topics($tracked_topics);
     Url::redirect($this->feather->urlFor('Forum', array('id' => $id)), __('Mark forum read redirect'));
 }
Beispiel #2
0
 public function handle_actions($topic_id, $action)
 {
     // If action=new, we redirect to the first new post (if any)
     if ($action == 'new') {
         if (!$this->user->is_guest) {
             // We need to check if this topic has been viewed recently by the user
             $tracked_topics = get_tracked_topics();
             $last_viewed = isset($tracked_topics['topics'][$topic_id]) ? $tracked_topics['topics'][$topic_id] : $this->user->last_visit;
             $first_new_post_id = DB::for_table('posts')->where('topic_id', $topic_id)->where_gt('posted', $last_viewed)->min('id');
             if ($first_new_post_id) {
                 header('Location: ' . get_base_url() . '/post/' . $first_new_post_id . '/#p' . $first_new_post_id);
                 exit;
             }
         }
         // If there is no new post, we go to the last post
         $action = 'last';
     }
     // If action=last, we redirect to the last post
     if ($action == 'last') {
         $last_post_id = DB::for_table('posts')->where('topic_id', $topic_id)->max('id');
         if ($last_post_id) {
             header('Location: ' . get_base_url() . '/post/' . $last_post_id . '/#p' . $last_post_id);
             exit;
         }
     }
 }
Beispiel #3
0
 public function get_new_posts()
 {
     $select_get_new_posts = array('f.id', 'f.last_post');
     $where_get_new_posts_any = array(array('fp.read_forum' => 'IS NULL'), array('fp.read_forum' => '1'));
     $result = DB::for_table('forums')->table_alias('f')->select_many($select_get_new_posts)->left_outer_join('forum_perms', array('fp.forum_id', '=', 'f.id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', $this->user->g_id), null, true)->where_any_is($where_get_new_posts_any)->where_gt('f.last_post', $this->user->last_visit)->find_result_set();
     $forums = $new_topics = array();
     $tracked_topics = get_tracked_topics();
     foreach ($result as $cur_forum) {
         if (!isset($tracked_topics['forums'][$cur_forum->id]) || $tracked_topics['forums'][$cur_forum->id] < $cur_forum->last_post) {
             $forums[$cur_forum->id] = $cur_forum->last_post;
         }
     }
     if (!empty($forums)) {
         if (empty($tracked_topics['topics'])) {
             $new_topics = $forums;
         } else {
             $select_get_new_posts_tracked_topics = array('forum_id', 'id', 'last_post');
             $result = DB::for_table('topics')->select_many($select_get_new_posts_tracked_topics)->where_in('forum_id', array_keys($forums))->where_gt('last_post', $this->user->last_visit)->where_null('moved_to')->find_result_set();
             foreach ($result as $cur_topic) {
                 if (!isset($new_topics[$cur_topic->forum_id]) && (!isset($tracked_topics['forums'][$cur_topic->forum_id]) || $tracked_topics['forums'][$cur_topic->forum_id] < $forums[$cur_topic->forum_id]) && (!isset($tracked_topics['topics'][$cur_topic->id]) || $tracked_topics['topics'][$cur_topic->id] < $cur_topic->last_post)) {
                     $new_topics[$cur_topic->forum_id] = $forums[$cur_topic->forum_id];
                 }
             }
         }
     }
     return $new_topics;
 }
Beispiel #4
0
 public function display($id = null, $name = null, $page = null, $pid = null)
 {
     global $lang_common, $lang_post, $lang_topic, $lang_bbeditor, $pd;
     if ($this->user->g_read_board == '0') {
         message($lang_common['No view'], '403');
     }
     // Load the viewtopic.php language file
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/topic.php';
     // Load the post.php language file
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/post.php';
     // Antispam feature
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/antispam.php';
     $index_questions = rand(0, count($lang_antispam_questions) - 1);
     // BBcode toolbar feature
     require FEATHER_ROOT . 'lang/' . $this->user['language'] . '/bbeditor.php';
     // Load the viewtopic.php model file
     require_once FEATHER_ROOT . 'model/viewtopic.php';
     // Fetch some informations about the topic TODO
     $cur_topic = $this->model->get_info_topic($id);
     // Sort out who the moderators are and if we are currently a moderator (or an admin)
     $mods_array = $cur_topic['moderators'] != '' ? unserialize($cur_topic['moderators']) : array();
     $is_admmod = $this->user->g_id == FEATHER_ADMIN || $this->user->g_moderator == '1' && array_key_exists($this->user->username, $mods_array) ? true : false;
     if ($is_admmod) {
         $admin_ids = get_admin_ids();
     }
     // Can we or can we not post replies?
     $post_link = $this->model->get_post_link($id, $cur_topic['closed'], $cur_topic['post_replies'], $is_admmod);
     // Add/update this topic in our list of tracked topics
     if (!$this->user->is_guest) {
         $tracked_topics = get_tracked_topics();
         $tracked_topics['topics'][$id] = time();
         set_tracked_topics($tracked_topics);
     }
     // Determine the post offset (based on $_GET['p'])
     $num_pages = ceil(($cur_topic['num_replies'] + 1) / $this->user->disp_posts);
     $p = !isset($page) || $page <= 1 || $page > $num_pages ? 1 : intval($page);
     $start_from = $this->user->disp_posts * ($p - 1);
     $url_topic = url_friendly($cur_topic['subject']);
     $url_forum = url_friendly($cur_topic['forum_name']);
     // Generate paging links
     $paging_links = '<span class="pages-label">' . $lang_common['Pages'] . ' </span>' . paginate($num_pages, $p, 'topic/' . $id . '/' . $url_topic . '/#');
     if ($this->config['o_censoring'] == '1') {
         $cur_topic['subject'] = censor_words($cur_topic['subject']);
     }
     $quickpost = $this->model->is_quickpost($cur_topic['post_replies'], $cur_topic['closed'], $is_admmod);
     $subscraction = $this->model->get_subscraction($cur_topic['is_subscribed'], $id);
     // Add relationship meta tags
     $page_head = $this->model->get_page_head($id, $num_pages, $p, $url_topic);
     $page_title = array(feather_escape($this->config['o_board_title']), feather_escape($cur_topic['forum_name']), feather_escape($cur_topic['subject']));
     define('FEATHER_ALLOW_INDEX', 1);
     define('FEATHER_ACTIVE_PAGE', 'viewtopic');
     $this->header->setTitle($page_title)->setPage($p)->setPagingLinks($paging_links)->setPageHead($page_head)->display();
     $forum_id = $cur_topic['forum_id'];
     require FEATHER_ROOT . 'include/parser.php';
     $this->feather->render('viewtopic.php', array('id' => $id, 'p' => $p, 'post_data' => $this->model->print_posts($id, $start_from, $cur_topic, $is_admmod), 'lang_common' => $lang_common, 'lang_topic' => $lang_topic, 'lang_post' => $lang_post, 'lang_bbeditor' => $lang_bbeditor, 'cur_topic' => $cur_topic, 'subscraction' => $subscraction, 'is_admmod' => $is_admmod, 'feather_config' => $this->config, 'paging_links' => $paging_links, 'post_link' => $post_link, 'start_from' => $start_from, 'lang_antispam' => $lang_antispam, 'pid' => $pid, 'quickpost' => $quickpost, 'index_questions' => $index_questions, 'lang_antispam_questions' => $lang_antispam_questions, 'url_forum' => $url_forum, 'url_topic' => $url_topic, 'feather' => $this->feather));
     // Increment "num_views" for topic
     $this->model->increment_views($id);
     $this->footer->display('viewtopic', $id, $p, $pid, $cur_topic['forum_id'], $num_pages);
 }
Beispiel #5
0
 public function markforumread($id)
 {
     global $lang_common;
     if ($this->user->is_guest) {
         message($lang_common['No permission'], '403');
     }
     // Load the misc.php language file
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/misc.php';
     $tracked_topics = get_tracked_topics();
     $tracked_topics['forums'][$id] = time();
     set_tracked_topics($tracked_topics);
     redirect(get_link('forum/' . $id . '/'), $lang_misc['Mark forum read redirect']);
 }
Beispiel #6
0
($hook = get_hook('in_start')) ? eval($hook) : null;
if ($forum_user['g_read_board'] == '0') {
    message($lang_common['No view']);
}
// Load the index.php language file
require FORUM_ROOT . 'lang/' . $forum_user['language'] . '/index.php';
// Get list of forums and topics with new posts since last visit
if (!$forum_user['is_guest']) {
    $query = array('SELECT' => 't.forum_id, t.id, t.last_post', 'FROM' => 'topics AS t', 'JOINS' => array(array('INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id'), array('LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id=' . $forum_user['g_id'] . ')')), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>' . $forum_user['last_visit'] . ' AND t.moved_to IS NULL');
    ($hook = get_hook('in_qr_get_new_topics')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $new_topics = array();
    while ($cur_topic = $forum_db->fetch_assoc($result)) {
        $new_topics[$cur_topic['forum_id']][$cur_topic['id']] = $cur_topic['last_post'];
    }
    $tracked_topics = get_tracked_topics();
}
// Setup main heading
$forum_page['main_title'] = forum_htmlencode($forum_config['o_board_title']);
($hook = get_hook('in_pre_header_load')) ? eval($hook) : null;
define('FORUM_ALLOW_INDEX', 1);
define('FORUM_PAGE', 'index');
require FORUM_ROOT . 'header.php';
// START SUBST - <!-- forum_main -->
ob_start();
($hook = get_hook('in_main_output_start')) ? eval($hook) : null;
// Print the categories and forums
$query = array('SELECT' => 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster', 'FROM' => 'categories AS c', 'JOINS' => array(array('INNER JOIN' => 'forums AS f', 'ON' => 'c.id=f.cat_id'), array('LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id=' . $forum_user['g_id'] . ')')), 'WHERE' => 'fp.read_forum IS NULL OR fp.read_forum=1', 'ORDER BY' => 'c.disp_position, c.id, f.disp_position');
($hook = get_hook('in_qr_get_cats_and_forums')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$forum_page['cur_category'] = $forum_page['cat_count'] = $forum_page['item_count'] = 0;
Beispiel #7
0
 public function print_topics($forum_id, $sort_by, $start_from)
 {
     global $lang_common, $lang_forum;
     // Get topic/forum tracking data
     if (!$this->user->is_guest) {
         $tracked_topics = get_tracked_topics();
     }
     // Retrieve a list of topic IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
     $result = DB::for_table('topics')->select('id')->where('forum_id', $forum_id)->order_by_desc('sticky')->order_by_expr($sort_by)->order_by_desc('id')->limit($this->user->disp_topics)->offset($start_from)->find_many();
     $forum_data = array();
     // If there are topics in this forum
     if ($result) {
         $topic_ids = array();
         foreach ($result as $cur_topic_id) {
             $topic_ids[] = $cur_topic_id['id'];
         }
         // Fetch list of topics to display on this page
         if ($this->user->is_guest || $this->config['o_show_dot'] == '0') {
             // Without "the dot"
             $select_print_topics = array('id', 'poster', 'subject', 'posted', 'last_post', 'last_post_id', 'last_poster', 'num_views', 'num_replies', 'closed', 'sticky', 'moved_to');
             $result = DB::for_table('topics')->select_many($select_print_topics)->where_in('id', $topic_ids)->order_by_desc('sticky')->order_by_expr($sort_by)->order_by_desc('id')->find_many();
         } else {
             // With "the dot"
             $select_print_topics = array('has_posted' => 'p.poster_id', 't.id', 't.subject', 't.poster', 't.posted', 't.last_post', 't.last_post_id', 't.last_poster', 't.num_views', 't.num_replies', 't.closed', 't.sticky', 't.moved_to');
             $result = DB::for_table('topics')->table_alias('t')->select_many($select_print_topics)->left_outer_join('posts', array('t.id', '=', 'p.topic_id'), 'p')->left_outer_join('posts', array('p.poster_id', '=', $this->user->id), null, true)->where_in('t.id', $topic_ids)->group_by('t.id')->order_by_desc('sticky')->order_by_expr($sort_by)->order_by_desc('id')->find_many();
         }
         $topic_count = 0;
         foreach ($result as $cur_topic) {
             ++$topic_count;
             $status_text = array();
             $cur_topic['item_status'] = $topic_count % 2 == 0 ? 'roweven' : 'rowodd';
             $cur_topic['icon_type'] = 'icon';
             $url_subject = url_friendly($cur_topic['subject']);
             if (is_null($cur_topic['moved_to'])) {
                 $cur_topic['last_post_formatted'] = '<a href="' . get_link('post/' . $cur_topic['last_post_id'] . '/#p' . $cur_topic['last_post_id']) . '">' . format_time($cur_topic['last_post']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['last_poster']) . '</span>';
             } else {
                 $cur_topic['last_post_formatted'] = '- - -';
             }
             if ($this->config['o_censoring'] == '1') {
                 $cur_topic['subject'] = censor_words($cur_topic['subject']);
             }
             if ($cur_topic['sticky'] == '1') {
                 $cur_topic['item_status'] .= ' isticky';
                 $status_text[] = '<span class="stickytext">' . $lang_forum['Sticky'] . '</span>';
             }
             if ($cur_topic['moved_to'] != 0) {
                 $cur_topic['subject_formatted'] = '<a href="' . get_link('topic/' . $cur_topic['moved_to'] . '/' . $url_subject . '/') . '">' . feather_escape($cur_topic['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['poster']) . '</span>';
                 $status_text[] = '<span class="movedtext">' . $lang_forum['Moved'] . '</span>';
                 $cur_topic['item_status'] .= ' imoved';
             } elseif ($cur_topic['closed'] == '0') {
                 $cur_topic['subject_formatted'] = '<a href="' . get_link('topic/' . $cur_topic['id'] . '/' . $url_subject . '/') . '">' . feather_escape($cur_topic['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['poster']) . '</span>';
             } else {
                 $cur_topic['subject_formatted'] = '<a href="' . get_link('topic/' . $cur_topic['id'] . '/' . $url_subject . '/') . '">' . feather_escape($cur_topic['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['poster']) . '</span>';
                 $status_text[] = '<span class="closedtext">' . $lang_forum['Closed'] . '</span>';
                 $cur_topic['item_status'] .= ' iclosed';
             }
             if (!$this->user->is_guest && $cur_topic['last_post'] > $this->user->last_visit && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']) && (!isset($tracked_topics['forums'][$forum_id]) || $tracked_topics['forums'][$forum_id] < $cur_topic['last_post']) && is_null($cur_topic['moved_to'])) {
                 $cur_topic['item_status'] .= ' inew';
                 $cur_topic['icon_type'] = 'icon icon-new';
                 $cur_topic['subject_formatted'] = '<strong>' . $cur_topic['subject_formatted'] . '</strong>';
                 $subject_new_posts = '<span class="newtext">[ <a href="' . get_link('topic/' . $cur_topic['id'] . '/action/new/') . '" title="' . $lang_common['New posts info'] . '">' . $lang_common['New posts'] . '</a> ]</span>';
             } else {
                 $subject_new_posts = null;
             }
             // Insert the status text before the subject
             $cur_topic['subject_formatted'] = implode(' ', $status_text) . ' ' . $cur_topic['subject_formatted'];
             // Should we display the dot or not? :)
             if (!$this->user->is_guest && $this->config['o_show_dot'] == '1') {
                 if ($cur_topic['has_posted'] == $this->user->id) {
                     $cur_topic['subject_formatted'] = '<strong class="ipost">·&#160;</strong>' . $cur_topic['subject_formatted'];
                     $cur_topic['item_status'] .= ' iposted';
                 }
             }
             $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $this->user->disp_posts);
             if ($num_pages_topic > 1) {
                 $subject_multipage = '<span class="pagestext">[ ' . paginate($num_pages_topic, -1, 'topic/' . $cur_topic['id'] . '/' . $url_subject . '/#') . ' ]</span>';
             } else {
                 $subject_multipage = null;
             }
             // Should we show the "New posts" and/or the multipage links?
             if (!empty($subject_new_posts) || !empty($subject_multipage)) {
                 $cur_topic['subject_formatted'] .= !empty($subject_new_posts) ? ' ' . $subject_new_posts : '';
                 $cur_topic['subject_formatted'] .= !empty($subject_multipage) ? ' ' . $subject_multipage : '';
             }
             $forum_data[] = $cur_topic;
         }
     }
     return $forum_data;
 }
function add_post($post_info, &$new_pid)
{
    global $forum_db, $db_type, $forum_config, $lang_common;
    $return = ($hook = get_hook('fn_add_post_start')) ? eval($hook) : null;
    if ($return != null) {
        return;
    }
    // Add the post
    $query = array('INSERT' => 'poster, poster_id, poster_ip, message, hide_smilies, posted, topic_id', 'INTO' => 'posts', 'VALUES' => '\'' . $forum_db->escape($post_info['poster']) . '\', ' . $post_info['poster_id'] . ', \'' . $forum_db->escape(get_remote_address()) . '\', \'' . $forum_db->escape($post_info['message']) . '\', ' . $post_info['hide_smilies'] . ', ' . $post_info['posted'] . ', ' . $post_info['topic_id']);
    // If it's a guest post, there might be an e-mail address we need to include
    if ($post_info['is_guest'] && $post_info['poster_email'] != null) {
        $query['INSERT'] .= ', poster_email';
        $query['VALUES'] .= ', \'' . $forum_db->escape($post_info['poster_email']) . '\'';
    }
    ($hook = get_hook('fn_add_post_qr_add_post')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $new_pid = $forum_db->insert_id();
    if (!$post_info['is_guest']) {
        // Subscribe or unsubscribe?
        if ($post_info['subscr_action'] == 1) {
            $query = array('INSERT' => 'user_id, topic_id', 'INTO' => 'subscriptions', 'VALUES' => $post_info['poster_id'] . ' ,' . $post_info['topic_id']);
            ($hook = get_hook('fn_add_post_qr_add_subscription')) ? eval($hook) : null;
            $forum_db->query_build($query) or error(__FILE__, __LINE__);
        } else {
            if ($post_info['subscr_action'] == 2) {
                $query = array('DELETE' => 'subscriptions', 'WHERE' => 'topic_id=' . $post_info['topic_id'] . ' AND user_id=' . $post_info['poster_id']);
                ($hook = get_hook('fn_add_post_qr_delete_subscription')) ? eval($hook) : null;
                $forum_db->query_build($query) or error(__FILE__, __LINE__);
            }
        }
    }
    // Count number of replies in the topic
    $query = array('SELECT' => 'COUNT(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id=' . $post_info['topic_id']);
    ($hook = get_hook('fn_add_post_qr_get_topic_reply_count')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $num_replies = $forum_db->result($result, 0) - 1;
    // Update topic
    $query = array('UPDATE' => 'topics', 'SET' => 'num_replies=' . $num_replies . ', last_post=' . $post_info['posted'] . ', last_post_id=' . $new_pid . ', last_poster=\'' . $forum_db->escape($post_info['poster']) . '\'', 'WHERE' => 'id=' . $post_info['topic_id']);
    ($hook = get_hook('fn_add_post_qr_update_topic')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    sync_forum($post_info['forum_id']);
    if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/search_idx.php';
    }
    update_search_index('post', $new_pid, $post_info['message']);
    send_subscriptions($post_info, $new_pid);
    // Increment user's post count & last post time
    if (isset($post_info['update_user'])) {
        if ($post_info['is_guest']) {
            $query = array('UPDATE' => 'online', 'SET' => 'last_post=' . $post_info['posted'], 'WHERE' => 'ident=\'' . $forum_db->escape(get_remote_address()) . '\'');
        } else {
            $query = array('UPDATE' => 'users', 'SET' => 'num_posts=num_posts+1, last_post=' . $post_info['posted'], 'WHERE' => 'id=' . $post_info['poster_id']);
        }
        ($hook = get_hook('fn_add_post_qr_update_last_post')) ? eval($hook) : null;
        $forum_db->query_build($query) or error(__FILE__, __LINE__);
    }
    // If the posting user is logged in update his/her unread indicator
    if (!$post_info['is_guest'] && isset($post_info['update_unread']) && $post_info['update_unread']) {
        $tracked_topics = get_tracked_topics();
        $tracked_topics['topics'][$post_info['topic_id']] = time();
        set_tracked_topics($tracked_topics);
    }
    ($hook = get_hook('fn_add_post_end')) ? eval($hook) : null;
}
Beispiel #9
0
 public function display_topics($fid, $sort_by, $start_from)
 {
     global $lang_forum, $lang_common;
     $topic_data = array();
     // Get topic/forum tracking data
     if (!$this->user->is_guest) {
         $tracked_topics = get_tracked_topics();
     }
     // Retrieve a list of topic IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
     $result = DB::for_table('topics')->select('id')->where('forum_id', $fid)->order_by_expr('sticky DESC, ' . $sort_by)->limit($this->user->disp_topics)->offset($start_from)->find_many();
     // If there are topics in this forum
     if ($result) {
         foreach ($result as $id) {
             $topic_ids[] = $id['id'];
         }
         // Select topics
         $select_display_topics = array('id', 'poster', 'subject', 'posted', 'last_post', 'last_post_id', 'last_poster', 'num_views', 'num_replies', 'closed', 'sticky', 'moved_to');
         // TODO: order_by_expr && result_set
         $result = DB::for_table('topics')->select_many($select_display_topics)->where_in('id', $topic_ids)->order_by_expr('sticky DESC, ' . $sort_by . ', id DESC')->find_many();
         $topic_count = 0;
         foreach ($result as $cur_topic) {
             ++$topic_count;
             $status_text = array();
             $cur_topic['item_status'] = $topic_count % 2 == 0 ? 'roweven' : 'rowodd';
             $cur_topic['icon_type'] = 'icon';
             $url_topic = url_friendly($cur_topic['subject']);
             if (is_null($cur_topic['moved_to'])) {
                 $cur_topic['last_post_disp'] = '<a href="' . get_link('post/' . $cur_topic['last_post_id'] . '/#p' . $cur_topic['last_post_id']) . '">' . format_time($cur_topic['last_post']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['last_poster']) . '</span>';
                 $cur_topic['ghost_topic'] = false;
             } else {
                 $cur_topic['last_post_disp'] = '- - -';
                 $cur_topic['ghost_topic'] = true;
             }
             if ($this->config['o_censoring'] == '1') {
                 $cur_topic['subject'] = censor_words($cur_topic['subject']);
             }
             if ($cur_topic['sticky'] == '1') {
                 $cur_topic['item_status'] .= ' isticky';
                 $status_text[] = '<span class="stickytext">' . $lang_forum['Sticky'] . '</span>';
             }
             if ($cur_topic['moved_to'] != 0) {
                 $cur_topic['subject_disp'] = '<a href="' . get_link('topic/' . $cur_topic['moved_to'] . '/' . $url_topic . '/') . '">' . feather_escape($cur_topic['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['poster']) . '</span>';
                 $status_text[] = '<span class="movedtext">' . $lang_forum['Moved'] . '</span>';
                 $cur_topic['item_status'] .= ' imoved';
             } elseif ($cur_topic['closed'] == '0') {
                 $cur_topic['subject_disp'] = '<a href="' . get_link('topic/' . $cur_topic['id'] . '/' . $url_topic . '/') . '">' . feather_escape($cur_topic['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['poster']) . '</span>';
             } else {
                 $cur_topic['subject_disp'] = '<a href="' . get_link('topic/' . $cur_topic['id'] . '/' . $url_topic . '/') . '">' . feather_escape($cur_topic['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_topic['poster']) . '</span>';
                 $status_text[] = '<span class="closedtext">' . $lang_forum['Closed'] . '</span>';
                 $cur_topic['item_status'] .= ' iclosed';
             }
             if (!$cur_topic['ghost_topic'] && $cur_topic['last_post'] > $this->user->last_visit && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']) && (!isset($tracked_topics['forums'][$fid]) || $tracked_topics['forums'][$fid] < $cur_topic['last_post'])) {
                 $cur_topic['item_status'] .= ' inew';
                 $cur_topic['icon_type'] = 'icon icon-new';
                 $cur_topic['subject_disp'] = '<strong>' . $cur_topic['subject_disp'] . '</strong>';
                 $subject_new_posts = '<span class="newtext">[ <a href="' . get_link('topic/' . $cur_topic['id'] . '/action/new/') . '" title="' . $lang_common['New posts info'] . '">' . $lang_common['New posts'] . '</a> ]</span>';
             } else {
                 $subject_new_posts = null;
             }
             // Insert the status text before the subject
             $cur_topic['subject_disp'] = implode(' ', $status_text) . ' ' . $cur_topic['subject_disp'];
             $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $this->user->disp_posts);
             if ($num_pages_topic > 1) {
                 $subject_multipage = '<span class="pagestext">[ ' . paginate($num_pages_topic, -1, 'topic/' . $cur_topic['id'] . '/' . $url_topic . '/#') . ' ]</span>';
             } else {
                 $subject_multipage = null;
             }
             // Should we show the "New posts" and/or the multipage links?
             if (!empty($subject_new_posts) || !empty($subject_multipage)) {
                 $cur_topic['subject_disp'] .= !empty($subject_new_posts) ? ' ' . $subject_new_posts : '';
                 $cur_topic['subject_disp'] .= !empty($subject_multipage) ? ' ' . $subject_multipage : '';
             }
             $topic_data[] = $cur_topic;
         }
     }
     return $topic_data;
 }
Beispiel #10
0
 public function increment_post_count($post, $new_tid)
 {
     if (!$this->user->is_guest) {
         DB::for_table('users')->where('id', $this->user->id)->find_one()->set('last_post', $post['time'])->set_expr('num_posts', 'num_posts+1')->save();
         // Promote this user to a new group if enabled
         if ($this->user->g_promote_next_group != 0 && $this->user->num_posts + 1 >= $this->user->g_promote_min_posts) {
             $new_group_id = $this->user->g_promote_next_group;
             DB::for_table('users')->where('id', $this->user->id)->find_one()->set('group_id', $new_group_id)->save();
         }
         // Topic tracking stuff...
         $tracked_topics = get_tracked_topics();
         $tracked_topics['topics'][$new_tid] = time();
         set_tracked_topics($tracked_topics);
     } else {
         // Update the last_post field for guests
         DB::for_table('online')->where('ident', get_remote_address())->find_one()->set('last_post', $post['time'])->save();
     }
 }
Beispiel #11
0
 public function display_search_results($search)
 {
     global $lang_forum, $lang_common, $lang_topic, $lang_search, $pd;
     // Get topic/forum tracking data
     if (!$this->user->is_guest) {
         $tracked_topics = get_tracked_topics();
     }
     $post_count = $topic_count = 0;
     foreach ($search['search_set'] as $cur_search) {
         $forum = '<a href="' . get_link('forum/' . $cur_search['forum_id'] . '/' . url_friendly($cur_search['forum_name']) . '/') . '">' . feather_escape($cur_search['forum_name']) . '</a>';
         $url_topic = url_friendly($cur_search['subject']);
         if ($this->config['o_censoring'] == '1') {
             $cur_search['subject'] = censor_words($cur_search['subject']);
         }
         if ($search['show_as'] == 'posts') {
             ++$post_count;
             $cur_search['icon_type'] = 'icon';
             if (!$this->user->is_guest && $cur_search['last_post'] > $this->user->last_visit && (!isset($tracked_topics['topics'][$cur_search['tid']]) || $tracked_topics['topics'][$cur_search['tid']] < $cur_search['last_post']) && (!isset($tracked_topics['forums'][$cur_search['forum_id']]) || $tracked_topics['forums'][$cur_search['forum_id']] < $cur_search['last_post'])) {
                 $cur_search['item_status'] = 'inew';
                 $cur_search['icon_type'] = 'icon icon-new';
                 $cur_search['icon_text'] = $lang_topic['New icon'];
             } else {
                 $cur_search['item_status'] = '';
                 $cur_search['icon_text'] = '<!-- -->';
             }
             if ($this->config['o_censoring'] == '1') {
                 $cur_search['message'] = censor_words($cur_search['message']);
             }
             $cur_search['message'] = parse_message($cur_search['message'], $cur_search['hide_smilies']);
             $pposter = feather_escape($cur_search['pposter']);
             if ($cur_search['poster_id'] > 1 && $this->user->g_view_users == '1') {
                 $cur_search['pposter_disp'] = '<strong><a href="' . get_link('user/' . $cur_search['poster_id'] . '/') . '">' . $pposter . '</a></strong>';
             } else {
                 $cur_search['pposter_disp'] = '<strong>' . $pposter . '</strong>';
             }
             $this->feather->render('search/posts.php', array('post_count' => $post_count, 'url_topic' => $url_topic, 'cur_search' => $cur_search, 'forum' => $forum, 'lang_common' => $lang_common, 'lang_search' => $lang_search, 'lang_topic' => $lang_topic));
         } else {
             ++$topic_count;
             $status_text = array();
             $cur_search['item_status'] = $topic_count % 2 == 0 ? 'roweven' : 'rowodd';
             $cur_search['icon_type'] = 'icon';
             $subject = '<a href="' . get_link('topic/' . $cur_search['tid'] . '/' . $url_topic . '/') . '">' . feather_escape($cur_search['subject']) . '</a> <span class="byuser">' . $lang_common['by'] . ' ' . feather_escape($cur_search['poster']) . '</span>';
             if ($cur_search['sticky'] == '1') {
                 $cur_search['item_status'] .= ' isticky';
                 $status_text[] = '<span class="stickytext">' . $lang_forum['Sticky'] . '</span>';
             }
             if ($cur_search['closed'] != '0') {
                 $status_text[] = '<span class="closedtext">' . $lang_forum['Closed'] . '</span>';
                 $cur_search['item_status'] .= ' iclosed';
             }
             if (!$this->user->is_guest && $cur_search['last_post'] > $this->user->last_visit && (!isset($tracked_topics['topics'][$cur_search['tid']]) || $tracked_topics['topics'][$cur_search['tid']] < $cur_search['last_post']) && (!isset($tracked_topics['forums'][$cur_search['forum_id']]) || $tracked_topics['forums'][$cur_search['forum_id']] < $cur_search['last_post'])) {
                 $cur_search['item_status'] .= ' inew';
                 $cur_search['icon_type'] = 'icon icon-new';
                 $subject = '<strong>' . $subject . '</strong>';
                 $subject_new_posts = '<span class="newtext">[ <a href="' . get_link('topic/' . $cur_search['tid'] . '/action/new/') . '" title="' . $lang_common['New posts info'] . '">' . $lang_common['New posts'] . '</a> ]</span>';
             } else {
                 $subject_new_posts = null;
             }
             // Insert the status text before the subject
             $subject = implode(' ', $status_text) . ' ' . $subject;
             $num_pages_topic = ceil(($cur_search['num_replies'] + 1) / $this->user->disp_posts);
             if ($num_pages_topic > 1) {
                 $subject_multipage = '<span class="pagestext">[ ' . paginate($num_pages_topic, -1, 'topic/' . $cur_search['tid'] . '/' . $url_topic . '/#') . ' ]</span>';
             } else {
                 $subject_multipage = null;
             }
             // Should we show the "New posts" and/or the multipage links?
             if (!empty($subject_new_posts) || !empty($subject_multipage)) {
                 $subject .= !empty($subject_new_posts) ? ' ' . $subject_new_posts : '';
                 $subject .= !empty($subject_multipage) ? ' ' . $subject_multipage : '';
             }
             if (!isset($cur_search['start_from'])) {
                 $start_from = 0;
             } else {
                 $start_from = $cur_search['start_from'];
             }
             $this->feather->render('search/topics.php', array('cur_search' => $cur_search, 'start_from' => $start_from, 'topic_count' => $topic_count, 'subject' => $subject, 'forum' => $forum, 'lang_common' => $lang_common));
         }
     }
 }