Пример #1
0
 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();
     }
 }
Пример #2
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.search.display');
     if (User::get()->g_search == '0') {
         throw new Error(__('No search permission'), 403);
     }
     // Figure out what to do :-)
     if (Input::query('action') || Input::query('search_id')) {
         $search = $this->model->get_search_results();
         // We have results to display
         if (!is_object($search) && isset($search['is_result'])) {
             View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Search results')), 'active_page' => 'search', 'search' => $search, 'footer' => $search));
             $display = $this->model->display_search_results($search);
             View::setPageInfo(array('display' => $display));
             View::addTemplate('search/header.php', 1);
             if ($search['show_as'] == 'posts') {
                 View::addTemplate('search/posts.php', 5);
             } else {
                 View::addTemplate('search/topics.php', 5);
             }
             View::addTemplate('search/footer.php', 10)->display();
         } else {
             return Router::redirect(Router::pathFor('search'), __('No hits'));
         }
     } else {
         View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('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();
     }
 }
Пример #3
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.statistics.display');
     AdminUtils::generateAdminMenu('index');
     $total = $this->model->get_total_size();
     return View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Server statistics')), 'active_page' => 'admin', 'admin_console' => true, 'server_load' => $this->model->get_server_load(), 'num_online' => $this->model->get_num_online(), 'total_size' => $total['size'], 'total_records' => $total['records'], 'php_accelerator' => $this->model->get_php_accelerator()))->addTemplate('admin/statistics.php')->display();
 }
Пример #4
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.maintenance.display');
     $action = '';
     if (Input::post('action')) {
         $action = Input::post('action');
     } elseif (Input::query('action')) {
         $action = Input::query('action');
     }
     if ($action == 'rebuild') {
         $this->model->rebuild();
         View::setPageInfo(array('page_title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Rebuilding search index')), 'query_str' => $this->model->get_query_str()))->addTemplate('admin/maintenance/rebuild.php')->display();
     }
     if ($action == 'prune') {
         $prune_from = Utils::trim(Input::post('prune_from'));
         $prune_sticky = intval(Input::post('prune_sticky'));
         AdminUtils::generateAdminMenu('maintenance');
         if (Input::post('prune_comply')) {
             $this->model->prune_comply($prune_from, $prune_sticky);
         }
         View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Prune')), 'active_page' => 'admin', 'admin_console' => true, 'prune_sticky' => $prune_sticky, 'prune_from' => $prune_from, 'prune' => $this->model->get_info_prune($prune_sticky, $prune_from)))->addTemplate('admin/maintenance/prune.php')->display();
     }
     AdminUtils::generateAdminMenu('maintenance');
     View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Maintenance')), 'active_page' => 'admin', 'admin_console' => true, 'first_id' => $this->model->get_first_id(), 'categories' => $this->model->get_categories()))->addTemplate('admin/maintenance/admin_maintenance.php')->display();
 }
Пример #5
0
 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='******'&amp;show_group=' . $show_group . '&amp;sort_by=' . $sort_by . '&amp;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();
 }
Пример #6
0
 public function validate_search_word($word, $idx)
 {
     static $stopwords;
     // If the word is a keyword we don't want to index it, but we do want to be allowed to search it
     if ($this->is_keyword($word)) {
         return !$idx;
     }
     if (!isset($stopwords)) {
         if (!$this->feather->cache->isCached('stopwords')) {
             $this->feather->cache->store('stopwords', \FeatherBB\Model\Cache::get_config(), '+1 week');
         }
         $stopwords = $this->feather->cache->retrieve('stopwords');
     }
     // If it is a stopword it isn't valid
     if (in_array($word, $stopwords)) {
         return false;
     }
     // If the word is CJK we don't want to index it, but we do want to be allowed to search it
     if ($this->is_cjk($word)) {
         return !$idx;
     }
     // Exclude % and * when checking whether current word is valid
     $word = str_replace(array('%', '*'), '', $word);
     // Check the word is within the min/max length
     $num_chars = Utils::strlen($word);
     return $num_chars >= $this->feather->forum_env['FEATHER_SEARCH_MIN_WORD'] && $num_chars <= $this->feather->forum_env['FEATHER_SEARCH_MAX_WORD'];
 }
Пример #7
0
 public function rules()
 {
     Container::get('hooks')->fire('controller.index.rules');
     if (ForumSettings::get('o_rules') == '0' || User::get()->is_guest && User::get()->g_read_board == '0' && ForumSettings::get('o_regs_allow') == '0') {
         throw new Error(__('Bad request'), 404);
     }
     View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Forum rules')), 'active_page' => 'rules'))->addTemplate('misc/rules.php')->display();
 }
Пример #8
0
 public function display()
 {
     if ($this->feather->request->isPost()) {
         $this->model->update_options();
     }
     AdminUtils::generateAdminMenu('options');
     $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Options')), 'active_page' => 'admin', 'admin_console' => true, 'languages' => $this->model->get_langs(), 'styles' => $this->model->get_styles(), 'times' => $this->model->get_times()))->addTemplate('admin/options.php')->display();
 }
Пример #9
0
 public function edit($id)
 {
     if ($this->request->post('add_edit_ban')) {
         $this->model->insert_ban();
     }
     AdminUtils::generateAdminMenu('bans');
     $this->feather->template->setPageInfo(array('admin_console' => true, 'focus_element' => array('bans2', 'ban_user'), 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans')), 'ban' => $this->model->edit_ban_info($id)))->addTemplate('admin/bans/add_ban.php')->display();
 }
Пример #10
0
 public static function get_info()
 {
     $data = array('exec_time' => Utils::get_microtime() - Container::get('start'));
     $data['nb_queries'] = isset(DB::get_query_log()[0]) ? count(DB::get_query_log()[0]) : 'N/A';
     $data['mem_usage'] = function_exists('memory_get_usage') ? Utils::file_size(memory_get_usage()) : 'N/A';
     $data['mem_peak_usage'] = function_exists('memory_get_peak_usage') ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
     return $data;
 }
Пример #11
0
 public function edit($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.bans.edit');
     if (Input::post('add_edit_ban')) {
         return $this->model->insert_ban();
     }
     AdminUtils::generateAdminMenu('bans');
     View::setPageInfo(array('admin_console' => true, 'focus_element' => array('bans2', 'ban_user'), 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Bans')), 'ban' => $this->model->edit_ban_info($args['id'])))->addTemplate('admin/bans/add_ban.php')->display();
 }
Пример #12
0
 public function display()
 {
     // Update permissions
     if ($this->feather->request->isPost()) {
         $this->model->update_permissions();
     }
     AdminUtils::generateAdminMenu('permissions');
     $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Permissions')), 'active_page' => 'admin', 'admin_console' => true))->addTemplate('admin/permissions.php')->display();
 }
Пример #13
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.options.display');
     if (Request::isPost()) {
         return $this->model->update_options();
     }
     AdminUtils::generateAdminMenu('options');
     View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Options')), 'active_page' => 'admin', 'admin_console' => true, 'languages' => $this->model->get_langs(), 'styles' => $this->model->get_styles(), 'times' => $this->model->get_times()))->addTemplate('admin/options.php')->display();
 }
Пример #14
0
 public static function get_info()
 {
     self::$feather = \Slim\Slim::getInstance();
     $data = array('exec_time' => Utils::get_microtime() - self::$feather->start);
     $data['nb_queries'] = isset(DB::get_query_log()[0]) ? count(DB::get_query_log()[0]) : 'N/A';
     $data['mem_usage'] = function_exists('memory_get_usage') ? Utils::file_size(memory_get_usage()) : 'N/A';
     $data['mem_peak_usage'] = function_exists('memory_get_peak_usage') ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
     return $data;
 }
Пример #15
0
 public function getName($items)
 {
     // Split name
     $classNamespace = explode('\\', get_class($this));
     $className = end($classNamespace);
     // Prettify and return name of child class
     preg_match_all('%[A-Z]*[a-z]+%m', $className, $result, PREG_PATTERN_ORDER);
     $items[] = Utils::escape(implode(' ', $result[0]));
     return $items;
 }
Пример #16
0
 public function index($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.plugins.index');
     View::addAsset('js', 'style/imports/common.js', array('type' => 'text/javascript'));
     $availablePlugins = Lister::getPlugins();
     $activePlugins = Container::get('cache')->isCached('activePlugins') ? Container::get('cache')->retrieve('activePlugins') : array();
     $officialPlugins = Lister::getOfficialPlugins();
     AdminUtils::generateAdminMenu('plugins');
     View::setPageInfo(array('admin_console' => true, 'active_page' => 'admin', 'availablePlugins' => $availablePlugins, 'activePlugins' => $activePlugins, 'officialPlugins' => $officialPlugins, 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Extension'))))->addTemplate('admin/plugins.php')->display();
 }
Пример #17
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.permissions.display');
     // Update permissions
     if (Request::isPost()) {
         return $this->model->update_permissions();
     }
     AdminUtils::generateAdminMenu('permissions');
     return View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Permissions')), 'active_page' => 'admin', 'admin_console' => true))->addTemplate('admin/permissions.php')->display();
 }
Пример #18
0
 public static function load_mock_forum_data(array $data)
 {
     $cat_name = __('Test category');
     $subject = __('Test post');
     $message = __('Message');
     $forum_name = __('Test forum');
     $forum_desc = __('This is just a test forum');
     $now = time();
     $ip = Utils::getIp();
     return $mock_data = array('categories' => array('cat_name' => $cat_name, 'disp_position' => 1), 'forums' => array('forum_name' => $forum_name, 'forum_desc' => $forum_desc, 'num_topics' => 1, 'num_posts' => 1, 'last_post' => $now, 'last_post_id' => 1, 'last_poster' => $data['username'], 'disp_position' => 1, 'cat_id' => 1), 'topics' => array('poster' => $data['username'], 'subject' => $subject, 'posted' => $now, 'first_post_id' => 1, 'last_post' => $now, 'last_post_id' => 1, 'last_poster' => $data['username'], 'forum_id' => 1), 'posts' => array('poster' => $data['username'], 'poster_id' => 2, 'poster_ip' => $ip, 'message' => $message, 'posted' => $now, 'topic_id' => 1));
 }
Пример #19
0
 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();
 }
Пример #20
0
 /**
  * Generate breadcrumbs from an array of name and URLs
  */
 public static function breadcrumbs_admin(array $links)
 {
     foreach ($links as $name => $url) {
         if ($name != '' && $url != '') {
             $tmp[] = '<span><a href="' . $url . '">' . Utils::escape($name) . '</a></span>';
         } else {
             $tmp[] = '<span>' . __('Deleted') . '</span>';
             return implode(' » ', $tmp);
         }
     }
     return implode(' » ', $tmp);
 }
Пример #21
0
 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&amp;fid=' . $id . '&amp;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&amp;fid=' . $id . '&amp;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);
 }
Пример #22
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.reports.display');
     // Zap a report
     if (Request::isPost()) {
         $zap_id = intval(key(Input::post('zap_id')));
         $this->model->zap_report($zap_id);
         return Router::redirect(Router::pathFor('adminReports'), __('Report zapped redirect'));
     }
     AdminUtils::generateAdminMenu('reports');
     return View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('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();
 }
Пример #23
0
 public function addedit($id = '')
 {
     $groups = $this->model->fetch_groups();
     // Add/edit a group (stage 2)
     if ($this->request->post('add_edit_group')) {
         $this->model->add_edit_group($groups, $this->feather);
     } elseif ($this->request->post('add_group') || isset($id)) {
         AdminUtils::generateAdminMenu('groups');
         $group = $this->model->info_add_group($groups, $id);
         $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('User groups')), 'active_page' => 'admin', 'admin_console' => true, 'focus_element' => array('groups2', 'req_title'), 'required_fields' => array('req_title' => __('Group title label')), 'group' => $group, 'groups' => $groups, 'id' => $id, 'group_list' => $this->model->get_group_list($groups, $group)))->addTemplate('admin/groups/add_edit_group.php')->display();
     }
 }
Пример #24
0
 public function index()
 {
     // AdminUtils::generateAdminMenu('plugins');
     $this->feather->template->addAsset('js', 'style/imports/common.js', array('type' => 'text/javascript'));
     $availablePlugins = Lister::getPlugins();
     // var_dump($availablePlugins);
     $activePlugins = $this->feather->cache->isCached('active_plugins') ? $this->feather->cache->retrieve('active_plugins') : array();
     // var_dump($activePlugins);
     // $this->feather->cache->delete('active_plugins');
     AdminUtils::generateAdminMenu('plugins');
     $this->feather->template->setPageInfo(array('admin_console' => true, 'active_page' => 'admin', 'availablePlugins' => $availablePlugins, 'activePlugins' => $activePlugins, 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Extension'))))->addTemplate('admin/plugins.php')->display();
 }
Пример #25
0
 public static function load_user($user_id)
 {
     $user_id = (int) $user_id;
     $result['select'] = array('u.*', 'g.*', 'o.logged', 'o.idle');
     $result['where'] = array('u.id' => $user_id);
     $result['join'] = $user_id == 1 ? Utils::getIp() : 'u.id';
     $escape = $user_id == 1 ? true : false;
     $result = DB::for_table('users')->table_alias('u')->select_many($result['select'])->inner_join('groups', array('u.group_id', '=', 'g.g_id'), 'g')->left_outer_join('online', array('o.user_id', '=', $result['join']), 'o', $escape)->where($result['where']);
     $result = $result->find_result_set();
     foreach ($result as $user) {
         return $user;
     }
 }
Пример #26
0
 public function addedit($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.groups.addedit');
     $groups = $this->model->fetch_groups();
     // Add/edit a group (stage 2)
     if (Input::post('add_edit_group')) {
         return $this->model->add_edit_group($groups);
     } elseif (Input::post('add_group') || isset($args['id'])) {
         AdminUtils::generateAdminMenu('groups');
         $group = $this->model->info_add_group($groups, $args['id']);
         View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('User groups')), 'active_page' => 'admin', 'admin_console' => true, 'focus_element' => array('groups2', 'req_title'), 'required_fields' => array('req_title' => __('Group title label')), 'group' => $group, 'groups' => $groups, 'id' => $args['id'], 'group_list' => $this->model->get_group_list($groups, $group)))->addTemplate('admin/groups/add_edit_group.php')->display();
     }
 }
Пример #27
0
 public function display()
 {
     // Add a censor word
     if ($this->request->post('add_word')) {
         $this->model->add_word();
     } elseif ($this->request->post('update')) {
         $this->model->update_word();
     } elseif ($this->request->post('remove')) {
         $this->model->remove_word();
     }
     AdminUtils::generateAdminMenu('censoring');
     $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Censoring')), 'focus_element' => array('censoring', 'new_search_for'), 'active_page' => 'admin', 'admin_console' => true, 'word_data' => $this->model->get_words()))->addTemplate('admin/censoring.php')->display();
 }
Пример #28
0
 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.censoring.display');
     // Add a censor word
     if (Input::post('add_word')) {
         return $this->model->add_word();
     } elseif (Input::post('update')) {
         return $this->model->update_word();
     } elseif (Input::post('remove')) {
         return $this->model->remove_word();
     }
     AdminUtils::generateAdminMenu('censoring');
     return View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Censoring')), 'focus_element' => array('censoring', 'new_search_for'), 'active_page' => 'admin', 'admin_console' => true, 'word_data' => $this->model->get_words()))->addTemplate('admin/censoring.php')->display();
 }
Пример #29
0
 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();
 }
Пример #30
0
 public function update_word()
 {
     $id = intval(key($this->request->post('update')));
     $search_for = Utils::trim($this->request->post('search_for')[$id]);
     $replace_with = Utils::trim($this->request->post('replace_with')[$id]);
     if ($search_for == '') {
         throw new Error(__('Must enter word message'), 400);
     }
     $set_search_word = array('search_for' => $search_for, 'replace_with' => $replace_with);
     $set_search_word = $this->hook->fire('update_censoring_word_start', $set_search_word);
     $result = DB::for_table('censoring')->find_one($id)->set($set_search_word)->save();
     // 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 updated redirect'));
 }