/** * Get Tree Query * * @param integer $start Starting level * @param integer $level Max depth * @param array $sql_array Array of elements to merge into query * array( * 'SELECT' => array('p.*'), * 'WHERE' => array('p.post_id = 2'), * ) * @return string The sql query */ public function qet_tree_sql($start = 0, $level = 0, $sql_array = array()) { $sql_array = array_merge_recursive(array('SELECT' => array('t.*'), 'FROM' => array($this->items_table => ' t'), 'WHERE' => array('t.depth ' . ($level ? " BETWEEN {$start} AND " . ($start + $level) : ' >= ' . $start), $this->sql_where ? 't.' . $this->sql_where : ''), 'ORDER_BY' => 't.left_id ASC'), $sql_array); $sql_array['SELECT'] = join(', ', array_filter($sql_array['SELECT'])); $sql_array['WHERE'] = join(' AND ', array_filter($sql_array['WHERE'])); return $this->db->sql_build_query('SELECT', $sql_array); }
/** * {@inheritdoc} */ public function get_group_rules($type = '') { $sql_array = array('SELECT' => 'agr.*, agt.autogroups_type_name', 'FROM' => array($this->autogroups_rules_table => 'agr', $this->autogroups_types_table => 'agt'), 'WHERE' => 'agr.autogroups_type_id = agt.autogroups_type_id' . ($type ? " AND agt.autogroups_type_name = '" . $this->db->sql_escape($type) . "'" : '')); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql, 7200); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $rows; }
/** * Get users that should not have their default status changed * * @return array An array of user ids * @access public */ public function get_default_exempt_users() { $user_id_ary = array(); // Get users whose default group is autogroup_default_exempt $sql_array = array('SELECT' => 'u.user_id', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(GROUPS_TABLE => 'g'), 'ON' => 'g.group_id = u.group_id')), 'WHERE' => 'g.autogroup_default_exempt = 1'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $user_id_ary[] = $row['user_id']; } $this->db->sql_freeresult($result); return $user_id_ary; }
/** * Build a cache of group names * * @param object $event The event object * @return null * @access public */ public function build_group_name_cache($event) { if ($this->cache->get('_user_groups') === false) { $sql_ary = array('SELECT' => 'ug.user_id, g.group_name, g.group_colour, g.group_type, g.group_id', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(USER_GROUP_TABLE => 'ug'), 'ON' => 'ug.user_id = u.user_id'), array('FROM' => array(GROUPS_TABLE => 'g'), 'ON' => 'ug.group_id = g.group_id')), 'WHERE' => $this->db->sql_in_set('u.user_type', array(USER_FOUNDER, USER_NORMAL)) . ' AND ug.user_pending = 0', 'ORDER_BY' => 'u.user_id ASC, g.group_name'); $result = $this->db->sql_query($this->db->sql_build_query('SELECT', $sql_ary)); $user_groups = array(); while ($row = $this->db->sql_fetchrow($result)) { $user_groups[$row['user_id']][] = array('group_name' => (string) $row['group_name'], 'group_colour' => $row['group_colour'], 'group_id' => $row['group_id'], 'group_type' => $row['group_type']); } $this->db->sql_freeresult($result); // cache this data for 5 minutes $this->cache->put('_user_groups', $user_groups, 300); } }
public function get_last_post_data($data) { $forum_id = (int) $data['forum_id']; $topic_id = (int) $data['topic_id']; $user_id = (int) $this->user->data['user_id']; $sql_array = array('SELECT' => 'f.enable_indexing, f.forum_id, p.bbcode_bitfield, p.bbcode_uid, p.post_created, p.enable_bbcode, p.enable_magic_url, p.enable_smilies, p.poster_id, p.post_attachment, p.post_edit_locked, p.post_id, p.post_subject, p.post_text, p.post_time, p.post_visibility, t.topic_attachment, t.topic_first_post_id, t.topic_id, t.topic_last_post_time', 'FROM' => array(FORUMS_TABLE => 'f', POSTS_TABLE => 'p', TOPICS_TABLE => 't'), 'WHERE' => "p.post_id = t.topic_last_post_id\n\t\t\t\tAND t.topic_posts_unapproved = 0\n\t\t\t\tAND t.topic_id = {$topic_id}\n\t\t\t\tAND (f.forum_id = t.forum_id \n\t\t\t\t\tOR f.forum_id = {$forum_id})"); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, 1); $last_post_data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); return $last_post_data; }
/** * Get contrib count for a category. * * @param $category_id * @return int */ public function _get_contrib_count($category_id) { // Bundle up the children in a nice array $child_list = array($category_id); $sql = 'SELECT left_id, right_id FROM ' . $this->categories_table . ' WHERE category_id = ' . (int) $category_id . ' ORDER BY left_id ASC'; $result = $this->db->sql_query($sql); $cat_row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!$cat_row) { return 0; } $sql = 'SELECT category_id FROM ' . $this->categories_table . ' WHERE left_id > ' . $cat_row['left_id'] . ' AND right_id < ' . $cat_row['right_id']; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $child_list[] = $row['category_id']; } $this->db->sql_freeresult($result); $sql_ary = array('SELECT' => 'COUNT(DISTINCT c.contrib_id) AS cnt', 'FROM' => array($this->contrib_in_categories_table => 'cic', $this->contribs_table => 'c'), 'WHERE' => 'cic.contrib_id = c.contrib_id AND ' . $this->db->sql_in_set('cic.category_id', array_map('intval', $child_list)) . ' AND c.contrib_visible = 1 AND ' . $this->db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED))); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $this->db->sql_query($sql); $cnt = (int) $this->db->sql_fetchfield('cnt'); $this->db->sql_freeresult(); return $cnt; }
/** * Display popup comment * * @param int $link_id The category ID * @param int $page Page number taken from the URL * @param string $mode add|edit * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object * @throws \phpbb\exception\http_exception */ public function view($link_id, $page, $mode = 'new') { $this->_check_comments_enable($link_id); $comment_id = $this->request->variable('c', 0); $view = $this->request->variable('view', ''); $start = ($page - 1) * $this->config['dir_comments_per_page']; $this->s_hidden_fields = array_merge($this->s_hidden_fields, array('page' => $page)); $this->_populate_form($link_id, $mode); $sql = 'SELECT COUNT(comment_id) AS nb_comments FROM ' . DIR_COMMENT_TABLE . ' WHERE comment_link_id = ' . (int) $link_id; $result = $this->db->sql_query($sql); $nb_comments = (int) $this->db->sql_fetchfield('nb_comments'); $this->db->sql_freeresult($result); // Make sure $start is set to the last page if it exceeds the amount $start = $this->pagination->validate_start($start, $this->config['dir_comments_per_page'], $nb_comments); $sql_array = array('SELECT' => 'a.comment_id, a.comment_user_id, a. comment_user_ip, a.comment_date, a.comment_text, a.comment_uid, a.comment_bitfield, a.comment_flags, u.username, u.user_id, u.user_colour, z.foe', 'FROM' => array(DIR_COMMENT_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'a.comment_user_id = u.user_id'), array('FROM' => array(ZEBRA_TABLE => 'z'), 'ON' => 'z.user_id = ' . $this->user->data['user_id'] . ' AND z.zebra_id = a.comment_user_id')), 'WHERE' => 'a.comment_link_id = ' . (int) $link_id, 'ORDER_BY' => 'a.comment_date DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $this->config['dir_comments_per_page'], $start); $have_result = false; while ($comments = $this->db->sql_fetchrow($result)) { $have_result = true; $edit_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_comment_dir') || $this->user->data['user_id'] == $comments['comment_user_id'] && $this->auth->acl_get('u_edit_comment_dir')); $delete_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_comment_dir') || $this->user->data['user_id'] == $comments['comment_user_id'] && $this->auth->acl_get('u_delete_comment_dir')); $this->template->assign_block_vars('comment', array('MINI_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'S_USER' => get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), 'S_USER_IP' => $comments['comment_user_ip'], 'S_DATE' => $this->user->format_date($comments['comment_date']), 'S_COMMENT' => generate_text_for_display($comments['comment_text'], $comments['comment_uid'], $comments['comment_bitfield'], $comments['comment_flags']), 'S_ID' => $comments['comment_id'], 'U_EDIT' => $edit_allowed ? $this->helper->route('ernadoo_phpbbdirectory_comment_edit_controller', array('link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id'])) : '', 'U_DELETE' => $delete_allowed ? $this->helper->route('ernadoo_phpbbdirectory_comment_delete_controller', array('link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id'], '_referer' => $this->helper->get_current_url())) : '', 'S_IGNORE_POST' => $comments['foe'] && ($view != 'show' || $comment_id != $comments['comment_id']) ? true : false, 'L_IGNORE_POST' => $comments['foe'] ? $this->user->lang('POST_BY_FOE', get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), '<a href="' . $this->helper->url('directory/link/' . $link_id . '/comment' . ($page > 1 ? '/' . $page : '') . '?view=show#c' . (int) $comments['comment_id']) . '">', '</a>') : '', 'L_POST_DISPLAY' => $comments['foe'] ? $this->user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="' . $comments['comment_id'] . '" href="' . $this->helper->url('directory/link/' . $link_id . '/comment' . ($page > 1 ? '/' . $page : '') . '?c=' . (int) $comments['comment_id'] . '&view=show#c' . (int) $comments['comment_id']) . '">', '</a>') : '', 'S_INFO' => $this->auth->acl_get('m_info'))); } $base_url = array('routes' => 'ernadoo_phpbbdirectory_comment_view_controller', 'params' => array('link_id' => (int) $link_id)); $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_comments, $this->config['dir_comments_per_page'], $start); $this->template->assign_vars(array('TOTAL_COMMENTS' => $this->user->lang('DIR_NB_COMMS', (int) $nb_comments), 'S_HAVE_RESULT' => $have_result ? true : false)); return $this->helper->render('comments.html', $this->user->lang['DIR_COMMENT_TITLE']); }
/** * {@inheritdoc} */ public function get_item() { if (!isset($this->result)) { if (!$this->get_sql()) { return false; } $sql_ary = $this->sql; /** * Event to modify the feed item sql * * @event core.feed_base_modify_item_sql * @var array sql_ary The SQL array to get the feed item data * * @since 3.1.10-RC1 */ $vars = array('sql_ary'); extract($this->phpbb_dispatcher->trigger_event('core.feed_base_modify_item_sql', compact($vars))); $this->sql = $sql_ary; unset($sql_ary); // Query database $sql = $this->db->sql_build_query('SELECT', $this->sql); $this->result = $this->db->sql_query_limit($sql, $this->num_items); } return $this->db->sql_fetchrow($this->result); }
/** * Performs a search on keywords depending on display specific params. You have to run split_keywords() first * * @param array $keywords_ary contains each words to search * @param string $fields contains either titleonly (link titles should be searched), desconly (only description bodies should be searched) * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query * @param string $sort_key is the key of $sort_by_sql for the selected sorting * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_cid_ary specifies an array of category ids which should not be searched * @param int $cat_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered * @param int $start indicates the first index of the page * @param int $per_page number of ids each page is supposed to contain * @return int total number of results */ public function keyword_search($keywords_ary, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_cid_ary, $cat_id, &$id_ary, $start, $per_page) { $matches = array(); switch ($fields) { case 'titleonly': $matches[] = 'l.link_name'; break; case 'desconly': $matches[] = 'l.link_description'; break; default: $matches = array('l.link_name', 'l.link_description'); } $search_query = ''; foreach ($keywords_ary as $word) { $match_search_query = ''; foreach ($matches as $match) { $match_search_query .= ($match_search_query ? ' OR ' : '') . 'LOWER(' . $match . ') '; $match_search_query .= $this->db->sql_like_expression(str_replace('*', $this->db->get_any_char(), $this->db->get_any_char() . strtolower($word) . $this->db->get_any_char())); } $search_query .= (!$search_query ? '' : ($terms == 'all' ? ' AND ' : ' OR ')) . '(' . $match_search_query . ')'; } $direction = $sort_dir == 'd' ? 'DESC' : 'ASC'; if (is_array($sort_by_sql[$sort_key])) { $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; } else { $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; } $sql_array = array('SELECT' => 'l.link_id', 'FROM' => array(DIR_LINK_TABLE => 'l'), 'WHERE' => 'l.link_active = 1 ' . ($search_query ? 'AND (' . $search_query . ')' : '') . ' ' . (sizeof($ex_cid_ary) ? ' AND ' . $this->db->sql_in_set('l.link_cat', $ex_cid_ary, true) : '') . ' ' . ($cat_id ? ' AND ' . $this->db->sql_in_set('l.link_cat', $cat_id) : '') . ' ' . ($sort_days ? ' AND l.link_time >= ' . (time() - $sort_days * 86400) : ''), 'ORDER_BY' => $sql_sort_order); if ($sql_sort_order[0] == 'u') { $sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = l.link_user_id'); } $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $id_ary[] = $row['link_id']; } $this->db->sql_freeresult($result); $total_match_count = sizeof($id_ary); $id_ary = array_slice($id_ary, $start, (int) $per_page); return $total_match_count; }
/** * Get post data * * @param mixed|false $topic_first_or_last_post (first|last) * @param array $post_ids * @param bool|false $limit * @param int $start * @param array $sql_array * @return array */ public function get_post_data($topic_first_or_last_post = false, $post_ids = array(), $limit = false, $start = 0, $sql_array = array()) { $sql = $this->db->sql_build_query('SELECT_DISTINCT', $this->_get_posts_sql_array($topic_first_or_last_post, $post_ids, $sql_array)); $result = $this->db->sql_query_limit($sql, $limit, $start, $this->cache_time); $post_data = array(); while ($row = $this->db->sql_fetchrow($result)) { $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); $post_data[$row['topic_id']][$row['post_id']] = $row; $this->store['poster_ids'][] = $row['poster_id']; $this->store['poster_ids'][] = $row['post_edit_user']; $this->store['poster_ids'][] = $row['post_delete_user']; $this->store['attachments'][] = $row['post_id']; } $this->db->sql_freeresult($result); return $post_data; }
protected function get_sql_statement() { $sql_ary = array('SELECT' => 'u.user_id, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => $this->db->sql_in_set('u.user_type', array(USER_NORMAL, USER_FOUNDER))); $sql_method = '_set_' . $this->settings['query_type'] . '_sql'; call_user_func_array(array($this, $sql_method), array(&$sql_ary)); $this->_set_range_sql($sql_ary); return $this->db->sql_build_query('SELECT', $sql_ary); }
/** * Fetch messages from the database */ public function mchat_get_messages($sql_where, $total = 0, $offset = 0) { $sql_array = array('SELECT' => 'm.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm', 'FROM' => array($this->mchat_table => 'm'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'm.user_id = u.user_id')), 'WHERE' => $sql_where, 'ORDER_BY' => 'm.message_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $total, $offset); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $rows; }
/** * Fetches all topic solved data related to the given post. * * @param int $post_id ID of post to fetch topic/forum data for. * * @return mixed topic data, or false if not found */ public function get_topic_data($post_id) { $select_sql_array = array('SELECT' => 't.topic_id, t.topic_poster, t.topic_status, t.topic_type, t.topic_solved, ' . 'f.forum_id, f.forum_allow_solve, f.forum_allow_unsolve, f.forum_lock_solved, ' . 'p.post_id', 'FROM' => array(FORUMS_TABLE => 'f', POSTS_TABLE => 'p', TOPICS_TABLE => 't'), 'WHERE' => 'p.post_id = ' . (int) $post_id . ' AND t.topic_id = p.topic_id AND f.forum_id = t.forum_id'); $select_sql = $this->db->sql_build_query('SELECT', $select_sql_array); $result = $this->db->sql_query($select_sql); $topic_data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); return $topic_data; }
/** * Получение id пользователя по email * @param string $email * @return int|bool */ public function getUserIdByEmail($email = '') { $sql_array = array('SELECT' => 'user_id', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => "user_email = '{$this->db->sql_escape($email)}'"); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, 1); $result = $this->db->sql_fetchrow($result); $this->db->sql_freeresult(); return isset($result['user_id']) ? $result['user_id'] : false; }
/** * Get the usage count of the tag that is used the most * * @return int maximum */ private function get_maximum_tag_usage_count() { $sql_array = array('SELECT' => 't.count', 'FROM' => array($this->table_prefix . tables::TAGS => 't'), 'WHERE' => 't.count > 0', 'ORDER_BY' => 't.count DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, 1); $re = (int) $this->db->sql_fetchfield('count'); $this->db->sql_freeresult($result); return $re; }
public function info($user_id) { if (!$this->auth->acl_gets('u_viewprofile')) { trigger_error('NOT_AUTHORISED'); } $sql_ary = array('SELECT' => 'u.username, u.user_colour, u.user_regdate, u.user_posts, u.user_lastvisit, u.user_rank, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = ' . (int) $user_id); /** * Modify SQL query in tas2580 AJAX userinfo extension * * @event tas2580.userinfo_modify_sql * @var string sql_ary The SQL query * @var int user_id The ID of the user * @since 0.2.3 */ $vars = array('sql_ary', 'user_id'); extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_sql', compact($vars))); $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_ary), 1); $this->data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!function_exists('phpbb_get_user_rank')) { include $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; } $user_rank_data = phpbb_get_user_rank($this->data, $this->data['user_posts']); // Get the avatar // Wen need to use the full URL here because we don't know the path where userinfo is called define('PHPBB_USE_BOARD_URL_PATH', true); $avatar = phpbb_get_user_avatar($this->data); $avatar = empty($avatar) ? '<img src="' . generate_board_url() . '/styles/' . $this->user->style['style_name'] . '/theme/images/no_avatar.gif" width="100" height="100" alt="' . $this->user->lang('USER_AVATAR') . '">' : $avatar; $memberdays = max(1, round((time() - $this->data['user_regdate']) / 86400)); $posts_per_day = $this->data['user_posts'] / $memberdays; $percentage = $this->config['num_posts'] ? min(100, $this->data['user_posts'] / $this->config['num_posts'] * 100) : 0; $result = array('userinfo_header' => sprintf($this->user->lang['VIEWING_PROFILE'], $this->data['username']), 'username' => get_username_string('no_profile', $user_id, $this->data['username'], $this->data['user_colour']), 'regdate' => $this->user->format_date($this->data['user_regdate']), 'posts' => $this->data['user_posts'], 'lastvisit' => $this->user->format_date($this->data['user_lastvisit']), 'avatar' => $avatar, 'rank' => empty($user_rank_data['title']) ? $this->user->lang('NA') : $user_rank_data['title'], 'postsperday' => $this->user->lang('POST_DAY', $posts_per_day), 'percentage' => $this->user->lang('POST_PCT', $percentage)); /** * Modify return data in tas2580 AJAX userinfo extension * * @event tas2580.userinfo_modify_result * @var array result The result array * @var int user_id The ID of the user * @since 0.2.3 */ $vars = array('result', 'user_id'); extract($this->phpbb_dispatcher->trigger_event('tas2580.userinfo_modify_result', compact($vars))); return new JsonResponse($result); }
/** * Display the output for this extension * * @return null * @access public */ public function display_output() { // Add the language file $this->language->add_lang('acp_activesessions', 'david63/activesessions'); // Start initial var setup $action = $this->request->variable('action', ''); $start = $this->request->variable('start', 0); $fc = $this->request->variable('fc', ''); $sort_key = $this->request->variable('sk', 's'); $sd = $sort_dir = $this->request->variable('sd', 'd'); $sort_dir = $sort_dir == 'd' ? ' DESC' : ' ASC'; $order_ary = array('i' => 's.session_ip' . $sort_dir . ', u.username_clean ASC', 's' => 's.session_start' . $sort_dir . ', u.username_clean ASC', 'u' => 'u.username_clean' . $sort_dir); $filter_by = ''; if ($fc == 'other') { for ($i = ord($this->language->lang('START_CHARACTER')); $i <= ord($this->language->lang('END_CHARACTER')); $i++) { $filter_by .= ' AND u.username_clean ' . $this->db->sql_not_like_expression(utf8_clean_string(chr($i)) . $this->db->get_any_char()); } } else { if ($fc) { $filter_by .= ' AND u.username_clean ' . $this->db->sql_like_expression(utf8_clean_string(substr($fc, 0, 1)) . $this->db->get_any_char()); } } $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, s.*, f.forum_id, f.forum_name', 'FROM' => array(USERS_TABLE => 'u', SESSIONS_TABLE => 's'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 's.session_forum_id = f.forum_id')), 'WHERE' => 'u.user_id = s.session_user_id AND s.session_time >= ' . (time() - $this->config['session_length'] * 60) . $filter_by, 'ORDER_BY' => $sort_key == '' ? 'u.username_clean' : $order_ary[$sort_key])); $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('active_sessions', array('ADMIN' => $row['session_admin'] ? $this->language->lang('YES') : $this->language->lang('NO'), 'AUTO_LOGIN' => $row['session_autologin'] ? $this->language->lang('YES') : $this->language->lang('NO'), 'BROWSER' => $row['session_browser'], 'FORUM' => $row['forum_id'] > 0 ? $row['forum_name'] : '', 'LAST_VISIT' => $this->user->format_date($row['session_last_visit']), 'SESSION_FORWARD' => $row['session_forwarded_for'], 'SESSION_ID' => $row['session_id'], 'SESSION_IP' => $row['session_ip'], 'SESSION_KEY' => $row['session_id'] . $row['user_id'], 'SESSION_ONLINE' => $row['session_viewonline'] ? $this->language->lang('YES') : $this->language->lang('NO'), 'SESSION_PAGE' => $row['session_page'], 'SESSION_START' => $this->user->format_date($row['session_start']), 'SESSION_TIME' => $this->user->format_date($row['session_time']), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))); } $this->db->sql_freeresult($result); $sort_by_text = array('u' => $this->language->lang('SORT_USERNAME'), 'i' => $this->language->lang('SESSION_IP'), 's' => $this->language->lang('SESSION_START')); $limit_days = array(); $s_sort_key = $s_limit_days = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Get total session count for output $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'COUNT(s.session_id) AS total_sessions', 'FROM' => array(USERS_TABLE => 'u', SESSIONS_TABLE => 's'), 'WHERE' => 'u.user_id = s.session_user_id' . $filter_by)); $result = $this->db->sql_query($sql); $session_count = (int) $this->db->sql_fetchfield('total_sessions'); $this->db->sql_freeresult($result); $action = "{$this->u_action}&sk={$sort_key}&sd={$sd}"; $link = $session_count ? adm_back_link($action . '&start=' . $start) : ''; if ($session_count == 0) { trigger_error($this->language->lang('NO_SESSION_DATA') . $link); } $start = $this->pagination->validate_start($start, $this->config['topics_per_page'], $session_count); $this->pagination->generate_template_pagination($action, 'pagination', 'start', $session_count, $this->config['topics_per_page'], $start); $first_characters = array(); $first_characters[''] = $this->language->lang('ALL'); for ($i = ord($this->language->lang('START_CHARACTER')); $i <= ord($this->language->lang('END_CHARACTER')); $i++) { $first_characters[chr($i)] = chr($i); } $first_characters['other'] = $this->language->lang('OTHER'); foreach ($first_characters as $char => $desc) { $this->template->assign_block_vars('first_char', array('DESC' => $desc, 'U_SORT' => $action . '&fc=' . $char)); } $this->template->assign_vars(array('ACTIVE_SESSIONS_VERSION' => ext::ACTIVE_SESSIONS_VERSION, 'S_SORT_DIR' => $s_sort_dir, 'S_SORT_KEY' => $s_sort_key, 'TOTAL_USERS' => $this->language->lang('TOTAL_SESSIONS', (int) $session_count), 'U_ACTION' => $action)); }
/** * Get batch of rows to process. * * @return array */ protected function get_batch() { $sql_ary = array('SELECT' => 'c.contrib_id, c.contrib_type, c.contrib_status, c.contrib_user_id, ca.user_id', 'FROM' => array($this->contribs_table => 'c'), 'LEFT_JOIN' => array(array('FROM' => array($this->contrib_coauthors_table => 'ca'), 'ON' => 'ca.contrib_id = c.contrib_id')), 'WHERE' => 'c.contrib_visible = 1 AND ' . $this->db->sql_in_set('c.contrib_status', $this->valid_statuses), 'ORDER_BY' => 'c.contrib_id'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query_limit($sql, $this->limit, $this->start); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $rows; }
/** * Get all auto group rules from the database * * @return array Array of auto group rules and their associated data * @access public */ protected function get_all_autogroups() { $sql_array = array('SELECT' => 'agr.*, agt.autogroups_type_name, g.group_name', 'FROM' => array($this->autogroups_rules_table => 'agr', $this->autogroups_types_table => 'agt', GROUPS_TABLE => 'g'), 'WHERE' => 'agr.autogroups_type_id = agt.autogroups_type_id AND agr.autogroups_group_id = g.group_id', 'ORDER_BY' => 'g.group_name ASC, autogroups_min_value ASC'); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $rows; }
/** * Count the number of results * * @param mixed $sql_ary * @param mixed $field * @return int */ public function sql_count($sql_ary, $field) { $sql_ary['SELECT'] = "COUNT({$field}) AS cnt"; unset($sql_ary['ORDER_BY']); $count_sql = $this->db->sql_build_query('SELECT', $sql_ary); $this->db->sql_query($count_sql); $this->total = (int) $this->db->sql_fetchfield('cnt'); $this->db->sql_freeresult(); return $this->total; }
/** * Get all page link location data for generating page links * * @param array $page_ids Optional array of page ids * @return array Array of page link location data for the specified pages, or all pages * @access public */ public function get_page_links($page_ids = array()) { $sql_array = array('SELECT' => 'ppl.*, pl.page_link_location, pl.page_link_event_name, p.page_route, p.page_title, p.page_display, p.page_display_to_guests', 'FROM' => array($this->pages_pages_links_table => 'ppl'), 'LEFT_JOIN' => array(array('FROM' => array($this->pages_links_table => 'pl'), 'ON' => 'pl.page_link_id = ppl.page_link_id'), array('FROM' => array($this->pages_table => 'p'), 'ON' => 'p.page_id = ppl.page_id')), 'WHERE' => !empty($page_ids) ? $this->db->sql_in_set('ppl.page_id', $page_ids) : '', 'ORDER_BY' => 'p.page_order ASC, ppl.page_link_id ASC'); // Cache the SQL query for 1 hour if page_ids is empty $cache_ttl = empty($page_ids) ? 3600 : 0; $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql, $cache_ttl); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $rows; }
function main() { // Only registered users can go beyond this point if (!$this->user->data['is_registered']) { if ($this->user->data['is_bot']) { redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}")); } login_box('', $this->user->lang['LOGIN_INFO']); } $adm_points = $this->request->variable('adm_points', false); $u_id = $this->request->variable('user_id', 0); $post_id = $this->request->variable('post_id', 0); if (empty($u_id)) { $message = $this->user->lang['EDIT_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $user_id = $u_id; add_form_key('bank_edit'); if ($adm_points != false && ($this->auth->acl_get('a_') || $this->auth->acl_get('m_chg_bank'))) { $this->template->assign_block_vars('administer_bank', array()); $submit = isset($_POST['submit']) ? true : false; if ($submit) { if (!check_form_key('bank_edit')) { trigger_error('FORM_INVALID'); } $new_points = round($this->request->variable('points', 0.0), 2); $this->functions_points->set_bank($u_id, $new_points); $sql_array = array('SELECT' => 'user_id, username, user_points, user_colour', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $u_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $points_user = $this->db->sql_fetchrow($result); // Add logs $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_BANK', false, array($points_user['username'])); $message = $post_id ? sprintf($this->user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($this->user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") . '">', '</a>'); trigger_error(sprintf($this->user->lang['EDIT_POINTS_SET'], $this->config['points_name']) . $message); } else { $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_points, u.user_colour, b.holding', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array($this->points_bank_table => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'u.user_id = ' . (int) $u_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); if (empty($u_id)) { $message = $this->user->lang['EDIT_USER_NOT_EXIST'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit')) . '">« ' . $this->user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $hidden_fields = build_hidden_fields(array('user_id' => $u_id, 'post_id' => $post_id)); $this->template->assign_vars(array('USER_NAME' => get_username_string('full', $u_id, $row['username'], $row['user_colour']), 'BANK_POINTS' => sprintf($this->functions_points->number_format_points($row['holding'])), 'POINTS_NAME' => $this->config['points_name'], 'CURRENT_VALUE' => $row['holding'], 'L_POINTS_MODIFY' => sprintf($this->user->lang['EDIT_BANK_MODIFY'], $this->config['points_name']), 'L_P_BANK_TITLE' => sprintf($this->user->lang['EDIT_P_BANK_TITLE'], $this->config['points_name']), 'L_USERNAME' => $this->user->lang['USERNAME'], 'L_SET_AMOUNT' => $this->user->lang['EDIT_SET_AMOUNT'], 'U_USER_LINK' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&u=" . $u_id), 'S_ACTION' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank_edit', 'adm_points' => '1')), 'S_HIDDEN_FIELDS' => $hidden_fields)); } } // Generate the page page_header($this->user->lang['EDIT_POINTS_ADMIN']); // Generate the page template $this->template->set_filenames(array('body' => 'points/points_bank_edit.html')); page_footer(); }
/** * Run SQL query for fetching posts from database * * @param int $post_time Post time * @param int $number_of_posts Number of posts to fetch * @param int $start Start of query * * @return int Result pointer */ protected function run_sql_query($post_time, $number_of_posts, $start) { $sql_array = array('SELECT' => 't.forum_id, t.topic_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_time, t.topic_title, t.topic_attachment, t.topic_views, t.poll_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_poster, t.topic_type, t.topic_status, t.topic_last_poster_name, t.topic_last_poster_id, t.topic_last_poster_colour, t.icon_id, u.username, u.user_id, u.user_type, u.user_colour, p.post_id, p.poster_id, p.post_time, p.post_text, p.post_attachment, p.post_username, p.enable_smilies, p.enable_bbcode, p.enable_magic_url, p.bbcode_bitfield, p.bbcode_uid, f.forum_name, f.enable_icons', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => $this->user_link), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id=f.forum_id'), array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => $this->post_link)), 'WHERE' => $this->topic_type . ' ' . $post_time . ' AND t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_visibility = 1 AND t.topic_moved_id = 0 ' . $this->where_string, 'ORDER_BY' => $this->topic_order); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $this->user->data['user_id']); $sql_array['SELECT'] .= ', tp.topic_posted'; $sql = $this->db->sql_build_query('SELECT', $sql_array); // Cache queries for 10 minutes if ($number_of_posts != 0) { $result = $this->db->sql_query_limit($sql, $number_of_posts, $start, 600); } else { $result = $this->db->sql_query($sql, 600); } return $result; }
public function get_post_info($post_id = false) { if (!$post_id) { return array(); } $sql_array = array('SELECT' => 'p.post_id, p.poster_id, p.topic_id, p.forum_id, p.post_subject', 'FROM' => array($this->posts_table => 'p'), 'WHERE' => 'p.post_id =' . (int) $post_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); return $row ?: array(); }
/** * Get informations about a cat or subcat * * @param int $cat_id The category ID * @return null|false */ public function get($cat_id = 0) { if ($cat_id) { $sql_array = array('SELECT' => 'c.*, w.notify_status', 'FROM' => array(DIR_CAT_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(DIR_WATCH_TABLE => 'w'), 'ON' => 'c.cat_id = w.cat_id AND w.user_id = ' . (int) $this->user->data['user_id'])), 'WHERE' => 'c.cat_id = ' . (int) $cat_id); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); if (!($this->data = $this->db->sql_fetchrow($result))) { return false; } $this->db->sql_freeresult($result); } }
/** * Get informations about links selected * * @param $mark Website selected for (dis)approval * @return null */ private function _get_infos_links($mark) { $sql_array = array('SELECT' => 'a.link_id, a.link_name, a.link_url, a.link_description, a.link_banner, a.link_user_id, a.link_guest_email, u.username, u.user_email, u.user_lang, u.user_notify_type, c.cat_id, c.cat_name', 'FROM' => array(DIR_LINK_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.link_user_id'), array('FROM' => array(DIR_CAT_TABLE => 'c'), 'ON' => 'a.link_cat = c.cat_id')), 'WHERE' => $this->db->sql_in_set('a.link_id', $mark)); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $row['link_cat'] = $this->request->variable('c' . $row['link_id'], (int) $row['cat_id']); $this->links_data[] = $row; $this->affected_link_name[] = $row['link_name']; $this->cat_data[$row['link_cat']] = isset($this->cat_data[$row['link_cat']]) ? $this->cat_data[$row['link_cat']] + 1 : 1; } }
public function display_title() { $form_key = 'acp_video_title'; add_form_key($form_key); include $this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx; $form_action = $this->u_action . '&action=add'; $lang_mode = $this->user->lang['ACP_VIDEO_TITLE']; $video_id = $this->request->variable('video_id', 0); $video_title = $this->request->variable('video_title', '', true); $video_cat_id = $this->request->variable('video_cat_id', 0); $video_cat_title = $this->request->variable('video_cat_title', '', true); $action = isset($_POST['add']) ? 'add' : (isset($_POST['delete']) ? 'delete' : $this->request->variable('action', '')); //Make SQL Array $sql_ary = array('video_cat_id' => $video_cat_id, 'video_cat_title' => $video_cat_title); switch ($action) { case 'edit': $form_action = $this->u_action . '&action=update'; $lang_mode = $this->user->lang['ACP_CATEGORY_EDIT']; $sql = 'SELECT * FROM ' . $this->video_cat_table . ' WHERE video_cat_id = ' . (int) $this->request->variable('id', ''); $result = $this->db->sql_query_limit($sql, 1); $row = $this->db->sql_fetchrow($result); $this->template->assign_vars(array('S_EDIT_MODE' => true, 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'])); break; case 'update': $this->db->sql_query('UPDATE ' . $this->video_cat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE VIDEO_CAT_ID = ' . $video_cat_id); trigger_error($this->user->lang['ACP_CATEGORY_UPDATED'] . adm_back_link($this->u_action)); break; case 'delete': if (confirm_box(true)) { $sql = 'DELETE FROM ' . $this->video_table . ' WHERE video_id = ' . (int) $this->request->variable('id', ''); $this->db->sql_query($sql); trigger_error($this->user->lang['ACP_TITLE_DELETED'] . adm_back_link($this->u_action)); } else { confirm_box(false, $this->user->lang['ACP_TITLE_DELETE'], build_hidden_fields(array('video_id' => $video_id, 'action' => 'delete'))); } break; } // // Start output the page // $sql_title_ary = array('SELECT' => 'v.*,ct.*, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'ct.video_cat_id = v.video_cat_id AND u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC'); $sql = $this->db->sql_build_query('SELECT', $sql_title_ary); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('title', array('VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_TITLE' => $row['video_title'], 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row['video_cat_id'], 'U_DEL' => $this->u_action . '&action=delete&id=' . $row['video_id'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))); } $this->db->sql_freeresult($result); $this->template->assign_vars(array('U_ACTION' => $form_action, 'L_MODE_TITLE' => $lang_mode)); }
function get_item() { if (!isset($this->result)) { if (!$this->get_sql()) { return false; } // Query database $sql = $this->db->sql_build_query('SELECT', $this->sql); $this->result = $this->db->sql_query_limit($sql, $this->num_items); } return $this->db->sql_fetchrow($this->result); }
/** * Display subscription items. * * @return null */ protected function display_items() { $object_types = array(TITANIA_CONTRIB, TITANIA_TOPIC); $subscription_count = $this->get_subscription_count($object_types); $this->build_sort($subscription_count); $cases = array(TITANIA_CONTRIB => 'c.contrib_last_update', TITANIA_TOPIC => 't.topic_last_post_time'); $sql_ary = $this->get_subscription_sql_ary($cases, $object_types, TITANIA_CONTRIB); $sql_ary['LEFT_JOIN'][] = array('FROM' => array($this->topics_table => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . ' AND t.topic_id = w.watch_object_id'); // Additional tracking for support topics $this->tracking->get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id'); $this->tracking->get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa'); $this->tracking->get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc'); $this->tracking->get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); // Tracking for contributions $this->tracking->get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc'); $sql = $this->db->sql_build_query('SELECT', $sql_ary); $result = $this->db->sql_query_limit($sql, $this->sort->limit, $this->sort->start); $user_ids = $contributions = $topics = $rows = array(); while ($row = $this->db->sql_fetchrow($result)) { $this->tracking->store_from_db($row); $rows[] = $row; if ($row['watch_object_type'] == TITANIA_TOPIC) { $user_ids[] = (int) $row['topic_first_post_user_id']; $user_ids[] = (int) $row['topic_last_post_user_id']; } else { $user_ids[] = (int) $row['contrib_user_id']; } } $this->db->sql_freeresult($result); // Get user data \users_overlord::load_users($user_ids); foreach ($rows as $row) { if ($row['watch_object_type'] == TITANIA_TOPIC) { // Topic was deleted, remove all subscriptions for it. if (!$row['topic_id']) { $this->delete_subscription($row['watch_object_type'], $row['watch_object_id'], false); continue; } $vars = $this->get_topic_tpl_row($row); } else { // Contribution no longer exists. if (!$row['contrib_id']) { $this->delete_subscription($row['watch_object_type'], $row['watch_object_id'], false); continue; } $vars = $this->get_contribution_tpl_row($row); } $this->template->assign_block_vars('subscriptions', $vars); } $this->template->assign_vars(array('S_WATCHED_ITEMS' => true)); }
public function handle_ultimatepoints_list() { // UPlist disabled if (!$this->config['points_enable']) { trigger_error($this->user->lang['POINTS_LIST_DISABLE'], E_USER_NOTICE); } // Get some values $sql_array = array('SELECT' => '*', 'FROM' => array($this->points_values_table => 'v')); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); $points_values = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // Generate donors list $start = $this->request->variable('start', 0); $limit = $points_values['number_show_per_page']; $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_points > 0 ORDER BY user_points DESC'; $result = $this->db->sql_query_limit($sql, $limit, $start); while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('ultimatelist', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POINT' => sprintf($this->functions_points->number_format_points($row['user_points'])))); } $this->db->sql_freeresult($result); // Generate pagination $sql = 'SELECT COUNT(user_points) AS ultimatepoints_total FROM ' . USERS_TABLE . ' WHERE user_points > 0'; $result = $this->db->sql_query($sql); $ultimatepoints_total = (int) $this->db->sql_fetchfield('ultimatepoints_total'); //Start pagination $pagination_url = $this->helper->route('dmzx_ultimatepoints_list_controller'); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $ultimatepoints_total, $limit, $start); $this->template->assign_vars(array('TOTAL_ULTIMATEPOINTS_LIST' => $ultimatepoints_total == 1 ? $this->user->lang['POINTS_LIST_USER'] : sprintf($this->user->lang['POINTS_LIST_USERS'], $ultimatepoints_total), 'POINTSLIST' => $this->config['points_name'])); // Output the page page_header($this->user->lang['POINTS_LIST_TOTAL']); $this->template->set_filenames(array('body' => 'points/points_list.html')); page_footer(); }