Пример #1
0
    /**
     * Modified version of the jumpbox, just lists authed forums (in the correct order)
     */
    function get_forum_list($ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false)
    {
        // This query is identical to the jumpbox one
        $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
			FROM ' . FORUMS_TABLE . '
			ORDER BY left_id ASC';
        $result = $this->db->sql_query($sql, 600);
        // We include the forum root/index to make tree traversal easier
        $forum_list[0] = array('forum_id' => '0', 'forum_name' => $this->user->lang['FORUMS'], 'forum_type' => '0', 'link' => append_sid("{$this->root_path}index.{$this->phpEx}"), 'parent_id' => false, 'current' => false, 'current_child' => false, 'disabled' => false);
        // Sometimes it could happen that forums will be displayed here not be displayed within the index page
        // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
        // If this happens, the padding could be "broken"
        while ($row = $this->db->sql_fetchrow($result)) {
            $disabled = false;
            if (!$ignore_acl && $this->auth->acl_gets(array('f_list', 'f_read'), $row['forum_id'])) {
                if ($only_acl_post && !$this->auth->acl_get('f_post', $row['forum_id']) || !$this->auth->acl_get('m_approve', $row['forum_id']) && !$this->auth->acl_get('f_noapprove', $row['forum_id'])) {
                    $disabled = true;
                }
            } else {
                if (!$ignore_acl) {
                    continue;
                }
            }
            if (is_array($ignore_id) && in_array($row['forum_id'], $ignore_id) || $row['forum_id'] == $ignore_id || $row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id'] && $ignore_emptycat || $row['forum_type'] != FORUM_POST && $ignore_nonpost) {
                $disabled = true;
            }
            $u_viewforum = append_sid("{$this->root_path}viewforum.{$this->phpEx}", 'f=' . $row['forum_id']);
            $forum_list[$row['forum_id']] = array('forum_id' => $row['forum_id'], 'forum_name' => $row['forum_name'], 'forum_type' => $row['forum_type'], 'link' => $u_viewforum, 'parent_id' => $row['parent_id'], 'current' => false, 'current_child' => false, 'disabled' => $disabled);
        }
        $this->db->sql_freeresult($result);
        return $forum_list;
    }
 /**
  * Only display quick reply for admins and mods
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_modify_page_title($event)
 {
     $is_authed = $this->auth->acl_gets('a_', 'm_');
     if (!$is_authed) {
         $this->template->assign_vars(array('S_QUICK_REPLY' => false));
     }
 }
 public function main($event)
 {
     if ($this->config['load_birthdays'] && $this->config['allow_birthdays'] && $this->config['allow_birthdays_ahead'] > 0 && $this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
         $this->user->add_lang_ext('rmcgirr83/upcomingbirthdays', 'upcomingbirthdays');
         $this->upcoming_birthdays();
     }
 }
 public function action_conditions($event)
 {
     $topic_data = $event['topic_data'];
     $topic_id = $topic_data['topic_id'];
     $forum_id = $topic_data['forum_id'];
     $topic_status = $topic_data['topic_status'];
     if ($this->user->data['user_id'] == $topic_data['topic_poster'] && $this->auth->acl_gets('f_topicmod', $topic_data['forum_id']) || $this->auth->acl_gets('m_edit', $topic_data['forum_id'])) {
         $this->template->assign_vars(array('S_TOPIC_CLOSED' => $topic_data['topic_status'] == 1 ? true : false, 'S_CAN_CLOSE' => true, 'U_CLOSE_TOPIC' => append_sid("{$this->phpbb_root_path}topicmod", "fid={$forum_id}&tid={$topic_id}&topic_status={$topic_status}")));
         $event['force_edit_allowed'] = true;
     }
 }
Пример #5
0
    /**
     * Generates the user legend markup
     */
    public function mchat_legend()
    {
        // Grab group details for legend display for who is online on the custom page
        $order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
        if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
            $sql = 'SELECT group_id, group_name, group_colour, group_type
				FROM ' . GROUPS_TABLE . '
				WHERE group_legend <> 0
				ORDER BY ' . $order_legend . ' ASC';
        } else {
            $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
				FROM ' . GROUPS_TABLE . ' g
				LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (g.group_id = ug.group_id AND ug.user_id = ' . $this->user->data['user_id'] . ' AND ug.user_pending = 0)
				WHERE g.group_legend <> 0
					AND (g.group_type <> ' . GROUP_HIDDEN . '
					OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
				ORDER BY g.' . $order_legend . ' ASC';
        }
        $result = $this->db->sql_query($sql);
        $rows = $this->db->sql_fetchrowset($result);
        $this->db->sql_freeresult($result);
        $legend = array();
        foreach ($rows as $row) {
            $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
            $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang('G_' . $row['group_name']) : $row['group_name'];
            if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')) {
                $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
            } else {
                $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
            }
        }
        return $legend;
    }
Пример #6
0
    /**
     * Submit profile field for validation
     */
    public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
    {
        $sql_where = '';
        switch ($mode) {
            case 'register':
                // If the field is required we show it on the registration page
                $sql_where .= ' AND f.field_show_on_reg = 1';
                break;
            case 'profile':
                // Show hidden fields to moderators/admins
                if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) {
                    $sql_where .= ' AND f.field_show_profile = 1';
                }
                break;
            default:
                trigger_error('Wrong profile mode specified', E_USER_ERROR);
                break;
        }
        $sql = 'SELECT l.*, f.*
			FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . ' f
			WHERE l.lang_id = ' . (int) $lang_id . "\n\t\t\t\tAND f.field_active = 1\n\t\t\t\t{$sql_where}\n\t\t\t\tAND l.field_id = f.field_id\n\t\t\tORDER BY f.field_order";
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $profile_field = $this->type_collection[$row['field_type']];
            $cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row);
            $check_value = $cp_data['pf_' . $row['field_ident']];
            if (($cp_result = $profile_field->validate_profile_field($check_value, $row)) !== false) {
                // If the result is not false, it's an error message
                $cp_error[] = $cp_result;
            }
        }
        $this->db->sql_freeresult($result);
    }
    /**
     * Clear user reputation
     *
     * @param int $uid	User ID
     * @return null
     * @access public
     */
    public function clear_user($uid)
    {
        $this->user->add_lang_ext('pico/reputation', 'reputation_system');
        $is_ajax = $this->request->is_ajax();
        $submit = false;
        $sql_array = array('SELECT' => 'r.*, ut.username AS username_to', 'FROM' => array($this->reputations_table => 'r'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'ut'), 'ON' => 'r.user_id_to = ut.user_id ')), 'WHERE' => 'r.user_id_to = ' . $uid);
        $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);
        //We couldn't find this reputation. May be it was deleted meanwhile?
        if (empty($row)) {
            $message = $this->user->lang('RS_NO_REPUTATION');
            $json_data = array('error_msg' => $message);
            $redirect = append_sid("{$this->root_path}index.{$this->php_ext}");
            $redirect_text = 'RETURN_INDEX';
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        $redirect = $this->helper->route('reputation_details_controller', array('uid' => $uid));
        if ($this->request->is_set_post('cancel')) {
            redirect($redirect);
        }
        $post_ids = array();
        $post_type_id = (int) $this->reputation_manager->get_reputation_type_id('post');
        $sql = 'SELECT reputation_item_id
			FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$uid}\n\t\t\t\tAND reputation_type_id = {$post_type_id}\n\t\t\tGROUP BY reputation_item_id";
        $result = $this->db->sql_query($sql);
        while ($post_row = $this->db->sql_fetchrow($result)) {
            $post_ids[] = $post_row['reputation_item_id'];
        }
        $this->db->sql_freeresult($result);
        $redirect_text = 'RETURN_PAGE';
        if ($this->auth->acl_gets('m_rs_moderate')) {
            if ($is_ajax) {
                $submit = true;
            } else {
                $s_hidden_fields = build_hidden_fields(array('u' => $uid));
                if (confirm_box(true)) {
                    $submit = true;
                } else {
                    confirm_box(false, $this->user->lang('RS_CLEAR_POST_CONFIRM'), $s_hidden_fields);
                }
            }
        } else {
            $message = $this->user->lang('RS_USER_CANNOT_DELETE');
            $json_data = array('error_msg' => $message);
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        if ($submit) {
            try {
                $this->reputation_manager->clear_user_reputation($uid, $row, $post_ids);
            } catch (\pico\reputation\exception\base $e) {
                // Catch exception
                trigger_error($e->get_message($this->user));
            }
            $message = $this->user->lang('RS_CLEARED_USER');
            $json_data = array('clear_user' => true, 'post_ids' => $post_ids, 'poster_id' => $uid, 'user_reputation' => 0, 'post_reputation' => 0, 'reputation_class' => 'neutral');
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
    }
Пример #8
0
	/**
	* Determine whether the user is allowed to read and/or moderate the forum of the topic
	*
	* @param	array	$topic_ids	Array with the topic ids
	*
	* @return	array		Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample:
	*						array(
	*							'permission' => array(
	*								topic_id => forum_id
	*							),
	*						),
	*/
	protected function get_topic_auth(array $topic_ids)
	{
		$forum_auth = array('f_read' => array(), 'm_' => array());
		$topic_ids = array_unique($topic_ids);

		$sql = 'SELECT topic_id, forum_id
			FROM ' . TOPICS_TABLE . '
			WHERE ' . $this->db->sql_in_set('topic_id', array_map('intval', $topic_ids));
		$result = $this->db->sql_query($sql);

		while ($row = $this->db->sql_fetchrow($result))
		{
			$row['topic_id'] = (int) $row['topic_id'];
			$row['forum_id'] = (int) $row['forum_id'];

			if ($this->auth->acl_get('f_read', $row['forum_id']))
			{
				$forum_auth['f_read'][$row['topic_id']] = $row['forum_id'];
			}

			if ($this->auth->acl_gets('a_', 'm_', $row['forum_id']))
			{
				$forum_auth['m_'][$row['topic_id']] = $row['forum_id'];
			}
		}
		$this->db->sql_freeresult($result);

		return $forum_auth;
	}
Пример #9
0
    private function make_forum_select2($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false)
    {
        $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
			FROM ' . FORUMS_TABLE . '
			ORDER BY left_id ASC';
        $result = $this->db->sql_query($sql, 600);
        $right = 0;
        $padding_store = array('0' => '');
        $padding = '';
        $forum_list = $return_array ? array() : '';
        while ($row = $this->db->sql_fetchrow($result)) {
            if ($row['left_id'] < $right) {
                $padding .= '&nbsp; &nbsp;';
                $padding_store[$row['parent_id']] = $padding;
            } else {
                if ($row['left_id'] > $right + 1) {
                    $padding = isset($padding_store[$row['parent_id']]) ? $padding_store[$row['parent_id']] : '';
                }
            }
            $right = $row['right_id'];
            $disabled = false;
            if (!$ignore_acl && $this->auth->acl_get('f_list', $row['forum_id'])) {
                if ($only_acl_post && !$this->auth->acl_get('f_post', $row['forum_id']) || !$this->auth->acl_get('m_approve', $row['forum_id']) && !$this->auth->acl_get('f_noapprove', $row['forum_id'])) {
                    $disabled = true;
                } else {
                    if (!$only_acl_post && !$this->auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) {
                        $disabled = true;
                    }
                }
            } else {
                if (!$ignore_acl) {
                    continue;
                }
            }
            if (is_array($ignore_id) && in_array($row['forum_id'], $ignore_id) || $row['forum_id'] == $ignore_id || $row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id'] && $ignore_emptycat || $row['forum_type'] != FORUM_POST && $ignore_nonpost) {
                $disabled = true;
            }
            if ($return_array) {
                $selected = is_array($select_id) ? in_array($row['forum_id'], $select_id) ? true : false : ($row['forum_id'] == $select_id ? true : false);
                $forum_list[$row['forum_id']] = array_merge(array('padding' => $padding, 'selected' => $selected && !$disabled, 'disabled' => $disabled), $row);
            } else {
                $selected = is_array($select_id) ? in_array($row['forum_id'], $select_id) ? ' selected="selected"' : '' : ($row['forum_id'] == $select_id ? ' selected="selected"' : '');
                $forum_list .= '<option value="posting.php?mode=post&amp;f=' . $row['forum_id'] . '"' . ($disabled ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>';
            }
        }
        return $forum_list;
    }
Пример #10
0
 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);
 }
    public function main()
    {
        $topic_id = $this->request->variable('tid', 0);
        $forum_id = $this->request->variable('fid', 0);
        $topic_status = $this->request->variable('topic_status', 0);
        $action = $topic_status ? 0 : 1;
        $url = append_sid("{$this->phpbb_root_path}viewtopic." . $this->php_ext . "", "f={$forum_id}&amp;t={$topic_id}");
        if ($this->auth->acl_gets('f_topicmod', $forum_id) || $this->auth->acl_gets('m_edit', $forum_id)) {
            $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_status = ' . $action . '
				WHERE topic_id = ' . $topic_id . '';
            $this->db->sql_query($sql);
            $message = $topic_status ? $this->user->lang['OPEN_SUCCESS'] : $this->user->lang['CLOSE_SUCCESS'];
        } else {
            $message = $this->user->lang['CANNOT_MANAGE_TOPIC'];
        }
        $message .= '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $url . '">', '</a> ');
        meta_refresh(3, $url);
        trigger_error($message);
        return new Response('', 200);
    }
    /**
     * User details controller
     *
     * @param int $uid			User ID taken from the URL
     * @param string $sort_key	Sort key: id|username|time|point|action (default: id)
     * @param string $sort_dir	Sort direction: dsc|asc (descending|ascending) (default: dsc)
     * @return Symfony\Component\HttpFoundation\Response A Symfony Response object
     * @access public
     */
    public function userdetails($uid, $sort_key, $sort_dir)
    {
        $this->user->add_lang_ext('pico/reputation', array('reputation_system', 'reputation_rating'));
        $is_ajax = $this->request->is_ajax();
        $referer = $this->symfony_request->get('_referer');
        if (empty($this->config['rs_enable'])) {
            if ($is_ajax) {
                $json_response = new \phpbb\json_response();
                $json_data = array('error_msg' => $this->user->lang('RS_DISABLED'));
                $json_response->send($json_data);
            }
            redirect(append_sid("{$this->root_path}index.{$this->php_ext}"));
        }
        $sql = 'SELECT user_id, username, user_colour
			FROM ' . USERS_TABLE . '
			WHERE user_type <> 2
				AND user_id =' . (int) $uid;
        $result = $this->db->sql_query($sql);
        $user_row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($user_row)) {
            $message = $this->user->lang('RS_NO_USER_ID');
            $json_data = array('error_msg' => $message);
            $redirect = append_sid("{$this->root_path}index.{$this->php_ext}");
            $redirect_text = 'RETURN_INDEX';
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        if (!$this->auth->acl_get('u_rs_view')) {
            $message = $this->user->lang('RS_VIEW_DISALLOWED');
            $json_data = array('error_msg' => $message);
            $redirect = append_sid("memberlist.{$this->php_ext}", 'mode=viewprofile&amp;u=' . $uid);
            $redirect_text = 'RETURN_PAGE';
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        $sort_key_sql = array('username' => 'u.username_clean', 'time' => 'r.reputation_time', 'point' => 'r.reputation_points', 'action' => 'rt.reputation_type_name', 'id' => 'r.reputation_id');
        // Sql order depends on sort key
        $order_by = $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'dsc' ? 'DESC' : 'ASC');
        $reputation_type_id = (int) $this->reputation_manager->get_reputation_type_id('post');
        $sql_array = array('SELECT' => 'r.*, rt.reputation_type_name, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, p.post_id, p.forum_id, p.post_subject', 'FROM' => array($this->reputations_table => 'r', $this->reputation_types_table => 'rt'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = r.user_id_from'), array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => 'p.post_id = r.reputation_item_id
						AND r.reputation_type_id = ' . $reputation_type_id)), 'WHERE' => 'r.user_id_to = ' . $uid . '
				AND r.reputation_type_id = rt.reputation_type_id', 'ORDER_BY' => $order_by);
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $this->template->assign_block_vars('reputation', array('ID' => $row['reputation_id'], 'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']), 'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'), 'AVATAR' => phpbb_get_user_avatar($row), 'TIME' => $this->user->format_date($row['reputation_time']), 'COMMENT' => $row['reputation_comment'], 'POINTS' => $row['reputation_points'], 'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']), 'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']), 'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])), 'S_COMMENT' => !empty($row['reputation_comment']), 'S_DELETE' => $this->auth->acl_get('m_rs_moderate') || $row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete') ? true : false));
            // Generate post url
            $this->reputation_manager->generate_post_link($row);
        }
        $this->db->sql_freeresult($result);
        $this->template->assign_vars(array('USER_ID' => $uid, 'U_USER_DETAILS' => $this->helper->route('reputation_details_controller', array('uid' => $uid)), 'U_SORT_USERNAME' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'username', 'sort_dir' => $sort_key == 'username' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_TIME' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'time', 'sort_dir' => $sort_key == 'time' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_POINT' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'point', 'sort_dir' => $sort_key == 'point' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_ACTION' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'action', 'sort_dir' => $sort_key == 'action' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_CLEAR' => $this->helper->route('reputation_clear_user_controller', array('uid' => $uid)), 'U_REPUTATION_REFERER' => $referer, 'L_RS_USER_REPUTATION' => $this->user->lang('RS_USER_REPUTATION', get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour'])), 'S_RS_AVATAR' => $this->config['rs_display_avatar'] ? true : false, 'S_RS_COMMENT' => $this->config['rs_enable_comment'] ? true : false, 'S_RS_POINTS_IMG' => $this->config['rs_point_type'] ? true : false, 'S_CLEAR' => $this->auth->acl_gets('m_rs_moderate') ? true : false, 'S_IS_AJAX' => $is_ajax ? true : false));
        return $this->helper->render('userdetails.html');
    }
Пример #13
0
 /**
  * Get navigation tab options.
  *
  * @return array
  */
 protected function get_navigation_options()
 {
     /**
      * Menu Array
      *
      * 'filename' => array(
      *	'title'		=> 'nav menu title',
      * 	'url'		=> $page_url,
      *	'auth'		=> ($can_see_page) ? true : false, // Not required, always true if missing
      * ),
      */
     return array('attention' => array('title' => 'ATTENTION', 'url' => $this->helper->route('phpbb.titania.manage.attention'), 'auth' => $this->auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') || $this->types->find_authed('moderate'), 'count' => $this->get_open_attention_count()), 'queue' => array('title' => 'VALIDATION_QUEUE', 'url' => $this->helper->route('phpbb.titania.queue'), 'auth' => $this->types->find_authed('view') && $this->ext_config->use_queue), 'queue_discussion' => array('title' => 'QUEUE_DISCUSSION', 'url' => $this->helper->route('phpbb.titania.queue_discussion'), 'auth' => $this->types->find_authed('queue_discussion') && $this->ext_config->use_queue), 'administration' => array('title' => 'ADMINISTRATION', 'url' => $this->helper->route('phpbb.titania.administration'), 'auth' => $this->auth->acl_get('u_titania_admin'), 'match' => array('categories')), 'categories' => array('title' => 'MANAGE_CATEGORIES', 'url' => $this->helper->route('phpbb.titania.manage.categories'), 'auth' => $this->auth->acl_get('u_titania_admin'), 'display' => false));
 }
Пример #14
0
 /**
  * Modify the viewtopic post row
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_modify_post_row($event)
 {
     $users_groups = $this->cache->get('_user_groups');
     $user_id = $event['user_poster_data']['user_id'];
     if (!empty($users_groups[$user_id])) {
         $user_in_groups = '<ul>';
         foreach ($users_groups[$user_id] as $key => $value) {
             if ($value['group_type'] == GROUP_HIDDEN && (!$this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') || $user_id != (int) $this->user->data['user_id'])) {
                 continue;
             }
             $group_name = isset($this->user->lang['G_' . $value['group_name']]) ? $this->user->lang['G_' . $value['group_name']] : $value['group_name'];
             $group_link = append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $value['group_id']);
             $group_colour = !empty($value['group_colour']) ? 'style="color:#' . $value['group_colour'] . ';"' : '';
             $user_in_groups .= '<li><a href=' . $group_link . ' ' . $group_colour . '>' . $group_name . '</a></li>';
         }
         $user_in_groups .= '</ul>';
         $event['post_row'] = array_merge($event['post_row'], array('POSTER_GROUP' => $user_in_groups));
     }
 }
Пример #15
0
 /**
  * Assigns all message rows to the template
  *
  * @param $rows array
  */
 protected function assign_messages($rows)
 {
     if (empty($rows)) {
         return;
     }
     // Reverse the array if messages appear at the bottom
     if (!$this->config['mchat_message_top']) {
         $rows = array_reverse($rows);
     }
     $foes = $this->functions_mchat->mchat_foes();
     $this->template->destroy_block_vars('mchatrow');
     $user_avatars = array();
     foreach ($rows as $i => $row) {
         if (!isset($user_avatars[$row['user_id']])) {
             $display_avatar = $this->display_avatars() && $row['user_avatar'];
             $user_avatars[$row['user_id']] = !$display_avatar ? '' : phpbb_get_user_avatar(array('avatar' => $row['user_avatar'], 'avatar_type' => $row['user_avatar_type'], 'avatar_width' => $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], 'avatar_height' => $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']));
         }
     }
     foreach ($rows as $i => $row) {
         // Auth checks
         if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
             continue;
         }
         $message_edit = $row['message'];
         decode_message($message_edit, $row['bbcode_uid']);
         $message_edit = str_replace('"', '&quot;', $message_edit);
         $message_edit = mb_ereg_replace("'", '&#146;', $message_edit);
         if (in_array($row['user_id'], $foes)) {
             $row['message'] = sprintf($this->user->lang('MCHAT_FOE'), get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')));
         }
         $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
         $message = str_replace("'", '&rsquo;', $row['message']);
         $username_full = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST'));
         // Remove root path if we render messages for the index page
         if (strpos($this->user->data['session_page'], 'app.' . $this->php_ext) === false) {
             $username_full = str_replace('.' . $this->root_path, '', $username_full);
         }
         $this->template->assign_block_vars('mchatrow', array('S_ROW_COUNT' => $i, 'MCHAT_ALLOW_BAN' => $this->auth->acl_get('a_authusers'), 'MCHAT_ALLOW_EDIT' => $this->auth_message('u_mchat_edit', $row['user_id'], $row['message_time']), 'MCHAT_ALLOW_DEL' => $this->auth_message('u_mchat_delete', $row['user_id'], $row['message_time']), 'MCHAT_USER_AVATAR' => $user_avatars[$row['user_id']], 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? generate_board_url() . append_sid("/{$this->root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'MCHAT_IS_POSTER' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] == $row['user_id'], 'MCHAT_PM' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? generate_board_url() . append_sid("/{$this->root_path}ucp.{$this->php_ext}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => $username_full, 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_IP' => $this->helper->route('dmzx_mchat_page_controller', array('page' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => generate_board_url() . append_sid("/{$this->root_path}adm/index.{$this->php_ext}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => censor_text(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config['mchat_date']), 'MCHAT_MESSAGE_TIME' => $row['message_time'], 'MCHAT_EDIT_TIME' => $row['edit_time']));
     }
 }
Пример #16
0
    /**
     * {@inheritdoc}
     */
    public function get_template_center($module_id)
    {
        $order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
        // Grab group details for legend display
        if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
            $sql = 'SELECT group_id, group_name, group_colour, group_type
				FROM ' . GROUPS_TABLE . '
				WHERE group_legend > 0
				ORDER BY ' . $order_legend . ' ASC';
        } else {
            $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
				FROM ' . GROUPS_TABLE . ' g
				LEFT JOIN ' . USER_GROUP_TABLE . ' ug
					ON (
						g.group_id = ug.group_id
						AND ug.user_id = ' . (int) $this->user->data['user_id'] . '
						AND ug.user_pending = 0
					)
				WHERE g.group_legend > 0
					AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
				ORDER BY g.' . $order_legend . ' ASC';
        }
        $result = $this->db->sql_query($sql);
        $legend = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
            $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
            if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')) {
                $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
            } else {
                $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
            }
        }
        $this->db->sql_freeresult($result);
        $legend = implode(', ', $legend);
        $this->template->assign_var('PORTAL_LEGEND', $legend);
        return 'whois_online_center.html';
    }
Пример #17
0
    /**
     * Method to render the page data
     *
     * @var bool		Bool if the rendering is only for index
     * @return array	Data for page rendering
     */
    public function render_data_for_page($only_for_index = false)
    {
        $include_on_index = $only_for_index === true;
        // Add lang file
        $this->user->add_lang('posting');
        //chat enabled
        if (!$this->config['mchat_enable']) {
            trigger_error($this->user->lang['MCHAT_ENABLE'], E_USER_NOTICE);
        }
        //	avatars
        if (!function_exists('get_user_avatar')) {
            include $this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx;
        }
        if (($this->config_mchat = $this->cache->get('_mchat_config')) === false) {
            $this->functions_mchat->mchat_cache();
        }
        $this->config_mchat = $this->cache->get('_mchat_config');
        // Access rights
        $mchat_allow_bbcode = $this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode') ? true : false;
        $mchat_smilies = $this->config['allow_smilies'] && $this->auth->acl_get('u_mchat_smilies') ? true : false;
        $mchat_urls = $this->config['allow_post_links'] && $this->auth->acl_get('u_mchat_urls') ? true : false;
        $mchat_ip = $this->auth->acl_get('u_mchat_ip') ? true : false;
        $mchat_pm = $this->auth->acl_get('u_mchat_pm') ? true : false;
        $mchat_like = $this->auth->acl_get('u_mchat_like') ? true : false;
        $mchat_quote = $this->auth->acl_get('u_mchat_quote') ? true : false;
        $mchat_add_mess = $this->auth->acl_get('u_mchat_use') ? true : false;
        $mchat_view = $this->auth->acl_get('u_mchat_view') ? true : false;
        $mchat_no_flood = $this->auth->acl_get('u_mchat_flood_ignore') ? true : false;
        $mchat_read_archive = $this->auth->acl_get('u_mchat_archive') ? true : false;
        $mchat_founder = $this->user->data['user_type'] == USER_FOUNDER ? true : false;
        $mchat_session_time = !empty($this->config_mchat['timeout']) ? $this->config_mchat['timeout'] : (!empty($this->config['load_online_time']) ? $this->config['load_online_time'] * 60 : $this->config['session_length']);
        $mchat_rules = !empty($this->config_mchat['rules']) || isset($this->user->lang[strtoupper('mchat_rules')]) ? true : false;
        $mchat_avatars = !empty($this->config_mchat['avatars']) && $this->user->optionget('viewavatars') && $this->user->data['user_mchat_avatars'] ? true : false;
        // needed variables
        // Request options.
        $mchat_mode = $this->request->variable('mode', '');
        $mchat_read_mode = $mchat_archive_mode = $mchat_custom_page = $mchat_no_message = false;
        // set redirect if on index or custom page
        $on_page = $include_on_index ? 'index' : 'mchat';
        // grab fools..uhmmm, foes the user has
        $foes_array = array();
        $sql = 'SELECT * FROM ' . ZEBRA_TABLE . '
			WHERE user_id = ' . $this->user->data['user_id'] . '	AND foe = 1';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $foes_array[] = $row['zebra_id'];
        }
        $this->db->sql_freeresult($result);
        // Request mode...
        switch ($mchat_mode) {
            // rules popup..
            case 'rules':
                // If the rules are defined in the language file use them, else just use the entry in the database
                if ($mchat_rules || isset($this->user->lang[strtoupper('mchat_rules')])) {
                    if (isset($this->user->lang[strtoupper('mchat_rules')])) {
                        $this->template->assign_var('MCHAT_RULES', $this->user->lang[strtoupper('mchat_rules')]);
                    } else {
                        $mchat_rules = $this->config_mchat['rules'];
                        $mchat_rules = explode("\n", $mchat_rules);
                        foreach ($mchat_rules as $mchat_rule) {
                            $mchat_rule = utf8_htmlspecialchars($mchat_rule);
                            $this->template->assign_block_vars('rule', array('MCHAT_RULE' => $mchat_rule));
                        }
                    }
                    // Output the page
                    // Return for: \$this->helper->render(filename, lang_title);
                    return array('filename' => 'mchat_rules.html', 'lang_title' => $this->user->lang['MCHAT_HELP']);
                } else {
                    // Show no rules
                    trigger_error('MCHAT_NO_RULES', E_USER_NOTICE);
                }
                break;
                // whois function..
            // whois function..
            case 'whois':
                // Must have auths
                if ($mchat_mode == 'whois' && $mchat_ip) {
                    // function already exists..
                    if (!function_exists('user_ipwhois')) {
                        include $this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx;
                    }
                    $this->user_ip = $this->request->variable('ip', '');
                    $this->template->assign_var('WHOIS', user_ipwhois($this->user_ip));
                    // Output the page
                    // Return for: \$this->helper->render(filename, lang_title);
                    return array('filename' => 'viewonline_whois.html', 'lang_title' => $this->user->lang['WHO_IS_ONLINE']);
                } else {
                    // Show not authorized
                    trigger_error('NO_AUTH_OPERATION', E_USER_NOTICE);
                }
                break;
                // Clean function...
            // Clean function...
            case 'clean':
                // User logged in?
                if (!$this->user->data['is_registered'] || !$mchat_founder) {
                    if (!$this->user->data['is_registered']) {
                        // Login box...
                        login_box('', $this->user->lang['LOGIN']);
                    } else {
                        if (!$mchat_founder) {
                            // Show not authorized
                            trigger_error('NO_AUTH_OPERATION', E_USER_NOTICE);
                        }
                    }
                }
                $mchat_redirect = $this->request->variable('redirect', '');
                $mchat_redirect = $mchat_redirect == 'index' ? append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") : $this->helper->route('dmzx_mchat_controller', array('#mChat'));
                if (confirm_box(true)) {
                    // Run cleaner
                    $sql = 'TRUNCATE TABLE ' . $this->mchat_table;
                    $this->db->sql_query($sql);
                    meta_refresh(3, $mchat_redirect);
                    trigger_error($this->user->lang['MCHAT_CLEANED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                } else {
                    // Display confirm box
                    confirm_box(false, $this->user->lang['MCHAT_DELALLMESS']);
                }
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
                redirect($mchat_redirect);
                break;
                // Archive function...
            // Archive function...
            case 'archive':
                if (!$mchat_read_archive || !$mchat_view) {
                    // redirect to correct page
                    $mchat_redirect = append_sid("{$this->phpbb_root_path}index.{$this->phpEx}");
                    // Redirect to previous page
                    meta_refresh(3, $mchat_redirect);
                    trigger_error($this->user->lang['MCHAT_NOACCESS_ARCHIVE'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                }
                if ($this->config['mchat_enable'] && $mchat_read_archive && $mchat_view) {
                    // how many chats do we have?
                    $sql = 'SELECT COUNT(message_id) AS messages FROM ' . $this->mchat_table;
                    $result = $this->db->sql_query($sql);
                    $mchat_total_messages = $this->db->sql_fetchfield('messages');
                    $this->db->sql_freeresult($result);
                    // prune the chats if necessary and amount in ACP not empty
                    if ($this->config_mchat['prune_enable'] && ($mchat_total_messages > $this->config_mchat['prune_num'] && $this->config_mchat['prune_num'] > 0)) {
                        $this->functions_mchat->mchat_prune((int) $this->config_mchat['prune_num']);
                    }
                    // Reguest...
                    $mchat_archive_start = $this->request->variable('start', 0);
                    $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
                    // Message row
                    $sql = '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 ' . $this->mchat_table . ' m
							LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
						' . $sql_where . '
						ORDER BY m.message_id DESC';
                    $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
                    $rows = $this->db->sql_fetchrowset($result);
                    $this->db->sql_freeresult($result);
                    foreach ($rows as $row) {
                        // auth check
                        if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                            continue;
                        }
                        // edit, delete and permission auths
                        $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                        $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                        $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                        $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                        $message_edit = $row['message'];
                        decode_message($message_edit, $row['bbcode_uid']);
                        $message_edit = str_replace('"', '&quot;', $message_edit);
                        // Edit Fix ;)
                        if (sizeof($foes_array)) {
                            if (in_array($row['user_id'], $foes_array)) {
                                $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                            }
                        }
                        $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                        $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                    }
                    // Write no message
                    if (empty($rows)) {
                        $mchat_no_message = true;
                    }
                }
                // Run query again to get the total message rows...
                $sql = 'SELECT COUNT(message_id) AS mess_id FROM ' . $this->mchat_table;
                $result = $this->db->sql_query($sql);
                $mchat_total_message = $this->db->sql_fetchfield('mess_id');
                $this->db->sql_freeresult($result);
                // Page list function...
                $pagination_url = $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'));
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $mchat_total_message, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
                $this->template->assign_vars(array('MCHAT_TOTAL_MESSAGES' => sprintf($this->user->lang['MCHAT_TOTALMESSAGES'], $mchat_total_message)));
                //add to navlinks
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['MCHAT_ARCHIVE_PAGE'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'))));
                // If archive mode request set true
                $mchat_archive_mode = true;
                $old_mode = 'archive';
                break;
                // Read function...
            // Read function...
            case 'read':
                // If mChat disabled or user can't view the chat
                if (!$this->config['mchat_enable'] || !$mchat_view) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // if we're reading on the custom page, then we are chatting
                if ($mchat_custom_page) {
                    // insert user into the mChat sessions table
                    $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                }
                // Request
                $mchat_message_last_id = $this->request->variable('message_last_id', 0);
                $sql_and = $this->user->data['user_mchat_topics'] ? '' : 'AND m.forum_id = 0';
                $sql = '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 ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
					WHERE m.user_id = u.user_id
					AND m.message_id > ' . (int) $mchat_message_last_id . '
					' . $sql_and . '
					ORDER BY m.message_id DESC';
                $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['message_limit']);
                $rows = $this->db->sql_fetchrowset($result);
                $this->db->sql_freeresult($result);
                // Reverse the array wanting messages appear in reverse
                if ($this->config['mchat_message_top']) {
                    $rows = array_reverse($rows);
                }
                foreach ($rows as $row) {
                    // auth check
                    if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                        continue;
                    }
                    // edit auths
                    if ($this->user->data['user_id'] == ANONYMOUS && $this->user->data['user_id'] == $row['user_id']) {
                        $chat_auths = $this->user->data['session_ip'] == $row['user_ip'] ? true : false;
                    } else {
                        $chat_auths = $this->user->data['user_id'] == $row['user_id'] ? true : false;
                    }
                    // edit, delete and permission auths
                    $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                    $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                    $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                    $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                    $message_edit = $row['message'];
                    decode_message($message_edit, $row['bbcode_uid']);
                    $message_edit = str_replace('"', '&quot;', $message_edit);
                    $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                    // Edit Fix ;)
                    if (sizeof($foes_array)) {
                        if (in_array($row['user_id'], $foes_array)) {
                            $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                        }
                    }
                    $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                    $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                }
                // Write no message
                if (empty($rows)) {
                    $mchat_no_message = true;
                }
                // If read mode request set true
                $mchat_read_mode = true;
                break;
                // Stats function...
            // Stats function...
            case 'stats':
                // If mChat disabled or user can't view the chat
                if (!$this->config['mchat_enable'] || !$mchat_view || !$this->config_mchat['whois']) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                $mchat_stats = $this->functions_mchat->mchat_users($mchat_session_time);
                if (!empty($mchat_stats['online_userlist'])) {
                    $message = '<div class="mChatStats" id="mChatStats"><a href="#" onclick="mChat.toggle(\'UserList\'); return false;">' . $mchat_stats['mchat_users_count'] . '</a>&nbsp;' . $mchat_stats['refresh_message'] . '<br /><span id="mChatUserList" style="display: none; float: left;">' . $mchat_stats['online_userlist'] . '</span></div>';
                } else {
                    $message = '<div class="mChatStats" id="Div1">' . $this->user->lang['MCHAT_NO_CHATTERS'] . '&nbsp;(' . $mchat_stats['refresh_message'] . ')</div>';
                }
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'message' => $message);
                } else {
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                break;
                // Add function...
            // Add function...
            case 'add':
                // If mChat disabled
                if (!$this->config['mchat_enable'] || !$mchat_add_mess || !check_form_key('mchat_posting', -1)) {
                    // Forbidden (for jQ AJAX request)
                    if ($this->request->is_ajax()) {
                        // FOR DEBUG
                        throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                    }
                }
                // Reguest...
                $message = utf8_ucfirst(utf8_normalize_nfc($this->request->variable('message', '', true)));
                // must have something other than bbcode in the message
                if (empty($mchatregex)) {
                    //let's strip all the bbcode
                    $mchatregex = '#\\[/?[^\\[\\]]+\\]#mi';
                }
                $message_chars = preg_replace($mchatregex, '', $message);
                $message_chars = utf8_strlen(trim($message_chars)) > 0 ? true : false;
                if (!$message || !$message_chars) {
                    // Not Implemented (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                // Flood control
                if (!$mchat_no_flood && $this->config_mchat['flood_time']) {
                    $mchat_flood_current_time = time();
                    $sql = 'SELECT message_time FROM ' . $this->mchat_table . '
						WHERE user_id = ' . (int) $this->user->data['user_id'] . '
						ORDER BY message_time DESC';
                    $result = $this->db->sql_query_limit($sql, 1);
                    $row = $this->db->sql_fetchrow($result);
                    $this->db->sql_freeresult($result);
                    if ($row['message_time'] > 0 && $mchat_flood_current_time - $row['message_time'] < (int) $this->config_mchat['flood_time']) {
                        // Locked (for jQ AJAX request)
                        throw new \phpbb\exception\http_exception(400, 'MCHAT_BAD_REQUEST');
                    }
                }
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // we override the $this->config['min_post_chars'] entry?
                if ($this->config_mchat['override_min_post_chars']) {
                    $old_cfg['min_post_chars'] = $this->config['min_post_chars'];
                    $this->config['min_post_chars'] = 0;
                }
                //we do the same for the max number of smilies?
                if ($this->config_mchat['override_smilie_limit']) {
                    $old_cfg['max_post_smilies'] = $this->config['max_post_smilies'];
                    $this->config['max_post_smilies'] = 0;
                }
                // Add function part code from http://wiki.phpbb.com/Parsing_text
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
                // Not allowed bbcodes
                if (!$mchat_allow_bbcode || $this->config_mchat['bbcode_disallowed']) {
                    if (!$mchat_allow_bbcode) {
                        $bbcode_remove = '#\\[/?[^\\[\\]]+\\]#Usi';
                        $message = preg_replace($bbcode_remove, '', $message);
                    } else {
                        if ($this->config_mchat['bbcode_disallowed']) {
                            if (empty($bbcode_replace)) {
                                $bbcode_replace = array('#\\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi', '#\\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi');
                            }
                            $message = preg_replace($bbcode_replace, '', $message);
                        }
                    }
                }
                $sql_ary = array('forum_id' => 0, 'post_id' => 0, 'user_id' => $this->user->data['user_id'], 'user_ip' => $this->user->data['session_ip'], 'message' => str_replace('\'', '&rsquo;', $message), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options, 'message_time' => time());
                $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                // reset the config settings
                if (isset($old_cfg['min_post_chars'])) {
                    $this->config['min_post_chars'] = $old_cfg['min_post_chars'];
                    unset($old_cfg['min_post_chars']);
                }
                if (isset($old_cfg['max_post_smilies'])) {
                    $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
                    unset($old_cfg['max_post_smilies']);
                }
                // Stop run code!
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'success' => true);
                } else {
                    exit_handler();
                }
                break;
                // Edit function...
            // Edit function...
            case 'edit':
                $message_id = $this->request->variable('message_id', 0);
                // If mChat disabled and not edit
                if (!$this->config['mchat_enable'] || !$message_id) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // check for the correct user
                $sql = 'SELECT *
					FROM ' . $this->mchat_table . '
					WHERE message_id = ' . (int) $message_id;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                // edit and delete auths
                $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                // If mChat disabled and not edit
                if (!$mchat_edit) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // Reguest...
                $message = $this->request->variable('message', '', true);
                // must have something other than bbcode in the message
                if (empty($mchatregex)) {
                    //let's strip all the bbcode
                    $mchatregex = '#\\[/?[^\\[\\]]+\\]#mi';
                }
                $message_chars = preg_replace($mchatregex, '', $message);
                $message_chars = utf8_strlen(trim($message_chars)) > 0 ? true : false;
                if (!$message || !$message_chars) {
                    // Not Implemented (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                // Message limit
                $message = $this->config_mchat['max_message_lngth'] != 0 && utf8_strlen($message) >= $this->config_mchat['max_message_lngth'] + 3 ? utf8_substr($message, 0, $this->config_mchat['max_message_lngth']) . '...' : $message;
                // we override the $this->config['min_post_chars'] entry?
                if ($this->config_mchat['override_min_post_chars']) {
                    $old_cfg['min_post_chars'] = $this->config['min_post_chars'];
                    $this->config['min_post_chars'] = 0;
                }
                //we do the same for the max number of smilies?
                if ($this->config_mchat['override_smilie_limit']) {
                    $old_cfg['max_post_smilies'] = $this->config['max_post_smilies'];
                    $this->config['max_post_smilies'] = 0;
                }
                // Edit function part code from http://wiki.phpbb.com/Parsing_text
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
                // Not allowed bbcodes
                if (!$mchat_allow_bbcode || $this->config_mchat['bbcode_disallowed']) {
                    if (!$mchat_allow_bbcode) {
                        $bbcode_remove = '#\\[/?[^\\[\\]]+\\]#Usi';
                        $message = preg_replace($bbcode_remove, '', $message);
                    } else {
                        if ($this->config_mchat['bbcode_disallowed']) {
                            if (empty($bbcode_replace)) {
                                $bbcode_replace = array('#\\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi', '#\\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi');
                            }
                            $message = preg_replace($bbcode_replace, '', $message);
                        }
                    }
                }
                $sql_ary = array('message' => str_replace('\'', '&rsquo;', $message), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options);
                $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE message_id = ' . (int) $message_id;
                $this->db->sql_query($sql);
                // Message edited...now read it
                $sql = '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 ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
					WHERE m.user_id = u.user_id
						AND m.message_id = ' . (int) $message_id . '
					ORDER BY m.message_id DESC';
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $message_edit = $row['message'];
                decode_message($message_edit, $row['bbcode_uid']);
                $message_edit = str_replace('"', '&quot;', $message_edit);
                // Edit Fix ;)
                $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                // Edit Fix ;)
                $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => censor_text(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                // reset the config settings
                if (isset($old_cfg['min_post_chars'])) {
                    $this->config['min_post_chars'] = $old_cfg['min_post_chars'];
                    unset($old_cfg['min_post_chars']);
                }
                if (isset($old_cfg['max_post_smilies'])) {
                    $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
                    unset($old_cfg['max_post_smilies']);
                }
                //adds a log
                //	$message_author = get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']);
                //	add_log('admin', 'LOG_EDITED_MCHAT', $message_author);
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($row['username']));
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // If read mode request set true
                $mchat_read_mode = true;
                break;
                // Delete function...
            // Delete function...
            case 'delete':
                $message_id = $this->request->variable('message_id', 0);
                // If mChat disabled
                if (!$this->config['mchat_enable'] || !$message_id) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // check for the correct user
                $sql = 'SELECT m.*, u.username, u.user_colour
					FROM ' . $this->mchat_table . ' m
					LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
					WHERE m.message_id = ' . (int) $message_id;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                // edit and delete auths
                $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                // If mChat disabled
                if (!$mchat_del) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // Run delete!
                $sql = 'DELETE FROM ' . $this->mchat_table . '
					WHERE message_id = ' . (int) $message_id;
                $this->db->sql_query($sql);
                //adds a log
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($row['username']));
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // Stop running code
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'success' => true);
                } else {
                    exit_handler();
                }
                break;
                // Default function...
            // Default function...
            default:
                // If not include in index.php set mchat.php page true
                if (!$include_on_index) {
                    // Yes its custom page...
                    $mchat_custom_page = true;
                    // If custom page false mchat.php page redirect to index...
                    if (!$this->config_mchat['custom_page'] && $mchat_custom_page) {
                        $mchat_redirect = append_sid("{$this->phpbb_root_path}index.{$this->phpEx}");
                        // Redirect to previous page
                        meta_refresh(3, $mchat_redirect);
                        trigger_error($this->user->lang['MCHAT_NO_CUSTOM_PAGE'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                    }
                    // user has permissions to view the custom chat?
                    if (!$mchat_view && $mchat_custom_page) {
                        trigger_error('NOT_AUTHORISED', E_USER_NOTICE);
                    }
                    // if whois true
                    if ($this->config_mchat['whois']) {
                        // Grab group details for legend display for who is online on the custom page.
                        $order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
                        if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
                            $sql = 'SELECT group_id, group_name, group_colour, group_type FROM ' . GROUPS_TABLE . '
						WHERE group_legend <> 0
							ORDER BY ' . $order_legend . ' ASC';
                        } else {
                            $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type FROM ' . GROUPS_TABLE . ' g
						LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (g.group_id = ug.group_id AND ug.user_id = ' . $this->user->data['user_id'] . ' AND ug.user_pending = 0)
							WHERE g.group_legend <> 0
								AND (g.group_type <> ' . GROUP_HIDDEN . '
									OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
							ORDER BY g.' . $order_legend . ' ASC';
                        }
                        $result = $this->db->sql_query($sql);
                        $legend = array();
                        while ($row = $this->db->sql_fetchrow($result)) {
                            $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
                            $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
                            if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')) {
                                $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
                            } else {
                                $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
                            }
                        }
                        $this->db->sql_freeresult($result);
                        $legend = implode(', ', $legend);
                        // Assign index specific vars
                        $this->template->assign_vars(array('LEGEND' => $legend));
                    }
                    $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['MCHAT_TITLE'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller')));
                }
                // Run code...
                if ($mchat_view) {
                    $message_number = $mchat_custom_page ? $this->config_mchat['message_limit'] : $this->config_mchat['message_num'];
                    $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
                    // Message row
                    $sql = '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 ' . $this->mchat_table . ' m
							LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
						' . $sql_where . '
						ORDER BY message_id DESC';
                    $result = $this->db->sql_query_limit($sql, $message_number);
                    $rows = $this->db->sql_fetchrowset($result);
                    $this->db->sql_freeresult($result);
                    if ($this->config['mchat_message_top']) {
                        $rows = array_reverse($rows, true);
                    }
                    foreach ($rows as $row) {
                        // auth check
                        if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                            continue;
                        }
                        // edit, delete and permission auths
                        $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                        // edit auths
                        if ($this->user->data['user_id'] == ANONYMOUS && $this->user->data['user_id'] == $row['user_id']) {
                            $chat_auths = $this->user->data['session_ip'] == $row['user_ip'] ? true : false;
                        } else {
                            $chat_auths = $this->user->data['user_id'] == $row['user_id'] ? true : false;
                        }
                        $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                        $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                        $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                        $message_edit = $row['message'];
                        decode_message($message_edit, $row['bbcode_uid']);
                        $message_edit = str_replace('"', '&quot;', $message_edit);
                        // Edit Fix ;)
                        $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                        if (sizeof($foes_array)) {
                            if (in_array($row['user_id'], $foes_array)) {
                                $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                            }
                        }
                        $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                        $message = str_replace('\'', '&rsquo;', $row['message']);
                        $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                    }
                    // Write no message
                    if (empty($rows)) {
                        $mchat_no_message = true;
                    }
                    // display custom bbcodes
                    if ($mchat_allow_bbcode && $this->config['allow_bbcode']) {
                        $this->functions_mchat->display_mchat_bbcodes();
                    }
                    // Smile row
                    if ($mchat_smilies) {
                        if (!function_exists('generate_smilies')) {
                            include $this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx;
                        }
                        generate_smilies('inline', 0);
                    }
                    // If the static message is defined in the language file use it, else just use the entry in the database
                    if (isset($this->user->lang[strtoupper('static_message')]) || !empty($this->config_mchat['static_message'])) {
                        $this->config_mchat['static_message'] = $this->config_mchat['static_message'];
                        if (isset($this->user->lang[strtoupper('static_message')])) {
                            $this->config_mchat['static_message'] = $this->user->lang[strtoupper('static_message')];
                        }
                    }
                    // If the static message is defined in the language file use it, else just use the entry in the database
                    if (isset($this->user->lang[strtoupper('mchat_rules')]) || !empty($this->config_mchat['rules'])) {
                        if (isset($this->user->lang[strtoupper('mchat_rules')])) {
                            $this->config_mchat['rules'] = $this->user->lang[strtoupper('mchat_rules')];
                        }
                    }
                    // a list of users using the chat
                    if ($mchat_custom_page) {
                        $mchat_users = $this->functions_mchat->mchat_users($mchat_session_time, true);
                    } else {
                        $mchat_users = $this->functions_mchat->mchat_users($mchat_session_time);
                    }
                    $this->template->assign_vars(array('MCHAT_USERS_COUNT' => $mchat_users['mchat_users_count'], 'MCHAT_USERS_LIST' => $mchat_users['online_userlist']));
                }
                break;
        }
        // show index stats
        if (!empty($this->config['mchat_stats_index']) && !empty($this->user->data['user_mchat_stats_index'])) {
            // stats display
            $mchat_session_time = !empty($this->config_mchat['timeout']) ? $this->config_mchat['timeout'] : $this->config['session_length'];
            $mchat_stats = $this->functions_mchat->mchat_users($mchat_session_time);
            $this->template->assign_vars(array('MCHAT_INDEX_STATS' => true, 'MCHAT_INDEX_USERS_COUNT' => $mchat_stats['mchat_users_count'], 'MCHAT_INDEX_USERS_LIST' => !empty($mchat_stats['online_userlist']) ? $mchat_stats['online_userlist'] : '', 'L_MCHAT_ONLINE_EXPLAIN' => $mchat_stats['refresh_message']));
        }
        $copyright = base64_decode('PGEgaHJlZj0iaHR0cDovL3JtY2dpcnI4My5vcmciPlJNY0dpcnI4MzwvYT4gJmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly93d3cuZG16eC13ZWIubmV0IiB0aXRsZT0id3d3LmRtengtd2ViLm5ldCI+ZG16eDwvYT4=');
        add_form_key('mchat_posting');
        // Template function...
        $this->template->assign_vars(array('MCHAT_FILE_NAME' => $this->helper->route('dmzx_mchat_controller'), 'MCHAT_REFRESH_JS' => 1000 * $this->config_mchat['refresh'], 'MCHAT_ADD_MESSAGE' => $mchat_add_mess, 'MCHAT_READ_MODE' => $mchat_read_mode, 'MCHAT_ARCHIVE_MODE' => $mchat_archive_mode, 'MCHAT_INPUT_TYPE' => $this->user->data['user_mchat_input_area'], 'MCHAT_RULES' => $mchat_rules, 'MCHAT_ALLOW_SMILES' => $mchat_smilies, 'MCHAT_ALLOW_IP' => $mchat_ip, 'MCHAT_ALLOW_PM' => $mchat_pm, 'MCHAT_ALLOW_LIKE' => $mchat_like, 'MCHAT_ALLOW_QUOTE' => $mchat_quote, 'MCHAT_NOMESSAGE_MODE' => $mchat_no_message, 'MCHAT_ALLOW_BBCODES' => $mchat_allow_bbcode && $this->config['allow_bbcode'] ? true : false, 'MCHAT_MESSAGE_TOP' => $this->config['mchat_message_top'] ? true : false, 'MCHAT_ENABLE' => $this->config['mchat_enable'], 'MCHAT_ARCHIVE_URL' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive')), 'MCHAT_CUSTOM_PAGE' => $mchat_custom_page, 'MCHAT_INDEX_HEIGHT' => $this->config_mchat['index_height'], 'MCHAT_CUSTOM_HEIGHT' => $this->config_mchat['custom_height'], 'MCHAT_READ_ARCHIVE_BUTTON' => $mchat_read_archive, 'MCHAT_FOUNDER' => $mchat_founder, 'MCHAT_CLEAN_URL' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'clean', 'redirect' => $on_page)), 'MCHAT_STATIC_MESS' => !empty($this->config_mchat['static_message']) ? htmlspecialchars_decode($this->config_mchat['static_message']) : '', 'L_MCHAT_COPYRIGHT' => $copyright, 'MCHAT_WHOIS' => $this->config_mchat['whois'], 'MCHAT_MESSAGE_LNGTH' => $this->config_mchat['max_message_lngth'], 'L_MCHAT_MESSAGE_LNGTH_EXPLAIN' => intval($this->config_mchat['max_message_lngth']) ? sprintf($this->user->lang['MCHAT_MESSAGE_LNGTH_EXPLAIN'], intval($this->config_mchat['max_message_lngth'])) : '', 'MCHAT_MESS_LONG' => sprintf($this->user->lang['MCHAT_MESS_LONG'], $this->config_mchat['max_message_lngth']), 'MCHAT_USER_TIMEOUT' => $this->config_mchat['timeout'] ? 1000 * $this->config_mchat['timeout'] : false, 'MCHAT_WHOIS_REFRESH' => 1000 * $this->config_mchat['whois_refresh'], 'MCHAT_PAUSE_ON_INPUT' => $this->config_mchat['pause_on_input'] ? true : false, 'L_MCHAT_ONLINE_EXPLAIN' => $this->functions_mchat->mchat_session_time($mchat_session_time), 'MCHAT_REFRESH_YES' => sprintf($this->user->lang['MCHAT_REFRESH_YES'], $this->config_mchat['refresh']), 'L_MCHAT_WHOIS_REFRESH_EXPLAIN' => sprintf($this->user->lang['WHO_IS_REFRESH_EXPLAIN'], $this->config_mchat['whois_refresh']), 'S_MCHAT_AVATARS' => $mchat_avatars, 'S_MCHAT_LOCATION' => $this->config_mchat['location'], 'S_MCHAT_SOUND_YES' => $this->user->data['user_mchat_sound'], 'S_MCHAT_INDEX_STATS' => $this->user->data['user_mchat_stats_index'], 'U_MORE_SMILIES' => append_sid("{$this->phpbb_root_path}posting.{$this->phpEx}", 'mode=smilies'), 'U_MCHAT_RULES' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'rules')), 'S_MCHAT_ON_INDEX' => $this->config['mchat_on_index'] && !empty($this->user->data['user_mchat_index']) ? true : false));
        // Return for: \$this->helper->render(filename, lang_title);
        return array('filename' => 'mchat_body.html', 'lang_title' => $this->user->lang['MCHAT_TITLE']);
    }
Пример #18
0
    public function main()
    {
        include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
        $this->user->add_lang(array('memberlist', 'groups', 'search'));
        $this->user->add_lang_ext('gfksx/ThanksForPosts', 'thanks_mod');
        // Grab data
        $mode = $this->request->variable('mode', '');
        $end_row_rating = isset($this->config['thanks_number_row_reput']) ? $this->config['thanks_number_row_reput'] : false;
        $full_post_rating = $full_topic_rating = $full_forum_rating = false;
        $u_search_post = $u_search_topic = $u_search_forum = '';
        $total_match_count = 0;
        //$page_title = $this->user->lang['REPUT_TOPLIST'];
        $topic_id = $this->request->variable('t', 0);
        $return_chars = $this->request->variable('ch', $topic_id ? -1 : 300);
        $words = array();
        $ex_fid_ary = array_keys($this->auth->acl_getf('!f_read', true));
        $ex_fid_ary = sizeof($ex_fid_ary) ? $ex_fid_ary : true;
        $pagination_url = append_sid("{$this->phpbb_root_path}toplist", 'mode=' . $mode);
        if (!$this->auth->acl_gets('u_viewtoplist')) {
            if ($this->user->data['user_id'] != ANONYMOUS) {
                trigger_error('RATING_NO_VIEW_TOPLIST');
            }
            login_box('', isset($this->user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]) ? $this->user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $this->user->lang['RETING_LOGIN_EXPLAIN']);
        }
        $notoplist = true;
        $start = $this->request->variable('start', 0);
        $max_post_thanks = $this->config['thanks_post_reput_view'] ? $this->gfksx_helper->get_max_post_thanks() : 1;
        $max_topic_thanks = $this->config['thanks_topic_reput_view'] ? $this->gfksx_helper->get_max_topic_thanks() : 1;
        $max_forum_thanks = $this->config['thanks_forum_reput_view'] ? $this->gfksx_helper->get_max_forum_thanks() : 1;
        switch ($mode) {
            case 'post':
                $sql = 'SELECT COUNT(DISTINCT post_id) as total_post_count
					FROM ' . $this->thanks_table . '
					WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true);
                $result = $this->db->sql_query($sql);
                $total_match_count = (int) $this->db->sql_fetchfield('total_post_count');
                $this->db->sql_freeresult($result);
                $full_post_rating = true;
                $notoplist = false;
                break;
            case 'topic':
                $sql = 'SELECT COUNT(DISTINCT topic_id) as total_topic_count
					FROM ' . $this->thanks_table . '
					WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true);
                $result = $this->db->sql_query($sql);
                $total_match_count = (int) $this->db->sql_fetchfield('total_topic_count');
                $this->db->sql_freeresult($result);
                $full_topic_rating = true;
                $notoplist = false;
                break;
            case 'forum':
                $sql = 'SELECT COUNT(DISTINCT forum_id) as total_forum_count
					FROM ' . $this->thanks_table . '
					WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true);
                $result = $this->db->sql_query($sql);
                $total_match_count = (int) $this->db->sql_fetchfield('total_forum_count');
                $this->db->sql_freeresult($result);
                $full_forum_rating = true;
                $notoplist = false;
                break;
            default:
                $page_title = $this->user->lang['REPUT_TOPLIST'];
                $total_match_count = 0;
        }
        $page_title = sprintf($this->user->lang['REPUT_TOPLIST'], $total_match_count);
        //post rating
        if (!$full_forum_rating && !$full_topic_rating && $this->config['thanks_post_reput_view']) {
            $end = $full_post_rating ? $this->config['topics_per_page'] : $end_row_rating;
            $sql_p_array['FROM'] = array($this->thanks_table => 't');
            $sql_p_array['SELECT'] = 'u.user_id, u.username, u.user_colour, p.post_subject, p.post_id, p.post_time, p.poster_id, p.post_username, p.topic_id, p.forum_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment';
            $sql_p_array['SELECT'] .= ', t.post_id, COUNT(*) AS post_thanks';
            $sql_p_array['LEFT_JOIN'][] = array('FROM' => array($this->posts_table => 'p'), 'ON' => 't.post_id = p.post_id');
            $sql_p_array['LEFT_JOIN'][] = array('FROM' => array($this->users_table => 'u'), 'ON' => 'p.poster_id = u.user_id');
            $sql_p_array['GROUP_BY'] = 't.post_id';
            $sql_p_array['ORDER_BY'] = 'post_thanks DESC';
            $sql_p_array['WHERE'] = $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true);
            $sql = $this->db->sql_build_query('SELECT', $sql_p_array);
            $result = $this->db->sql_query_limit($sql, $end, $start);
            $u_search_post = append_sid("{$this->phpbb_root_path}toplist", "mode=post");
            if (!($row = $this->db->sql_fetchrow($result))) {
                trigger_error('RATING_VIEW_TOPLIST_NO');
            } else {
                $notoplist = false;
                $bbcode_bitfield = $text_only_message = '';
                do {
                    // We pre-process some variables here for later usage
                    $row['post_text'] = censor_text($row['post_text']);
                    $text_only_message = $row['post_text'];
                    // make list items visible as such
                    if ($row['bbcode_uid']) {
                        $text_only_message = str_replace('[*:' . $row['bbcode_uid'] . ']', '&sdot;&nbsp;', $text_only_message);
                        // no BBCode in text only message
                        strip_bbcode($text_only_message, $row['bbcode_uid']);
                    }
                    if ($return_chars == -1 || utf8_strlen($text_only_message) < $return_chars + 3) {
                        $row['display_text_only'] = false;
                        $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
                        // Does this post have an attachment? If so, add it to the list
                        if ($row['post_attachment'] && $this->config['allow_attachments']) {
                            $attach_list[$row['forum_id']][] = $row['post_id'];
                        }
                    } else {
                        $row['post_text'] = $text_only_message;
                        $row['display_text_only'] = true;
                    }
                    $rowset[] = $row;
                    unset($text_only_message);
                    // Instantiate BBCode if needed
                    if ($bbcode_bitfield !== '' and !class_exists('bbcode')) {
                        include $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext;
                        $bbcode = new \bbcode(base64_encode($bbcode_bitfield));
                    }
                    // Replace naughty words such as farty pants
                    $row['post_subject'] = censor_text($row['post_subject']);
                    if ($row['display_text_only']) {
                        $row['post_text'] = get_context($row['post_text'], $words, $return_chars);
                        $row['post_text'] = bbcode_nl2br($row['post_text']);
                    } else {
                        // Second parse bbcode here
                        if ($row['bbcode_bitfield']) {
                            $bbcode->bbcode_second_pass($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']);
                        }
                        $row['post_text'] = bbcode_nl2br($row['post_text']);
                        $row['post_text'] = smiley_text($row['post_text']);
                    }
                    $post_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'p=' . $row['post_id'] . '#p' . $row['post_id']);
                    $this->template->assign_block_vars('toppostrow', array('MESSAGE' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['post_text'] : (!empty($row['forum_id']) ? $this->user->lang['SORRY_AUTH_READ'] : $row['post_text']), 'POST_DATE' => !empty($row['post_time']) ? $this->user->format_date($row['post_time']) : '', 'MINI_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'POST_ID' => $post_url, 'POST_SUBJECT' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['post_subject'] : (!empty($row['forum_id']) ? '' : $row['post_subject']), 'POST_AUTHOR' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_REPUT' => round($row['post_thanks'] / ($max_post_thanks / 100), $this->config['thanks_number_digits']) . '%', 'POST_THANKS' => $row['post_thanks'], 'S_THANKS_POST_REPUT_VIEW' => isset($this->config['thanks_post_reput_view']) ? $this->config['thanks_post_reput_view'] : false, 'S_THANKS_REPUT_GRAPHIC' => isset($this->config['thanks_reput_graphic']) ? $this->config['thanks_reput_graphic'] : false, 'THANKS_REPUT_HEIGHT' => sprintf('%dpx', $this->config['thanks_reput_height']), 'THANKS_REPUT_GRAPHIC_WIDTH' => sprintf('%dpx', $this->config['thanks_reput_level'] * $this->config['thanks_reput_height']), 'THANKS_REPUT_IMAGE' => isset($this->config['thanks_reput_image']) ? $this->phpbb_root_path . $this->config['thanks_reput_image'] : '', 'THANKS_REPUT_IMAGE_BACK' => isset($this->config['thanks_reput_image_back']) ? $this->phpbb_root_path . $this->config['thanks_reput_image_back'] : ''));
                } while ($row = $this->db->sql_fetchrow($result));
                $this->db->sql_freeresult($result);
            }
        }
        //topic rating
        if (!$full_forum_rating && !$full_post_rating && $this->config['thanks_topic_reput_view']) {
            $end = $full_topic_rating ? $this->config['topics_per_page'] : $end_row_rating;
            $sql_t_array['FROM'] = array($this->thanks_table => 'f');
            $sql_t_array['SELECT'] = 'u.user_id, u.username, u.user_colour, t.topic_title, t.topic_id, t.topic_time, t.topic_poster, t.topic_first_poster_name, t.topic_first_poster_colour, t.forum_id, t.topic_type, t.topic_status, t.poll_start';
            $sql_t_array['SELECT'] .= ', f.topic_id, COUNT(*) AS topic_thanks';
            $sql_t_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'f.topic_id = t.topic_id');
            $sql_t_array['LEFT_JOIN'][] = array('FROM' => array($this->users_table => 'u'), 'ON' => 't.topic_poster = u.user_id');
            $sql_t_array['GROUP_BY'] = 'f.topic_id';
            $sql_t_array['ORDER_BY'] = 'topic_thanks DESC';
            $sql_t_array['WHERE'] = $this->db->sql_in_set('f.forum_id', $ex_fid_ary, true);
            $sql = $this->db->sql_build_query('SELECT', $sql_t_array);
            $result = $this->db->sql_query_limit($sql, $end, $start);
            $u_search_topic = append_sid("{$this->phpbb_root_path}toplist", "mode=topic");
            if (!($row = $this->db->sql_fetchrow($result))) {
                trigger_error('RATING_VIEW_TOPLIST_NO');
            } else {
                $notoplist = false;
                do {
                    // Get folder img, topic status/type related information
                    $folder_img = $folder_alt = $topic_type = '';
                    topic_status($row, 0, false, $folder_img, $folder_alt, $topic_type);
                    $view_topic_url_params = 'f=' . ($row['forum_id'] ? $row['forum_id'] : '') . '&amp;t=' . $row['topic_id'];
                    $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", $view_topic_url_params);
                    $this->template->assign_block_vars('toptopicrow', array('TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG_SRC' => $row['forum_id'] ? 'topic_read' : 'announce_read', 'TOPIC_TITLE' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['topic_title'] : (!empty($row['forum_id']) ? $this->user->lang['SORRY_AUTH_READ'] : $row['topic_title']), 'U_VIEW_TOPIC' => $view_topic_url, 'TOPIC_AUTHOR' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_THANKS' => $row['topic_thanks'], 'TOPIC_REPUT' => round($row['topic_thanks'] / ($max_topic_thanks / 100), $this->config['thanks_number_digits']) . '%', 'S_THANKS_TOPIC_REPUT_VIEW' => isset($this->config['thanks_topic_reput_view']) ? $this->config['thanks_topic_reput_view'] : false, 'S_THANKS_REPUT_GRAPHIC' => isset($this->config['thanks_reput_graphic']) ? $this->config['thanks_reput_graphic'] : false, 'THANKS_REPUT_HEIGHT' => sprintf('%dpx', $this->config['thanks_reput_height']), 'THANKS_REPUT_GRAPHIC_WIDTH' => sprintf('%dpx', $this->config['thanks_reput_level'] * $this->config['thanks_reput_height']), 'THANKS_REPUT_IMAGE' => isset($this->config['thanks_reput_image']) ? $this->phpbb_root_path . $this->config['thanks_reput_image'] : '', 'THANKS_REPUT_IMAGE_BACK' => isset($this->config['thanks_reput_image_back']) ? $this->phpbb_root_path . $this->config['thanks_reput_image_back'] : ''));
                } while ($row = $this->db->sql_fetchrow($result));
                $this->db->sql_freeresult($result);
            }
        }
        //forum rating
        if (!$full_topic_rating && !$full_post_rating && $this->config['thanks_forum_reput_view']) {
            $end = $full_forum_rating ? $this->config['topics_per_page'] : $end_row_rating;
            $sql_f_array['FROM'] = array($this->thanks_table => 't');
            $sql_f_array['SELECT'] = 'f.forum_name, f.forum_id';
            $sql_f_array['SELECT'] .= ', t.forum_id, COUNT(*) AS forum_thanks';
            $sql_f_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id');
            $sql_f_array['GROUP_BY'] = 't.forum_id';
            $sql_f_array['ORDER_BY'] = 'forum_thanks DESC';
            $sql_f_array['WHERE'] = $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true);
            $sql = $this->db->sql_build_query('SELECT', $sql_f_array);
            $result = $this->db->sql_query_limit($sql, $end, $start);
            $u_search_forum = append_sid("{$this->phpbb_root_path}toplist", "mode=forum");
            if (!($row = $this->db->sql_fetchrow($result))) {
                trigger_error('RATING_VIEW_TOPLIST_NO');
            } else {
                $notoplist = false;
                do {
                    if (!empty($row['forum_id'])) {
                        $u_viewforum = append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']);
                        $folder_image = 'forum_read';
                        $this->template->assign_block_vars('topforumrow', array('FORUM_FOLDER_IMG_SRC' => $this->user->img('forum_read', 'NO_NEW_POSTS', false, '', 'src'), 'FORUM_IMG_STYLE' => $folder_image, 'FORUM_NAME' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['forum_name'] : (!empty($row['forum_id']) ? $this->user->lang['SORRY_AUTH_READ'] : $row['forum_name']), 'U_VIEW_FORUM' => $u_viewforum, 'FORUM_THANKS' => $row['forum_thanks'], 'FORUM_REPUT' => round($row['forum_thanks'] / ($max_forum_thanks / 100), $this->config['thanks_number_digits']) . '%', 'S_THANKS_FORUM_REPUT_VIEW' => isset($this->config['thanks_forum_reput_view']) ? $this->config['thanks_forum_reput_view'] : false, 'S_THANKS_REPUT_GRAPHIC' => isset($this->config['thanks_reput_graphic']) ? $this->config['thanks_reput_graphic'] : false, 'THANKS_REPUT_HEIGHT' => sprintf('%dpx', $this->config['thanks_reput_height']), 'THANKS_REPUT_GRAPHIC_WIDTH' => sprintf('%dpx', $this->config['thanks_reput_level'] * $this->config['thanks_reput_height']), 'THANKS_REPUT_IMAGE' => isset($this->config['thanks_reput_image']) ? $this->phpbb_root_path . $this->config['thanks_reput_image'] : '', 'THANKS_REPUT_IMAGE_BACK' => isset($this->config['thanks_reput_image_back']) ? $this->phpbb_root_path . $this->config['thanks_reput_image_back'] : ''));
                    }
                } while ($row = $this->db->sql_fetchrow($result));
                $this->db->sql_freeresult($result);
            }
        }
        if ($notoplist) {
            trigger_error('RATING_VIEW_TOPLIST_NO');
        }
        $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_match_count, $this->config['topics_per_page'], $start);
        // Output the page
        $this->template->assign_vars(array('PAGE_NUMBER' => $this->pagination->on_page($total_match_count, $this->config['posts_per_page'], $start), 'PAGE_TITLE' => $page_title, 'S_THANKS_FORUM_REPUT_VIEW' => isset($this->config['thanks_forum_reput_view']) ? $this->config['thanks_forum_reput_view'] : false, 'S_THANKS_TOPIC_REPUT_VIEW' => isset($this->config['thanks_topic_reput_view']) ? $this->config['thanks_topic_reput_view'] : false, 'S_THANKS_POST_REPUT_VIEW' => isset($this->config['thanks_post_reput_view']) ? $this->config['thanks_post_reput_view'] : false, 'S_FULL_POST_RATING' => $full_post_rating, 'S_FULL_TOPIC_RATING' => $full_topic_rating, 'S_FULL_FORUM_RATING' => $full_forum_rating, 'U_SEARCH_POST' => $u_search_post, 'U_SEARCH_TOPIC' => $u_search_topic, 'U_SEARCH_FORUM' => $u_search_forum));
        page_header($page_title);
        $this->template->set_filenames(array('body' => 'toplist_body.html'));
        make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}"));
        page_footer();
        return new Response($this->template->return_display('body'), 200);
    }
    /**
     * Convert Local Url To Link Name
     *
     * @return null
     * @access public
     */
    public function convert_local_url_to_link_name($event)
    {
        $this->user->add_lang_ext('hammer663/ConvertLocalUrlToLinkName', 'convert_local_url');
        $allow_bbcode = $event['allow_bbcode'];
        $allow_magic_url = $event['allow_magic_url'];
        $allow_enable = $this->config['clutln_enable'];
        $allow_rules = $this->config['clutln_allow_rules'];
        $allow_wiki = $this->config['clutln_allow_wiki'];
        $allow_faq = $this->config['clutln_allow_faq'];
        $allow_youtube = $this->config['clutln_allow_youtube'];
        $allow_allow_seo = $this->config['clutln_allow_seo'];
        $message = $event['message'];
        if ($allow_bbcode && $allow_magic_url && $allow_enable) {
            $board_url = generate_board_url();
            $firstchar = '(^|[\\n\\t (>.])';
            $lastchar = '([\\w\\#$%&~\\-;:=,?@+]*)';
            $viewtopic_url = str_replace('\\://', '\\://(www\\.)*', $firstchar . '(' . preg_quote($board_url . '/viewtopic.' . $this->php_ext . '?') . ')');
            $viewforum_url = str_replace('\\://', '\\://(www\\.)*', $firstchar . '(' . preg_quote($board_url . '/viewforum.' . $this->php_ext . '?') . ')');
            $viewprofile_url = str_replace('\\://', '\\://(www\\.)*', $firstchar . '(' . preg_quote($board_url . '/memberlist.' . $this->php_ext . '?') . 'mode=viewprofile&amp;)');
            $forums_auth = array();
            $matches0 = array();
            //			preg_match_all('#' . $viewtopic_url . '(f)=([0-9]+)&amp;(t|p)=([0-9]+)' . $lastchar . '#si', $message, $matches0[]);
            //			preg_match_all('#' . $viewtopic_url . '(p)=([0-9]+)' . $lastchar . '#si', ' ' . $message, $matches0[]);
            preg_match_all('#' . $viewtopic_url . '(f|t)=([0-9]+)&amp;(t|p)=([0-9]+)' . $lastchar . '#si', $message, $matches0[]);
            preg_match_all('#' . $viewtopic_url . '(t|p)=([0-9]+)' . $lastchar . '#si', ' ' . $message, $matches0[]);
            preg_match_all('#' . $viewforum_url . '(f)=([0-9]+)' . $lastchar . '#si', ' ' . $message, $matches0[]);
            preg_match_all('#' . $viewprofile_url . '(u)=([0-9]+)' . $lastchar . '#si', ' ' . $message, $matches0[]);
            $last_char_patt = '/([\\),]*)$/';
            foreach ($matches0 as $matches) {
                foreach ($matches[0] as $k => $str) {
                    if (preg_match('@(\\[code(?:=([a-z]+))?\\].*?)' . preg_quote($str) . '(.*?\\[\\/code\\])@is', $message)) {
                        continue;
                    }
                    $topic_title = '';
                    $topic_post_id = (int) $matches[4 + 1][$k];
                    $type_url = $matches[3 + 1][$k];
                    switch ($type_url) {
                        case 'f':
                            switch ($matches[5 + 1][$k]) {
                                case 'p':
                                    $topic_post_id = (int) $matches[6 + 1][$k];
                                    $type_url = 'p';
                                    break;
                                case 't':
                                    $topic_post_id = (int) $matches[6 + 1][$k];
                                    $sql = 'SELECT topic_title, topic_type, forum_id
										FROM ' . TOPICS_TABLE . ' t
										WHERE t.topic_id = ' . $topic_post_id;
                                    break;
                                default:
                                    $sql = 'SELECT forum_name as topic_title, forum_id
										FROM ' . FORUMS_TABLE . '
										WHERE forum_id = ' . $topic_post_id;
                                    break;
                            }
                            break;
                            // Canonical URL
                        // Canonical URL
                        case 't':
                            switch ($matches[5 + 1][$k]) {
                                case 'p':
                                    $topic_post_id = (int) $matches[6 + 1][$k];
                                    $type_url = 'p';
                                    break;
                                default:
                                    $topic_post_id = (int) $matches[4 + 1][$k];
                                    $sql = 'SELECT topic_title, topic_type, forum_id
										FROM ' . TOPICS_TABLE . '
										WHERE topic_id = ' . $topic_post_id;
                                    break;
                            }
                            break;
                        case 'u':
                            $sql = 'SELECT username
								FROM ' . USERS_TABLE . '
								WHERE user_id = ' . $topic_post_id;
                            break;
                    }
                    if ($type_url == 'p') {
                        $sql = 'SELECT t.topic_title, t.topic_type, t.forum_id, p.post_subject, p.post_id, u.username
							FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
							LEFT JOIN ' . USERS_TABLE . ' u on u.user_id = p.poster_id
							WHERE p.post_id = ' . $topic_post_id . '
								AND p.topic_id = t.topic_id';
                        //	echo $sql;
                    }
                    if (!empty($topic_post_id) && ($result = $this->db->sql_query($sql))) {
                        $row = $this->db->sql_fetchrow($result);
                        switch ($type_url) {
                            case 'u':
                                $topic_title = $row['username'];
                                break;
                            case 'f':
                            case 't':
                            case 'p':
                                if (!isset($forums_auth[$row['forum_id']])) {
                                    $forums_auth[$row['forum_id']] = $this->auth->acl_gets('f_list', 'f_read', $row['forum_id']);
                                }
                                if ($forums_auth[$row['forum_id']] || $row['topic_type'] == POST_GLOBAL) {
                                    $topic_title = !empty($row['post_subject']) ? $row['post_subject'] : $row['topic_title'];
                                }
                                break;
                        }
                        $this->db->sql_freeresult($result);
                    }
                    if (!empty($topic_title)) {
                        $internal_url = substr($str, strlen($matches[1][$k]));
                        $internal_url = preg_replace('/f=[0-9](&amp;)/', '', $internal_url);
                        // Canonical - destroy f=*
                        $internal_url = preg_replace('/(&amp;)sid=[0-9a-f]{32}/', '', $internal_url);
                        if (preg_match($last_char_patt, $str, $math)) {
                            $internal_url = preg_replace($last_char_patt, '', $internal_url);
                        }
                        $topic_title = $type_url == 'p' ? $topic_title . ' (' . $this->user->lang('POST_BY', $row['username'], $row['post_id']) . ')' : $topic_title;
                        $message = str_replace($str, $matches[1][$k] . '[url=' . trim($internal_url) . ']' . $topic_title . '[/url]' . (isset($math[1]) ? $math[1] : ''), ' ' . $message);
                    }
                }
            }
            // Board Rules Url to Link name
            if ($allow_rules) {
                $rules_url = generate_board_url() . '/rules';
                $firstchar = '(^|[\\n\\t (>.])';
                $lastchar = '(\\?)?(sid=[0-9a-f]{32})*(\\#rule|\\#cat)([\\d\\.]+)([,\\)])*';
                $rules_url = str_replace('\\://', '\\://(www\\.)*', $firstchar . '(' . preg_quote($rules_url) . ')');
                $matches = array();
                preg_match_all('#' . $rules_url . $lastchar . '#si', $message, $matches);
                foreach ($matches[0] as $k => $str) {
                    if (preg_match('@(\\[code(?:=([a-z]+))?\\].*?)' . preg_quote($str) . '(.*?\\[\\/code\\])@i', $message)) {
                        continue;
                    }
                    $rule_num = $matches[7][$k];
                    $rule_url = $matches[2][$k] . $matches[4][$k] . $matches[6][$k] . $rule_num;
                    $rule_url_name = sprintf($this->user->lang['BOARD_RULE_NUMBER'], $rule_num);
                    $message = str_replace($str, $matches[1][$k] . '[url=' . trim($rule_url) . ']' . $rule_url_name . '[/url]' . $matches[8][$k], ' ' . $message);
                }
            }
            // Wiki-Url to Link Name
            if ($allow_wiki) {
                // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
                $message = str_replace(array('[code]', '[/code]'), array('[code] ', ' [/code]'), ' ' . $message);
                $wiki_urls = array('(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(wiki)\\.phpbb\\.com', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(wiki)\\.phpbbguru\\.net', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(\\S+)\\.wikipedia\\.org', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(\\S+)\\.wikiquote\\.org', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(\\S+)\\.wikibooks\\.org', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(www\\.)*sportswiki\\.ru', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(www\\.)*lurkmore\\.ru', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(www\\.)*lurkmore\\.to', '(^|[\\n\\t (>.])(http[s]?\\:\\/\\/(www\\.)*lurkmo\\.re');
                $last_char_patt = '/([\\),]*)$/';
                $matches = array();
                foreach ($wiki_urls as $url_pattern) {
                    preg_match_all('#' . $url_pattern . '(\\S*)\\/)([\\S$+]*)#si', $message, $matches);
                    foreach ($matches[0] as $k => $str) {
                        if (preg_match('@(\\[code(?:=([a-z]+))?\\].*?)' . preg_quote($str) . '(.*?\\[\\/code\\])@is', $message)) {
                            continue;
                        }
                        $topic_title = $matches[5][$k];
                        if (!empty($topic_title)) {
                            if (preg_match('/\\%([A-Z0-9]{2})/i', $topic_title)) {
                                $topic_title = rawurldecode($topic_title);
                                if (empty($topic_title)) {
                                    $topic_title = urldecode($matches[5][$k]);
                                }
                                if (empty($topic_title)) {
                                    $topic_title = $matches[5][$k];
                                }
                            }
                            $wiki_url = substr($str, strlen($matches[1][$k]));
                            if (preg_match($last_char_patt, $str, $math)) {
                                if (strpos($wiki_url, '(') === false && strpos($wiki_url, ')') === false) {
                                    $wiki_url = preg_replace($last_char_patt, '', $wiki_url);
                                    $topic_title = preg_replace($last_char_patt, '', $topic_title);
                                } else {
                                    $pos = strpos($math[1], ')');
                                    if ($pos !== false) {
                                        $math[1] = substr_replace($math[1], '', $pos, 1);
                                    }
                                }
                            }
                            $wiki_url = str_replace($topic_title, rawurlencode($topic_title), $wiki_url);
                            $wiki_url = str_replace(array('%3A', '%2C', '%23'), array(':', ',', '#'), $wiki_url);
                            $topic_title = str_replace('_', ' ', $topic_title);
                            if ($tok = strtok($topic_title, '#')) {
                                $topic_title = $tok;
                                if ($sec_tok = strtok('#')) {
                                    if (preg_match('/\\.([A-Z0-9]{2})/i', $sec_tok)) {
                                        $sec_tok = str_replace('.', '%', $sec_tok);
                                    }
                                    $topic_title .= ': ' . urldecode($sec_tok);
                                }
                            }
                            $message = substr_replace($message, $matches[1][$k] . '[url=' . trim($wiki_url) . ']' . $topic_title . '[/url]' . (isset($math[1]) ? $math[1] : ''), strpos($message, $str), strlen($str));
                        }
                    }
                }
                // Remove our padding from the string..
                $message = substr(str_replace(array('[code] ', ' [/code]'), array('[code]', '[/code]'), $message), 1);
            }
            //FAQ Url to Link name
            if ($allow_faq) {
                $faqs_url = generate_board_url() . '/faq.' . $this->php_ext;
                $firstchar = '(^|[\\n\\t (>.])';
                $lastchar = '(sid=[0-9a-f]{32})*((\\#f([\\d]+))+(r([\\d]+))*)([,\\)])*';
                $faqs_url = str_replace('\\://', '\\://(www\\.)*', $firstchar . '(' . preg_quote($faqs_url) . ')');
                $matches = array();
                preg_match_all('#' . $faqs_url . $lastchar . '#si', $message, $matches);
                foreach ($matches[0] as $k => $str) {
                    if (preg_match('@(\\[code(?:=([a-z]+))?\\].*?)' . preg_quote($str) . '(.*?\\[\\/code\\])@is', $message)) {
                        continue;
                    }
                    $faq_url = $matches[1][$k] . $matches[2][$k] . $matches[5][$k];
                    $faq_url_name = sprintf($this->user->lang['FAQ_NUMBER'], $matches[7][$k], $matches[9][$k]);
                    $message = str_replace($str, $matches[1][$k] . '[url=' . trim($faq_url) . ']' . $faq_url_name . '[/url]' . $matches[10][$k], ' ' . $message);
                }
            }
            // YouTube link
            if ($allow_youtube) {
                $matches0 = array();
                preg_match_all('#(^|[\\n\\t (>.])(http[s]*://(?:www\\.)?youtube\\.com)/(v)/([0-9a-z\\-\\_\\+]+)([\\S$+]*)#i', $message, $matches0[]);
                preg_match_all('#(^|[\\n\\t (>.])(http[s]*://(?:www\\.)?youtube\\.com/watch\\?)(v)=([0-9a-z\\-\\_\\+]+)([\\S$+]*)#i', $message, $matches0[]);
                preg_match_all('#(^|[\\n\\t (>.])(http[s]*://(?:www\\.)?youtube\\.com/watch\\?)([feature=].*?)&amp;(v)=([0-9a-z\\-\\_\\+]+)([\\S$+]*)#i', $message, $matches0[]);
                preg_match_all('#(^|[\\n\\t (>.])(http[s]*://(youtu\\.be)/)([0-9a-z\\-\\_\\+]+)([\\S$+]*)#i', $message, $matches0[]);
                foreach ($matches0 as $matches) {
                    foreach ($matches[0] as $k => $str) {
                        if (preg_match('@(\\[code(?:=([a-z]+))?\\])' . preg_quote($str) . '(\\[\\/code\\])@is', $message)) {
                            continue;
                        }
                        for ($i = 1, $sizeofm = sizeof($matches); $i < $sizeofm; ++$i) {
                            if ($matches[$i][$k] === 'v' || $matches[$i][$k] === 'youtu.be') {
                                $video_id = $matches[$i + 1][$k];
                                $laststr = $matches[sizeof($matches) - 1][$k];
                                if (preg_match('/([&feature=].*?)/i', $laststr)) {
                                    $laststr = '';
                                }
                                $message = str_replace($str, $matches[1][$k] . '[youtube]' . $video_id . '[/youtube]' . $laststr, $message);
                                break;
                            }
                        }
                    }
                }
            }
            // phpBB SEO Ultimate SEO URL (Simple mode)
            if ($allow_allow_seo == 1) {
                $last_char_patt = '/([\\),]*)$/';
                //	$parse_url  = '(^|[\n\t (>.])' . preg_quote(generate_board_url()) . '/(\w*\/)*(topic|post|forum|member|\-u)([0-9]+)([\w\-+]*)\.html';
                $seo_ext = '(' . preg_quote($this->core->seo_ext['forum']) . '|' . preg_quote($this->core->seo_ext['topic']) . '|' . preg_quote($this->core->seo_ext['post']) . '|' . preg_quote($this->core->seo_ext['user']) . ')';
                $parse_url = '(^|[\\n\\t (>.])' . preg_quote(generate_board_url()) . '/(\\S*)(topic|post|forum|member|\\-u)([0-9]+)(-([0-9]+))?' . $seo_ext;
                //([\w\-+]+)
                $parse_url = str_replace('\\://', '\\://(www\\.)*', $parse_url);
                $matches = array();
                preg_match_all('#' . $parse_url . '([\\w\\#$%&~\\-;:=,?@\\[\\]+]*)#si', ' ' . $message, $matches);
                $forums_auth = array();
                foreach ($matches[0] as $k => $str) {
                    if (preg_match('@(\\[code(?:=([a-z]+))?\\].*?)' . preg_quote($str) . '(.*?\\[\\/code\\])@is', $message)) {
                        continue;
                    }
                    $topic_title = '';
                    $type_url = $matches[4][$k];
                    $topic_post_id = (int) $matches[5][$k];
                    // Forums without id
                    if (!in_array($type_url, array('topic', 'post', 'forum', 'member', '-u'))) {
                        $type_url = $matches[3][$k];
                        $this->core->get_forum_id($topic_post_id, $type_url);
                        if (!empty($topic_post_id)) {
                            $type_url = 'forum';
                        } else {
                            $type_url = '';
                        }
                    }
                    switch ($type_url) {
                        case 'topic':
                            $sql = 'SELECT topic_title, topic_type, forum_id
								FROM ' . TOPICS_TABLE . '
								WHERE topic_id = ' . $topic_post_id;
                            break;
                        case 'post':
                            $sql = 'SELECT t.topic_title, t.topic_type, t.forum_id, p.post_subject, p.post_id, u.username
								FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
								LEFT JOIN ' . USERS_TABLE . ' u on u.user_id = p.poster_id
								WHERE p.post_id = ' . $topic_post_id . '
									AND p.topic_id = t.topic_id';
                            break;
                        case 'forum':
                            $sql = 'SELECT forum_name as topic_title, forum_id
								FROM ' . FORUMS_TABLE . '
								WHERE forum_id = ' . $topic_post_id;
                            break;
                        case '-u':
                        case 'member':
                            $sql = 'SELECT username
								FROM ' . USERS_TABLE . '
								WHERE user_id = ' . $topic_post_id;
                            break;
                    }
                    if (!empty($topic_post_id) && ($result = $this->db->sql_query($sql))) {
                        $row = $this->db->sql_fetchrow($result);
                        switch ($type_url) {
                            case 'forum':
                            case 'topic':
                            case 'post':
                                if (!isset($forums_auth[$row['forum_id']])) {
                                    $forums_auth[$row['forum_id']] = $this->auth->acl_gets('f_list', 'f_read', $row['forum_id']);
                                }
                                if ($forums_auth[$row['forum_id']] || $row['topic_type'] == POST_GLOBAL) {
                                    $topic_title = !empty($row['post_subject']) ? $row['post_subject'] : $row['topic_title'];
                                }
                                break;
                            case '-u':
                            case 'member':
                                $topic_title = $row['username'];
                                break;
                        }
                        $this->db->sql_freeresult($result);
                    }
                    if (!empty($topic_title)) {
                        $internal_url = substr($str, strlen($matches[1][$k]));
                        $internal_url = preg_replace('/(&amp;)sid=[0-9a-f]{32}/', '', $internal_url);
                        if (preg_match($last_char_patt, $str, $math)) {
                            $internal_url = preg_replace($last_char_patt, '', $internal_url);
                        }
                        $topic_title = $type_url == 'post' ? $topic_title . ' (' . $this->user->lang('POST_BY', $row['username'], $row['post_id']) . ')' : $topic_title;
                        $message = str_replace($str, $matches[1][$k] . '[url=' . trim($internal_url) . ']' . $topic_title . '[/url]' . (isset($math[1]) ? $math[1] : ''), ' ' . $message);
                    }
                }
            }
            // phpBB SEO Ultimate SEO URL (Advanced mode)
            if ($allow_allow_seo == 2) {
                $seo_ext = '(' . preg_quote($this->core->seo_ext['forum']) . '|' . preg_quote($this->core->seo_ext['topic']) . '|' . preg_quote($this->core->seo_ext['post']) . '|' . preg_quote($this->core->seo_ext['user']) . ')';
                $parse_url = '(^|[\\n\\t (>.])' . preg_quote(generate_board_url()) . '/(\\S*)(\\-t|post|\\-f|member|\\-u)([0-9]+)(-([0-9]+))?' . $seo_ext;
                //([\w\-+]+)
                $parse_url = str_replace('\\://', '\\://(www\\.)*', $parse_url);
                $matches0 = array();
                preg_match_all('#' . $parse_url . '([\\w\\#$%&~\\-;:=,?@\\[\\]+]*)#si', ' ' . $message, $matches0[]);
                // Forums without id
                $seo_ext = '(' . preg_quote($this->core->seo_ext['forum']) . '|\\.html))?';
                $parse_url = '(^|[\\n\\t (>.])' . preg_quote(generate_board_url()) . '/([a-z0-9_-]+)/?(page([0-9]+)' . $seo_ext;
                $parse_url = str_replace('\\://', '\\://(www\\.)*', $parse_url);
                preg_match_all('#' . $parse_url . '([\\#$%&~\\-;:=,?@\\[\\]+]*)#si', ' ' . $message, $matches0[]);
                $forums_auth = array();
                $last_char_patt = '/([\\),]*)$/';
                foreach ($matches0 as $matches) {
                    foreach ($matches[0] as $k => $str) {
                        if (preg_match('@(\\[code(?:=([a-z]+))?\\].*?)' . preg_quote($str) . '(.*?\\[\\/code\\])@is', $message)) {
                            continue;
                        }
                        $topic_title = '';
                        $type_url = $matches[4][$k];
                        $topic_post_id = (int) $matches[5][$k];
                        // Forums without id
                        if (!in_array($type_url, array('-t', 'post', '-f', 'member', '-u'))) {
                            $type_url = $matches[3][$k];
                            $this->core->get_forum_id($topic_post_id, $type_url);
                            if (!empty($topic_post_id)) {
                                $type_url = '-f';
                            } else {
                                $type_url = '';
                            }
                        }
                        switch ($type_url) {
                            case '-t':
                                $sql = 'SELECT topic_title, topic_type, forum_id
									FROM ' . TOPICS_TABLE . '
									WHERE topic_id = ' . $topic_post_id;
                                break;
                            case 'post':
                                $sql = 'SELECT t.topic_title, t.topic_type, t.forum_id, p.post_subject, p.post_id, u.username
									FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
									LEFT JOIN ' . USERS_TABLE . ' u on u.user_id = p.poster_id
									WHERE p.post_id = ' . $topic_post_id . '
										AND p.topic_id = t.topic_id';
                                break;
                            case '-f':
                                $sql = 'SELECT forum_name as topic_title, forum_id
									FROM ' . FORUMS_TABLE . '
									WHERE forum_id = ' . $topic_post_id;
                                break;
                            case '-u':
                            case 'member':
                                $sql = 'SELECT username
									FROM ' . USERS_TABLE . '
									WHERE user_id = ' . $topic_post_id;
                                break;
                        }
                        if (!empty($topic_post_id) && ($result = $this->db->sql_query($sql))) {
                            $row = $this->db->sql_fetchrow($result);
                            switch ($type_url) {
                                case '-f':
                                case '-t':
                                case 'post':
                                    if (!isset($forums_auth[$row['forum_id']])) {
                                        $forums_auth[$row['forum_id']] = $this->auth->acl_gets('f_list', 'f_read', $row['forum_id']);
                                    }
                                    if ($forums_auth[$row['forum_id']] || $row['topic_type'] == POST_GLOBAL) {
                                        $topic_title = !empty($row['post_subject']) ? $row['post_subject'] : $row['topic_title'];
                                    }
                                    break;
                                case '-u':
                                case 'member':
                                    $topic_title = $row['username'];
                                    break;
                            }
                            $this->db->sql_freeresult($result);
                        }
                        if (!empty($topic_title)) {
                            $internal_url = preg_replace('/(&amp;)sid=[0-9a-f]{32}/', '', substr($str, strlen($matches[1][$k])));
                            if (preg_match($last_char_patt, $str, $math)) {
                                $internal_url = preg_replace($last_char_patt, '', $internal_url);
                            }
                            $topic_title = $type_url == 'post' ? $topic_title . ' (' . $this->user->lang('POST_BY', $row['username'], $row['post_id']) . ')' : $topic_title;
                            $replacement = $matches[1][$k] . '[url=' . trim($internal_url) . ']' . $topic_title . '[/url]' . (isset($math[1]) ? $math[1] : '');
                            $message = preg_replace("@{$str}@", $replacement, ' ' . $message);
                        }
                    }
                }
            }
            //
        }
        $event['message'] = $message;
    }
Пример #20
0
 /**
  * Check whether the board has been disabled and should not be shown
  *
  * @return bool True if board has been disabled, false if not
  */
 protected function board_disabled()
 {
     return $this->config['board_disable'] && !defined('SKIP_CHECK_DISABLED') && !$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_');
 }
Пример #21
0
    public function main($mode, $author_id, $give)
    {
        $this->user->add_lang(array('memberlist', 'groups', 'search'));
        $this->user->add_lang_ext('gfksx/ThanksForPosts', 'thanks_mod');
        // Grab data
        $row_number = $total_users = 0;
        $givens = $reseved = $rowsp = $rowsu = $words = $where = array();
        $sthanks = false;
        $ex_fid_ary = array_keys($this->auth->acl_getf('!f_read', true));
        $ex_fid_ary = sizeof($ex_fid_ary) ? $ex_fid_ary : false;
        if (!$this->auth->acl_gets('u_viewthanks')) {
            if ($this->user->data['user_id'] != ANONYMOUS) {
                trigger_error('NO_VIEW_USERS_THANKS');
            }
            login_box('', isset($this->user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]) ? $this->user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $this->user->lang['LOGIN_EXPLAIN_MEMBERLIST']);
        }
        $top = $this->request->variable('top', 0);
        $start = $this->request->variable('start', 0);
        $submit = isset($_POST['submit']) ? true : false;
        $default_key = 'a';
        $sort_key = $this->request->variable('sk', $default_key);
        $sort_dir = $this->request->variable('sd', 'd');
        $topic_id = $this->request->variable('t', 0);
        $return_chars = $this->request->variable('ch', $topic_id ? -1 : 300);
        $order_by = '';
        switch ($mode) {
            case 'givens':
                $per_page = $this->config['posts_per_page'];
                $total_match_count = 0;
                $page_title = $this->user->lang['SEARCH'];
                $template_html = 'thanks_results.html';
                switch ($give) {
                    case 'true':
                        $u_search = $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $author_id, 'give' => 'true', 'tslash' => ''));
                        $sql = 'SELECT COUNT(user_id) AS total_match_count
						FROM ' . $this->thanks_table . '
						WHERE (' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0) AND user_id = ' . $author_id;
                        $where = 'user_id';
                        break;
                    case 'false':
                        $u_search = $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $author_id, 'give' => 'false', 'tslash' => ''));
                        $sql = 'SELECT COUNT(DISTINCT post_id) as total_match_count
						FROM ' . $this->thanks_table . '
						WHERE (' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0) AND poster_id = ' . $author_id;
                        $where = 'poster_id';
                        break;
                }
                $result = $this->db->sql_query($sql);
                if (!($row = $this->db->sql_fetchrow($result))) {
                    break;
                } else {
                    $total_match_count = (int) $row['total_match_count'];
                    $this->db->sql_freeresult($result);
                    $sql_array = array('SELECT' => 'u.username, u.user_colour, p.poster_id, p.post_id, p.topic_id, p.forum_id, p.post_time, p.post_subject, p.post_text, p.post_username, p.bbcode_bitfield, p.bbcode_uid, p.post_attachment, p.enable_bbcode, p. enable_smilies, p.enable_magic_url', 'FROM' => array($this->thanks_table => 't'), 'WHERE' => '(' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) . ' OR t.forum_id = 0) AND t.' . $where . "= {$author_id}");
                    $sql_array['LEFT_JOIN'][] = array('FROM' => array($this->users_table => 'u'), 'ON' => 't.poster_id = u.user_id');
                    $sql_array['LEFT_JOIN'][] = array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => 't.post_id = p.post_id');
                    $sql = $this->db->sql_build_query('SELECT_DISTINCT', $sql_array);
                    $result = $this->db->sql_query_limit($sql, $per_page, $start);
                    if (!($row = $this->db->sql_fetchrow($result))) {
                        break;
                    } else {
                        $bbcode_bitfield = $text_only_message = '';
                        do {
                            // We pre-process some variables here for later usage
                            $row['post_text'] = censor_text($row['post_text']);
                            $text_only_message = $row['post_text'];
                            // make list items visible as such
                            if ($row['bbcode_uid']) {
                                // no BBCode in text only message
                                strip_bbcode($text_only_message, $row['bbcode_uid']);
                            }
                            if ($return_chars == -1 || utf8_strlen($text_only_message) < $return_chars + 3) {
                                $row['display_text_only'] = false;
                                $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
                                // Does this post have an attachment? If so, add it to the list
                                if ($row['post_attachment'] && $config['allow_attachments']) {
                                    $attach_list[$row['forum_id']][] = $row['post_id'];
                                }
                            } else {
                                $row['post_text'] = $text_only_message;
                                $row['display_text_only'] = true;
                            }
                            unset($text_only_message);
                            if ($row['display_text_only']) {
                                // limit the message length to return_chars value
                                $row['post_text'] = get_context($row['post_text'], array(), $return_chars);
                                $row['post_text'] = bbcode_nl2br($row['post_text']);
                            } else {
                                $flags = ($row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0);
                                $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $flags);
                            }
                            $this->template->assign_block_vars('searchresults', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_SUBJECT' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['post_subject'] : (!empty($row['forum_id']) ? '' : $row['post_subject']), 'POST_DATE' => !empty($row['post_time']) ? $this->user->format_date($row['post_time']) : '', 'MESSAGE' => $this->auth->acl_get('f_read', $row['forum_id']) ? $row['post_text'] : (!empty($row['forum_id']) ? $this->user->lang['SORRY_AUTH_READ'] : $row['post_text']), 'FORUM_ID' => $row['forum_id'], 'TOPIC_ID' => $row['topic_id'], 'POST_ID' => $row['post_id'], 'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 't=' . $row['topic_id']), 'U_VIEW_FORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']), 'U_VIEW_POST' => !empty($row['post_id']) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "t=" . $row['topic_id'] . '&amp;p=' . $row['post_id']) . '#p' . $row['post_id'] : ''));
                        } while ($row = $this->db->sql_fetchrow($result));
                        $this->db->sql_freeresult($result);
                    }
                }
                if ($total_match_count > 1000) {
                    $total_match_count--;
                    $l_search_matches = $this->user->lang('FOUND_MORE_SEARCH_MATCHES', $total_match_count);
                } else {
                    $l_search_matches = $this->user->lang('FOUND_SEARCH_MATCHES', $total_match_count);
                }
                $this->pagination->generate_template_pagination($u_search, 'pagination', 'start', $total_match_count, $per_page, $start);
                $this->template->assign_vars(array('PAGE_NUMBER' => $this->pagination->on_page($total_match_count, $per_page, $start), 'TOTAL_MATCHES' => $total_match_count, 'SEARCH_MATCHES' => $l_search_matches, 'U_THANKS' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('tslash' => ''))));
                break;
            default:
                $page_title = $this->user->lang['THANKS_USER'];
                $template_html = 'thankslist_body.html';
                // Grab relevant data thanks
                $sql = 'SELECT user_id, COUNT(user_id) AS tally
					FROM ' . $this->thanks_table . '
					WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0
					GROUP BY user_id';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $givens[$row['user_id']] = $row['tally'];
                }
                $this->db->sql_freeresult($result);
                $sql = 'SELECT poster_id, COUNT(user_id) AS tally
					FROM ' . $this->thanks_table . '
					WHERE ' . $this->db->sql_in_set('forum_id', $ex_fid_ary, true) . ' OR forum_id = 0
					GROUP BY poster_id';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $reseved[$row['poster_id']] = $row['tally'];
                }
                $this->db->sql_freeresult($result);
                // Sorting
                $sort_key_text = array('a' => $this->user->lang['SORT_USERNAME'], 'b' => $this->user->lang['SORT_LOCATION'], 'c' => $this->user->lang['SORT_JOINED'], 'd' => $this->user->lang['SORT_POST_COUNT'], 'e' => 'R_THANKS', 'f' => 'G_THANKS');
                $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'e' => 'count_thanks', 'f' => 'count_thanks');
                $sort_dir_text = array('a' => $this->user->lang['ASCENDING'], 'd' => $this->user->lang['DESCENDING']);
                if ($this->auth->acl_get('u_viewonline')) {
                    $sort_key_text['l'] = $this->user->lang['SORT_LAST_ACTIVE'];
                    $sort_key_sql['l'] = 'u.user_lastvisit';
                }
                $s_sort_key = '';
                foreach ($sort_key_text as $key => $value) {
                    $selected = $sort_key == $key ? ' selected="selected"' : '';
                    $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
                }
                $s_sort_dir = '';
                foreach ($sort_dir_text as $key => $value) {
                    $selected = $sort_dir == $key ? ' selected="selected"' : '';
                    $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
                }
                // Sorting and order
                if (!isset($sort_key_sql[$sort_key])) {
                    $sort_key = $default_key;
                }
                $order_by .= $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC');
                // Build a relevant pagination_url
                $params = array();
                $check_params = array('sk' => array('sk', $default_key), 'sd' => array('sd', 'a'));
                foreach ($check_params as $key => $call) {
                    if (!isset($_REQUEST[$key])) {
                        continue;
                    }
                    $param = call_user_func_array(array($this->request, 'variable'), $call);
                    $param = is_string($param) ? urlencode($param) : $param;
                    $params[$key] = $param;
                    if ($key != 'sk' && $key != 'sd') {
                        $sort_params[] = $param;
                    }
                }
                $pagination_url = $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array_merge($params, array('tslash' => '')));
                // Grab relevant data
                $sql = 'SELECT DISTINCT poster_id
					FROM ' . $this->thanks_table;
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $rowsp[] = $row['poster_id'];
                }
                $sql = 'SELECT DISTINCT user_id
					FROM ' . $this->thanks_table;
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $rowsu[] = $row['user_id'];
                }
                if ($sort_key == 'e') {
                    $sortparam = 'poster';
                    $rows = $rowsp;
                } else {
                    if ($sort_key == 'f') {
                        $sortparam = 'user';
                        $rows = $rowsu;
                    } else {
                        $sortparam = '';
                        $rows = array_merge($rowsp, $rowsu);
                    }
                }
                $total_users = count(array_unique($rows));
                if (empty($rows)) {
                    break;
                }
                $sql_array = array('SELECT' => 'u.*', 'FROM' => array($this->users_table => 'u'), 'ORDER_BY' => $order_by);
                if ($top) {
                    $total_users = $top;
                    $start = 0;
                    $page_title = $this->user->lang['REPUT_TOPLIST'];
                } else {
                    $top = $this->config['topics_per_page'];
                }
                if ($sortparam) {
                    $sql_array['FROM'] = array($this->thanks_table => 't');
                    $sql_array['SELECT'] .= ', count(t.' . $sortparam . '_id) as count_thanks';
                    $sql_array['LEFT_JOIN'][] = array('FROM' => array($this->users_table => 'u'), 'ON' => 't.' . $sortparam . '_id = u.user_id');
                    $sql_array['GROUP_BY'] = 't.' . $sortparam . '_id';
                }
                $where[] = $rows[0];
                for ($i = 1, $end = sizeof($rows); $i < $end; ++$i) {
                    $where[] = $rows[$i];
                }
                $sql_array['WHERE'] = $this->db->sql_in_set('u.user_id', $where);
                $sql = $this->db->sql_build_query('SELECT', $sql_array);
                $result = $this->db->sql_query_limit($sql, $top, $start);
                if (!($row = $this->db->sql_fetchrow($result))) {
                    trigger_error('NO_USER');
                } else {
                    $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
						FROM ' . SESSIONS_TABLE . '
						WHERE session_time >= ' . (time() - $this->config['session_length']) . '
							AND ' . $this->db->sql_in_set('session_user_id', $where) . '
						GROUP BY session_user_id';
                    $result_sessions = $this->db->sql_query($sql);
                    $session_times = array();
                    while ($session = $this->db->sql_fetchrow($result_sessions)) {
                        $session_times[$session['session_user_id']] = $session['session_time'];
                    }
                    $this->db->sql_freeresult($result_sessions);
                    $user_list = array();
                    $id_cache = array();
                    do {
                        $row['session_time'] = !empty($session_times[$session['user_id']]) ? $session_times[$session['user_id']] : 0;
                        $row['last_visit'] = !empty($session['session_time']) ? $session['session_time'] : $session['user_lastvisit'];
                        $user_list[] = (int) $row['user_id'];
                        $id_cache[$row['user_id']] = $row;
                    } while ($row = $this->db->sql_fetchrow($result));
                    $this->db->sql_freeresult($result);
                    // Load custom profile fields
                    if ($this->config['load_cpf_memberlist']) {
                        $cp_row = $this->profilefields_manager->generate_profile_fields_template_headlines('field_show_on_ml');
                        foreach ($cp_row as $profile_field) {
                            $this->template->assign_block_vars('custom_fields', $profile_field);
                        }
                        // Grab all profile fields from users in id cache for later use - similar to the poster cache
                        $profile_fields_cache = $this->profilefields_manager->grab_profile_fields_data($user_list);
                        // Filter the fields we don't want to show
                        foreach ($profile_fields_cache as $user_id => $user_profile_fields) {
                            foreach ($user_profile_fields as $field_ident => $profile_field) {
                                if (!$profile_field['data']['field_show_on_ml']) {
                                    unset($profile_fields_cache[$user_id][$field_ident]);
                                }
                            }
                        }
                    }
                    //do
                    for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i) {
                        $user_id = $user_list[$i];
                        $row = $id_cache[$user_id];
                        $last_visit = $row['user_lastvisit'];
                        $rank_title = $rank_img = $rank_img_src = '';
                        include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext;
                        get_user_rank($row['user_rank'], $user_id == ANONYMOUS ? false : $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
                        $sthanks = true;
                        // Custom Profile Fields
                        $cp_row = array();
                        if ($this->config['load_cpf_memberlist']) {
                            $cp_row = isset($profile_fields_cache[$user_id]) ? $this->profilefields_manager->generate_profile_fields_template_data($profile_fields_cache[$user_id], false) : array();
                        }
                        $memberrow = array_merge(phpbb_show_profile($row), array('ROW_NUMBER' => $row_number + ($start + 1), 'RANK_TITLE' => $rank_title, 'RANK_IMG' => $rank_img, 'RANK_IMG_SRC' => $rank_img_src, 'GIVENS' => !isset($givens[$user_id]) ? 0 : $givens[$user_id], 'RECEIVED' => !isset($reseved[$user_id]) ? 0 : $reseved[$user_id], 'JOINED' => $this->user->format_date($row['user_regdate']), 'VISITED' => empty($last_visit) ? ' - ' : $this->user->format_date($last_visit), 'POSTS' => $row['user_posts'] ? $row['user_posts'] : 0, 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_SEARCH_USER' => $this->auth->acl_get('u_search') ? append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", "author_id={$user_id}&amp;sr=posts") : '', 'U_SEARCH_USER_GIVENS' => $this->auth->acl_get('u_search') ? $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $user_id, 'give' => 'true', 'tslash' => '')) : '', 'U_SEARCH_USER_RECEIVED' => $this->auth->acl_get('u_search') ? $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller_user', array('mode' => 'givens', 'author_id' => $user_id, 'give' => 'false', 'tslash' => '')) : '', 'L_VIEWING_PROFILE' => sprintf($this->user->lang['VIEWING_PROFILE'], $row['username']), 'VISITED' => empty($last_visit) ? ' - ' : $this->user->format_date($last_visit), 'S_CUSTOM_FIELDS' => isset($cp_row['row']) && sizeof($cp_row['row']) ? true : false));
                        if (isset($cp_row['row']) && sizeof($cp_row['row'])) {
                            $memberrow = array_merge($memberrow, $cp_row['row']);
                        }
                        $this->template->assign_block_vars('memberrow', $memberrow);
                        if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow'])) {
                            foreach ($cp_row['blockrow'] as $field_data) {
                                $this->template->assign_block_vars('memberrow.custom_fields', $field_data);
                            }
                        }
                        $row_number++;
                    }
                    $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $this->config['topics_per_page'], $start);
                    $this->template->assign_vars(array('PAGE_NUMBER' => $this->pagination->on_page($total_users, $this->config['topics_per_page'], $start), 'U_SORT_POSTS' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'd', 'sd' => $sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_USERNAME' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'a', 'sd' => $sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_FROM' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'b', 'sd' => $sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_JOINED' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'c', 'sd' => $sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')), 'U_SORT_THANKS_R' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'e', 'sd' => $sort_key == 'e' && $sort_dir == 'd' ? 'a' : 'd', 'tslash' => '')), 'U_SORT_THANKS_G' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'f', 'sd' => $sort_key == 'f' && $sort_dir == 'd' ? 'a' : 'd', 'tslash' => '')), 'U_SORT_ACTIVE' => $this->auth->acl_get('u_viewonline') ? $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('mode' => $mode, 'sk' => 'l', 'sd' => $sort_key == 'l' && $sort_dir == 'a' ? 'd' : 'a', 'tslash' => '')) : ''));
                }
                break;
        }
        // Output the page
        $this->template->assign_vars(array('TOTAL_USERS' => $this->user->lang('LIST_USERS', $total_users), 'U_THANKS' => $this->controller_helper->route('gfksx_ThanksForPosts_thankslist_controller', array('tslash' => '')), 'S_THANKS' => $sthanks));
        page_header($page_title);
        $this->template->set_filenames(array('body' => $template_html));
        make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}"));
        page_footer();
        return new Response($this->template->return_display('body'), 200);
    }
Пример #22
0
 /**
  * @return string
  */
 private function _get_viewonline_url()
 {
     return $this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel') ? append_sid("{$this->phpbb_root_path}viewonline." . $this->php_ext) : '';
 }
Пример #23
0
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        // Display a listing of board admins, moderators
        $this->user->add_lang('groups');
        $order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
        if ($this->config['board3_leaders_ext_' . $module_id]) {
            $legends = array();
            $groups = array();
            if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
                $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
					FROM ' . GROUPS_TABLE . '
					WHERE group_legend >= 1
					ORDER BY ' . $order_legend . ' ASC';
            } else {
                $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
					FROM ' . GROUPS_TABLE . ' g
					LEFT JOIN ' . USER_GROUP_TABLE . ' ug
						ON (
							g.group_id = ug.group_id
							AND ug.user_id = ' . $this->user->data['user_id'] . '
							AND ug.user_pending = 0
						)
					WHERE g.group_legend >= 1
						AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $this->user->data['user_id'] . ')
					ORDER BY g.' . $order_legend . ' ASC';
            }
            $result = $this->db->sql_query($sql, 600);
            while ($row = $this->db->sql_fetchrow($result)) {
                $groups[$row['group_id']] = array('group_name' => $row['group_name'], 'group_colour' => $row['group_colour'], 'group_type' => $row['group_type'], 'group_users' => array());
                $legends[] = $row['group_id'];
            }
            $this->db->sql_freeresult($result);
            if (sizeof($legends)) {
                $sql = 'SELECT
							u.user_id AS user_id, u.username AS username, u.username_clean AS username_clean,
							u.user_colour AS user_colour, ug.group_id AS group_id
						FROM
							' . USERS_TABLE . ' AS u,
							' . USER_GROUP_TABLE . ' AS ug
						WHERE
							ug.user_id = u.user_id
							AND ' . $this->db->sql_in_set('ug.group_id', $legends) . '
						ORDER BY u.username_clean ASC';
                $result = $this->db->sql_query($sql, 600);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $groups[$row['group_id']]['group_users'][] = array('user_id' => $row['user_id'], 'username' => $row['username'], 'user_colour' => $row['user_colour']);
                }
                $this->db->sql_freeresult($result);
            }
            if (sizeof($groups)) {
                foreach ($groups as $group_id => $group) {
                    if (sizeof($group['group_users'])) {
                        $group_name = $group['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $group['group_name']] : $group['group_name'];
                        $u_group = append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $group_id);
                        $this->template->assign_block_vars('group', array('GROUP_NAME' => $group_name, 'GROUP_COLOUR' => $group['group_colour'], 'U_GROUP' => $u_group));
                        foreach ($group['group_users'] as $group_user) {
                            $this->template->assign_block_vars('group.member', array('USER_ID' => $group_user['user_id'], 'USERNAME_FULL' => get_username_string('full', $group_user['user_id'], $group_user['username'], $group_user['user_colour'])));
                        }
                    }
                }
            }
            return 'leaders_ext_side.html';
        } else {
            $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.user_colour, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend, ug.user_id as ug_user_id', 'FROM' => array(USERS_TABLE => 'u', GROUPS_TABLE => 'g'), 'LEFT_JOIN' => array(array('FROM' => array(USER_GROUP_TABLE => 'ug'), 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $this->user->data['user_id'])), 'WHERE' => 'u.group_id = g.group_id AND ' . $this->db->sql_in_set('g.group_name', array('ADMINISTRATORS', 'GLOBAL_MODERATORS')), 'ORDER_BY' => 'g.' . $order_legend . ' ASC, u.username_clean ASC'));
            $result = $this->db->sql_query($sql, 600);
            while ($row = $this->db->sql_fetchrow($result)) {
                if ($row['group_name'] == 'ADMINISTRATORS') {
                    $which_row = 'b3p_admins';
                } else {
                    if ($row['group_name'] == 'GLOBAL_MODERATORS') {
                        $which_row = 'b3p_moderators';
                    } else {
                        continue;
                    }
                }
                if ($row['group_type'] == GROUP_HIDDEN && !$this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $this->user->data['user_id']) {
                    $group_name = $this->user->lang['GROUP_UNDISCLOSED'];
                    $u_group = '';
                } else {
                    $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
                    $u_group = append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $row['group_id']);
                }
                $this->template->assign_block_vars($which_row, array('USER_ID' => $row['user_id'], 'GROUP_NAME' => $group_name, 'GROUP_COLOR' => $row['group_colour'], 'U_GROUP' => $u_group, 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour'])));
            }
            $this->db->sql_freeresult($result);
            return 'leaders_side.html';
        }
    }