public function display($req, $res, $args) { Container::get('hooks')->fire('controller.userlist.display'); if (User::get()->g_view_users == '0') { throw new Error(__('No permission'), 403); } // Determine if we are allowed to view post counts $show_post_count = ForumSettings::get('o_show_post_count') == '1' || User::get()->is_admmod ? true : false; $username = Input::query('username') && User::get()->g_search_users == '1' ? Utils::trim(Input::query('username')) : ''; $show_group = Input::query('show_group') ? intval(Input::query('show_group')) : -1; $sort_by = Input::query('sort_by') && (in_array(Input::query('sort_by'), array('username', 'registered')) || Input::query('sort_by') == 'num_posts' && $show_post_count) ? Input::query('sort_by') : 'username'; $sort_dir = Input::query('sort_dir') && Input::query('sort_dir') == 'DESC' ? 'DESC' : 'ASC'; $num_users = $this->model->fetch_user_count($username, $show_group); // Determine the user offset (based on $page) $num_pages = ceil($num_users / 50); $p = !Input::query('p') || $page <= 1 || $page > $num_pages ? 1 : intval($page); $start_from = 50 * ($p - 1); if (User::get()->g_search_users == '1') { $focus_element = array('userlist', 'username'); } else { $focus_element = array(); } // Generate paging links $paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?username='******'&show_group=' . $show_group . '&sort_by=' . $sort_by . '&sort_dir=' . $sort_dir); View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('User list')), 'active_page' => 'userlist', 'page_number' => $p, 'paging_links' => $paging_links, 'focus_element' => $focus_element, 'is_indexed' => true, 'username' => $username, 'show_group' => $show_group, 'sort_by' => $sort_by, 'sort_dir' => $sort_dir, 'show_post_count' => $show_post_count, 'dropdown_menu' => $this->model->generate_dropdown_menu($show_group), 'userlist_data' => $this->model->print_users($username, $start_from, $sort_by, $sort_dir, $show_group)))->addTemplate('userlist.php')->display(); }
public function markforumread($id) { $tracked_topics = get_tracked_topics(); $tracked_topics['forums'][$id] = time(); Track::set_tracked_topics($tracked_topics); Url::redirect($this->feather->urlFor('Forum', array('id' => $id)), __('Mark forum read redirect')); }
public function display() { if ($this->user->g_search == '0') { throw new Error(__('No search permission'), 403); } // Figure out what to do :-) if ($this->request->get('action') || $this->request->get('search_id')) { $search = $this->model->get_search_results(); // We have results to display if (isset($search['is_result'])) { $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Search results')), 'active_page' => 'search')); $this->model->display_search_results($search, $this->feather); $this->feather->template->setPageInfo(array('search' => $search)); $this->feather->template->addTemplate('search/header.php', 1); if ($search['show_as'] == 'posts') { $this->feather->template->addTemplate('search/posts.php', 5); } else { $this->feather->template->addTemplate('search/topics.php', 5); } $this->feather->template->addTemplate('search/footer.php', 10)->display(); } else { Url::redirect($this->feather->urlFor('search'), __('No hits')); } } else { $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Search')), 'active_page' => 'search', 'focus_element' => array('search', 'keywords'), 'is_indexed' => true, 'forums' => $this->model->get_list_forums()))->addTemplate('search/form.php')->display(); } }
public function deactivate($plugin = null) { if (!$plugin) { throw new Error(__('Bad request'), 400); } $manager = new PluginManager(); $manager->deactivate($plugin); // Plugin has been activated, confirm and redirect Url::redirect($this->feather->urlFor('adminPlugins'), array('warning', 'Plugin deactivated!')); }
public function display() { // Zap a report if ($this->feather->request->isPost()) { $zap_id = intval(key($this->request->post('zap_id'))); $user_id = $this->user->id; $this->model->zap_report($zap_id, $user_id); Url::redirect($this->feather->urlFor('adminReports'), __('Report zapped redirect')); } AdminUtils::generateAdminMenu('reports'); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Reports')), 'active_page' => 'admin', 'admin_console' => true, 'report_data' => $this->model->get_reports(), 'report_zapped_data' => $this->model->get_zapped_reports()))->addTemplate('admin/reports.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 remove_word() { $id = intval(key($this->request->post('remove'))); $id = $this->hook->fire('remove_censoring_word_start', $id); $result = DB::for_table('censoring')->find_one($id); $result = $this->hook->fireDB('remove_censoring_word', $result); $result = $result->delete(); // Regenerate the censoring cache $this->feather->cache->store('search_for', Cache::get_censoring('search_for')); $this->feather->cache->store('replace_with', Cache::get_censoring('replace_with')); Url::redirect($this->feather->urlFor('adminCensoring'), __('Word removed redirect')); }
public function edit($req, $res, $args) { Container::get('hooks')->fire('controller.admin.forums.edit'); if (Request::isPost()) { if (Input::post('save') && Input::post('read_forum_old')) { // Forums parameters / TODO : better handling of wrong parameters $forum_data = array('forum_name' => Utils::escape(Input::post('forum_name')), 'forum_desc' => Input::post('forum_desc') ? Utils::linebreaks(Utils::trim(Input::post('forum_desc'))) : NULL, 'cat_id' => (int) Input::post('cat_id'), 'sort_by' => (int) Input::post('sort_by'), 'redirect_url' => Url::is_valid(Input::post('redirect_url')) ? Utils::escape(Input::post('redirect_url')) : NULL); if ($forum_data['forum_name'] == '') { return Router::redirect(Router::pathFor('editForum', array('id' => $args['id'])), __('Must enter name message')); } if ($forum_data['cat_id'] < 1) { return Router::redirect(Router::pathFor('editForum', array('id' => $args['id'])), __('Must be valid category')); } $this->model->update_forum($args['id'], $forum_data); // Permissions $permissions = $this->model->get_default_group_permissions(false); foreach ($permissions as $perm_group) { $permissions_data = array('group_id' => $perm_group['g_id'], 'forum_id' => $args['id']); if ($perm_group['g_read_board'] == '1' && isset(Input::post('read_forum_new')[$perm_group['g_id']]) && Input::post('read_forum_new')[$perm_group['g_id']] == '1') { $permissions_data['read_forum'] = '1'; } else { $permissions_data['read_forum'] = '0'; } $permissions_data['post_replies'] = isset(Input::post('post_replies_new')[$perm_group['g_id']]) ? '1' : '0'; $permissions_data['post_topics'] = isset(Input::post('post_topics_new')[$perm_group['g_id']]) ? '1' : '0'; // Check if the new settings differ from the old if ($permissions_data['read_forum'] != Input::post('read_forum_old')[$perm_group['g_id']] || $permissions_data['post_replies'] != Input::post('post_replies_old')[$perm_group['g_id']] || $permissions_data['post_topics'] != Input::post('post_topics_old')[$perm_group['g_id']]) { // If there is no group permissions override for this forum if ($permissions_data['read_forum'] == '1' && $permissions_data['post_replies'] == $perm_group['g_post_replies'] && $permissions_data['post_topics'] == $perm_group['g_post_topics']) { $this->model->delete_permissions($args['id'], $perm_group['g_id']); } else { // Run an UPDATE and see if it affected a row, if not, INSERT $this->model->update_permissions($permissions_data); } } } // Regenerate the quick jump cache Container::get('cache')->store('quickjump', Cache::get_quickjump()); return Router::redirect(Router::pathFor('editForum', array('id' => $args['id'])), __('Forum updated redirect')); } elseif (Input::post('revert_perms')) { $this->model->delete_permissions($args['id']); // Regenerate the quick jump cache Container::get('cache')->store('quickjump', Cache::get_quickjump()); return Router::redirect(Router::pathFor('editForum', array('id' => $args['id'])), __('Perms reverted redirect')); } } else { AdminUtils::generateAdminMenu('forums'); View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Forums')), 'active_page' => 'admin', 'admin_console' => true, 'perm_data' => $this->model->get_permissions($args['id']), 'cur_index' => 7, 'cur_forum' => $this->model->get_forum_info($args['id']), 'forum_data' => $this->model->get_forums()))->addTemplate('admin/forums/permissions.php')->display(); } }
public function delete_category() { $cat_to_delete = (int) $this->request->post('cat_to_delete'); if ($cat_to_delete < 1) { throw new Error(__('Bad request'), '400'); } if (intval($this->request->post('disclaimer')) != 1) { Url::redirect($this->feather->urlFor('adminCategories'), __('Delete category not validated')); } if ($this->model->delete_category($cat_to_delete)) { Url::redirect($this->feather->urlFor('adminCategories'), __('Category deleted redirect')); } else { Url::redirect($this->feather->urlFor('adminCategories'), __('Unable to delete category')); } }
public function rules() { // If we are logged in, we shouldn't be here if (!$this->user->is_guest) { Url::redirect($this->feather->urlFor('home')); } // Display an error message if new registrations are disabled if ($this->config['o_regs_allow'] == '0') { throw new Error(__('No new regs'), 403); } if ($this->config['o_rules'] != '1') { Url::redirect($this->feather->urlFor('register')); } $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Register'), __('Forum rules')), 'active_page' => 'register'))->addTemplate('register/rules.php')->display(); }
public function display() { // Display bans if ($this->request->get('find_ban')) { $ban_info = $this->model->find_ban(); // Determine the ban offset (based on $_GET['p']) $num_pages = ceil($ban_info['num_bans'] / 50); $p = !$this->request->get('p') || $this->request->get('p') <= 1 || $this->request->get('p') > $num_pages ? 1 : intval($this->request->get('p')); $start_from = 50 * ($p - 1); $ban_data = $this->model->find_ban($start_from); $this->feather->template->setPageInfo(array('admin_console' => true, 'page' => $p, 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans'), __('Results head')), 'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?find_ban=&' . implode('&', $ban_info['query_str'])), 'ban_data' => $ban_data['data']))->addTemplate('admin/bans/search_ban.php')->display(); } else { AdminUtils::generateAdminMenu('bans'); $this->feather->template->setPageInfo(array('admin_console' => true, 'focus_element' => array('bans', 'new_ban_user'), 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans'))))->addTemplate('admin/bans/admin_bans.php')->display(); } }
public function display($req, $res, $args) { Container::get('hooks')->fire('controller.admin.bans.display'); // Display bans if (Input::query('find_ban')) { $ban_info = $this->model->find_ban(); // Determine the ban offset (based on $_GET['p']) $num_pages = ceil($ban_info['num_bans'] / 50); $p = !Input::query('p') || Input::query('p') <= 1 || Input::query('p') > $num_pages ? 1 : intval(Input::query('p')); $start_from = 50 * ($p - 1); $ban_data = $this->model->find_ban($start_from); View::setPageInfo(array('admin_console' => true, 'page' => $p, 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Bans'), __('Results head')), 'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?find_ban=&' . implode('&', $ban_info['query_str'])), 'ban_data' => $ban_data['data']))->addTemplate('admin/bans/search_ban.php')->display(); } else { AdminUtils::generateAdminMenu('bans'); View::setPageInfo(array('admin_console' => true, 'focus_element' => array('bans', 'new_ban_user'), 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Bans'))))->addTemplate('admin/bans/admin_bans.php')->display(); } }
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 update_permissions() { $form = array_map('intval', $this->request->post('form')); $form = $this->hook->fire('permissions.update_permissions.form', $form); foreach ($form as $key => $input) { // Make sure the input is never a negative value if ($input < 0) { $input = 0; } // Only update values that have changed if (array_key_exists('p_' . $key, $this->config) && $this->config['p_' . $key] != $input) { DB::for_table('config')->where('conf_name', 'p_' . $key)->update_many('conf_value', $input); } } // Regenerate the config cache $this->feather->cache->store('config', Cache::get_config()); // $this->clear_feed_cache(); Url::redirect($this->feather->urlFor('adminPermissions'), __('Perms updated redirect')); }
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 display($action = null) { // Check for upgrade if ($action == 'check_upgrade') { if (!ini_get('allow_url_fopen')) { throw new Error(__('fopen disabled message'), 500); } $latest_version = trim(@file_get_contents('http://featherbb.org/latest_version')); if (empty($latest_version)) { throw new Error(__('Upgrade check failed message'), 500); } if (version_compare($this->config['o_cur_version'], $latest_version, '>=')) { Url::redirect($this->feather->urlFor('adminIndex'), __('Running latest version message')); } else { Url::redirect($this->feather->urlFor('adminIndex'), sprintf(__('New version available message'), '<a href="http://featherbb.org/">FeatherBB.org</a>')); } } AdminUtils::generateAdminMenu('index'); $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Index')), 'active_page' => 'admin', 'admin_console' => true))->addTemplate('admin/index.php')->display(); }
public function handle_deletion($is_topic_post, $id, $tid, $fid) { $this->hook->fire('handle_deletion_start', $is_topic_post, $id, $tid, $fid); if ($is_topic_post) { $this->hook->fire('handle_deletion_topic_post', $tid, $fid); // Delete the topic and all of its posts self::topic($tid); Forum::update($fid); Url::redirect($this->feather->urlFor('Forum', array('id' => $fid)), __('Topic del redirect')); } else { $this->hook->fire('handle_deletion', $tid, $fid, $id); // Delete just this one post self::post($id, $tid); Forum::update($fid); // Redirect towards the previous post $post = DB::for_table('posts')->select('id')->where('topic_id', $tid)->where_lt('id', $id)->order_by_desc('id'); $post = $this->hook->fireDB('handle_deletion_query', $post); $post = $post->find_one(); Url::redirect($this->feather->urlFor('viewPost', ['pid' => $post['id']]) . '#p' . $post['id'], __('Post del redirect')); } }
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(); }
?> "<?php echo $button_status; ?> /> <input type="submit" name="delete_posts" value="<?php _e('Delete'); ?> "<?php echo $button_status; ?> /></p> <div class="clearer"></div> </div> <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' => $fid, 'name' => $url_forum]); ?> "><?php echo Utils::escape($cur_topic['forum_name']); ?> </a></li> <li><span>» </span><a href="<?php echo Router::pathFor('Topic', ['id' => $id, 'name' => $url_topic]); ?>
echo "\t\t\t\t\t\t" . '</tr>' . "\n"; } ?> <tr> <td class="tcl" colspan="2"><?php echo sprintf(__('Total query time'), round($queries_info['total_time'], 7)) . ' s'; ?> </td> </tr> </tbody> </table> </div> </div> </div> <?php } ?> </section> </body> <!-- JS --> <?php foreach ($assets['js'] as $script) { echo '<script '; foreach ($script['params'] as $key => $value) { echo $key . '="' . $value . '" '; } echo 'src="' . Url::base() . '/' . $script['file'] . '"/></script>' . "\n"; } ?> </html>
public function insert_user($user) { $user = $this->hook->fire('insert_user_start', $user); // Insert the new user into the database. We do this now to get the last inserted ID for later use $now = time(); $intial_group_id = $this->config['o_regs_verify'] == '0' ? $this->config['o_default_user_group'] : $this->feather->forum_env['FEATHER_UNVERIFIED']; $password_hash = Random::hash($user['password1']); // Add the user $user['insert'] = array('username' => $user['username'], 'group_id' => $intial_group_id, 'password' => $password_hash, 'email' => $user['email1'], 'email_setting' => $this->config['o_default_email_setting'], 'timezone' => $this->config['o_default_timezone'], 'dst' => 0, 'language' => $user['language'], 'style' => $this->config['o_default_style'], 'registered' => $now, 'registration_ip' => $this->request->getIp(), 'last_visit' => $now); $user = DB::for_table('users')->create()->set($user['insert']); $user = $this->hook->fireDB('insert_user_query', $user); $user = $user->save(); $new_uid = DB::get_db()->lastInsertId($this->feather->forum_settings['db_prefix'] . 'users'); if ($this->config['o_regs_verify'] == '0') { // Regenerate the users info cache if (!$this->feather->cache->isCached('users_info')) { $this->feather->cache->store('users_info', Cache::get_users_info()); } $stats = $this->feather->cache->retrieve('users_info'); } // If the mailing list isn't empty, we may need to send out some alerts if ($this->config['o_mailing_list'] != '') { // If we previously found out that the email was banned if (isset($user['banned_email'])) { // Load the "banned email register" template $mail_tpl = trim(file_get_contents($this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->user->language . '/mail_templates/banned_email_register.tpl')); $mail_tpl = $this->hook->fire('insert_user_banned_mail_tpl', $mail_tpl); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_subject = $this->hook->fire('insert_user_banned_mail_subject', $mail_subject); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<email>', $user['email1'], $mail_message); $mail_message = str_replace('<profile_url>', $this->feather->urlFor('userProfile', ['id' => $new_uid]), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); $mail_message = $this->hook->fire('insert_user_banned_mail_message', $mail_message); $this->email->feather_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } // If we previously found out that the email was a dupe if (!empty($dupe_list)) { // Load the "dupe email register" template $mail_tpl = trim(file_get_contents($this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->user->language . '/mail_templates/dupe_email_register.tpl')); $mail_tpl = $this->hook->fire('insert_user_dupe_mail_tpl', $mail_tpl); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_subject = $this->hook->fire('insert_user_dupe_mail_subject', $mail_subject); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<dupe_list>', implode(', ', $dupe_list), $mail_message); $mail_message = str_replace('<profile_url>', $this->feather->urlFor('userProfile', ['id' => $new_uid]), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); $mail_message = $this->hook->fire('insert_user_dupe_mail_message', $mail_message); $this->email->feather_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } // Should we alert people on the admin mailing list that a new user has registered? if ($this->config['o_regs_report'] == '1') { // Load the "new user" template $mail_tpl = trim(file_get_contents($this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->user->language . '/mail_templates/new_user.tpl')); $mail_tpl = $this->hook->fire('insert_user_new_mail_tpl', $mail_tpl); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_subject = $this->hook->fire('insert_user_new_mail_subject', $mail_subject); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<base_url>', $this->feather->urlFor('home'), $mail_message); $mail_message = str_replace('<profile_url>', $this->feather->urlFor('userProfile', ['id' => $new_uid]), $mail_message); $mail_message = str_replace('<admin_url>', $this->feather->urlFor('profileSection', ['id' => $new_uid, 'section' => 'admin']), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); $mail_message = $this->hook->fire('insert_user_new_mail_message', $mail_message); $this->email->feather_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } } // Must the user verify the registration or do we log him/her in right now? if ($this->config['o_regs_verify'] == '1') { // Load the "welcome" template $mail_tpl = trim(file_get_contents($this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->user->language . '/mail_templates/welcome.tpl')); $mail_tpl = $this->hook->fire('insert_user_welcome_mail_tpl', $mail_tpl); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_subject = $this->hook->fire('insert_user_welcome_mail_subject', $mail_subject); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_subject = str_replace('<board_title>', $this->config['o_board_title'], $mail_subject); $mail_message = str_replace('<base_url>', $this->feather->urlFor('home'), $mail_message); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<password>', $user['password1'], $mail_message); $mail_message = str_replace('<login_url>', $this->feather->urlFor('login'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); $mail_message = $this->hook->fire('insert_user_welcome_mail_message', $mail_message); $this->email->feather_mail($user['email1'], $mail_subject, $mail_message); Url::redirect($this->feather->urlFor('home'), __('Reg email') . ' <a href="mailto:' . Utils::escape($this->config['o_admin_email']) . '">' . Utils::escape($this->config['o_admin_email']) . '</a>.'); } $this->auth->feather_setcookie($new_uid, $password_hash, time() + $this->config['o_timeout_visit']); $this->hook->fire('insert_user'); Url::redirect($this->feather->urlFor('home'), __('Reg complete')); }
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 subscribe_forum($forum_id) { $forum_id = $this->hook->fire('subscribe_forum_start', $forum_id); if ($this->config['o_forum_subscriptions'] != '1') { throw new Error(__('No permission'), 403); } // Make sure the user can view the forum $authorized['where'] = array(array('fp.read_forum' => 'IS NULL'), array('fp.read_forum' => '1')); $authorized = DB::for_table('forums')->table_alias('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($authorized['where'])->where('f.id', $forum_id); $authorized = $this->hook->fireDB('subscribe_forum_authorized_query', $authorized); $authorized = $authorized->find_one(); if (!$authorized) { throw new Error(__('Bad request'), 404); } $is_subscribed = DB::for_table('forum_subscriptions')->where('user_id', $this->user->id)->where('forum_id', $forum_id); $is_subscribed = $this->hook->fireDB('subscribe_forum_subscribed_query', $is_subscribed); $is_subscribed = $is_subscribed->find_one(); if ($is_subscribed) { throw new Error(__('Already subscribed forum'), 400); } // Insert the subscription $subscription['insert'] = array('user_id' => $this->user->id, 'forum_id' => $forum_id); $subscription = DB::for_table('forum_subscriptions')->create()->set($subscription['insert']); $subscription = $this->hook->fireDB('subscribe_forum_query', $subscription); $subscription = $subscription->save(); Url::redirect($this->feather->urlFor('Forum', ['id' => $forum_id]), __('Subscribe redirect')); }
public function print_posts($topic_id, $start_from, $cur_topic, $is_admmod) { $post_data = array(); $post_data = Container::get('hooks')->fire('model.topic.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(User::get()->disp_topics)->offset($start_from); $result = Container::get('hooks')->fireDB('model.topic.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 ' . ForumSettings::get('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 = Container::get('hooks')->fireDB('model.topic.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 (User::get()->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 (ForumSettings::get('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 (ForumSettings::get('o_avatars') == '1' && User::get()->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 (ForumSettings::get('o_show_user_info') == '1') { if ($cur_post['location'] != '') { if (ForumSettings::get('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') . ' ' . Utils::format_time($cur_post['registered'], true) . '</span></dd>'; if (ForumSettings::get('o_show_post_count') == '1' || User::get()->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' && !User::get()->is_guest || User::get()->is_admmod) && User::get()->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' && !User::get()->is_guest && User::get()->g_send_email == '1') { $cur_post['user_contacts'][] = '<span class="email"><a href="' . Router::pathFor('email', ['id' => $cur_post['poster_id']]) . '">' . __('Email') . '</a></span>'; } if ($cur_post['url'] != '') { if (ForumSettings::get('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 (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || User::get()->g_moderator == '1' && User::get()->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 (User::get()->is_admmod) { $cur_post['user_info'][] = '<dd><span><a href="' . Router::pathFor('getPostHost', ['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 (User::get()->is_admmod) { $cur_post['user_info'][] = '<dd><span><a href="' . Router::pathFor('getPostHost', ['pid' => $cur_post['id']]) . '" title="' . Utils::escape($cur_post['poster_ip']) . '">' . __('IP address logged') . '</a></span></dd>'; } if (ForumSettings::get('o_show_user_info') == '1' && $cur_post['poster_email'] != '' && !User::get()->is_guest && User::get()->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 (!User::get()->is_guest) { $cur_post['post_actions'][] = '<li class="postreport"><span><a href="' . Router::pathFor('report', ['id' => $cur_post['id']]) . '">' . __('Report') . '</a></span></li>'; } if ($cur_topic['closed'] == '0') { if ($cur_post['poster_id'] == User::get()->id) { if ($start_from + $post_count == 1 && User::get()->g_delete_topics == '1' || $start_from + $post_count > 1 && User::get()->g_delete_posts == '1') { $cur_post['post_actions'][] = '<li class="postdelete"><span><a href="' . Router::pathFor('deletePost', ['id' => $cur_post['id']]) . '">' . __('Delete') . '</a></span></li>'; } if (User::get()->g_edit_posts == '1') { $cur_post['post_actions'][] = '<li class="postedit"><span><a href="' . Router::pathFor('editPost', ['id' => $cur_post['id']]) . '">' . __('Edit') . '</a></span></li>'; } } if ($cur_topic['post_replies'] == '' && User::get()->g_post_replies == '1' || $cur_topic['post_replies'] == '1') { $cur_post['post_actions'][] = '<li class="postquote"><span><a href="' . Router::pathFor('newQuoteReply', ['tid' => $topic_id, 'qid' => $cur_post['id']]) . '">' . __('Quote') . '</a></span></li>'; } } } else { $cur_post['post_actions'][] = '<li class="postreport"><span><a href="' . Router::pathFor('report', ['id' => $cur_post['id']]) . '">' . __('Report') . '</a></span></li>'; if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || !in_array($cur_post['poster_id'], $admin_ids)) { $cur_post['post_actions'][] = '<li class="postdelete"><span><a href="' . Router::pathFor('deletePost', ['id' => $cur_post['id']]) . '">' . __('Delete') . '</a></span></li>'; $cur_post['post_actions'][] = '<li class="postedit"><span><a href="' . Router::pathFor('editPost', ['id' => $cur_post['id']]) . '">' . __('Edit') . '</a></span></li>'; } $cur_post['post_actions'][] = '<li class="postquote"><span><a href="' . Router::pathFor('newQuoteReply', ['tid' => $topic_id, 'qid' => $cur_post['id']]) . '">' . __('Quote') . '</a></span></li>'; } // 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']); // Do signature parsing/caching if (ForumSettings::get('o_signatures') == '1' && $cur_post['signature'] != '' && User::get()->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'] = Container::get('parser')->parse_signature($cur_post['signature']); // $avatar_cache[$cur_post['poster_id']] = $cur_post['signature_formatted']; // } } $cur_post = Container::get('hooks')->fire('model.print_posts.one', $cur_post); $post_data[] = $cur_post; } $post_data = Container::get('hooks')->fire('model.topic.print_posts', $post_data); return $post_data; }
<p><a name="img"></a><?php _e('Images info'); ?> </p> dede <p><code>[img=<?php _e('FeatherBB bbcode test'); ?> ]<?php echo Utils::escape(Url::base(true)); ?> /style/img/logo.png[/img]</code> <?php _e('produces'); ?> <samp><img style="height: 21px" src="<?php echo Utils::escape(Url::base(true)); ?> /style/img/logo.png" alt="<?php _e('FeatherBB bbcode test'); ?> " /></samp></p> </div> </div> <h2><span><?php _e('Quotes'); ?> </span></h2> <div class="box"> <div class="inbox"> <p><?php _e('Quotes info');
} 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'); ?>
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 update_profile($id, $info, $section) { $info = Container::get('hooks')->fire('model.profile.update_profile_start', $info, $id, $section); $username_updated = false; $section = Container::get('hooks')->fire('model.profile.update_profile_section', $section, $id, $info); // Validate input depending on section switch ($section) { case 'essentials': $form = array('timezone' => floatval(Input::post('form_timezone')), 'dst' => Input::post('form_dst') ? '1' : '0', 'time_format' => intval(Input::post('form_time_format')), 'date_format' => intval(Input::post('form_date_format'))); // Make sure we got a valid language string if (Input::post('form_language')) { $languages = \FeatherBB\Core\Lister::getLangs(); $form['language'] = Utils::trim(Input::post('form_language')); if (!in_array($form['language'], $languages)) { throw new Error(__('Bad request'), 404); } } if (User::get()->is_admmod) { $form['admin_note'] = Utils::trim(Input::post('admin_note')); // Are we allowed to change usernames? if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || User::get()->g_moderator == '1' && User::get()->g_mod_rename_users == '1') { $form['username'] = Utils::trim(Input::post('req_username')); if ($form['username'] != $info['old_username']) { $errors = ''; $errors = $this->check_username($form['username'], $errors, $id); if (!empty($errors)) { throw new Error($errors[0]); } $username_updated = true; } } // We only allow administrators to update the post count if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) { $form['num_posts'] = intval(Input::post('num_posts')); } } if (ForumSettings::get('o_regs_verify') == '0' || User::get()->is_admmod) { // Validate the email address $form['email'] = strtolower(Utils::trim(Input::post('req_email'))); if (!Container::get('email')->is_valid_email($form['email'])) { throw new Error(__('Invalid email')); } } break; case 'personal': $form = array('realname' => Input::post('form_realname') ? Utils::trim(Input::post('form_realname')) : '', 'url' => Input::post('form_url') ? Utils::trim(Input::post('form_url')) : '', 'location' => Input::post('form_location') ? Utils::trim(Input::post('form_location')) : ''); // Add http:// if the URL doesn't contain it already (while allowing https://, too) if (User::get()->g_post_links == '1') { if ($form['url'] != '') { $url = Url::is_valid($form['url']); if ($url === false) { throw new Error(__('Invalid website URL')); } $form['url'] = $url['url']; } } else { if (!empty($form['url'])) { throw new Error(__('Website not allowed')); } $form['url'] = ''; } if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) { $form['title'] = Utils::trim(Input::post('title')); } elseif (User::get()->g_set_title == '1') { $form['title'] = Utils::trim(Input::post('title')); if ($form['title'] != '') { // A list of words that the title may not contain // If the language is English, there will be some duplicates, but it's not the end of the world $forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', utf8_strtolower(__('Member')), utf8_strtolower(__('Moderator')), utf8_strtolower(__('Administrator')), utf8_strtolower(__('Banned')), utf8_strtolower(__('Guest'))); if (in_array(utf8_strtolower($form['title']), $forbidden)) { throw new Error(__('Forbidden title')); } } } break; case 'messaging': $form = array('jabber' => Utils::trim(Input::post('form_jabber')), 'icq' => Utils::trim(Input::post('form_icq')), 'msn' => Utils::trim(Input::post('form_msn')), 'aim' => Utils::trim(Input::post('form_aim')), 'yahoo' => Utils::trim(Input::post('form_yahoo'))); // If the ICQ UIN contains anything other than digits it's invalid if (preg_match('%[^0-9]%', $form['icq'])) { throw new Error(__('Bad ICQ')); } break; case 'personality': $form = array(); // Clean up signature from POST if (ForumSettings::get('o_signatures') == '1') { $form['signature'] = Utils::linebreaks(Utils::trim(Input::post('signature'))); // Validate signature if (Utils::strlen($form['signature']) > ForumSettings::get('p_sig_length')) { throw new Error(sprintf(__('Sig too long'), ForumSettings::get('p_sig_length'), Utils::strlen($form['signature']) - ForumSettings::get('p_sig_length'))); } elseif (substr_count($form['signature'], "\n") > ForumSettings::get('p_sig_lines') - 1) { throw new Error(sprintf(__('Sig too many lines'), ForumSettings::get('p_sig_lines'))); } elseif ($form['signature'] && ForumSettings::get('p_sig_all_caps') == '0' && Utils::is_all_uppercase($form['signature']) && !User::get()->is_admmod) { $form['signature'] = utf8_ucwords(utf8_strtolower($form['signature'])); } // Validate BBCode syntax if (ForumSettings::get('p_sig_bbcode') == '1') { $errors = array(); $form['signature'] = Container::get('parser')->preparse_bbcode($form['signature'], $errors, true); if (count($errors) > 0) { throw new Error('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'); } } } break; case 'display': $form = array('disp_topics' => Utils::trim(Input::post('form_disp_topics')), 'disp_posts' => Utils::trim(Input::post('form_disp_posts')), 'show_smilies' => Input::post('form_show_smilies') ? '1' : '0', 'show_img' => Input::post('form_show_img') ? '1' : '0', 'show_img_sig' => Input::post('form_show_img_sig') ? '1' : '0', 'show_avatars' => Input::post('form_show_avatars') ? '1' : '0', 'show_sig' => Input::post('form_show_sig') ? '1' : '0'); if ($form['disp_topics'] != '') { $form['disp_topics'] = intval($form['disp_topics']); if ($form['disp_topics'] < 3) { $form['disp_topics'] = 3; } elseif ($form['disp_topics'] > 75) { $form['disp_topics'] = 75; } } if ($form['disp_posts'] != '') { $form['disp_posts'] = intval($form['disp_posts']); if ($form['disp_posts'] < 3) { $form['disp_posts'] = 3; } elseif ($form['disp_posts'] > 75) { $form['disp_posts'] = 75; } } // Make sure we got a valid style string if (Input::post('form_style')) { $styles = \FeatherBB\Core\Lister::getStyles(); $form['style'] = Utils::trim(Input::post('form_style')); if (!in_array($form['style'], $styles)) { throw new Error(__('Bad request'), 404); } } break; case 'privacy': $form = array('email_setting' => intval(Input::post('form_email_setting')), 'notify_with_post' => Input::post('form_notify_with_post') ? '1' : '0', 'auto_notify' => Input::post('form_auto_notify') ? '1' : '0'); if ($form['email_setting'] < 0 || $form['email_setting'] > 2) { $form['email_setting'] = ForumSettings::get('o_default_email_setting'); } break; default: throw new Error(__('Bad request'), 404); } $form = Container::get('hooks')->fire('model.profile.update_profile_form', $form, $section, $id, $info); // Single quotes around non-empty values and nothing for empty values $temp = array(); foreach ($form as $key => $input) { $temp[$key] = $input; } if (empty($temp)) { throw new Error(__('Bad request'), 404); } $update_user = DB::for_table('users')->where('id', $id)->find_one()->set($temp); $update_user = Container::get('hooks')->fireDB('model.profile.update_profile_query', $update_user); $update_user = $update_user->save(); // If we changed the username we have to update some stuff if ($username_updated) { $bans_updated = DB::for_table('bans')->where('username', $info['old_username']); $bans_updated = Container::get('hooks')->fireDB('model.profile.update_profile_bans_updated', $bans_updated); $bans_updated = $bans_updated->update_many('username', $form['username']); $update_poster_id = DB::for_table('posts')->where('poster_id', $id); $update_poster_id = Container::get('hooks')->fireDB('model.profile.update_profile_poster_id', $update_poster_id); $update_poster_id = $update_poster_id->update_many('poster', $form['username']); $update_posts = DB::for_table('posts')->where('edited_by', $info['old_username']); $update_posts = Container::get('hooks')->fireDB('model.profile.update_profile_posts', $update_posts); $update_posts = $update_posts->update_many('edited_by', $form['username']); $update_topics_poster = DB::for_table('topics')->where('poster', $info['old_username']); $update_topics_poster = Container::get('hooks')->fireDB('model.profile.update_profile_topics_poster', $update_topics_poster); $update_topics_poster = $update_topics_poster->update_many('poster', $form['username']); $update_topics_last_poster = DB::for_table('topics')->where('last_poster', $info['old_username']); $update_topics_last_poster = Container::get('hooks')->fireDB('model.profile.update_profile_topics_last_poster', $update_topics_last_poster); $update_topics_last_poster = $update_topics_last_poster->update_many('last_poster', $form['username']); $update_forums = DB::for_table('forums')->where('last_poster', $info['old_username']); $update_forums = Container::get('hooks')->fireDB('model.profile.update_profile_forums', $update_forums); $update_forums = $update_forums->update_many('last_poster', $form['username']); $update_online = DB::for_table('online')->where('ident', $info['old_username']); $update_online = Container::get('hooks')->fireDB('model.profile.update_profile_online', $update_online); $update_online = $update_online->update_many('ident', $form['username']); // If the user is a moderator or an administrator we have to update the moderator lists $group_id = DB::for_table('users')->where('id', $id); // TODO: restore hook // $group_id = Container::get('hooks')->fireDB('model.profile.update_profile_group_id', $update_online); $group_id = $group_id->find_one_col('group_id'); $group_mod = DB::for_table('groups')->where('g_id', $group_id); $group_mod = Container::get('hooks')->fireDB('model.profile.update_profile_group_mod', $group_mod); $group_mod = $group_mod->find_one_col('g_moderator'); if ($group_id == ForumEnv::get('FEATHER_ADMIN') || $group_mod == '1') { // Loop through all forums $result = $this->loop_mod_forums(); foreach ($result as $cur_forum) { $cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array(); if (in_array($id, $cur_moderators)) { unset($cur_moderators[$info['old_username']]); $cur_moderators[$form['username']] = $id; uksort($cur_moderators, 'utf8_strcasecmp'); $update_mods = DB::for_table('forums')->where('id', $cur_forum['id'])->find_one()->set('moderators', serialize($cur_moderators)); $update_mods = Container::get('hooks')->fireDB('model.profile.update_profile_mods', $update_mods); $update_mods = $update_mods->save(); } } } // Regenerate the users info cache if (!Container::get('cache')->isCached('users_info')) { Container::get('cache')->store('users_info', Cache::get_users_info()); } $stats = Container::get('cache')->retrieve('users_info'); // Check if the bans table was updated and regenerate the bans cache when needed if ($bans_updated) { Container::get('cache')->store('bans', Cache::get_bans()); } } $section = Container::get('hooks')->fireDB('model.profile.update_profile', $section, $id); return Router::redirect(Router::pathFor('profileSection', array('id' => $id, 'section' => $section)), __('Profile redirect')); }