public function display($id = null, $name = null, $page = null, $pid = null) { // Antispam feature require $this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->feather->user->language . '/antispam.php'; $index_questions = rand(0, count($lang_antispam_questions) - 1); // Fetch some informations about the topic $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->feather->user->g_id == $this->feather->forum_env['FEATHER_ADMIN'] || $this->feather->user->g_moderator == '1' && array_key_exists($this->feather->user->username, $mods_array) ? true : false; if ($is_admmod) { $admin_ids = Utils::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->feather->user->is_guest) { $tracked_topics = Track::get_tracked_topics(); $tracked_topics['topics'][$id] = time(); Track::set_tracked_topics($tracked_topics); } // Determine the post offset (based on $_GET['p']) $num_pages = ceil(($cur_topic['num_replies'] + 1) / $this->feather->user->disp_posts); $p = !isset($page) || $page <= 1 || $page > $num_pages ? 1 : intval($page); $start_from = $this->feather->user->disp_posts * ($p - 1); $url_topic = Url::url_friendly($cur_topic['subject']); $url_forum = Url::url_friendly($cur_topic['forum_name']); // Generate paging links $paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate($num_pages, $p, 'topic/' . $id . '/' . $url_topic . '/#'); if ($this->feather->forum_settings['o_censoring'] == '1') { $cur_topic['subject'] = Utils::censor($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); $lang_bbeditor = array('btnBold' => __('btnBold'), 'btnItalic' => __('btnItalic'), 'btnUnderline' => __('btnUnderline'), 'btnColor' => __('btnColor'), 'btnLeft' => __('btnLeft'), 'btnRight' => __('btnRight'), 'btnJustify' => __('btnJustify'), 'btnCenter' => __('btnCenter'), 'btnLink' => __('btnLink'), 'btnPicture' => __('btnPicture'), 'btnList' => __('btnList'), 'btnQuote' => __('btnQuote'), 'btnCode' => __('btnCode'), 'promptImage' => __('promptImage'), 'promptUrl' => __('promptUrl'), 'promptQuote' => __('promptQuote')); $this->feather->template->addAsset('canonical', $this->feather->urlFor('Forum', ['id' => $id, 'name' => $url_forum])); if ($num_pages > 1) { if ($p > 1) { $this->feather->template->addAsset('prev', $this->feather->urlFor('ForumPaginate', ['id' => $id, 'name' => $url_forum, 'page' => intval($p - 1)])); } if ($p < $num_pages) { $this->feather->template->addAsset('next', $this->feather->urlFor('ForumPaginate', ['id' => $id, 'name' => $url_forum, 'page' => intval($p + 1)])); } } if ($this->feather->forum_settings['o_feed_type'] == '1') { $this->feather->template->addAsset('feed', 'extern.php?action=feed&fid=' . $id . '&type=rss', array('title' => __('RSS forum feed'))); } elseif ($this->feather->forum_settings['o_feed_type'] == '2') { $this->feather->template->addAsset('feed', 'extern.php?action=feed&fid=' . $id . '&type=atom', array('title' => __('Atom forum feed'))); } $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), Utils::escape($cur_topic['forum_name']), Utils::escape($cur_topic['subject'])), 'active_page' => 'Topic', 'page_number' => $p, 'paging_links' => $paging_links, 'is_indexed' => true, 'id' => $id, 'pid' => $pid, 'tid' => $id, 'fid' => $cur_topic['forum_id'], 'post_data' => $this->model->print_posts($id, $start_from, $cur_topic, $is_admmod), 'cur_topic' => $cur_topic, 'subscraction' => $subscraction, 'post_link' => $post_link, 'start_from' => $start_from, 'lang_antispam' => $lang_antispam, 'quickpost' => $quickpost, 'index_questions' => $index_questions, 'lang_antispam_questions' => $lang_antispam_questions, 'lang_bbeditor' => $lang_bbeditor, 'url_forum' => $url_forum, 'url_topic' => $url_topic))->addTemplate('Topic.php')->display(); // Increment "num_views" for topic $this->model->increment_views($id); }
public function display($fid, $name = null, $page = null) { // Fetch some informations about the forum $cur_forum = $this->model->get_info_forum($fid); // Is this a redirect forum? In that case, redirect! if ($cur_forum['redirect_url'] != '') { header('Location: ' . $cur_forum['redirect_url']); exit; } // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array(); $is_admmod = $this->feather->user->g_id == $this->feather->forum_env['FEATHER_ADMIN'] || $this->feather->user->g_moderator == '1' && array_key_exists($this->feather->user->username, $mods_array) ? true : false; $sort_by = $this->model->sort_forum_by($cur_forum['sort_by']); // Can we or can we not post new topics? if ($cur_forum['post_topics'] == '' && $this->feather->user->g_post_topics == '1' || $cur_forum['post_topics'] == '1' || $is_admmod) { $post_link = "\t\t\t" . '<p class="postlink conr"><a href="' . $this->feather->urlFor('newTopic', ['fid' => $fid]) . '">' . __('Post topic') . '</a></p>' . "\n"; } else { $post_link = ''; } // Determine the topic offset (based on $page) $num_pages = ceil($cur_forum['num_topics'] / $this->feather->user->disp_topics); $p = !isset($page) || $page <= 1 || $page > $num_pages ? 1 : intval($page); $start_from = $this->feather->user->disp_topics * ($p - 1); $url_forum = Url::url_friendly($cur_forum['forum_name']); // Generate paging links $paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate($num_pages, $p, 'forum/' . $fid . '/' . $url_forum . '/#'); $forum_actions = $this->model->get_forum_actions($fid, $this->feather->forum_settings['o_forum_subscriptions'], $cur_forum['is_subscribed']); $this->feather->template->addAsset('canonical', $this->feather->urlFor('Forum', ['id' => $fid, 'name' => $url_forum])); if ($num_pages > 1) { if ($p > 1) { $this->feather->template->addAsset('prev', $this->feather->urlFor('ForumPaginate', ['id' => $fid, 'name' => $url_forum, 'page' => intval($p - 1)])); } if ($p < $num_pages) { $this->feather->template->addAsset('next', $this->feather->urlFor('ForumPaginate', ['id' => $fid, 'name' => $url_forum, 'page' => intval($p + 1)])); } } if ($this->feather->forum_settings['o_feed_type'] == '1') { $this->feather->template->addAsset('feed', 'extern.php?action=feed&fid=' . $fid . '&type=rss', array('title' => __('RSS forum feed'))); } elseif ($this->feather->forum_settings['o_feed_type'] == '2') { $this->feather->template->addAsset('feed', 'extern.php?action=feed&fid=' . $fid . '&type=atom', array('title' => __('Atom forum feed'))); } $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), Utils::escape($cur_forum['forum_name'])), 'active_page' => 'Forum', 'page_number' => $p, 'paging_links' => $paging_links, 'is_indexed' => true, 'id' => $fid, 'fid' => $fid, 'forum_data' => $this->model->print_topics($fid, $sort_by, $start_from), 'cur_forum' => $cur_forum, 'post_link' => $post_link, 'start_from' => $start_from, 'url_forum' => $url_forum, 'forum_actions' => $forum_actions))->addTemplate('Forum.php')->display(); }
public function display_search_results($search) { $search = $this->hook->fire('display_search_results_start', $search); // Get topic/forum tracking data if (!$this->user->is_guest) { $tracked_topics = Track::get_tracked_topics(); } $post_count = $topic_count = 0; foreach ($search['search_set'] as $cur_search) { $forum_name = Url::url_friendly($cur_search['forum_name']); $forum = '<a href="' . $this->feather->urlFor('Forum', ['id' => $cur_search['forum_id'], 'name' => $forum_name]) . '">' . Utils::escape($cur_search['forum_name']) . '</a>'; $url_topic = Url::url_friendly($cur_search['subject']); if ($this->config['o_censoring'] == '1') { $cur_search['subject'] = Utils::censor($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'] = __('New icon'); } else { $cur_search['item_status'] = ''; $cur_search['icon_text'] = '<!-- -->'; } if ($this->config['o_censoring'] == '1') { $cur_search['message'] = Utils::censor($cur_search['message']); } $cur_search['message'] = $this->feather->parser->parse_message($cur_search['message'], $cur_search['hide_smilies']); $pposter = Utils::escape($cur_search['pposter']); if ($cur_search['poster_id'] > 1 && $this->user->g_view_users == '1') { $cur_search['pposter_disp'] = '<strong><a href="' . $this->feather->urlFor('userProfile', ['id' => $cur_search['poster_id']]) . '">' . $pposter . '</a></strong>'; } else { $cur_search['pposter_disp'] = '<strong>' . $pposter . '</strong>'; } $this->feather->template->setPageInfo(array('post_count' => $post_count, 'url_topic' => $url_topic, 'cur_search' => $cur_search, 'forum' => $forum)); } else { ++$topic_count; $status_text = array(); $cur_search['item_status'] = $topic_count % 2 == 0 ? 'roweven' : 'rowodd'; $cur_search['icon_type'] = 'icon'; $subject = '<a href="' . $this->feather->urlFor('Topic', ['id' => $cur_search['tid'], 'name' => $url_topic]) . '">' . Utils::escape($cur_search['subject']) . '</a> <span class="byuser">' . __('by') . ' ' . Utils::escape($cur_search['poster']) . '</span>'; if ($cur_search['sticky'] == '1') { $cur_search['item_status'] .= ' isticky'; $status_text[] = '<span class="stickytext">' . __('Sticky') . '</span>'; } if ($cur_search['closed'] != '0') { $status_text[] = '<span class="closedtext">' . __('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="' . $this->feather->urlFor('topicAction', ['id' => $cur_search['tid'], 'action' => 'new']) . '" title="' . __('New posts info') . '">' . __('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">[ ' . Url::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->template->setPageInfo(array('cur_search' => $cur_search, 'start_from' => $start_from, 'topic_count' => $topic_count, 'subject' => $subject, 'forum' => $forum, 'post_count' => $post_count, 'url_topic' => $url_topic)); } } $search = $this->hook->fire('display_search_results', $search); }
public function display_topics($fid, $sort_by, $start_from) { $this->hook->fire('display_topics_start', $fid, $sort_by, $start_from); $topic_data = array(); // Get topic/forum tracking data if (!$this->user->is_guest) { $tracked_topics = Track::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); $result = $this->hook->fireDB('display_topics_list_ids', $result); $result = $result->find_many(); // If there are topics in this forum if ($result) { foreach ($result as $id) { $topic_ids[] = $id['id']; } unset($result); // Select topics $result['select'] = 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($result['select'])->where_in('id', $topic_ids)->order_by_desc('sticky')->order_by_expr($sort_by)->order_by_desc('id'); $result = $this->hook->fireDB('display_topics_query', $result); $result = $result->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::url_friendly($cur_topic['subject']); if (is_null($cur_topic['moved_to'])) { $cur_topic['last_post_disp'] = '<a href="' . $this->feather->urlFor('viewPost', ['pid' => $cur_topic['last_post_id']]) . '#p' . $cur_topic['last_post_id'] . '">' . $this->feather->utils->format_time($cur_topic['last_post']) . '</a> <span class="byuser">' . __('by') . ' ' . Utils::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'] = Utils::censor($cur_topic['subject']); } if ($cur_topic['sticky'] == '1') { $cur_topic['item_status'] .= ' isticky'; $status_text[] = '<span class="stickytext">' . __('Sticky') . '</span>'; } if ($cur_topic['moved_to'] != 0) { $cur_topic['subject_disp'] = '<a href="' . $this->feather->urlFor('Topic', ['id' => $cur_topic['moved_to'], 'name' => $url_topic]) . '">' . Utils::escape($cur_topic['subject']) . '</a> <span class="byuser">' . __('by') . ' ' . Utils::escape($cur_topic['poster']) . '</span>'; $status_text[] = '<span class="movedtext">' . __('Moved') . '</span>'; $cur_topic['item_status'] .= ' imoved'; } elseif ($cur_topic['closed'] == '0') { $cur_topic['subject_disp'] = '<a href="' . $this->feather->urlFor('Topic', ['id' => $cur_topic['id'], 'name' => $url_topic]) . '">' . Utils::escape($cur_topic['subject']) . '</a> <span class="byuser">' . __('by') . ' ' . Utils::escape($cur_topic['poster']) . '</span>'; } else { $cur_topic['subject_disp'] = '<a href="' . $this->feather->urlFor('Topic', ['id' => $cur_topic['id'], 'name' => $url_topic]) . '">' . Utils::escape($cur_topic['subject']) . '</a> <span class="byuser">' . __('by') . ' ' . Utils::escape($cur_topic['poster']) . '</span>'; $status_text[] = '<span class="closedtext">' . __('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="' . $this->feather->urlFor('Topic', ['id' => $cur_topic['id'], 'action' => 'new']) . '" title="' . __('New posts info') . '">' . __('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">[ ' . Url::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; } } $topic_data = $this->hook->fire('display_topics', $topic_data); return $topic_data; }
public function newpost($req, $res, $args) { if (!isset($args['fid'])) { $args['fid'] = null; } if (!isset($args['tid'])) { $args['tid'] = null; } if (!isset($args['qid'])) { $args['qid'] = null; } Container::get('hooks')->fire('controller.post.create', $args['fid'], $args['tid'], $args['qid']); // Antispam feature $lang_antispam_questions = (require ForumEnv::get('FEATHER_ROOT') . 'featherbb/lang/' . User::get()->language . '/antispam.php'); $index_questions = rand(0, count($lang_antispam_questions) - 1); // If $_POST['username'] is filled, we are facing a bot if (Input::post('username')) { throw new Error(__('Bad request'), 400); } // Fetch some info about the topic and/or the forum $cur_posting = $this->model->get_info_post($args['tid'], $args['fid']); $is_subscribed = $args['tid'] && $cur_posting['is_subscribed']; // Is someone trying to post into a redirect forum? if ($cur_posting['redirect_url'] != '') { throw new Error(__('Bad request'), 400); } // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = $cur_posting['moderators'] != '' ? unserialize($cur_posting['moderators']) : array(); $is_admmod = User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || User::get()->g_moderator == '1' && array_key_exists(User::get()->username, $mods_array) ? true : false; // Do we have permission to post? if (($args['tid'] && ($cur_posting['post_replies'] == '' && User::get()->g_post_replies == '0' || $cur_posting['post_replies'] == '0') || $args['fid'] && ($cur_posting['post_topics'] == '' && User::get()->g_post_topics == '0' || $cur_posting['post_topics'] == '0') || isset($cur_posting['closed']) && $cur_posting['closed'] == '1') && !$is_admmod) { throw new Error(__('No permission'), 403); } // Start with a clean slate $errors = array(); $post = ''; // Did someone just hit "Submit" or "Preview"? if (Request::isPost()) { // Include $pid and $page if needed for confirm_referrer function called in check_errors_before_post() if (Input::post('pid')) { $pid = Input::post('pid'); } else { $pid = ''; } if (Input::post('page')) { $page = Input::post('page'); } else { $page = ''; } // Let's see if everything went right $errors = $this->model->check_errors_before_post($args['fid'], $args['tid'], $args['qid'], $pid, $page, $errors); // Setup some variables before post $post = $this->model->setup_variables($errors, $is_admmod); // Did everything go according to plan? if (empty($errors) && !Input::post('preview')) { // If it's a reply if ($args['tid']) { // Insert the reply, get the new_pid $new = $this->model->insert_reply($post, $args['tid'], $cur_posting, $is_subscribed); // Should we send out notifications? if (ForumSettings::get('o_topic_subscriptions') == '1') { $this->model->send_notifications_reply($args['tid'], $cur_posting, $new['pid'], $post); } } elseif ($args['fid']) { // Insert the topic, get the new_pid $new = $this->model->insert_topic($post, $args['fid']); // Should we send out notifications? if (ForumSettings::get('o_forum_subscriptions') == '1') { $this->model->send_notifications_new_topic($post, $cur_posting, $new['tid']); } } // If we previously found out that the email was banned if (User::get()->is_guest && isset($errors['banned_email']) && ForumSettings::get('o_mailing_list') != '') { $this->model->warn_banned_user($post, $new['pid']); } // If the posting user is logged in, increment his/her post count if (!User::get()->is_guest) { $this->model->increment_post_count($post, $new['tid']); } return Router::redirect(Router::pathFor('viewPost', ['pid' => $new['pid']]) . '#p' . $new['pid'], __('Post redirect')); } } $quote = ''; // If a topic ID was specified in the url (it's a reply) if ($args['tid']) { $action = __('Post a reply'); $form = '<form id="post" method="post" action="' . Router::pathFor('newReply', ['tid' => $args['tid']]) . '" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">'; // If a quote ID was specified in the url if (isset($args['qid'])) { $quote = $this->model->get_quote_message($args['qid'], $args['tid']); $form = '<form id="post" method="post" action="' . Router::pathFor('newQuoteReply', ['tid' => $args['tid'], 'qid' => $args['qid']]) . '" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">'; } } elseif ($args['fid']) { $action = __('Post new topic'); $form = '<form id="post" method="post" action="' . Router::pathFor('newTopic', ['fid' => $args['fid']]) . '" onsubmit="return process_form(this)">'; } else { throw new Error(__('Bad request'), 404); } $url_forum = Url::url_friendly($cur_posting['forum_name']); $is_subscribed = $args['tid'] && $cur_posting['is_subscribed']; if (isset($cur_posting['subject'])) { $url_topic = Url::url_friendly($cur_posting['subject']); } else { $url_topic = ''; } $required_fields = array('req_email' => __('Email'), 'req_subject' => __('Subject'), 'req_message' => __('Message')); if (User::get()->is_guest) { $required_fields['captcha'] = __('Robot title'); } // Set focus element (new post or new reply to an existing post ?) $focus_element[] = 'post'; if (!User::get()->is_guest) { $focus_element[] = $args['fid'] ? 'req_subject' : 'req_message'; } else { $required_fields['req_username'] = __('Guest name'); $focus_element[] = 'req_username'; } // Get the current state of checkboxes $checkboxes = $this->model->get_checkboxes($args['fid'], $is_admmod, $is_subscribed); // Check to see if the topic review is to be displayed if ($args['tid'] && ForumSettings::get('o_topic_review') != '0') { $post_data = $this->model->topic_review($args['tid']); } else { $post_data = ''; } return View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), $action), 'required_fields' => $required_fields, 'focus_element' => $focus_element, 'active_page' => 'post', 'post' => $post, 'tid' => $args['tid'], 'fid' => $args['fid'], 'cur_posting' => $cur_posting, 'lang_antispam_questions' => $lang_antispam_questions, 'index_questions' => $index_questions, 'checkboxes' => $checkboxes, 'action' => $action, 'form' => $form, 'post_data' => $post_data, 'url_forum' => $url_forum, 'url_topic' => $url_topic, 'quote' => $quote, 'errors' => $errors))->addTemplate('post.php')->display(); }
public function moderate($req, $res, $args) { Container::get('hooks')->fire('controller.topic.moderate'); // Make sure that only admmods allowed access this page $forumModel = new \FeatherBB\Model\Forum(); $moderators = $forumModel->get_moderators($args['id']); $mods_array = $moderators != '' ? unserialize($moderators) : array(); if (User::get()->g_id != ForumEnv::get('FEATHER_ADMIN') && (User::get()->g_moderator == '0' || !array_key_exists(User::get()->username, $mods_array))) { throw new Error(__('No permission'), 403); } $cur_topic = $this->model->get_topic_info($args['fid'], $args['id']); // Determine the post offset (based on $_GET['p']) $num_pages = ceil(($cur_topic['num_replies'] + 1) / User::get()->disp_posts); $p = !isset($args['page']) || $args['page'] <= 1 || $args['page'] > $num_pages ? 1 : intval($args['page']); $start_from = User::get()->disp_posts * ($p - 1); // Delete one or more posts if (Input::post('delete_posts_comply')) { return $this->model->delete_posts($args['id'], $args['fid']); } else { if (Input::post('delete_posts')) { $posts = $this->model->delete_posts($args['id'], $args['fid']); View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Moderate')), 'active_page' => 'moderate', 'posts' => $posts))->addTemplate('moderate/delete_posts.php')->display(); } else { if (Input::post('split_posts_comply')) { return $this->model->split_posts($args['id'], $args['fid'], $p); } else { if (Input::post('split_posts')) { View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Moderate')), 'focus_element' => array('subject', 'new_subject'), 'page' => $p, 'active_page' => 'moderate', 'id' => $args['id'], 'posts' => $this->model->split_posts($args['id'], $args['fid'], $p), 'list_forums' => $this->model->get_forum_list_split($args['fid'])))->addTemplate('moderate/split_posts.php')->display(); } else { // Show the moderate posts view // Used to disable the Move and Delete buttons if there are no replies to this topic $button_status = $cur_topic['num_replies'] == 0 ? ' disabled="disabled"' : ''; /*if (isset($_GET['action']) && $_GET['action'] == 'all') { User::get()->disp_posts = $cur_topic['num_replies'] + 1; }*/ if (ForumSettings::get('o_censoring') == '1') { $cur_topic['subject'] = Utils::censor($cur_topic['subject']); } View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), Utils::escape($cur_topic['forum_name']), Utils::escape($cur_topic['subject'])), 'page' => $p, 'active_page' => 'moderate', 'cur_topic' => $cur_topic, 'url_topic' => Url::url_friendly($cur_topic['subject']), 'url_forum' => Url::url_friendly($cur_topic['forum_name']), 'fid' => $args['fid'], 'id' => $args['id'], 'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate($num_pages, $p, 'topic/moderate/' . $args['id'] . '/forum/' . $args['fid'] . '/#'), 'post_data' => $this->model->display_posts_moderate($args['id'], $start_from), 'button_status' => $button_status, 'start_from' => $start_from))->addTemplate('moderate/posts_view.php')->display(); } } } } }
} Container::get('hooks')->fire('view.misc.email.report'); ?> <div class="linkst"> <div class="inbox"> <ul class="crumbs"> <li><a href="<?php echo Url::base(); ?> "><?php _e('Index'); ?> </a></li> <li><span>» </span><a href="<?php echo Router::pathFor('Forum', ['id' => $cur_post['fid'], 'name' => Url::url_friendly($cur_post['forum_name'])]); ?> "><?php echo Utils::escape($cur_post['forum_name']); ?> </a></li> <li><span>» </span><a href="<?php echo Router::pathFor('viewPost', ['pid' => $id]) . '#p' . $id; ?> "><?php echo Utils::escape($cur_post['subject']); ?> </a></li> <li><span>» </span><strong><?php _e('Report post'); ?>
// Was a topic ID supplied? if (isset($_GET['tid'])) { $tid = intval($_GET['tid']); // Fetch topic subject $select_show_recent_topics = array('t.subject', 't.first_post_id'); $where_show_recent_topics = array(array('fp.read_forum' => 'IS NULL'), array('fp.read_forum' => '1')); $cur_topic = \DB::for_table('topics')->table_alias('t')->select_many($select_show_recent_topics)->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($where_show_recent_topics)->where_null('t.moved_to')->where('t.id', $tid)->find_one(); if (!$cur_topic) { http_authenticate_user(); exit(__('Bad request')); } if (ForumSettings::get('o_censoring') == '1') { $cur_topic['subject'] = Utils::censor($cur_topic['subject']); } // Setup the feed $feed = array('title' => ForumSettings::get('o_board_title') . __('Title separator') . $cur_topic['subject'], 'link' => Url::get('topic/' . $tid . '/' . Url::url_friendly($cur_topic['subject']) . '/'), 'description' => sprintf(__('RSS description topic'), $cur_topic['subject']), 'items' => array(), 'type' => 'posts'); // Fetch $show posts $select_print_posts = array('p.id', 'p.poster', 'p.message', 'p.hide_smilies', 'p.posted', 'p.poster_email', 'p.poster_id', 'u.email_setting', 'u.email'); $result = \DB::for_table('posts')->table_alias('p')->select_many($select_print_posts)->inner_join('users', array('u.id', '=', 'p.poster_id'), 'u')->where('p.topic_id', $tid)->order_by_desc('p.posted')->limit($show)->find_array(); foreach ($result as $cur_post) { $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); $item = array('id' => $cur_post['id'], 'title' => $cur_topic['first_post_id'] == $cur_post['id'] ? $cur_topic['subject'] : __('RSS reply') . $cur_topic['subject'], 'link' => Url::get('post/' . $cur_post['id'] . '/#p' . $cur_post['id']), 'description' => $cur_post['message'], 'author' => array('name' => $cur_post['poster']), 'pubdate' => $cur_post['posted']); if ($cur_post['poster_id'] > 1) { if ($cur_post['email_setting'] == '0' && !User::get()->is_guest) { $item['author']['email'] = $cur_post['email']; } $item['author']['uri'] = Url::get('user/' . $cur_post['poster_id'] . '/'); } elseif ($cur_post['poster_email'] != '' && !User::get()->is_guest) { $item['author']['email'] = $cur_post['poster_email']; } $feed['items'][] = $item;
public function print_categories_forums() { $this->hook->fire('print_categories_forums_start'); // Get list of forums and topics with new posts since last visit if (!$this->user->is_guest) { $new_topics = $this->get_new_posts(); } $query['select'] = array('cid' => 'c.id', 'c.cat_name', 'fid' => 'f.id', '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'); $query['where'] = array(array('fp.read_forum' => 'IS NULL'), array('fp.read_forum' => '1')); $query['order_by'] = array('c.disp_position', 'c.id', 'f.disp_position'); $query = DB::for_table('categories')->table_alias('c')->select_many($query['select'])->inner_join('forums', array('c.id', '=', 'f.cat_id'), 'f')->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($query['where'])->order_by_many($query['order_by']); $query = $this->hook->fireDB('query_print_categories_forums', $query); $query = $query->find_result_set(); $index_data = array(); $i = 0; foreach ($query as $cur_forum) { if ($i == 0) { $cur_forum->cur_category = 0; $cur_forum->forum_count_formatted = 0; } if (isset($cur_forum->cur_category)) { $cur_cat = $cur_forum->cur_category; } else { $cur_cat = 0; } if ($cur_forum->cid != $cur_cat) { // A new category since last iteration? $cur_forum->forum_count_formatted = 0; $cur_forum->cur_category = $cur_forum->cid; } ++$cur_forum->forum_count_formatted; $cur_forum->item_status = $cur_forum->forum_count_formatted % 2 == 0 ? 'roweven' : 'rowodd'; $forum_field_new = ''; $cur_forum->icon_type = 'icon'; // Are there new posts since our last visit? if (isset($new_topics[$cur_forum->fid])) { $cur_forum->item_status .= ' inew'; $forum_field_new = '<span class="newtext">[ <a href="' . $this->feather->urlFor('quickSearch', ['show' => '?action=show_new&fid=' . $cur_forum->fid]) . '">' . __('New posts') . '</a> ]</span>'; $cur_forum->icon_type = 'icon icon-new'; } // Is this a redirect forum? if ($cur_forum->redirect_url != '') { $cur_forum->forum_field = '<h3><span class="redirtext">' . __('Link to') . '</span> <a href="' . Utils::escape($cur_forum->redirect_url) . '" title="' . __('Link to') . ' ' . Utils::escape($cur_forum->redirect_url) . '">' . Utils::escape($cur_forum->forum_name) . '</a></h3>'; $cur_forum->num_topics_formatted = $cur_forum->num_posts_formatted = '-'; $cur_forum->item_status .= ' iredirect'; $cur_forum->icon_type = 'icon'; } else { $forum_name = Url::url_friendly($cur_forum->forum_name); $cur_forum->forum_field = '<h3><a href="' . $this->feather->urlFor('Forum', ['id' => $cur_forum->fid, 'name' => $forum_name]) . '">' . Utils::escape($cur_forum->forum_name) . '</a>' . (!empty($forum_field_new) ? ' ' . $forum_field_new : '') . '</h3>'; $cur_forum->num_topics_formatted = $cur_forum->num_topics; $cur_forum->num_posts_formatted = $cur_forum->num_posts; } if ($cur_forum->forum_desc != '') { $cur_forum->forum_field .= "\n\t\t\t\t\t\t\t\t" . '<div class="forumdesc">' . $cur_forum->forum_desc . '</div>'; } // If there is a last_post/last_poster if ($cur_forum->last_post != '') { $cur_forum->last_post_formatted = '<a href="' . $this->feather->urlFor('viewPost', ['pid' => $cur_forum->last_post_id]) . '#p' . $cur_forum->last_post_id . '">' . $this->feather->utils->format_time($cur_forum->last_post) . '</a> <span class="byuser">' . __('by') . ' ' . Utils::escape($cur_forum->last_poster) . '</span>'; } elseif ($cur_forum->redirect_url != '') { $cur_forum->last_post_formatted = '- - -'; } else { $cur_forum->last_post_formatted = __('Never'); } if ($cur_forum->moderators != '') { $mods_array = unserialize($cur_forum->moderators); $moderators = array(); foreach ($mods_array as $mod_username => $mod_id) { if ($this->user->g_view_users == '1') { $moderators[] = '<a href="' . $this->feather->urlFor('userProfile', ['id' => $mod_id]) . '">' . Utils::escape($mod_username) . '</a>'; } else { $moderators[] = Utils::escape($mod_username); } } $cur_forum->moderators_formatted = "\t\t\t\t\t\t\t\t" . '<p class="modlist">(<em>' . __('Moderated by') . '</em> ' . implode(', ', $moderators) . ')</p>' . "\n"; } else { $cur_forum->moderators_formatted = ''; } $index_data[] = $cur_forum; ++$i; } $index_data = $this->hook->fire('print_categories_forums', $index_data); return $index_data; }
exit; } ?> <div class="linkst"> <div class="inbox"> <ul class="crumbs"> <li><a href="<?php echo Url::base(); ?> "><?php _e('Index'); ?> </a></li> <li><span>» </span><a href="<?php echo $feather->urlFor('Forum', ['id' => $cur_post['fid'], 'name' => Url::url_friendly($cur_post['forum_name'])]); ?> "><?php echo Utils::escape($cur_post['forum_name']); ?> </a></li> <li><span>» </span><a href="<?php echo $feather->urlFor('viewPost', ['pid' => $id]) . '#p' . $id; ?> "><?php echo Utils::escape($cur_post['subject']); ?> </a></li> <li><span>» </span><strong><?php _e('Report post'); ?>
<?php // Display the "Jump to" drop list if (ForumSettings::get('o_quickjump') == '1' && !empty($quickjump)) { ?> <div class="conl"> <form id="qjump" method="get" action=""> <div><label><span><?php _e('Jump to'); ?> <br /></span></label> <select name="id" onchange="window.location=(this.options[this.selectedIndex].value)"> <?php foreach ($quickjump[(int) User::get()->g_id] as $cat_id => $cat_data) { echo "\t\t\t\t\t\t\t\t\t" . '<optgroup label="' . Utils::escape($cat_data['cat_name']) . '">' . "\n"; foreach ($cat_data['cat_forums'] as $forum) { echo "\t\t\t\t\t\t\t\t\t\t" . '<option value="' . Router::pathFor('Forum', ['id' => $forum['forum_id'], 'name' => Url::url_friendly($forum['forum_name'])]) . '"' . ($fid == 2 ? ' selected="selected"' : '') . '>' . $forum['forum_name'] . '</option>' . "\n"; } echo "\t\t\t\t\t\t\t\t\t" . '</optgroup>' . "\n"; } ?> </select> </div> </form> </div> <?php } ?> <div class="conr"> <?php if ($active_page == 'index') { if (ForumSettings::get('o_feed_type') == '1') {
<li><a href="<?php echo Url::base(); ?> "><?php _e('Index'); ?> </a></li> <li><span>» </span><a href="<?php echo $feather->urlFor('Forum', ['id' => $cur_post['fid'], 'name' => Url::url_friendly($cur_post['forum_name'])]); ?> "><?php echo Utils::escape($cur_post['forum_name']); ?> </a></li> <li><span>» </span><a href="<?php echo $feather->urlFor('Topic', ['id' => $cur_post['tid'], 'name' => Url::url_friendly($cur_post['subject'])]); ?> "><?php echo Utils::escape($cur_post['subject']); ?> </a></li> <li><span>» </span><strong><?php _e('Edit post'); ?> </strong></li> </ul> </div> </div> <?php // If there are errors, we display them
<div class="inform"> <fieldset> <legend><?php printf(__('Zapped subhead'), Utils::format_time($report['zapped']), $report['zapped_by'] != '' ? '<a href="' . Router::pathFor('userProfile', ['id' => $report['zapped_by_id']]) . '">' . Utils::escape($report['zapped_by']) . '</a>' : __('NA')); ?> </legend> <div class="infldset"> <table class="aligntop"> <tr> <th scope="row"><?php printf(__('Reported by'), $report['reporter'] != '' ? '<a href="' . Router::pathFor('userProfile', ['id' => $report['reported_by']]) . '">' . Utils::escape($report['reporter']) . '</a>' : __('Deleted user')); ?> </th> <td class="location"> <?php echo AdminUtils::breadcrumbs_admin(array($report['forum_name'] => Router::pathFor('Forum', ['id' => $report['forum_id'], 'name' => Url::url_friendly($report['forum_name'])]), $report['subject'] => Router::pathFor('Forum', ['id' => $report['topic_id'], 'name' => Url::url_friendly($report['subject'])]), sprintf(__('Post ID'), $report['pid']) => Router::pathFor('viewPost', ['pid' => $report['pid']]) . '#p' . $report['pid'])); ?> </td> </tr> <tr> <th scope="row"><?php _e('Reason'); ?> </th> <td><?php echo str_replace("\n", '<br />', Utils::escape($report['message'])); ?> </td> </tr> </table> </div>
<li><a href="<?php echo Url::base(); ?> "><?php _e('Index'); ?> </a></li> <li><span>» </span><a href="<?php echo Router::pathFor('Forum', ['id' => $cur_post['fid'], 'name' => Url::url_friendly($cur_post['forum_name'])]); ?> "><?php echo Utils::escape($cur_post['forum_name']); ?> </a></li> <li><span>» </span><a href="<?php echo Router::pathFor('Topic', ['id' => $cur_post['tid'], 'name' => Url::url_friendly($cur_post['subject'])]); ?> "><?php echo Utils::escape($cur_post['subject']); ?> </a></li> <li><span>» </span><strong><?php _e('Edit post'); ?> </strong></li> </ul> </div> </div> <?php // If there are errors, we display them
public function moderate($req, $res, $args) { Container::get('hooks')->fire('controller.forum.moderate'); // Make sure that only admmods allowed access this page $moderators = $this->model->get_moderators($args['fid']); $mods_array = $moderators != '' ? unserialize($moderators) : array(); if (User::get()->g_id != ForumEnv::get('FEATHER_ADMIN') && (User::get()->g_moderator == '0' || !array_key_exists(User::get()->username, $mods_array))) { throw new Error(__('No permission'), 403); } // Fetch some info about the forum $cur_forum = $this->model->get_forum_info($args['fid']); // Is this a redirect forum? In that case, abort! if ($cur_forum['redirect_url'] != '') { throw new Error(__('Bad request'), '404'); } $sort_by = $this->model->sort_forum_by($cur_forum['sort_by']); // Determine the topic offset (based on $_GET['p']) $num_pages = ceil($cur_forum['num_topics'] / User::get()->disp_topics); $p = !isset($args['page']) || $args['page'] <= 1 || $args['page'] > $num_pages ? 1 : intval($args['page']); $start_from = User::get()->disp_topics * ($p - 1); $url_forum = Url::url_friendly($cur_forum['forum_name']); View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), Utils::escape($cur_forum['forum_name'])), 'active_page' => 'moderate', 'page' => $p, 'id' => $args['fid'], 'p' => $p, 'url_forum' => $url_forum, 'cur_forum' => $cur_forum, 'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate($num_pages, $p, 'forum/moderate/' . $args['fid'] . '/#'), 'topic_data' => $this->model->display_topics_moderate($args['fid'], $sort_by, $start_from), 'start_from' => $start_from))->addTemplate('moderate/moderator_forum.php')->display(); }
public function display($id, $name = null, $page = null) { // Make sure that only admmods allowed access this page $moderators = $this->model->get_moderators($id); $mods_array = $moderators != '' ? unserialize($moderators) : array(); if ($this->user->g_id != $this->feather->forum_env['FEATHER_ADMIN'] && ($this->user->g_moderator == '0' || !array_key_exists($this->user->username, $mods_array))) { throw new Error(__('No permission'), 403); } // Fetch some info about the forum $cur_forum = $this->model->get_forum_info($id); // Is this a redirect forum? In that case, abort! if ($cur_forum['redirect_url'] != '') { throw new Error(__('Bad request'), '404'); } $sort_by = $this->model->forum_sort_by($cur_forum['sort_by']); // Determine the topic offset (based on $_GET['p']) $num_pages = ceil($cur_forum['num_topics'] / $this->user->disp_topics); $p = !isset($page) || $page <= 1 || $page > $num_pages ? 1 : intval($page); $start_from = $this->user->disp_topics * ($p - 1); $url_forum = Url::url_friendly($cur_forum['forum_name']); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), Utils::escape($cur_forum['forum_name'])), 'active_page' => 'moderate', 'page' => $p, 'id' => $id, 'p' => $p, 'url_forum' => $url_forum, 'cur_forum' => $cur_forum, 'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate($num_pages, $p, 'moderate/forum/' . $id . '/#'), 'topic_data' => $this->model->display_topics($id, $sort_by, $start_from), 'start_from' => $start_from))->addTemplate('moderate/moderator_forum.php')->display(); }