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(); }
public function get_query_str() { $query_str = ''; $per_page = Input::query('i_per_page') ? intval(Input::query('i_per_page')) : 0; $per_page = Container::get('hooks')->fire('model.admin.maintenance.get_query_str.per_page', $per_page); $start_at = Input::query('i_start_at') ? intval(Input::query('i_start_at')) : 0; $start_at = Container::get('hooks')->fire('model.admin.maintenance.get_query_str.start_at', $start_at); // Fetch posts to process this cycle $result['select'] = array('p.id', 'p.message', 't.subject', 't.first_post_id'); $result = DB::for_table('posts')->table_alias('p')->select_many($result['select'])->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't')->where_gte('p.id', $start_at)->order_by_asc('p.id')->limit($per_page); $result = Container::get('hooks')->fireDB('model.admin.maintenance.get_query_str.query', $result); $result = $result->find_many(); $end_at = 0; foreach ($result as $cur_item) { echo '<p><span>' . sprintf(__('Processing post'), $cur_item['id']) . '</span></p>' . "\n"; if ($cur_item['id'] == $cur_item['first_post_id']) { $this->search->update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']); } else { $this->search->update_search_index('post', $cur_item['id'], $cur_item['message']); } $end_at = $cur_item['id']; } // Check if there is more work to do if ($end_at > 0) { $id = DB::for_table('posts')->where_gt('id', $end_at)->order_by_asc('id')->find_one_col('id'); if ($id) { $query_str = '?action=rebuild&i_per_page=' . $per_page . '&i_start_at=' . intval($id); } } $pdo = DB::get_db(); $pdo = null; $query_str = Container::get('hooks')->fire('model.admin.maintenance.get_query_str', $query_str); return $query_str; }
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(); } }
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 get_set($lang = null) { if (isset($lang) && $this->checkLang($lang)) { Config::set('application.language', $lang); } else { Config::set('application.language', $this->default); } $url = Input::query('redirect_to', '/'); return Redirect::to($url); }
public function index() { $this->layout->body_class = ''; $zip_code = Input::query('zip_code', ''); $distance = Input::query('distance', '50'); if (empty($zip_code)) { $this->findLocation(); $zip_code = Session::get('zip_code', ''); } Session::put('zip_code', $zip_code); Session::put('distance', $distance); $data = array('search_text' => '', 'zip_code' => $zip_code, 'distance' => $distance, 'status' => $this->getStatus(), 'makes' => $this->getPropertiesList(Make::orderBy('make')->get(), 'make'), 'bodies' => $this->getPropertiesList(Body::orderBy('body')->get(), 'body'), 'transmissions' => $this->getPropertiesList(Transmission::orderBy('transmission')->get(), 'transmission'), 'drives' => $this->getPropertiesList(Drive::orderBy('drive')->get(), 'drive'), 'interiors' => $this->getPropertiesList(Interior::orderBy('interior', 'DESC')->take(10)->get(), 'interior'), 'exteriors' => $this->getPropertiesList(Exterior::orderBy('exterior', 'DESC')->take(10)->get(), 'exterior'), 'fuels' => $this->getPropertiesList(Fuel::orderBy('fuel')->get(), 'fuel'), 'doors_count' => $this->getDoorsCounts(), 'cylinders_count' => $this->getCylindersCounts()); $this->layout->contents = View::make('search/search-advanced', $data); }
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 getFilterUrlAttribute() { $current_filters = Input::query(); if (array_key_exists('financing', $current_filters)) { if (!is_array($current_filters['financing'])) { $current_filters['financing'] = [$current_filters['financing']]; } if (in_array($this->id, $current_filters['financing'])) { unset($current_filters['financing'][array_search($this->id, $current_filters['financing'])]); $new_filter = array(); } else { $new_filter = array('financing' => array($this->id)); } } else { $new_filter = array('financing' => array($this->id)); } $query = array_filter(array_merge_recursive($current_filters, $new_filter)); return URL::route('schools.index', $query); }
public function promote_user($id) { $id = Container::get('hooks')->fire('model.profile.promote_user_start', $id); $pid = Input::query('pid') ? intval(Input::query('pid')) : 0; // Find the group ID to promote the user to $next_group_id = DB::for_table('groups')->table_alias('g')->inner_join('users', array('u.group_id', '=', 'g.g_id'), 'u')->where('u.id', $id); $next_group_id = Container::get('hooks')->fireDB('model.profile.promote_user_group_id', $next_group_id); $next_group_id = $next_group_id->find_one_col('g.g_promote_next_group'); if (!$next_group_id) { throw new Error(__('Bad request'), 404); } // Update the user $update_user = DB::for_table('users')->where('id', $id)->find_one()->set('group_id', $next_group_id); $update_user = Container::get('hooks')->fireDB('model.profile.promote_user_query', $update_user); $update_user = $update_user->save(); $pid = Container::get('hooks')->fire('model.profile.promote_user', $pid); return Router::redirect(Router::pathFor('viewPost', ['pid' => $pid]) . '#p' . $pid, __('User promote redirect')); }
public function find_ban($start_from = false) { $ban_info = array(); Container::get('hooks')->fire('model.admin.bans.find_ban_start'); // trim() all elements in $form $ban_info['conditions'] = $ban_info['query_str'] = array(); $expire_after = Input::query('expire_after') ? Utils::trim(Input::query('expire_after')) : ''; $expire_before = Input::query('expire_before') ? Utils::trim(Input::query('expire_before')) : ''; $ban_info['order_by'] = Input::query('order_by') && in_array(Input::query('order_by'), array('username', 'ip', 'email', 'expire')) ? 'b.' . Input::query('order_by') : 'b.username'; $ban_info['direction'] = Input::query('direction') && Input::query('direction') == 'DESC' ? 'DESC' : 'ASC'; $ban_info['query_str'][] = 'order_by=' . $ban_info['order_by']; $ban_info['query_str'][] = 'direction=' . $ban_info['direction']; // Build the query $result = DB::for_table('bans')->table_alias('b')->where_gt('b.id', 0); // Try to convert date/time to timestamps if ($expire_after != '') { $ban_info['query_str'][] = 'expire_after=' . $expire_after; $expire_after = strtotime($expire_after); if ($expire_after === false || $expire_after == -1) { throw new Error(__('Invalid date message'), 400); } $result = $result->where_gt('b.expire', $expire_after); } if ($expire_before != '') { $ban_info['query_str'][] = 'expire_before=' . $expire_before; $expire_before = strtotime($expire_before); if ($expire_before === false || $expire_before == -1) { throw new Error(__('Invalid date message'), 400); } $result = $result->where_lt('b.expire', $expire_before); } if (Input::query('username')) { $result = $result->where_like('b.username', str_replace('*', '%', Input::query('username'))); $ban_info['query_str'][] = 'username='******'username')); } if (Input::query('ip')) { $result = $result->where_like('b.ip', str_replace('*', '%', Input::query('ip'))); $ban_info['query_str'][] = 'ip=' . urlencode(Input::query('ip')); } if (Input::query('email')) { $result = $result->where_like('b.email', str_replace('*', '%', Input::query('email'))); $ban_info['query_str'][] = 'email=' . urlencode(Input::query('email')); } if (Input::query('message')) { $result = $result->where_like('b.message', str_replace('*', '%', Input::query('message'))); $ban_info['query_str'][] = 'message=' . urlencode(Input::query('message')); } // Fetch ban count if (is_numeric($start_from)) { $ban_info['data'] = array(); $select_bans = array('b.id', 'b.username', 'b.ip', 'b.email', 'b.message', 'b.expire', 'b.ban_creator', 'ban_creator_username' => 'u.username'); $result = $result->select_many($select_bans)->left_outer_join('users', array('b.ban_creator', '=', 'u.id'), 'u')->order_by($ban_info['order_by'], $ban_info['direction'])->offset($start_from)->limit(50)->find_many(); foreach ($result as $cur_ban) { $ban_info['data'][] = $cur_ban; } } else { $ban_info['num_bans'] = $result->count('id'); } Container::get('hooks')->fire('model.admin.bans.find_ban', $ban_info); return $ban_info; }
<input type="text" name="dvs-filters[<?php echo $filterName; ?> ]" data-dvs-replacement="<?php echo $replacementSelector; ?> " value="<?php echo Input::query('dvs-filters[' . $filterName . ']'); ?> " <?php echo $attributes; ?> >
public function get_search_results() { $search = array(); $search = Container::get('hooks')->fire('model.search.get_search_results_start', $search); $action = Input::query('action') ? Input::query('action') : null; $forums = Input::query('forums') ? is_array(Input::query('forums')) ? Input::query('forums') : array_filter(explode(',', Input::query('forums'))) : (Input::query('forums') ? array(Input::query('forums')) : array()); $sort_dir = Input::query('sort_dir') && Input::query('sort_dir') == 'DESC' ? 'DESC' : 'ASC'; $forums = array_map('intval', $forums); // Allow the old action names for backwards compatibility reasons if ($action == 'show_user') { $action = 'show_user_posts'; } elseif ($action == 'show_24h') { $action = 'show_recent'; } // If a search_id was supplied if (Input::query('search_id')) { $search_id = intval(Input::query('search_id')); if ($search_id < 1) { throw new Error(__('Bad request'), 400); } } elseif ($action == 'search') { $keywords = Input::query('keywords') ? utf8_strtolower(Utils::trim(Input::query('keywords'))) : null; $author = Input::query('author') ? utf8_strtolower(Utils::trim(Input::query('author'))) : null; if (preg_match('%^[\\*\\%]+$%', $keywords) || Utils::strlen(str_replace(array('*', '%'), '', $keywords)) < ForumEnv::get('FEATHER_SEARCH_MIN_WORD') && !$this->search->is_cjk($keywords)) { $keywords = ''; } if (preg_match('%^[\\*\\%]+$%', $author) || Utils::strlen(str_replace(array('*', '%'), '', $author)) < 2) { $author = ''; } if (!$keywords && !$author) { throw new Error(__('No terms'), 400); } if ($author) { $author = str_replace('*', '%', $author); } $show_as = Input::query('show_as') && Input::query('show_as') == 'topics' ? 'topics' : 'posts'; $sort_by = Input::query('sort_by') ? intval(Input::query('sort_by')) : 0; $search_in = !Input::query('search_in') || Input::query('search_in') == '0' ? 0 : (Input::query('search_in') == '1' ? 1 : -1); } elseif ($action == 'show_user_posts' || $action == 'show_user_topics' || $action == 'show_subscriptions') { $user_id = Input::query('user_id') ? intval(Input::query('user_id')) : User::get()->id; if ($user_id < 2) { throw new Error(__('Bad request'), 404); } // Subscribed topics can only be viewed by admins, moderators and the users themselves if ($action == 'show_subscriptions' && !User::get()->is_admmod && $user_id != User::get()->id) { throw new Error(__('No permission'), 403); } } elseif ($action == 'show_recent') { $interval = Input::query('value') ? intval(Input::query('value')) : 86400; } elseif ($action == 'show_replies') { if (User::get()->is_guest) { throw new Error(__('Bad request'), 404); } } elseif ($action != 'show_new' && $action != 'show_unanswered') { throw new Error(__('Bad request'), 404); } // If a valid search_id was supplied we attempt to fetch the search results from the db if (isset($search_id)) { $ident = User::get()->is_guest ? Utils::getIp() : User::get()->username; $search_data = DB::for_table('search_cache')->where('id', $search_id)->where('ident', $ident); $search_data = Container::get('hooks')->fireDB('model.search.get_search_results_search_data_query', $search_data); $search_data = $search_data->find_one_col('search_data'); if ($search_data) { $temp = unserialize($search_data); $temp = Container::get('hooks')->fire('model.search.get_search_results_temp', $temp); $search_ids = unserialize($temp['search_ids']); $num_hits = $temp['num_hits']; $sort_by = $temp['sort_by']; $sort_dir = $temp['sort_dir']; $show_as = $temp['show_as']; $search_type = $temp['search_type']; unset($temp); } else { throw new Error(__('No hits'), 404); } } else { $keyword_results = $author_results = array(); // Search a specific forum? $forum_sql = !empty($forums) || empty($forums) && ForumSettings::get('o_search_all_forums') == '0' && !User::get()->is_admmod ? ' AND t.forum_id IN (' . implode(',', $forums) . ')' : ''; if (!empty($author) || !empty($keywords)) { // Flood protection if (User::get()->last_search && time() - User::get()->last_search < User::get()->g_search_flood && time() - User::get()->last_search >= 0) { throw new Error(sprintf(__('Search flood'), User::get()->g_search_flood, User::get()->g_search_flood - (time() - User::get()->last_search)), 429); } if (!User::get()->is_guest) { $update_last_search = DB::for_table('users')->where('id', User::get()->id); } else { $update_last_search = DB::for_table('online')->where('ident', Utils::getIp()); } $update_last_search = Container::get('hooks')->fireDB('model.search.get_search_results_update_last_search', $update_last_search); $update_last_search = $update_last_search->update_many('last_search', time()); switch ($sort_by) { case 1: $sort_by_sql = $show_as == 'topics' ? 't.poster' : 'p.poster'; $sort_type = SORT_STRING; break; case 2: $sort_by_sql = 't.subject'; $sort_type = SORT_STRING; break; case 3: $sort_by_sql = 't.forum_id'; $sort_type = SORT_NUMERIC; break; case 4: $sort_by_sql = 't.last_post'; $sort_type = SORT_NUMERIC; break; default: $sort_by_sql = $show_as == 'topics' ? 't.last_post' : 'p.posted'; $sort_type = SORT_NUMERIC; break; } $sort_by = Container::get('hooks')->fire('model.search.get_search_results_sort_by', $sort_by); // If it's a search for keywords if ($keywords) { // split the keywords into words $keywords_array = $this->search->split_words($keywords, false); $keywords_array = Container::get('hooks')->fire('model.search.get_search_results_keywords_array', $keywords_array); if (empty($keywords_array)) { throw new Error(__('No hits'), 400); } // Should we search in message body or topic subject specifically? $search_in_cond = $search_in ? $search_in > 0 ? ' AND m.subject_match = 0' : ' AND m.subject_match = 1' : ''; $search_in_cond = Container::get('hooks')->fire('model.search.get_search_results_search_cond', $search_in_cond); $word_count = 0; $match_type = 'and'; $sort_data = array(); foreach ($keywords_array as $cur_word) { switch ($cur_word) { case 'and': case 'or': case 'not': $match_type = $cur_word; break; default: if ($this->search->is_cjk($cur_word)) { $where_cond = str_replace('*', '%', $cur_word); $where_cond_cjk = $search_in ? $search_in > 0 ? 'p.message LIKE %:where_cond%' : 't.subject LIKE %:where_cond%' : 'p.message LIKE %:where_cond% OR t.subject LIKE %:where_cond%'; $result = DB::for_table('posts')->raw_query('SELECT p.id AS post_id, p.topic_id, ' . $sort_by_sql . ' AS sort_by FROM ' . ForumSettings::get('db_prefix') . 'posts AS p INNER JOIN ' . ForumSettings::get('db_prefix') . 'topics AS t ON t.id=p.topic_id LEFT JOIN ' . ForumSettings::get('db_prefix') . 'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=' . User::get()->g_id . ') WHERE (' . $where_cond_cjk . ') AND (fp.read_forum IS NULL OR fp.read_forum=1)' . $forum_sql, array(':where_cond' => $where_cond)); } else { $result = DB::for_table('posts')->raw_query('SELECT m.post_id, p.topic_id, ' . $sort_by_sql . ' AS sort_by FROM ' . ForumSettings::get('db_prefix') . 'search_words AS w INNER JOIN ' . ForumSettings::get('db_prefix') . 'search_matches AS m ON m.word_id = w.id INNER JOIN ' . ForumSettings::get('db_prefix') . 'posts AS p ON p.id=m.post_id INNER JOIN ' . ForumSettings::get('db_prefix') . 'topics AS t ON t.id=p.topic_id LEFT JOIN ' . ForumSettings::get('db_prefix') . 'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=' . User::get()->g_id . ') WHERE w.word LIKE :where_cond' . $search_in_cond . ' AND (fp.read_forum IS NULL OR fp.read_forum=1)' . $forum_sql, array(':where_cond' => str_replace('*', '%', $cur_word))); } $result = Container::get('hooks')->fireDB('model.search.get_search_results_search_first_query', $result); $result = $result->find_many(); $row = array(); foreach ($result as $temp) { $row[$temp['post_id']] = $temp['topic_id']; if (!$word_count) { $keyword_results[$temp['post_id']] = $temp['topic_id']; $sort_data[$temp['post_id']] = $temp['sort_by']; } elseif ($match_type == 'or') { $keyword_results[$temp['post_id']] = $temp['topic_id']; $sort_data[$temp['post_id']] = $temp['sort_by']; } elseif ($match_type == 'not') { unset($keyword_results[$temp['post_id']]); unset($sort_data[$temp['post_id']]); } } if ($match_type == 'and' && $word_count) { foreach ($keyword_results as $post_id => $topic_id) { if (!isset($row[$post_id])) { unset($keyword_results[$post_id]); unset($sort_data[$post_id]); } } } ++$word_count; $pdo = DB::get_db(); $pdo = null; break; } } $keyword_results = Container::get('hooks')->fire('model.search.get_search_results_search_keyword_results', $keyword_results); // Sort the results - annoyingly array_multisort re-indexes arrays with numeric keys, so we need to split the keys out into a separate array then combine them again after $post_ids = array_keys($keyword_results); $topic_ids = array_values($keyword_results); array_multisort(array_values($sort_data), $sort_dir == 'DESC' ? SORT_DESC : SORT_ASC, $sort_type, $post_ids, $topic_ids); // combine the arrays back into a key => value array $keyword_results = array_combine($post_ids, $topic_ids); unset($sort_data, $post_ids, $topic_ids); } // If it's a search for author name (and that author name isn't Guest) if ($author && $author != 'guest' && $author != utf8_strtolower(__('Guest'))) { $username_exists = DB::for_table('users')->select('id')->where_like('username', $author); $username_exists = Container::get('hooks')->fireDB('model.search.get_search_results_username_exists', $username_exists); $username_exists = $username_exists->find_many(); if ($username_exists) { $user_ids = array(); foreach ($username_exists as $row) { $user_ids[] = $row['id']; } $result = DB::for_table('posts')->raw_query('SELECT p.id AS post_id, p.topic_id FROM ' . ForumSettings::get('db_prefix') . 'posts AS p INNER JOIN ' . ForumSettings::get('db_prefix') . 'topics AS t ON t.id=p.topic_id LEFT JOIN ' . ForumSettings::get('db_prefix') . 'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=' . User::get()->g_id . ') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id IN(' . implode(',', $user_ids) . ')' . $forum_sql . ' ORDER BY ' . $sort_by_sql . ' ' . $sort_dir); $result = Container::get('hooks')->fireDB('model.search.get_search_results_search_second_query', $result); $result = $result->find_many(); foreach ($result as $temp) { $author_results[$temp['post_id']] = $temp['topic_id']; } $pdo = DB::get_db(); $pdo = null; } } // If we searched for both keywords and author name we want the intersection between the results if ($author && $keywords) { $search_ids = array_intersect_assoc($keyword_results, $author_results); $search_type = array('both', array($keywords, Utils::trim(Input::query('author'))), implode(',', $forums), $search_in); } elseif ($keywords) { $search_ids = $keyword_results; $search_type = array('keywords', $keywords, implode(',', $forums), $search_in); } else { $search_ids = $author_results; $search_type = array('author', Utils::trim(Input::query('author')), implode(',', $forums), $search_in); } $search_ids = Container::get('hooks')->fire('model.search.get_search_results_search_ids', $search_ids); $search_type = Container::get('hooks')->fire('model.search.get_search_results_search_type', $search_type); unset($keyword_results, $author_results); if ($show_as == 'topics') { $search_ids = array_values($search_ids); } else { $search_ids = array_keys($search_ids); } $search_ids = array_unique($search_ids); $search_ids = Container::get('hooks')->fire('model.search.get_search_results_search_ids', $search_ids); $search_type = Container::get('hooks')->fire('model.search.get_search_results_search_type', $search_type); $num_hits = count($search_ids); if (!$num_hits) { throw new Error(__('No hits'), 400); } } elseif ($action == 'show_new' || $action == 'show_recent' || $action == 'show_replies' || $action == 'show_user_posts' || $action == 'show_user_topics' || $action == 'show_subscriptions' || $action == 'show_unanswered') { $search_type = array('action', $action); $show_as = 'topics'; // We want to sort things after last post $sort_by = 0; $sort_dir = 'DESC'; $result['where'] = array(array('fp.read_forum' => 'IS NULL'), array('fp.read_forum' => '1')); // If it's a search for new posts since last visit if ($action == 'show_new') { if (User::get()->is_guest) { throw new Error(__('No permission'), 403); } $result = DB::for_table('topics')->table_alias('t')->select('t.id')->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($result['where'])->where_gt('t.last_post', User::get()->last_visit)->where_null('t.moved_to')->order_by_desc('t.last_post'); if (Input::query('fid')) { $result = $result->where('t.forum_id', intval(Input::query('fid'))); } $result = Container::get('hooks')->fireDB('model.search.get_search_results_topic_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('home'), __('No new posts')); } } elseif ($action == 'show_recent') { $result = DB::for_table('topics')->table_alias('t')->select('t.id')->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($result['where'])->where_gt('t.last_post', time() - $interval)->where_null('t.moved_to')->order_by_desc('t.last_post'); if (Input::query('fid')) { $result = $result->where('t.forum_id', intval(Input::query('fid'))); } $result = Container::get('hooks')->fireDB('model.search.get_search_results_topic_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('home'), __('No recent posts')); } } elseif ($action == 'show_replies') { $result = DB::for_table('topics')->table_alias('t')->select('t.id')->inner_join('posts', array('t.id', '=', 'p.topic_id'), 'p')->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($result['where'])->where('p.poster_id', User::get()->id)->group_by('t.id'); if (ForumSettings::get('db_type') == 'pgsql') { $result = $result->group_by('t.last_post'); } $result = Container::get('hooks')->fireDB('model.search.get_search_results_topic_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('home'), __('No user posts')); } } elseif ($action == 'show_user_posts') { $show_as = 'posts'; $result = DB::for_table('posts')->table_alias('p')->select('p.id')->inner_join('topics', array('p.topic_id', '=', 't.id'), 't')->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($result['where'])->where('p.poster_id', $user_id)->order_by_desc('p.posted'); $result = Container::get('hooks')->fireDB('model.search.get_search_results_post_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('search'), __('No user posts')); } // Pass on the user ID so that we can later know whose posts we're searching for $search_type[2] = $user_id; } elseif ($action == 'show_user_topics') { $result = DB::for_table('topics')->table_alias('t')->select('t.id')->inner_join('posts', array('t.first_post_id', '=', 'p.id'), 'p')->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($result['where'])->where('p.poster_id', $user_id)->order_by_desc('t.last_post'); $result = Container::get('hooks')->fireDB('model.search.get_search_results_topic_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('search'), __('No user topics')); } // Pass on the user ID so that we can later know whose topics we're searching for $search_type[2] = $user_id; } elseif ($action == 'show_subscriptions') { if (User::get()->is_guest) { throw new Error(__('Bad request'), 404); } $result = DB::for_table('topics')->table_alias('t')->select('t.id')->inner_join('topic_subscriptions', array('t.id', '=', 's.topic_id'), 's')->inner_join('topic_subscriptions', array('s.user_id', '=', $user_id), null, true)->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where_any_is($result['where'])->order_by_desc('t.last_post'); $result = Container::get('hooks')->fireDB('model.search.get_search_results_topic_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('search'), __('No subscriptions')); } // Pass on user ID so that we can later know whose subscriptions we're searching for $search_type[2] = $user_id; } else { $result = DB::for_table('topics')->table_alias('t')->select('t.id')->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')->left_outer_join('forum_perms', array('fp.group_id', '=', User::get()->g_id), null, true)->where('t.num_replies', 0)->where_null('t.moved_to')->where_any_is($result['where'])->order_by_desc('t.last_post'); $result = Container::get('hooks')->fireDB('model.search.get_search_results_topic_query', $result); $result = $result->find_many(); $num_hits = count($result); if (!$num_hits) { return Router::redirect(Router::pathFor('home'), __('No unanswered')); } } $search_ids = array(); foreach ($result as $row) { $search_ids[] = $row['id']; } $pdo = DB::get_db(); $pdo = null; } else { throw new Error(__('Bad request'), 404); } // Prune "old" search results $old_searches = array(); $result = DB::for_table('online')->select('ident'); $result = Container::get('hooks')->fireDB('model.search.get_search_results_prune_search', $result); $result = $result->find_many(); if ($result) { foreach ($result as $row) { $old_searches[] = $row['ident']; } $delete_cache = DB::for_table('search_cache')->where_not_in('ident', $old_searches); $delete_cache = Container::get('hooks')->fireDB('model.search.get_search_results_delete_cache', $delete_cache); $delete_cache = $delete_cache->delete_many(); } // Fill an array with our results and search properties $temp = serialize(array('search_ids' => serialize($search_ids), 'num_hits' => $num_hits, 'sort_by' => $sort_by, 'sort_dir' => $sort_dir, 'show_as' => $show_as, 'search_type' => $search_type)); $search_id = mt_rand(1, 2147483647); $ident = User::get()->is_guest ? Utils::getIp() : User::get()->username; $cache['insert'] = array('id' => $search_id, 'ident' => $ident, 'search_data' => $temp); $cache = DB::for_table('search_cache')->create()->set($cache['insert']); $cache = Container::get('hooks')->fireDB('model.search.get_search_results_update_cache', $cache); $cache = $cache->save(); } // If we're on the new posts search, display a "mark all as read" link if (!User::get()->is_guest && $search_type[0] == 'action' && $search_type[1] == 'show_new') { $search['forum_actions'][] = '<a href="' . Router::pathFor('markRead') . '">' . __('Mark all as read') . '</a>'; } // Fetch results to display if (!empty($search_ids)) { // We have results $search['is_result'] = true; switch ($sort_by) { case 1: $sort_by_sql = $show_as == 'topics' ? 't.poster' : 'p.poster'; break; case 2: $sort_by_sql = 't.subject'; break; case 3: $sort_by_sql = 't.forum_id'; break; default: $sort_by_sql = $show_as == 'topics' ? 't.last_post' : 'p.posted'; break; } // Determine the topic or post offset (based on $_GET['p']) $per_page = $show_as == 'posts' ? User::get()->disp_posts : User::get()->disp_topics; $num_pages = ceil($num_hits / $per_page); $p = !Input::query('p') || Input::query('p') <= 1 || Input::query('p') > $num_pages ? 1 : intval(Input::query('p')); $start_from = $per_page * ($p - 1); $search['start_from'] = $start_from; // Generate paging links $search['paging_links'] = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?search_id=' . $search_id); // throw away the first $start_from of $search_ids, only keep the top $per_page of $search_ids $search_ids = array_slice($search_ids, $start_from, $per_page); // Run the query and fetch the results if ($show_as == 'posts') { $result['select'] = array('pid' => 'p.id', 'pposter' => 'p.poster', 'pposted' => 'p.posted', 'p.poster_id', 'p.message', 'p.hide_smilies', 'tid' => 't.id', 't.poster', 't.subject', 't.first_post_id', 't.last_post', 't.last_post_id', 't.last_poster', 't.num_replies', 't.forum_id', 'f.forum_name'); $result = DB::for_table('posts')->table_alias('p')->select_many($result['select'])->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't')->inner_join('forums', array('f.id', '=', 't.forum_id'), 'f')->where_in('p.id', $search_ids)->order_by($sort_by_sql, $sort_dir); $result = Container::get('hooks')->fireDB('model.search.get_search_results_select_posts_query', $result); } else { $result['select'] = array('tid' => 't.id', 't.poster', 't.subject', 't.last_post', 't.last_post_id', 't.last_poster', 't.num_replies', 't.closed', 't.sticky', 't.forum_id', 'f.forum_name'); $result = DB::for_table('topics')->table_alias('t')->select_many($result['select'])->inner_join('forums', array('f.id', '=', 't.forum_id'), 'f')->where_in('t.id', $search_ids)->order_by($sort_by_sql, $sort_dir); $result = Container::get('hooks')->fireDB('model.search.get_search_results_select_topics_query', $result); } $result = $result->find_array(); $search['search_set'] = array(); foreach ($result as $row) { $search['search_set'][] = $row; } $search['crumbs_text']['show_as'] = __('Search'); if ($search_type[0] == 'action') { if ($search_type[1] == 'show_user_topics') { $search['crumbs_text']['search_type'] = '<a href="' . Router::pathFor('search') . '?action=show_user_topics&user_id=' . $search_type[2] . '">' . sprintf(__('Quick search show_user_topics'), Utils::escape($search['search_set'][0]['poster'])) . '</a>'; } elseif ($search_type[1] == 'show_user_posts') { $search['crumbs_text']['search_type'] = '<a href="' . Router::pathFor('search') . '?action=show_user_posts&user_id=' . $search_type[2] . '">' . sprintf(__('Quick search show_user_posts'), Utils::escape($search['search_set'][0]['pposter'])) . '</a>'; } elseif ($search_type[1] == 'show_subscriptions') { // Fetch username of subscriber $subscriber_id = $search_type[2]; $subscriber_name = DB::for_table('users')->where('id', $subscriber_id); $subscriber_name = Container::get('hooks')->fireDB('model.search.get_search_results_subscriber_name', $result); $subscriber_name = $subscriber_name->find_one_col('username'); if (!$subscriber_name) { throw new Error(__('Bad request'), 404); } $search['crumbs_text']['search_type'] = '<a href="' . Router::pathFor('search') . '?action=show_subscription&user_id=' . $subscriber_id . '">' . sprintf(__('Quick search show_subscriptions'), Utils::escape($subscriber_name)) . '</a>'; } else { $search_url = str_replace('_', '/', $search_type[1]); $search['crumbs_text']['search_type'] = '<a href="' . Router::pathFor('search') . $search_url . '">' . __('Quick search ' . $search_type[1]) . '</a>'; } } else { $keywords = $author = ''; if ($search_type[0] == 'both') { list($keywords, $author) = $search_type[1]; $search['crumbs_text']['search_type'] = sprintf(__('By both show as ' . $show_as), Utils::escape($keywords), Utils::escape($author)); } elseif ($search_type[0] == 'keywords') { $keywords = $search_type[1]; $search['crumbs_text']['search_type'] = sprintf(__('By keywords show as ' . $show_as), Utils::escape($keywords)); } elseif ($search_type[0] == 'author') { $author = $search_type[1]; $search['crumbs_text']['search_type'] = sprintf(__('By user show as ' . $show_as), Utils::escape($author)); } $search['crumbs_text']['search_type'] = '<a href="' . Router::pathFor('search') . '?action=search&keywords=' . urlencode($keywords) . '&author=' . urlencode($author) . '&forums=' . $search_type[2] . '&search_in=' . $search_type[3] . '&sort_by=' . $sort_by . '&sort_dir=' . $sort_dir . '&show_as=' . $show_as . '">' . $search['crumbs_text']['search_type'] . '</a>'; } } $search['show_as'] = $show_as; $search = Container::get('hooks')->fire('model.search.get_search_results', $search); return $search; }
/** * API for model field frontend validation * @return json */ public function validateField() { // get field to validate $field = key(Input::query()); // create validator $validator = Validator::make(Input::all(), Role::$rules); $messages = $validator->messages(); if ($messages->has($field)) { // return error message //return json_encode(array("error"=>$messages->first($field))); return Response::make(array("error" => $messages->first($field)), 404); } return Response::make(array(), 200); }
/** * API for model field frontend validation * @return json */ public function validateField() { // get field to validate $field = key(Input::query()); // create validator $validator = Validator::make(Input::all(), Functionalscope::$rules); $messages = $validator->messages(); if ($messages->has($field)) { // return error message return json_encode(array("error" => $messages->first($field))); } else { // return true return json_encode(array("success" => '')); } }
public function action($req, $res, $args) { // Include UTF-8 function require ForumEnv::get('FEATHER_ROOT') . 'featherbb/Helpers/utf8/substr_replace.php'; require ForumEnv::get('FEATHER_ROOT') . 'featherbb/Helpers/utf8/ucwords.php'; // utf8_ucwords needs utf8_substr_replace require ForumEnv::get('FEATHER_ROOT') . 'featherbb/Helpers/utf8/strcasecmp.php'; $args['id'] = Container::get('hooks')->fire('controller.profile.action', $args['id']); if ($args['action'] != 'change_pass' || !Input::query('key')) { if (User::get()->g_read_board == '0') { throw new Error(__('No view'), 403); } elseif (User::get()->g_view_users == '0' && (User::get()->is_guest || User::get()->id != $args['id'])) { throw new Error(__('No permission'), 403); } } if ($args['action'] == 'change_pass') { if (Request::isPost()) { // TODO: Check if security "if (User::get()->id != $id)" (l.58 of Model/Profile) isn't bypassed // FOR ALL chained if below return $this->model->change_pass($args['id']); } View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Change pass')), 'active_page' => 'profile', 'id' => $args['id'], 'required_fields' => array('req_old_password' => __('Old pass'), 'req_new_password1' => __('New pass'), 'req_new_password2' => __('Confirm new pass')), 'focus_element' => array('change_pass', !User::get()->is_admmod ? 'req_old_password' : 'req_new_password1'))); View::addTemplate('profile/change_pass.php')->display(); } elseif ($args['action'] == 'change_email') { if (Request::isPost()) { return $this->model->change_email($args['id']); } View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Change email')), 'active_page' => 'profile', 'required_fields' => array('req_new_email' => __('New email'), 'req_password' => __('Password')), 'focus_element' => array('change_email', 'req_new_email'), 'id' => $args['id'])); View::addTemplate('profile/change_mail.php')->display(); } elseif ($args['action'] == 'upload_avatar' || $args['action'] == 'upload_avatar2') { if (ForumSettings::get('o_avatars') == '0') { throw new Error(__('Avatars disabled'), 400); } if (User::get()->id != $args['id'] && !User::get()->is_admmod) { throw new Error(__('No permission'), 403); } if (Request::isPost()) { return $this->model->upload_avatar($args['id'], $_FILES); } View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Profile'), __('Upload avatar')), 'active_page' => 'profile', 'required_fields' => array('req_file' => __('File')), 'focus_element' => array('upload_avatar', 'req_file'), 'id' => $args['id'])); View::addTemplate('profile/upload_avatar.php')->display(); } elseif ($args['action'] == 'delete_avatar') { if (User::get()->id != $args['id'] && !User::get()->is_admmod) { throw new Error(__('No permission'), 403); } $this->model->delete_avatar($args['id']); return Router::redirect(Router::pathFor('profileSection', array('id' => $args['id'], 'section' => 'personality')), __('Avatar deleted redirect')); } elseif ($args['action'] == 'promote') { if (User::get()->g_id != ForumEnv::get('FEATHER_ADMIN') && (User::get()->g_moderator != '1' || User::get()->g_mod_promote_users == '0')) { throw new Error(__('No permission'), 403); } $this->model->promote_user($args['id']); } else { throw new Error(__('Bad request'), 404); } }
?> <li id="navlogout"> <a href="<?php echo Router::pathFor('logout'); ?> ">Logout</a> </li> <?php } ?> </ul> </div> <div class="navbar-right"> <form class="nav-search" action="/plugins/search" method="get"> <input type="text" placeholder="Search" maxlength="100" size="20" name="keywords" value="<?php echo Input::query('keywords'); ?> "> </form> </div> </div> </div> </nav> <div class="container"> <div class="container-title-status"> <h1 class="title-site"> <a class="site-name" title="" href=""> <p>FeatherBB Marketplace</p> </a> <div id="brddesc"> <p>
public function render() { $query_params = Input::query(); $query = $this->_get_query(); $active_sort_by = isset($query_params['sort_by']) ? $query_params['sort_by'] : $this->config['default_sort']; if (!empty($active_sort_by) && $this->config['attributes'][$active_sort_by]['sortable']) { $active_sort_dir = Input::query('sort_dir'); if (empty($active_sort_dir)) { $active_sort_dir = $active_sort_by == $this->config['default_sort'] && !empty($this->config['default_sort_dir']) ? $this->config['default_sort_dir'] : 'ASC'; } if (!is_null($this->config['attributes'][$active_sort_by]['decoder_for_sql'])) { $decoder_for_sql = $this->config['attributes'][$active_sort_by]['decoder_for_sql']; $sort_column = is_callable($decoder_for_sql) ? $decoder_for_sql($active_sort_by) : $decoder_for_sql; $sort_column = DB::raw($sort_column); } else { $sort_column = $active_sort_by; } $query = $query->order_by($sort_column, strtolower($active_sort_dir)); } else { $active_sort_by = false; $active_sort_dir = false; } $paginate = isset($this->config['pager_enabled']) ? $this->config['pager_enabled'] : Config::get('autolist::autolist.pager_enabled', true); $per_page = isset($this->config['page_size']) ? $this->config['page_size'] : Config::get('autolist::autolist.page_size', 10); $page_links = FALSE; if ($paginate) { $pager = $query->paginate($per_page); $extra_query_params = $query_params; unset($extra_query_params['page']); $pager->appends($extra_query_params); $page_links = $pager->links(); $items = $pager->results; } else { $items = $query->get(); } $permission_check = isset($this->config['permission_check']) && is_callable($this->config['permission_check']) ? $this->config['permission_check'] : Config::get('autolist::autolist.permission_check'); list($detail_view_action, $detail_view_permission_check) = $this->_get_detail_view_action_details($this->config); $permitted_items = array(); $has_item_actions = false; foreach ($items as $item) { if (!is_null($detail_view_permission_check) && !$detail_view_permission_check($item, $item->{$this->model_key})) { continue; } else { if ($permission_check && is_callable($permission_check) && !$permission_check($detail_view_action, $item, $item->{$this->model_key})) { continue; } } $action_links = array(); foreach ($this->config['item_actions'] as $action => $action_options) { $action_details = $this->_get_action_details($action, $action_options); $action_permitted = true; if (is_callable($action_details['permission_check'])) { $action_permission_check = $action_details['permission_check']; $action_permitted = $action_permission_check($item, $item->{$this->model_key}); } else { if (is_callable($permission_check)) { $action_permitted = $permission_check($action_details['action'], $item, $item->{$this->model_key}); } } if ($action_permitted) { $action_details['id'] = $item->{$this->model_key}; $action_links[$action_details['action']] = render(Config::get('autolist::autolist.views.action_link'), $action_details); $has_item_actions = true; } } $item_data = array(); foreach ($this->config['attributes'] as $attribute => $attribute_details) { $item_data[$attribute] = $this->_get_attribute_value($item, $attribute_details, $detail_view_action); } $item_data['action_links'] = $action_links; $permitted_items[] = $item_data; } $global_action_links = array(); foreach ($this->config['global_actions'] as $action => $action_options) { $action_details = $this->_get_action_details($action, $action_options); $action_permitted = true; if (is_callable($action_details['permission_check'])) { $action_permission_check = $action_details['permission_check']; $action_permitted = $action_permission_check($item); } else { if (is_callable($permission_check)) { $action_permitted = $permission_check($action_details['action'], $item); } } if ($action_permitted) { $action_details['id'] = NULL; $global_action_links[$action_details['action']] = render(Config::get('autolist::autolist.views.action_link'), $action_details); } } $header_columns = array(); foreach ($this->config['attributes'] as $attribute => $attribute_details) { if ($attribute_details['sortable']) { $attribute_details['active_sort_by'] = $active_sort_by; $attribute_details['active_sort_dir'] = $active_sort_dir; $current_link_params = $query_params; $current_link_params['sort_by'] = $attribute; $current_link_params['sort_dir'] = 'ASC'; $attribute_details['sort_url_asc'] = URL::to(URI::current() . "?" . http_build_query($current_link_params), Request::secure()); $current_link_params['sort_dir'] = 'DESC'; $attribute_details['sort_url_desc'] = URL::to(URI::current() . "?" . http_build_query($current_link_params), Request::secure()); } $header_columns[$attribute] = render(Config::get('autolist::autolist.views.header_item'), $attribute_details); } $list_data = array('title' => $this->config['title'], 'header_columns' => $header_columns, 'has_item_actions' => $has_item_actions, 'items' => $permitted_items, 'global_action_links' => $global_action_links, 'page_links' => $page_links); return render(Config::get('autolist::autolist.views.list'), $list_data); }
public function search($req, $res, $args) { if (!Input::query('keywords')) { return Router::redirect(Router::pathFor('plugins')); } // Get number of pages $nbPlugins = PluginModel::countGetSearch(Input::query('keywords')); $nbPages = ceil(($nbPlugins + 1) / 20); // Determine the offset $p = !isset($args['page']) || $args['page'] <= 1 || $args['page'] > $nbPages ? 1 : intval($args['page']); $offset = 20 * ($p - 1); // Generate paging links $pagination = Router::paginate($nbPages, $p, 'plugins/search?keywords=' . Input::query('keywords') . '/#'); $plugins = PluginModel::getSearch(Input::query('keywords')); return View::setPageInfo(['plugins' => $plugins, 'pagination' => $pagination, 'title' => 'Search', 'active_nav' => 'plugins', 'top_right_link' => ['url' => Router::pathFor('plugins.create'), 'text' => 'Add plugin']])->addBreadcrumb([Router::pathFor('plugins') => 'Plugins', 'Search results', '"' . Input::query('keywords') . '"'])->addTemplate('plugins/index.php')->display(); }
public function search($req, $res, $args) { if (!Input::query('keywords')) { return Router::redirect(Router::pathFor('plugins')); } $plugins = PluginModel::getSearch(Input::query('keywords')); return View::setPageInfo(['plugins' => $plugins, 'title' => 'Search', 'active_nav' => 'plugins', 'top_right_link' => ['url' => Router::pathFor('plugins.create'), 'text' => 'Add plugin']])->addBreadcrumb([Router::pathFor('plugins') => 'Plugins', 'Search'])->addTemplate('plugins/index.php')->display(); }
| response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); /* |-------------------------------------------------------------------------- | CSRF Protection Filter |-------------------------------------------------------------------------- | | The CSRF filter is responsible for protecting your application against | cross-site request forgery attacks. If this special token in a user | session does not match the one given in this request, we'll bail. | */ Route::filter('csrf', function () { if (Session::token() != Input::get('_token')) { throw new Illuminate\Session\TokenMismatchException(); } }); View::composer(['layouts.dashboard.master', 'layouts.dashboard.master-app'], function ($view) { $view->with('currentUser', Sentry::getUser()); }); View::composer(Paginator::getViewName(), function (Illuminate\View\View $view) { $queryString = array_except(Input::query(), Paginator::getPageName()); $view->paginator->appends($queryString); }); include_once 'filters/exhibitions.php';
public function getIndex($slug = '', $link_id = 0) { $debug = ''; $bmStart = microtime(true); $perpage = intval(AppConfig::get('articles_per_page', 50)); $branch_prefixes = explode(',', AppConfig::get('branch_prefixes')); $virtualPerpage = intval(AppConfig::get('virtual_per_page', 20)); $page = Page::where('slug', '=', $slug)->cacheTags('pages')->remember(1440)->first(); //$page = Page::where('slug', '=', Str::slug($slug))->first(); if (count($page) > 0) { if ($filter_return = $this->authFilter($page->level)) { return $filter_return; } if ($page->redirect) { if (substr($page->redirect, 0, 1) == '{') { $redir_arr = json_decode($page->redirect, true); foreach ($redir_arr as $rlvl => $rslug) { if (strpos($this->auth_lvl, $rlvl) !== false) { return Redirect::to($rslug); } } if (isset($redir_arr['def'])) { return Redirect::to($redir_arr['def']); } } else { return Redirect::to($page->redirect); } } // get parameters from URL $page->category = Input::has('category') ? Input::get('category') : ($page->default_category ? $page->default_category : false); $page->section = Input::has('section') ? Input::get('section') : false; $page->keywordInput = $page->ddkeycol ? Input::get('keyword') : ''; $page_vars = new stdClass(); // separate slug into branch and section, if applicable $branch = $slug; if ($page->link_slug) { $branch = $page->link_slug; } $els = explode('/', $branch); if (in_array($els[0], $branch_prefixes) && count($els) > 1) { $branch = $els[0]; if (!$page->section) { $page->section = $els[1]; } } $dta = normal::getTypes(); // get list of categories, if there is a "ddlist" $categories = false; $normalized = false; if ($page->ddlist) { $fld = $page->ddlist; $catq = Link::where('branch', '=', $branch); if ($page->section) { $catq->where('section', '=', $page->section); } if ($dtp = array_search($fld, $dta)) { $catq->join('data', 'data.rec_id', '=', 'links.id')->where('data.table_name', '=', 'links')->where('data.type', '=', $dtp)->whereNull('data.deleted_at'); $fld = 'data_body'; $normalized = true; } $category_model = $catq->groupBy($fld)->whereRaw('trim(`' . $fld . '`) != ""')->cacheTags('links')->remember(1440)->get(array($fld)); $categories = array('' => 'All'); foreach ($category_model as $category_item) { $categories[$category_item->{$fld}] = $category_item->{$fld}; } } $links = false; $columns = false; // get list of links, specified by branch, section, category, state, and/or keyword if ($page->linkdef || $link_id && $page->detaildef) { // get column layout $columns = Listcolumns::where('def', '=', $link_id ? $page->detaildef : $page->linkdef)->cacheTags('links')->remember(1440)->orderBy('listorder')->get(); $perlinkpage = intval(AppConfig::get('links_per_page', 50)); $query = new Link(); if ($link_id) { $query = $query->where('id', '=', $link_id); } else { if ($page->section) { $query = $query->where('section', '=', $page->section); } if ($page->category) { if ($normalized) { $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', $dtp)->whereNull('d.deleted_at'); } $query = $query->where(isset($fld) ? $fld : ($page->section ? 'category' : 'section'), '=', $page->category); } if ($page->state) { $query = $query->where('state', '=', $page->state); } if ($page->keywordInput) { if ($page->keywordInput == "by_date") { $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', 7)->whereNull('d.deleted_at'); $month = Input::get('themonth'); $year = Input::get('theyear'); $pfx = $year . '-' . $month; $start_date = $pfx . '-01'; $end_date = $pfx . '-' . cal_days_in_month(CAL_GREGORIAN, $month, $year); $query = $query->whereRaw('d.`data_body` BETWEEN ? AND ?', array($start_date, $end_date)); unset($page->keywordInput); $page_vars->month = $month; $page_vars->year = $year; } else { $query = $query->whereRaw('`' . $page->ddkeycol . '` RLIKE ?', array($page->keywordInput)); } } if (!$page->allowBroken) { $query = $query->join('link_check', 'links.id', '=', 'link_check.id'); $query = $query->whereBetween('link_check.last_result', array('200', '399')); } } $order = 'name'; $orderdir = 'asc'; if ($page->linkorder) { $ordera = explode(',', $page->linkorder); $order = $ordera[0]; if (count($ordera) > 1) { $orderdir = $ordera[1]; } if ($dtp = array_search($order, $dta)) { $query = $query->join('data AS d2', 'd2.rec_id', '=', 'links.id')->where('d2.table_name', '=', 'links')->where('d2.type', '=', $dtp)->whereNull('d2.deleted_at'); $order = 'd2.data_body'; } } if ($page->where) { $query = $query->whereRaw($page->where); } if ($page->remove_dupes) { $query = $query->groupBy('name', 'url'); } $links = $query->where('branch', '=', $branch)->select(array('links.*'))->orderBy($order, $orderdir)->cacheTags('links')->remember(1440)->paginate($perlinkpage); $ids = array(); foreach ($links as $link) { $ids[] = $link->id; } $xda = count($ids) ? Cache::tags('links')->remember('linkData|' . implode('-', $ids), 1440, function () use($ids) { $xdata = Data::where('table_name', '=', 'links')->join('data_types', 'data_types.id', '=', 'data.type')->whereIn('rec_id', $ids)->whereNull('data_types.deleted_at')->cacheTags('data')->remember(10080)->get(); $xdda = array(); foreach ($xdata as $xrec) { $xdda[$xrec->rec_id][$xrec->label] = $xrec->data_body; } return $xdda; }) : array(); foreach ($links as $lid => $link) { $id = $link->id; if (isset($xda[$id])) { foreach ($xda[$id] as $xid => $xdt) { $links[$lid]->{$xid} = $xdt; } } } } $thumbs = false; if ($page->virtual_type) { $thumbs = Ad::where('type', '=', $page->virtual_type)->where('category', '=', $page->category)->orderBy('vorder', 'desc')->cacheTags('ads')->remember(1440)->paginate($virtualPerpage); foreach ($thumbs as $thumb) { Ads::track($thumb, 3, $page->id); } // get list of categories $category_model = Ad::groupBy('category')->where('type', '=', $page->virtual_type)->cacheTags('ads')->remember(1440)->get(array('category')); $categories = array(); foreach ($category_model as $category_item) { $categories[$category_item->category] = $category_item->category; } // $page->dname = 'Category'; } // benchmarking the database access $bmEnd = microtime(true); $page->elapsed = $bmEnd - $bmStart; $page_vars->qstring = ''; if ($page->pass_query == 'Y') { $qry = Input::query(); $qry['mc_rnm'] = substr(time(), 2); if (count($qry)) { $page_vars->qstring = '?' . http_build_query($qry); } } if ($page->randomize) { foreach (explode(',', $page->randomize) as $random_tag) { $page_vars->{$random_tag} = mt_rand(10000, 99999); } } foreach (AppConfig::getAll() as $cfi => $cfd) { $page_vars->{$cfi} = $cfd; } $page_vars->nocache = NOCACHE_CODE; if (!$page->layout) { // if ($_SERVER['REMOTE_ADDR'] == '108.47.107.194') { // $page->layout = 'template.layout2'; // } else { $page->layout = 'template.layout'; // } } // get data on child and parent pages $childpages = new Page(); $P = clone $childpages->getConnection()->getPaginator(); $P->setPageName('article'); $childpages->getConnection()->setPaginator($P); $childpages = $childpages->join('article_pages', 'pages.id', '=', 'article_pages.page_id'); $childpages = $childpages->where('article_pages.parent_id', '=', $page->id); $childpages = $childpages->whereNull('article_pages.deleted_at'); $childpages = $childpages->orderBy('pageOrder'); $childpages = $childpages->cacheTags('pages')->remember(1440); $childpages = $childpages->paginate($perpage); // pass ALL the data to the view return View::make('page.page')->with('dyn_layout', $page->layout)->with('page', $page)->with('childpages', $childpages)->with('categories', $categories)->with('links', $links)->with('link_id', $link_id)->with('thumbs', $thumbs)->with('columns', $columns)->with('top_banner', empty($slug))->with('debug', $debug)->with('parse_body', Display::format($page->body, $page_vars, false, false)); } else { if (substr($slug, -5) == '.html') { $new_slug = substr($slug, 0, -5); $new_page = Page::where('slug', '=', $new_slug)->cacheTags('pages')->remember(1440)->first(); if (count($new_page) > 0) { return Redirect::to('/' . $new_slug, 301); } } $missing = new Missing(); $missing->slug = $slug; $missing->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "[none]"; $missing->save(); AppLog::alert('Page Not Found', 404, json_encode(array('slug' => $slug))); return Response::view('page.notfound', array('slug' => $slug), 404); } }
</form> </div> <div class="clearfix"> </div> <div class="row-fluid"> <div class="col-sm-2"> </div> <div class="col-sm-3"> </div> <div class="col-sm-7" style="text-align:right"> <?php echo $order->appends(Input::query())->render(); ?> </div> </div> <div class="row-fluid" > <table class="table table-striped"> <tr> <!-- <span id="span_id" class="glyphicon glyphicon-triangle-bottom"></span> --> <th width="10%" id="collapse_id">{!!sort_orders_by('id','ID')!!} </th> <th>Image</th> <th width="10%">{!!sort_orders_by('order_date','Order Date')!!} </th> <th width="18%">Products </th> <th>Size</th> <th width="10%">Grand Total</th>
| response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); /* |-------------------------------------------------------------------------- | CSRF Protection Filter |-------------------------------------------------------------------------- | | The CSRF filter is responsible for protecting your application against | cross-site request forgery attacks. If this special token in a user | session does not match the one given in this request, we'll bail. | */ Route::filter('csrf', function () { if (Session::token() != Input::get('_token')) { throw new Illuminate\Session\TokenMismatchException(); } }); Route::filter('check-query', function () { Session::forget('error'); if (!is_null(Input::query('name'))) { Session::flash('error', 'Why would you submit a GET form...'); } // User::all(); // this is the problem - erase it. `User` is pointless in the app. });
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ //Route::get('elfinder','Barryvdh\elfinder\ElfinderController@showConnector'); Route::get('elfinder', 'Barryvdh\\elfinder\\ElfinderController@showTinyMCE4'); Route::get('/', function () { return view('welcome'); }); Route::resource('editor', 'ElfinderController'); Route::get('editore', 'ElfinderController@editore'); //Route::get('editor2','ElfinderController@editor2'); #Route::get("disk"); Route::get('glide/{path}', function ($path) { $server = \League\Glide\ServerFactory::create(['source' => app('filesystem')->disk('public')->getDriver(), 'cache' => storage_path('glide')]); return $server->getImageResponse($path, Input::query()); })->where('path', '.+'); // Route::get('/elfinder/tinymce','Barryvdh\Elfinder\ElfinderController@showTinyMCE4'); #Route::get('elfinder','ElfinderController@showConnector');
public function downloadClicks() { $filename = storage_path() . '/downloads/' . "vehicle_clicks_" . time() . ".csv"; $handle = fopen($filename, 'w+'); $from = Input::query('from', '0000-00-00'); $to = Input::query('to', '3000-00-00'); $from = $from . ' 00:00:00'; $to = $to . ' 23:59:59'; fputcsv($handle, array('VIN', 'Date', 'IP Address', 'Status')); $clicks = DB::table('click')->whereBetween('datetime', [$from, $to])->get(); foreach ($clicks as $click) { fputcsv($handle, array($click->vin, $click->datetime, $click->ip, $click->paid == 0 ? 'Free' : 'Paid')); } fclose($handle); $headers = array('Content-Type' => 'text/csv'); return Response::download($filename, 'VehicleClicksDetails.csv', $headers); }
</a> </div> </div> <div class="col-sm-10 col-md-10 col-lg-10"> <?php if (Input::get('order') == 'asc') { $new_url = array_merge(Input::query(), ['order' => 'desc']); ?> <a href="{{ url( 'notifications/?'. http_build_query( $new_url ) ) }}"> <i class="fa fa-chevron-circle-up"></i> Mais recente antes </a> <?php } else { $new_url = array_merge(Input::query(), ['order' => 'asc']); ?> <a href="{{ url( 'notifications/?'. http_build_query( $new_url ) ) }}"> <i class="fa fa-chevron-circle-down"></i> Mais antiga antes </a> <?php } ?> @include('notifications.panels.index') {{ $notifications->appends( Request::except('page') )->links() }} </div> </div>
public function buildFilterQuery($exclude) { $and = array(); $zip_code = Input::query('zip_code', ''); $distance = Input::query('distance', '50'); if (!empty($zip_code) && !empty($distance)) { $locations = Location::where('zip_code', '=', $zip_code); if ($locations->count()) { $location = Location::where('zip_code', '=', $zip_code)->first(); $latitude = $location->latitude; $longitude = $location->longitude; $distance = $distance * 1.609344 . 'km'; array_push($and, array("geo_distance" => array("pin.location" => array("lat" => $latitude, "lon" => $longitude), "distance" => $distance))); } } if ($exclude != 'make') { $and = $this->utility_make->buildFilterQuery($and, Input::get('make', '')); } if ($exclude != 'model') { $and = $this->utility_model->buildFilterQuery($and, Input::get('model', '')); } if ($exclude != 'price') { $and = $this->utility_price->buildFilterQuery($and, Input::get('price', '')); $and = $this->utility_price->buildCustomFilterQuery($and, Input::get('price-custom', '')); } if ($exclude != 'mileage') { $and = $this->utility_mileage->buildFilterQuery($and, Input::get('mileage', '')); $and = $this->utility_mileage->buildCustomFilterQuery($and, Input::get('mileage-custom', '')); } if ($exclude != 'photo') { $and = $this->utility_photo->buildFilterQuery($and, Input::get('photo', '')); } if ($exclude != 'transmission') { $and = $this->utility_transmission->buildFilterQuery($and, Input::get('transmission', '')); } if ($exclude != 'year') { $and = $this->utility_year->buildFilterQuery($and, Input::get('year', '')); $and = $this->utility_year->buildCustomFilterQuery($and, Input::get('year-custom', '')); } if ($exclude != 'status') { $and = $this->utility_status->buildFilterQuery($and, Input::get('status', '')); } if ($exclude != 'body') { $and = $this->utility_body->buildFilterQuery($and, Input::get('body', '')); } if ($exclude != 'certified') { $and = $this->utility_certified->buildFilterQuery($and, Input::get('certified', '')); } if ($exclude != 'doors') { $and = $this->utility_doors->buildFilterQuery($and, Input::get('doors', '')); } if ($exclude != 'cylinders') { $and = $this->utility_cylinders->buildFilterQuery($and, Input::get('cylinders', '')); } if ($exclude != 'fuel') { $and = $this->utility_fuel->buildFilterQuery($and, Input::get('fuel', '')); } if ($exclude != 'drive') { $and = $this->utility_drive->buildFilterQuery($and, Input::get('drive', '')); } if ($exclude != 'interior') { $and = $this->utility_interior->buildFilterQuery($and, Input::get('interior', '')); } if ($exclude != 'exterior') { $and = $this->utility_exterior->buildFilterQuery($and, Input::get('exterior', '')); } $filter = array(); if (sizeof($and) > 0) { $filter['and'] = $and; return $filter; } else { return false; } }
<li><a href="#"><i class="fa fa-th-list"></i> KA1</a></li> <li><a href="#"><i class="fa fa-table"></i> {{$panel_title}}</a></li> </ol> </section> <!-- Main content --> <section class="content"> @if (Session::has('message')) <div class="alert alert-info alert-dismissable"> <i class="fa fa-info"></i> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> {{ Session::get('message') }} </div> @endif <div class="box box-primary"> <div class="box-body"> @include('staff.view.search') @include('staff.view.button') @include('staff.view.table') </div> <div class="box-footer"> <div class="text-center"> <?php echo $table->appends(array_except(Input::query(), Paginator::getPageName()))->links(); ?> </div> </div> </div> </section> </aside> @stop
if (isset($_GET['v'])) { Cookie::queue('docs_versions', $_GET['v']); } /** * Set Docs Cookie If Not Set... */ if (!Cookie::has('docs_version')) { Cookie::queue('docs_versions', '4.2'); } /** * Define Current Docs Version Constant */ if (!defined('DOCS_VERSION')) { $version = Cookie::get('docs_version', '4.2'); if (Input::query('version') and in_array(Input::query('version'), array('4.0', '4.1', '4.2', 'master'))) { $version = Input::query('version'); } define('DOCS_VERSION', $version); } /** * Catch A 404 On Docs... */ App::missing(function ($e) { if (Request::is('docs/*')) { return Redirect::to('docs'); } }); /** * Main Route... */ Route::get('/', function () {
<?php $sort = Input::get('sort', 'name'); $order = Input::get('order', 'asc'); $currentQuery = Input::query(); $nameQuery = array_merge($currentQuery, ['sort' => 'name', 'order' => $sort == 'name' && $order == 'asc' ? 'desc' : 'asc']); $cityQuery = array_merge($currentQuery, ['sort' => 'city', 'order' => $sort == 'city' && $order == 'asc' ? 'desc' : 'asc']); $stateQuery = array_merge($currentQuery, ['sort' => 'state', 'order' => $sort == 'state' && $order == 'asc' ? 'desc' : 'asc']); $phoneQuery = array_merge($currentQuery, ['sort' => 'phone', 'order' => $sort == 'phone' && $order == 'asc' ? 'desc' : 'asc']); ?> <div class="row"> <div class="col-md-8 col-xs-12"> <div class="panel panel-default"> <div class="panel-body"> <p class="lead">{{ trans('search/common.search_param') }}</p> <div class="row"> <div class="col-md-4 col-xs-4"> <strong>{{ trans('home/form.name') }}</strong> </div> <div class="col-md-8 col-xs-8"> <em>{{ array_get($input, 'name', '') }}</em> </div>