public function report($id) { if ($this->feather->request()->isPost()) { $this->model->insert_report($id); } // Fetch some info about the post, the topic and the forum $cur_post = $this->model->get_info_report($id); if ($this->feather->forum_settings['o_censoring'] == '1') { $cur_post['subject'] = Utils::censor($cur_post['subject']); } $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), __('Report post')), 'active_page' => 'report', 'required_fields' => array('req_reason' => __('Reason')), 'focus_element' => array('report', 'req_reason'), 'id' => $id, 'cur_post' => $cur_post))->addTemplate('misc/report.php')->display(); }
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 check_errors_before_edit($can_edit_subject, $errors) { $errors = $this->hook->fire('check_errors_before_edit_start', $errors); // If it's a topic it must contain a subject if ($can_edit_subject) { $subject = Utils::trim($this->request->post('req_subject')); if ($this->config['o_censoring'] == '1') { $censored_subject = Utils::trim(Utils::censor($subject)); } if ($subject == '') { $errors[] = __('No subject'); } elseif ($this->config['o_censoring'] == '1' && $censored_subject == '') { $errors[] = __('No subject after censoring'); } elseif (Utils::strlen($subject) > 70) { $errors[] = __('Too long subject'); } elseif ($this->config['p_subject_all_caps'] == '0' && Utils::is_all_uppercase($subject) && !$this->user->is_admmod) { $errors[] = __('All caps subject'); } } // Clean up message from POST $message = Utils::linebreaks(Utils::trim($this->request->post('req_message'))); // Here we use strlen() not Utils::strlen() as we want to limit the post to FEATHER_MAX_POSTSIZE bytes, not characters if (strlen($message) > $this->feather->forum_env['FEATHER_MAX_POSTSIZE']) { $errors[] = sprintf(__('Too long message'), Utils::forum_number_format($this->feather->forum_env['FEATHER_MAX_POSTSIZE'])); } elseif ($this->config['p_message_all_caps'] == '0' && Utils::is_all_uppercase($message) && !$this->user->is_admmod) { $errors[] = __('All caps message'); } // Validate BBCode syntax if ($this->config['p_message_bbcode'] == '1') { $message = $this->feather->parser->preparse_bbcode($message, $errors); } if (empty($errors)) { if ($message == '') { $errors[] = __('No message'); } elseif ($this->config['o_censoring'] == '1') { // Censor message to see if that causes problems $censored_message = Utils::trim(Utils::censor($message)); if ($censored_message == '') { $errors[] = __('No message after censoring'); } } } $errors = $this->hook->fire('check_errors_before_edit', $errors); return $errors; }
public function editpost($id) { // Fetch some informations about the post, the topic and the forum $cur_post = $this->model->get_info_edit($id); // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = $cur_post['moderators'] != '' ? unserialize($cur_post['moderators']) : array(); $is_admmod = $this->user->g_id == $this->feather->forum_env['FEATHER_ADMIN'] || $this->user->g_moderator == '1' && array_key_exists($this->user->username, $mods_array) ? true : false; $can_edit_subject = $id == $cur_post['first_post_id']; if ($this->config['o_censoring'] == '1') { $cur_post['subject'] = Utils::censor($cur_post['subject']); $cur_post['message'] = Utils::censor($cur_post['message']); } // Do we have permission to edit this post? if (($this->user->g_edit_posts == '0' || $cur_post['poster_id'] != $this->user->id || $cur_post['closed'] == '1') && !$is_admmod) { throw new Error(__('No permission'), 403); } if ($is_admmod && $this->user->g_id != $this->feather->forum_env['FEATHER_ADMIN'] && in_array($cur_post['poster_id'], Utils::get_admin_ids())) { throw new Error(__('No permission'), 403); } // Start with a clean slate $errors = array(); if ($this->feather->request()->isPost()) { // Let's see if everything went right $errors = $this->model->check_errors_before_edit($can_edit_subject, $errors); // Setup some variables before post $post = $this->model->setup_variables($cur_post, $is_admmod, $can_edit_subject, $errors); // Did everything go according to plan? if (empty($errors) && !$this->request->post('preview')) { // Edit the post $this->model->edit_post($id, $can_edit_subject, $post, $cur_post, $is_admmod); Url::redirect($this->feather->urlFor('viewPost', ['pid' => $id]) . '#p' . $id, __('Post redirect')); } } else { $post = ''; } if ($this->request->post('preview')) { $preview_message = $this->feather->parser->parse_message($post['message'], $post['hide_smilies']); } else { $preview_message = ''; } $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->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Edit post')), 'required_fields' => array('req_subject' => __('Subject'), 'req_message' => __('Message')), 'focus_element' => array('edit', 'req_message'), 'cur_post' => $cur_post, 'errors' => $errors, 'preview_message' => $preview_message, 'id' => $id, 'checkboxes' => $this->model->get_checkboxes($can_edit_subject, $is_admmod, $cur_post, 1), 'can_edit_subject' => $can_edit_subject, 'lang_bbeditor' => $lang_bbeditor, 'post' => $post))->addTemplate('edit.php')->display(); }
public function deletepost($id) { // Fetch some informations about the post, the topic and the forum $cur_post = $this->model->get_info_delete($id); if ($this->feather->forum_settings['o_censoring'] == '1') { $cur_post['subject'] = Utils::censor($cur_post['subject']); } // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = $cur_post['moderators'] != '' ? unserialize($cur_post['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; $is_topic_post = $id == $cur_post['first_post_id'] ? true : false; // Do we have permission to edit this post? if (($this->feather->user->g_delete_posts == '0' || $this->feather->user->g_delete_topics == '0' && $is_topic_post || $cur_post['poster_id'] != $this->feather->user->id || $cur_post['closed'] == '1') && !$is_admmod) { throw new Error(__('No permission'), 403); } if ($is_admmod && $this->feather->user->g_id != $this->feather->forum_env['FEATHER_ADMIN'] && in_array($cur_post['poster_id'], Utils::get_admin_ids())) { throw new Error(__('No permission'), 403); } if ($this->feather->request()->isPost()) { $this->model->handle_deletion($is_topic_post, $id, $cur_post['tid'], $cur_post['fid']); } $cur_post['message'] = $this->feather->parser->parse_message($cur_post['message'], $cur_post['hide_smilies']); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), __('Delete post')), 'active_page' => 'delete', 'cur_post' => $cur_post, 'id' => $id, 'is_topic_post' => $is_topic_post))->addTemplate('delete.php')->display(); }
public function folders() { $errors = array(); if ($this->request->post('add_folder')) { $folder = $this->request->post('req_folder') ? Utils::trim(Utils::escape($this->request->post('req_folder'))) : ''; if ($folder == '') { $errors[] = __('No folder name', 'private_messages'); } else { if (Utils::strlen($folder) < 4) { $errors[] = __('Folder too short', 'private_messages'); } else { if (Utils::strlen($folder) > 30) { $errors[] = __('Folder too long', 'private_messages'); } else { if ($this->feather->forum_settings['o_censoring'] == '1' && Utils::censor($folder) == '') { $errors[] = __('No folder after censoring', 'private_messages'); } } } } // TODO: Check perms when ready // $data = array( // ':uid' => $panther_user['id'], // ); // // if ($panther_user['g_pm_folder_limit'] != 0) // { // $ps = $db->select('folders', 'COUNT(id)', $data, 'user_id=:uid'); // $num_folders = $ps->fetchColumn(); // // if ($num_folders >= $panther_user['g_pm_folder_limit']) // $errors[] = sprintf($lang_pm['Folder limit'], $panther_user['g_pm_folder_limit']); // } if (empty($errors)) { $insert = array('user_id' => $this->feather->user->id, 'name' => $folder); $this->model->addFolder($insert); Url::redirect($this->feather->urlFor('Conversations.folders'), __('Folder added', 'private_messages')); } } else { if ($this->request->post('update_folder')) { $id = intval(key($this->request->post('update_folder'))); var_dump($id); $errors = array(); $folder = Utils::trim($this->request->post('folder')[$id]); if ($folder == '') { $errors[] = __('No folder name', 'private_messages'); } else { if (Utils::strlen($folder) < 4) { $errors[] = __('Folder too short', 'private_messages'); } else { if (Utils::strlen($folder) > 30) { $errors[] = __('Folder too long', 'private_messages'); } else { if ($this->feather->forum_settings['o_censoring'] == '1' && Utils::censor($folder) == '') { $errors[] = __('No folder after censoring', 'private_messages'); } } } } if (empty($errors)) { $update = array('name' => $folder); if ($this->model->updateFolder($this->feather->user->id, $id, $update)) { Url::redirect($this->feather->urlFor('Conversations.folders'), __('Folder updated', 'private_messages')); } else { throw new Error(__('Error'), 403); } } } else { if ($this->request->post('remove_folder')) { $id = intval(key($this->request->post('remove_folder'))); // Before we do anything, check we blocked this user if (!$this->model->checkFolderOwner($id, intval($this->feather->user->id))) { throw new Error(__('No permission'), 403); } if ($this->model->removeFolder($this->feather->user->id, $id)) { Url::redirect($this->feather->urlFor('Conversations.folders'), __('Folder removed', 'private_messages')); } else { throw new Error(__('Error'), 403); } } } } Utils::generateBreadcrumbs(array($this->feather->urlFor('Conversations.home') => __('PMS', 'private_messages'), __('Options'), __('My Folders', 'private_messages'))); $this->generateMenu('folders'); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->config['o_board_title']), __('PMS', 'private_messages'), __('Blocked Users', 'private_messages')), 'admin_console' => true, 'errors' => $errors))->addTemplate('folders.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 report($req, $res, $args) { $args['id'] = Container::get('hooks')->fire('controller.post.report', $args['id']); if (Request::isPost()) { $this->model->insert_report($args['id']); } // Fetch some info about the post, the topic and the forum $cur_post = $this->model->get_info_report($args['id']); if (ForumSettings::get('o_censoring') == '1') { $cur_post['subject'] = Utils::censor($cur_post['subject']); } View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Report post')), 'active_page' => 'report', 'required_fields' => array('req_reason' => __('Reason')), 'focus_element' => array('report', 'req_reason'), 'id' => $args['id'], 'cur_post' => $cur_post))->addTemplate('misc/report.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(); } } } } }
public function display_posts_moderate($tid, $start_from) { Container::get('hooks')->fire('model.topic.display_posts_view_start', $tid, $start_from); $post_data = array(); $post_count = 0; // Keep track of post numbers // Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data $find_ids = DB::for_table('posts')->select('id')->where('topic_id', $tid)->order_by('id')->limit(User::get()->disp_posts)->offset($start_from); $find_ids = Container::get('hooks')->fireDB('model.topic.display_posts_view_find_ids', $find_ids); $find_ids = $find_ids->find_many(); foreach ($find_ids as $id) { $post_ids[] = $id['id']; } // Retrieve the posts (and their respective poster) $result['select'] = array('u.title', 'u.num_posts', 'g.g_id', 'g.g_user_title', 'p.id', 'p.poster', 'p.poster_id', 'p.message', 'p.hide_smilies', 'p.posted', 'p.edited', 'p.edited_by'); $result = DB::for_table('posts')->table_alias('p')->select_many($result['select'])->inner_join('users', array('u.id', '=', 'p.poster_id'), 'u')->inner_join('groups', array('g.g_id', '=', 'u.group_id'), 'g')->where_in('p.id', $post_ids)->order_by('p.id'); $result = Container::get('hooks')->fireDB('model.topic.display_posts_view_query', $result); $result = $result->find_many(); foreach ($result as $cur_post) { $post_count++; // If the poster is a registered user if ($cur_post->poster_id > 1) { if (User::get()->g_view_users == '1') { $cur_post->poster_disp = '<a href="' . Router::pathFor('userProfile', ['id' => $cur_post->poster_id]) . '">' . Utils::escape($cur_post->poster) . '</a>'; } else { $cur_post->poster_disp = Utils::escape($cur_post->poster); } // Utils::get_title() requires that an element 'username' be present in the array $cur_post->username = $cur_post->poster; $cur_post->user_title = Utils::get_title($cur_post); if (ForumSettings::get('o_censoring') == '1') { $cur_post->user_title = Utils::censor($cur_post->user_title); } } else { $cur_post->poster_disp = Utils::escape($cur_post->poster); $cur_post->user_title = __('Guest'); } // Perform the main parsing of the message (BBCode, smilies, censor words etc) $cur_post->message = Container::get('parser')->parse_message($cur_post->message, $cur_post->hide_smilies); $post_data[] = $cur_post; } $post_data = Container::get('hooks')->fire('model.topic.display_posts_view', $post_data); return $post_data; }
public function check_username($username, $errors, $exclude_id = null) { // Include UTF-8 function require_once ForumEnv::get('FEATHER_ROOT') . 'featherbb/Helpers/utf8/strcasecmp.php'; translate('register'); translate('prof_reg'); // Convert multiple whitespace characters into one (to prevent people from registering with indistinguishable usernames) $username = preg_replace('%\\s+%s', ' ', $username); // Validate username if (Utils::strlen($username) < 2) { $errors[] = __('Username too short'); } elseif (Utils::strlen($username) > 25) { // This usually doesn't happen since the form element only accepts 25 characters $errors[] = __('Username too long'); } elseif (!strcasecmp($username, 'Guest') || !utf8_strcasecmp($username, __('Guest'))) { $errors[] = __('Username guest'); } elseif (filter_var($username, FILTER_VALIDATE_IP)) { $errors[] = __('Username IP'); } elseif ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false) { $errors[] = __('Username reserved chars'); } elseif (preg_match('%(?:\\[/?(?:b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|\\*|topic|post|forum|user)\\]|\\[(?:img|url|quote|list)=)%i', $username)) { $errors[] = __('Username BBCode'); } // Check username for any censored words if (ForumSettings::get('o_censoring') == '1' && Utils::censor($username) != $username) { $errors[] = __('Username censor'); } // Check that the username (or a too similar username) is not already registered $query = !is_null($exclude_id) ? ' AND id!=' . $exclude_id : ''; $result = DB::for_table('online')->raw_query('SELECT username FROM ' . ForumSettings::get('db_prefix') . 'users WHERE (UPPER(username)=UPPER(:username1) OR UPPER(username)=UPPER(:username2)) AND id>1' . $query, array(':username1' => $username, ':username2' => Utils::ucp_preg_replace('%[^\\p{L}\\p{N}]%u', '', $username)))->find_one(); if ($result) { $busy = $result['username']; $errors[] = __('Username dupe 1') . ' ' . Utils::escape($busy) . '. ' . __('Username dupe 2'); } // Check username for any banned usernames foreach (Container::get('bans') as $cur_ban) { if ($cur_ban['username'] != '' && utf8_strtolower($username) == utf8_strtolower($cur_ban['username'])) { $errors[] = __('Banned username'); break; } } return $errors; }
public function print_posts($topic_id, $start_from, $cur_topic, $is_admmod) { $post_data = array(); $post_data = $this->hook->fire('print_posts_start', $post_data, $topic_id, $start_from, $cur_topic, $is_admmod); $post_count = 0; // Keep track of post numbers // Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data $result = DB::for_table('posts')->select('id')->where('topic_id', $topic_id)->order_by('id')->limit($this->user->disp_topics)->offset($start_from); $result = $this->hook->fireDB('print_posts_ids_query', $result); $result = $result->find_many(); $post_ids = array(); foreach ($result as $cur_post_id) { $post_ids[] = $cur_post_id['id']; } if (empty($post_ids)) { throw new Error('The post table and topic table seem to be out of sync!', 500); } // Retrieve the posts (and their respective poster/online status) $result['select'] = array('u.email', 'u.title', 'u.url', 'u.location', 'u.signature', 'u.email_setting', 'u.num_posts', 'u.registered', 'u.admin_note', 'p.id', 'username' => 'p.poster', 'p.poster_id', 'p.poster_ip', 'p.poster_email', 'p.message', 'p.hide_smilies', 'p.posted', 'p.edited', 'p.edited_by', 'g.g_id', 'g.g_user_title', 'g.g_promote_next_group', 'is_online' => 'o.user_id'); $result = DB::for_table('posts')->table_alias('p')->select_many($result['select'])->inner_join('users', array('u.id', '=', 'p.poster_id'), 'u')->inner_join('groups', array('g.g_id', '=', 'u.group_id'), 'g')->raw_join('LEFT OUTER JOIN ' . $this->feather->forum_settings['db_prefix'] . 'online', "o.user_id!=1 AND o.idle=0 AND o.user_id=u.id", 'o')->where_in('p.id', $post_ids)->order_by('p.id'); $result = $this->hook->fireDB('print_posts_query', $result); $result = $result->find_array(); foreach ($result as $cur_post) { $post_count++; $cur_post['user_avatar'] = ''; $cur_post['user_info'] = array(); $cur_post['user_contacts'] = array(); $cur_post['post_actions'] = array(); $cur_post['is_online_formatted'] = ''; $cur_post['signature_formatted'] = ''; // If the poster is a registered user if ($cur_post['poster_id'] > 1) { if ($this->user->g_view_users == '1') { $cur_post['username_formatted'] = '<a href="' . Url::base() . '/user/' . $cur_post['poster_id'] . '/">' . Utils::escape($cur_post['username']) . '</a>'; } else { $cur_post['username_formatted'] = Utils::escape($cur_post['username']); } $cur_post['user_title_formatted'] = Utils::get_title($cur_post); if ($this->config['o_censoring'] == '1') { $cur_post['user_title_formatted'] = Utils::censor($cur_post['user_title_formatted']); } // Format the online indicator $cur_post['is_online_formatted'] = $cur_post['is_online'] == $cur_post['poster_id'] ? '<strong>' . __('Online') . '</strong>' : '<span>' . __('Offline') . '</span>'; if ($this->config['o_avatars'] == '1' && $this->user->show_avatars != '0') { if (isset($avatar_cache[$cur_post['poster_id']])) { $cur_post['user_avatar'] = $avatar_cache[$cur_post['poster_id']]; } else { $cur_post['user_avatar'] = $avatar_cache[$cur_post['poster_id']] = Utils::generate_avatar_markup($cur_post['poster_id']); } } // We only show location, register date, post count and the contact links if "Show user info" is enabled if ($this->config['o_show_user_info'] == '1') { if ($cur_post['location'] != '') { if ($this->config['o_censoring'] == '1') { $cur_post['location'] = Utils::censor($cur_post['location']); } $cur_post['user_info'][] = '<dd><span>' . __('From') . ' ' . Utils::escape($cur_post['location']) . '</span></dd>'; } $cur_post['user_info'][] = '<dd><span>' . __('Registered topic') . ' ' . $this->feather->utils->format_time($cur_post['registered'], true) . '</span></dd>'; if ($this->config['o_show_post_count'] == '1' || $this->user->is_admmod) { $cur_post['user_info'][] = '<dd><span>' . __('Posts topic') . ' ' . Utils::forum_number_format($cur_post['num_posts']) . '</span></dd>'; } // Now let's deal with the contact links (Email and URL) if (($cur_post['email_setting'] == '0' && !$this->user->is_guest || $this->user->is_admmod) && $this->user->g_send_email == '1') { $cur_post['user_contacts'][] = '<span class="email"><a href="mailto:' . Utils::escape($cur_post['email']) . '">' . __('Email') . '</a></span>'; } elseif ($cur_post['email_setting'] == '1' && !$this->user->is_guest && $this->user->g_send_email == '1') { $cur_post['user_contacts'][] = '<span class="email"><a href="' . $this->feather->urlFor('email', ['id' => $cur_post['poster_id']]) . '">' . __('Email') . '</a></span>'; } if ($cur_post['url'] != '') { if ($this->config['o_censoring'] == '1') { $cur_post['url'] = Utils::censor($cur_post['url']); } $cur_post['user_contacts'][] = '<span class="website"><a href="' . Utils::escape($cur_post['url']) . '" rel="nofollow">' . __('Website') . '</a></span>'; } } if ($this->user->g_id == $this->feather->forum_env['FEATHER_ADMIN'] || $this->user->g_moderator == '1' && $this->user->g_mod_promote_users == '1') { if ($cur_post['g_promote_next_group']) { $cur_post['user_info'][] = '<dd><span><a href="' . Url::base() . '/user/' . $cur_post['poster_id'] . '/action/promote/pid/' . $cur_post['id'] . '">' . __('Promote user') . '</a></span></dd>'; } } if ($this->user->is_admmod) { $cur_post['user_info'][] = '<dd><span><a href="' . $this->feather->urlFor('getHostPost', ['pid' => $cur_post['id']]) . '" title="' . Utils::escape($cur_post['poster_ip']) . '">' . __('IP address logged') . '</a></span></dd>'; if ($cur_post['admin_note'] != '') { $cur_post['user_info'][] = '<dd><span>' . __('Note') . ' <strong>' . Utils::escape($cur_post['admin_note']) . '</strong></span></dd>'; } } } else { $cur_post['username_formatted'] = Utils::escape($cur_post['username']); $cur_post['user_title_formatted'] = Utils::get_title($cur_post); if ($this->user->is_admmod) { $cur_post['user_info'][] = '<dd><span><a href="' . $this->feather->urlFor('getHostPost', ['pid' => $cur_post['id']]) . '" title="' . Utils::escape($cur_post['poster_ip']) . '">' . __('IP address logged') . '</a></span></dd>'; } if ($this->config['o_show_user_info'] == '1' && $cur_post['poster_email'] != '' && !$this->user->is_guest && $this->user->g_send_email == '1') { $cur_post['user_contacts'][] = '<span class="email"><a href="mailto:' . Utils::escape($cur_post['poster_email']) . '">' . __('Email') . '</a></span>'; } } // Generation post action array (quote, edit, delete etc.) if (!$is_admmod) { if (!$this->user->is_guest) { $cur_post['post_actions'][] = '<li class="postreport"><span><a href="' . $this->feather->urlFor('report', ['id' => $cur_post['id']]) . '">' . __('Report') . '</a></span></li>'; } if ($cur_topic['closed'] == '0') { if ($cur_post['poster_id'] == $this->user->id) { if ($start_from + $post_count == 1 && $this->user->g_delete_topics == '1' || $start_from + $post_count > 1 && $this->user->g_delete_posts == '1') { $cur_post['post_actions'][] = '<li class="postdelete"><span><a href="' . $this->feather->urlFor('deletePost', ['id' => $cur_post['id']]) . '">' . __('Delete') . '</a></span></li>'; } if ($this->user->g_edit_posts == '1') { $cur_post['post_actions'][] = '<li class="postedit"><span><a href="' . $this->feather->urlFor('editPost', ['id' => $cur_post['id']]) . '">' . __('Edit') . '</a></span></li>'; } } if ($cur_topic['post_replies'] == '' && $this->user->g_post_replies == '1' || $cur_topic['post_replies'] == '1') { $cur_post['post_actions'][] = '<li class="postquote"><span><a href="' . $this->feather->urlFor('newQuoteReply', ['tid' => $topic_id, 'quote' => $cur_post['id']]) . '">' . __('Quote') . '</a></span></li>'; } } } else { $cur_post['post_actions'][] = '<li class="postreport"><span><a href="' . $this->feather->urlFor('report', ['id' => $cur_post['id']]) . '">' . __('Report') . '</a></span></li>'; if ($this->user->g_id == $this->feather->forum_env['FEATHER_ADMIN'] || !in_array($cur_post['poster_id'], $admin_ids)) { $cur_post['post_actions'][] = '<li class="postdelete"><span><a href="' . $this->feather->urlFor('deletePost', ['id' => $cur_post['id']]) . '">' . __('Delete') . '</a></span></li>'; $cur_post['post_actions'][] = '<li class="postedit"><span><a href="' . $this->feather->urlFor('editPost', ['id' => $cur_post['id']]) . '">' . __('Edit') . '</a></span></li>'; } $cur_post['post_actions'][] = '<li class="postquote"><span><a href="' . $this->feather->urlFor('newQuoteReply', ['tid' => $topic_id, 'quote' => $cur_post['id']]) . '">' . __('Quote') . '</a></span></li>'; } // Perform the main parsing of the message (BBCode, smilies, censor words etc) $cur_post['message'] = $this->feather->parser->parse_message($cur_post['message'], $cur_post['hide_smilies']); // Do signature parsing/caching if ($this->config['o_signatures'] == '1' && $cur_post['signature'] != '' && $this->user->show_sig != '0') { if (isset($avatar_cache[$cur_post['poster_id']])) { $cur_post['signature_formatted'] = $avatar_cache[$cur_post['poster_id']]; } else { $cur_post['signature_formatted'] = $this->feather->parser->parse_signature($cur_post['signature']); $avatar_cache[$cur_post['poster_id']] = $cur_post['signature_formatted']; } } $post_data[] = $cur_post; } $post_data = $this->hook->fire('print_posts', $post_data); return $post_data; }
} // Load cached feed if (isset($cache_id) && file_exists(FORUM_CACHE_DIR . 'cache_' . $cache_id . '.php')) { include FORUM_CACHE_DIR . 'cache_' . $cache_id . '.php'; } $now = time(); if (!isset($feed) || $cache_expire < $now) { // Setup the feed $feed = array('title' => ForumSettings::get('o_board_title') . $forum_name, 'link' => '/index.php', 'description' => sprintf(__('RSS description'), ForumSettings::get('o_board_title')), 'items' => array(), 'type' => 'topics'); // Fetch $show topics $select_print_posts = array('t.id', 't.poster', 't.subject', 't.posted', 't.last_post', 't.last_poster', 'p.message', 'p.hide_smilies', 'u.email_setting', 'u.email', 'p.poster_id', 'p.poster_email'); $where_print_posts = array(array('fp.read_forum' => 'IS NULL'), array('fp.read_forum' => '1')); $result = $result->select_many($select_print_posts)->inner_join('posts', array('p.id', '=', $order_posted ? 't.first_post_id' : 't.last_post_id'), 'p')->inner_join('users', array('u.id', '=', 'p.poster_id'), 'u')->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_print_posts)->where_null('t.moved_to')->order_by($order_posted ? 't.posted' : 't.last_post')->limit(isset($cache_id) ? 50 : $show)->find_array(); foreach ($result as $cur_topic) { if (ForumSettings::get('o_censoring') == '1') { $cur_topic['subject'] = Utils::censor($cur_topic['subject']); } $cur_topic['message'] = parse_message($cur_topic['message'], $cur_topic['hide_smilies']); $item = array('id' => $cur_topic['id'], 'title' => $cur_topic['subject'], 'link' => Url::get('topic/' . $cur_topic['id'] . '/' . url_friendly($cur_topic['subject']) . '/') . ($order_posted ? '' : '/action/new/'), 'description' => $cur_topic['message'], 'author' => array('name' => $order_posted ? $cur_topic['poster'] : $cur_topic['last_poster']), 'pubdate' => $order_posted ? $cur_topic['posted'] : $cur_topic['last_post']); if ($cur_topic['poster_id'] > 1) { if ($cur_topic['email_setting'] == '0' && !User::get()->is_guest) { $item['author']['email'] = $cur_topic['email']; } $item['author']['uri'] = Url::get('user/' . $cur_topic['poster_id'] . '/'); } elseif ($cur_topic['poster_email'] != '' && !User::get()->is_guest) { $item['author']['email'] = $cur_topic['poster_email']; } $feed['items'][] = $item; } // Output feed as PHP code if (isset($cache_id)) {
public function get_quote_message($qid, $tid) { $quote = array(); $quote = Container::get('hooks')->fire('model.post.get_quote_message', $quote, $qid, $tid); $quote['select'] = array('poster', 'message'); $quote = DB::for_table('posts')->select_many($quote['select'])->where('id', $qid)->where('topic_id', $tid); $quote = Container::get('hooks')->fireDB('model.post.get_quote_message_query', $quote); $quote = $quote->find_one(); if (!$quote) { throw new Error(__('Bad request'), 404); } // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched) if (strpos($quote['message'], '[code]') !== false && strpos($quote['message'], '[/code]') !== false) { list($inside, $outside) = split_text($quote['message'], '[code]', '[/code]'); $quote['message'] = implode("", $outside); } // Remove [img] tags from quoted message $quote['message'] = preg_replace('%\\[img(?:=(?:[^\\[]*?))?\\]((ht|f)tps?://)([^\\s<"]*?)\\[/img\\]%U', '\\1\\3', $quote['message']); // If we split up the message before we have to concatenate it together again (code tags) if (isset($inside)) { $outside = explode("", $quote['message']); $quote['message'] = ''; $num_tokens = count($outside); for ($i = 0; $i < $num_tokens; ++$i) { $quote['message'] .= $outside[$i]; if (isset($inside[$i])) { $quote['message'] .= '[code]' . $inside[$i] . '[/code]'; } } unset($inside); } if (ForumSettings::get('o_censoring') == '1') { $quote['message'] = Utils::censor($quote['message']); } $quote['message'] = Utils::escape($quote['message']); if (ForumSettings::get('p_message_bbcode') == '1') { // Sanitize username for inclusion within QUOTE BBCode attribute. // This is a bit tricky because a username can have any "special" // characters such as backslash \ square brackets [] and quotes '". if (preg_match('/[[\\]\'"]/S', $quote['poster'])) { // Check if we need to quote it. // Post has special chars. Escape escapes and quotes then wrap in quotes. if (strpos($quote['poster'], '"') !== false && strpos($quote['poster'], '\'') === false) { // If there are double quotes but no single quotes, use single quotes, $quote['poster'] = Utils::escape(str_replace('\\', '\\\\', $quote['poster'])); $quote['poster'] = '\'' . $quote['poster'] . '#' . $qid . '\''; } else { // otherwise use double quotes. $quote['poster'] = Utils::escape(str_replace(array('\\', '"'), array('\\\\', '\\"'), $quote['poster'])); $quote['poster'] = '"' . $quote['poster'] . '#' . $qid . '"'; } } else { $quote['poster'] = $quote['poster'] . '#' . $qid; } $quote = '[quote=' . $quote['poster'] . ']' . $quote['message'] . '[/quote]' . "\n"; } else { $quote = '> ' . $quote['poster'] . ' ' . __('wrote') . "\n\n" . '> ' . $quote['message'] . "\n"; } $quote = Container::get('hooks')->fire('model.post.get_quote_message', $quote); return $quote; }
public function moderatetopic($id = null, $fid = null, $action = null, $param = null) { if ($action == 'get_host') { $this->model->display_ip_address(); } // 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); } // Move one topic if ($this->request->post('move_topics') || $this->request->post('move_topics_to')) { if ($this->request->post('move_topics_to')) { $this->model->move_topics_to($fid, $id, $param); } $topics = $this->request->post('topics') ? $this->request->post('topics') : array(); if (empty($topics)) { throw new Error(__('No topics selected'), 400); } $topics = implode(',', array_map('intval', array_keys($topics))); // Check if there are enough forums to move the topic $this->model->check_move_possible(); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Moderate')), 'active_page' => 'moderate', 'action' => 'multi', 'id' => $fid, 'topics' => $topics, 'list_forums' => $this->model->get_forum_list_move($fid)))->addTemplate('moderate/move_topics.php')->display(); } // Stick a topic if ($action == 'stick') { $this->model->stick_topic($id, $fid); Url::redirect($this->feather->urlFor('Topic', array('id' => $id)), __('Stick topic redirect')); } // Unstick a topic if ($action == 'unstick') { $this->model->unstick_topic($id, $fid); Url::redirect($this->feather->urlFor('Topic', array('id' => $id)), __('Unstick topic redirect')); } // Open a topic if ($action == 'open') { $this->model->open_topic($id, $fid); Url::redirect($this->feather->urlFor('Topic', array('id' => $id)), __('Open topic redirect')); } // Close a topic if ($action == 'close') { $this->model->close_topic($id, $fid); Url::redirect($this->feather->urlFor('Topic', array('id' => $id)), __('Close topic redirect')); } $cur_topic = $this->model->get_topic_info($fid, $id); // Determine the post offset (based on $_GET['p']) $num_pages = ceil(($cur_topic['num_replies'] + 1) / $this->user->disp_posts); $p = !isset($param) || $param <= 1 || $param > $num_pages ? 1 : intval($param); $start_from = $this->user->disp_posts * ($p - 1); // Move a topic - send a POST after if ($action == 'move') { // Check if there are enough forums to move the topic $this->model->check_move_possible(); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Moderate')), 'active_page' => 'moderate', 'page' => $p, 'action' => 'single', 'id' => $id, 'topics' => $id, 'list_forums' => $this->model->get_forum_list_move($fid)))->addTemplate('moderate/move_topics.php')->display(); } // Moderate a topic if ($action == 'moderate') { // Delete one or more posts if ($this->request->post('delete_posts') || $this->request->post('delete_posts_comply')) { $posts = $this->model->delete_posts($id, $fid, $p); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Moderate')), 'active_page' => 'moderate', 'page' => $p, 'id' => $id, 'posts' => $posts))->addTemplate('moderate/delete_posts.php')->display(); } if ($this->request->post('split_posts') || $this->request->post('split_posts_comply')) { $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Moderate')), 'focus_element' => array('subject', 'new_subject'), 'page' => $p, 'active_page' => 'moderate', 'id' => $id, 'posts' => $this->model->split_posts($id, $fid, $p), 'list_forums' => $this->model->get_forum_list_split($id)))->addTemplate('moderate/split_posts.php')->display(); } // 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') { $this->user->disp_posts = $cur_topic['num_replies'] + 1; }*/ if ($this->config['o_censoring'] == '1') { $cur_topic['subject'] = Utils::censor($cur_topic['subject']); } $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['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' => $fid, 'id' => $id, 'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate($num_pages, $p, 'moderate/topic/' . $id . '/forum/' . $fid . '/action/moderate/#'), 'post_data' => $this->model->display_posts_view($id, $start_from), 'button_status' => $button_status, 'start_from' => $start_from))->addTemplate('moderate/posts_view.php')->display(); } }