list_modules() public method

This creates a list, stored in $this->module_ary of all available modules for the given class (ucp, mcp and acp). Additionally $this->module_y_ary is created with indentation information for displaying the module list appropriately. Only modules for which the user has access rights are included in these lists.
public list_modules ( $p_class )
Beispiel #1
0
        $default = true;
        break;
}
// We use this approach because it does not impose large code changes
if (!$default) {
    return true;
}
// Only registered users can go beyond this point
if (!$user->data['is_registered']) {
    if ($user->data['is_bot']) {
        redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
    }
    login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
}
// Instantiate module system and generate list of available modules
$module->list_modules('ucp');
// Check if the zebra module is set
if ($module->is_active('zebra', 'friends')) {
    // Output listing of friends online
    $update_time = $config['load_online_time'] * 60;
    $sql = $db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
			AND z.friend = 1
			AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'));
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $which = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? 'online' : 'offline';
        $template->assign_block_vars("friends_{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])));
    }
    $db->sql_freeresult($result);
}
// Do not display subscribed topics/forums if not allowed
Beispiel #2
0
            $allow_user = true;
        }
    }
    if (!$allow_user) {
        trigger_error('NOT_AUTHORISED');
    }
}
// if the user cannot read the forum he tries to access then we won't allow mcp access either
if ($forum_id && !$auth->acl_get('f_read', $forum_id)) {
    trigger_error('NOT_AUTHORISED');
}
if ($forum_id) {
    $module->acl_forum_id = $forum_id;
}
// Instantiate module system and generate list of available modules
$module->list_modules('mcp');
if ($quickmod) {
    $mode = 'quickmod';
    switch ($action) {
        case 'lock':
        case 'unlock':
        case 'lock_post':
        case 'unlock_post':
        case 'make_sticky':
        case 'make_announce':
        case 'make_global':
        case 'make_normal':
        case 'fork':
        case 'move':
        case 'delete_post':
        case 'delete_topic':
/**
* View message folder
* Called from ucp_pm with mode == 'view' && action == 'view_folder'
*/
function view_folder($id, $mode, $folder_id, $folder)
{
	global $user, $template, $auth, $db, $cache;
	global $phpbb_root_path, $config, $phpEx;

	$submit_export = (isset($_POST['submit_export'])) ? true : false;

	$folder_info = get_pm_from($folder_id, $folder, $user->data['user_id']);

	if (!$submit_export)
	{
		$user->add_lang('viewforum');

		// Grab icons
		$icons = $cache->obtain_icons();

		$color_rows = array('marked', 'replied');

		// only show the friend/foe color rows if the module is enabled
		$zebra_enabled = false;

		$_module = new p_master();
		$_module->list_modules('ucp');
		$_module->set_active('zebra');

		$zebra_enabled = ($_module->active_module === false) ? false : true;

		unset($_module);

		if ($zebra_enabled)
		{
			$color_rows = array_merge($color_rows, array('friend', 'foe'));
		}

		foreach ($color_rows as $var)
		{
			$template->assign_block_vars('pm_colour_info', array(
				'IMG'	=> $user->img("pm_{$var}", ''),
				'CLASS'	=> "pm_{$var}_colour",
				'LANG'	=> $user->lang[strtoupper($var) . '_MESSAGE'])
			);
		}

		$mark_options = array('mark_important', 'delete_marked');

		$s_mark_options = '';
		foreach ($mark_options as $mark_option)
		{
			$s_mark_options .= '<option value="' . $mark_option . '">' . $user->lang[strtoupper($mark_option)] . '</option>';
		}

		// We do the folder moving options here too, for template authors to use...
		$s_folder_move_options = '';
		if ($folder_id != PRIVMSGS_NO_BOX && $folder_id != PRIVMSGS_OUTBOX)
		{
			foreach ($folder as $f_id => $folder_ary)
			{
				if ($f_id == PRIVMSGS_OUTBOX || $f_id == PRIVMSGS_SENTBOX || $f_id == $folder_id)
				{
					continue;
				}

				$s_folder_move_options .= '<option' . (($f_id != PRIVMSGS_INBOX) ? ' class="sep"' : '') . ' value="' . $f_id . '">';
				$s_folder_move_options .= sprintf($user->lang['MOVE_MARKED_TO_FOLDER'], $folder_ary['folder_name']);
				$s_folder_move_options .= (($folder_ary['unread_messages']) ? ' [' . $folder_ary['unread_messages'] . '] ' : '') . '</option>';
			}
		}
		$friend = $foe = array();

		// Get friends and foes
		$sql = 'SELECT *
			FROM ' . ZEBRA_TABLE . '
			WHERE user_id = ' . $user->data['user_id'];
		$result = $db->sql_query($sql);

		while ($row = $db->sql_fetchrow($result))
		{
			$friend[$row['zebra_id']] = $row['friend'];
			$foe[$row['zebra_id']] = $row['foe'];
		}
		$db->sql_freeresult($result);

		$template->assign_vars(array(
			'S_MARK_OPTIONS'		=> $s_mark_options,
			'S_MOVE_MARKED_OPTIONS'	=> $s_folder_move_options)
		);

		// Okay, lets dump out the page ...
		if (sizeof($folder_info['pm_list']))
		{
			$address_list = array();

			// Build Recipient List if in outbox/sentbox - max two additional queries
			if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
			{
				$recipient_list = $address = array();

				foreach ($folder_info['rowset'] as $message_id => $row)
				{
					$address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
					$_save = array('u', 'g');
					foreach ($_save as $save)
					{
						if (isset($address[$message_id][$save]) && sizeof($address[$message_id][$save]))
						{
							foreach (array_keys($address[$message_id][$save]) as $ug_id)
							{
								$recipient_list[$save][$ug_id] = array('name' => $user->lang['NA'], 'colour' => '');
							}
						}
					}
				}

				$_types = array('u', 'g');
				foreach ($_types as $ug_type)
				{
					if (!empty($recipient_list[$ug_type]))
					{
						if ($ug_type == 'u')
						{
							$sql = 'SELECT user_id as id, username as name, user_colour as colour
								FROM ' . USERS_TABLE . '
								WHERE ';
						}
						else
						{
							$sql = 'SELECT group_id as id, group_name as name, group_colour as colour, group_type
								FROM ' . GROUPS_TABLE . '
								WHERE ';
						}
						$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($recipient_list[$ug_type])));

						$result = $db->sql_query($sql);

						while ($row = $db->sql_fetchrow($result))
						{
							if ($ug_type == 'g')
							{
								$row['name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['name']] : $row['name'];
							}

							$recipient_list[$ug_type][$row['id']] = array('name' => $row['name'], 'colour' => $row['colour']);
						}
						$db->sql_freeresult($result);
					}
				}

				foreach ($address as $message_id => $adr_ary)
				{
					foreach ($adr_ary as $type => $id_ary)
					{
						foreach ($id_ary as $ug_id => $_id)
						{
							if ($type == 'u')
							{
								$address_list[$message_id][] = get_username_string('full', $ug_id, $recipient_list[$type][$ug_id]['name'], $recipient_list[$type][$ug_id]['colour']);
							}
							else
							{
								$user_colour = ($recipient_list[$type][$ug_id]['colour']) ? ' style="font-weight: bold; color:#' . $recipient_list[$type][$ug_id]['colour'] . '"' : '';
								$link = '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $ug_id) . '"' . $user_colour . '>';
								$address_list[$message_id][] = $link . $recipient_list[$type][$ug_id]['name'] . (($link) ? '</a>' : '');
							}
						}
					}
				}
				unset($recipient_list, $address);
			}

			$data = array();

			foreach ($folder_info['pm_list'] as $message_id)
			{
				$row = &$folder_info['rowset'][$message_id];

				$folder_img = ($row['pm_unread']) ? 'pm_unread' : 'pm_read';
				$folder_alt = ($row['pm_unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES';

				// Generate all URIs ...
				$view_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&amp;mode=view&amp;f=$folder_id&amp;p=$message_id");
				$remove_message_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&amp;mode=compose&amp;action=delete&amp;p=$message_id");

				$row_indicator = '';
				foreach ($color_rows as $var)
				{
					if (($var != 'friend' && $var != 'foe' && $row['pm_' . $var])
						||
						(($var == 'friend' || $var == 'foe') && isset(${$var}[$row['author_id']]) && ${$var}[$row['author_id']]))
					{
						$row_indicator = $var;
						break;
					}
				}

				// Send vars to template
				$template->assign_block_vars('messagerow', array(
					'PM_CLASS'			=> ($row_indicator) ? 'pm_' . $row_indicator . '_colour' : '',

					'MESSAGE_AUTHOR_FULL'		=> get_username_string('full', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
					'MESSAGE_AUTHOR_COLOUR'		=> get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
					'MESSAGE_AUTHOR'			=> get_username_string('username', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),
					'U_MESSAGE_AUTHOR'			=> get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour'], $row['username']),

					'FOLDER_ID'			=> $folder_id,
					'MESSAGE_ID'		=> $message_id,
					'SENT_TIME'			=> $user->format_date($row['message_time']),
					'SUBJECT'			=> censor_text($row['message_subject']),
					'FOLDER'			=> (isset($folder[$row['folder_id']])) ? $folder[$row['folder_id']]['folder_name'] : '',
					'U_FOLDER'			=> (isset($folder[$row['folder_id']])) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'folder=' . $row['folder_id']) : '',
					'PM_ICON_IMG'		=> (!empty($icons[$row['icon_id']])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',
					'PM_ICON_URL'		=> (!empty($icons[$row['icon_id']])) ? $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] : '',
					'FOLDER_IMG'		=> $user->img($folder_img, $folder_alt),
					'FOLDER_IMG_SRC'	=> $user->img($folder_img, $folder_alt, false, '', 'src'),
					'PM_IMG'			=> ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
					'ATTACH_ICON_IMG'	=> ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',

					'S_PM_DELETED'		=> ($row['pm_deleted']) ? true : false,
					'S_AUTHOR_DELETED'	=> ($row['author_id'] == ANONYMOUS) ? true : false,

					'U_VIEW_PM'			=> ($row['pm_deleted']) ? '' : $view_message_url,
					'U_REMOVE_PM'		=> ($row['pm_deleted']) ? $remove_message_url : '',
					'RECIPIENTS'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '')
				);
			}
			unset($folder_info['rowset']);

			$template->assign_vars(array(
				'S_SHOW_RECIPIENTS'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,
				'S_SHOW_COLOUR_LEGEND'	=> true,

				'S_PM_ICONS'			=> ($config['enable_pm_icons']) ? true : false)
			);
		}
	}
	else
	{
		$export_type = request_var('export_option', '');
		$enclosure = request_var('enclosure', '');
		$delimiter = request_var('delimiter', '');

		if ($export_type == 'CSV' && ($delimiter === '' || $enclosure === ''))
		{
			$template->assign_var('PROMPT', true);
		}
		else
		{
			// Build Recipient List if in outbox/sentbox
			$address = array();
			if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
			{
				foreach ($folder_info['rowset'] as $message_id => $row)
				{
					$address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
				}
			}

			foreach ($folder_info['pm_list'] as $message_id)
			{
				$row = &$folder_info['rowset'][$message_id];

				include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

				$sql = 'SELECT p.message_text, p.bbcode_uid
					FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u
					WHERE t.user_id = ' . $user->data['user_id'] . "
						AND p.author_id = u.user_id
						AND t.folder_id = $folder_id
						AND t.msg_id = p.msg_id
						AND p.msg_id = $message_id";
				$result = $db->sql_query_limit($sql, 1);
				$message_row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				$_types = array('u', 'g');
				foreach ($_types as $ug_type)
				{
					if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type]))
					{
						if ($ug_type == 'u')
						{
							$sql = 'SELECT user_id as id, username as name
								FROM ' . USERS_TABLE . '
								WHERE ';
						}
						else
						{
							$sql = 'SELECT group_id as id, group_name as name
								FROM ' . GROUPS_TABLE . '
								WHERE ';
						}
						$sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type])));

						$result = $db->sql_query($sql);

						while ($info_row = $db->sql_fetchrow($result))
						{
							$address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name'];
							unset($address[$message_id][$ug_type][$info_row['id']]);
						}
						$db->sql_freeresult($result);
					}
				}

				decode_message($message_row['message_text'], $message_row['bbcode_uid']);

				$data[] = array(
					'subject'	=> censor_text($row['message_subject']),
					'sender'	=> $row['username'],
					'date'		=> $user->format_date($row['message_time']),
					'to'		=> ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '',
					'message'	=> $message_row['message_text']
				);
			}

			switch ($export_type)
			{
				case 'CSV':
				case 'CSV_EXCEL':
					$mimetype = 'text/csv';
					$filetype = 'csv';

					if ($export_type == 'CSV_EXCEL')
					{
						$enclosure = '"';
						$delimiter = ',';
						$newline = "\r\n";
					}
					else
					{
						$newline = "\n";
					}

					$string = '';
					foreach ($data as $value)
					{
						$recipients = $value['to'];
						$value['to'] = $value['bcc'] = '';

						if (is_array($recipients))
						{
							foreach ($recipients as $values)
							{
								$value['bcc'] .= (isset($values['bcc']) && is_array($values['bcc'])) ? ',' . implode(',', $values['bcc']) : '';
								$value['to'] .= (isset($values['to']) && is_array($values['to'])) ? ',' . implode(',', $values['to']) : '';
							}

							// Remove the commas which will appear before the first entry.
							$value['to'] = substr($value['to'], 1);
							$value['bcc'] = substr($value['bcc'], 1);
						}

						foreach ($value as $tag => $text)
						{
							$cell = str_replace($enclosure, $enclosure . $enclosure, $text);

							if (strpos($cell, $enclosure) !== false || strpos($cell, $delimiter) !== false || strpos($cell, $newline) !== false)
							{
								$string .= $enclosure . $text . $enclosure . $delimiter;
							}
							else
							{
								$string .= $cell . $delimiter;
							}
						}
						$string = substr($string, 0, -1) . $newline;
					}
				break;

				case 'XML':
					$mimetype = 'application/xml';
					$filetype = 'xml';
					$string = '<?xml version="1.0"?>' . "\n";
					$string .= "<phpbb>\n";

					foreach ($data as $value)
					{
						$string .= "\t<privmsg>\n";

						if (is_array($value['to']))
						{
							foreach ($value['to'] as $key => $values)
							{
								foreach ($values as $type => $types)
								{
									foreach ($types as $name)
									{
										$string .= "\t\t<recipient type=\"$type\" status=\"$key\">$name</recipient>\n";
									}
								}
							}
						}

						unset($value['to']);

						foreach ($value as $tag => $text)
						{
							$string .= "\t\t<$tag>$text</$tag>\n";
						}

						$string .= "\t</privmsg>\n";
					}
					$string .= '</phpbb>';
				break;
			}

			header('Pragma: no-cache');
			header("Content-Type: $mimetype; name=\"data.$filetype\"");
			header("Content-disposition: attachment; filename=data.$filetype");
			echo $string;
			exit;
		}
	}
}
Beispiel #4
0
define('IN_ADMIN', true);
$phpbb_admin_path = defined('PHPBB_ADMIN_PATH') ? PHPBB_ADMIN_PATH : './';
// Some oft used variables
$safe_mode = @ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on' ? true : false;
$file_uploads = @ini_get('file_uploads') == '1' || strtolower(@ini_get('file_uploads')) === 'on' ? true : false;
$module_id = request_var('i', '');
$mode = request_var('mode', '');
// Set custom template for admin area
$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
// the acp template is never stored in the database
$user->theme['template_storedb'] = false;
// Instantiate new module
$module = new p_master();
// Instantiate module system and generate list of available modules
$module->list_modules('acp');
// Select the active module
$module->set_active($module_id, $mode);
// Assign data to the template engine for the list of modules
// We do this before loading the active module for correct menu display in trigger_error
$module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.{$phpEx}"));
// Load and execute the relevant module
$module->load_active();
// Generate the page
adm_page_header($module->get_page_title());
$template->set_filenames(array('body' => $module->get_tpl_name()));
adm_page_footer();
/**
* Header for acp pages
*/
function adm_page_header($page_title)
Beispiel #5
0
$result = $db->sql_query($sql, 3600);
$style = $db->sql_fetchfield('style_id');
$db->sql_freeresult($result);

$user->setup('mods/gallery', ((!$style) ? 1 : $style));

$module = new p_master();

// Setting a variable to let the style designer know where he is...
$template->assign_var('S_IN_GALLERY', true);

// Basic parameter data
$id 	= request_var('i', '');
$mode	= request_var('mode', '');

// Instantiate module system and generate list of available modules
$module->list_modules('gallery');

// Select the active module
$module->set_active($id, $mode);

// Load and execute the relevant module
$module->load_active();

// Assign data to the template engine for the list of modules
$module->assign_tpl_vars(append_sid("{$phpbb_root_path}gallery.$phpEx"));

// Generate the page, do not display/query online list
$module->display($module->get_page_title(), false);

?>
function get_user_info_func($xmlrpc_params)
{
    global $db, $user, $auth, $template, $config, $phpbb_root_path, $phpEx, $table_prefix;
    $user->setup(array('memberlist', 'groups'));
    if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) {
        if ($user->data['user_id'] != ANONYMOUS) {
            trigger_error('NO_VIEW_USERS');
        }
        trigger_error('LOGIN_EXPLAIN_VIEWPROFILE');
    }
    $params = php_xmlrpc_decode($xmlrpc_params);
    $username = $params[0];
    if (isset($params[1]) && !empty($params[1])) {
        $user_id = $params[1];
    } elseif (isset($params[0]) && !empty($params[0])) {
        $username = $params[0];
        $user_id = get_user_id_by_name($username);
    } else {
        $user_id = $user->data['user_id'];
    }
    $user_id = intval($user_id);
    // Display a profile
    if (!$user_id) {
        trigger_error('NO_USER');
    }
    // Get user...
    $sql = 'SELECT *
        FROM ' . USERS_TABLE . "\r\r\n        WHERE user_id = '{$user_id}'";
    $result = $db->sql_query($sql);
    $member = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if (!$member) {
        trigger_error('NO_USER');
    }
    // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
    // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
    if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER) {
        if ($member['user_type'] == USER_IGNORE) {
            trigger_error('NO_USER');
        } else {
            if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE) {
                trigger_error('NO_USER');
            }
        }
    }
    $user_id = (int) $member['user_id'];
    // Do the SQL thang
    $sql = 'SELECT g.group_id, g.group_name, g.group_type
        FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\r\r\n        WHERE ug.user_id = {$user_id}\r\r\n            AND g.group_id = ug.group_id" . (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
            AND ug.user_pending = 0
        ORDER BY g.group_type, g.group_name';
    $result = $db->sql_query($sql);
    $group_options = '';
    while ($row = $db->sql_fetchrow($result)) {
        if ($row['group_type'] == GROUP_SPECIAL) {
            // Lookup group name in language dictionary
            if (isset($user->lang['G_' . $row['group_name']])) {
                $row['group_name'] = $user->lang['G_' . $row['group_name']];
            }
        } else {
            if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) {
                // Skip over hidden groups the user cannot see
                continue;
            }
        }
        $group_options .= $row['group_id'] == $member['group_id'] ? $row['group_name'] . " *\n" : $row['group_name'] . "\n";
    }
    $group_options = trim($group_options);
    $db->sql_freeresult($result);
    // What colour is the zebra
    $sql = 'SELECT friend, foe
        FROM ' . ZEBRA_TABLE . "\r\r\n        WHERE zebra_id = {$user_id}\r\r\n            AND user_id = {$user->data['user_id']}";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $foe = $row['foe'] ? true : false;
    $friend = $row['friend'] ? true : false;
    $db->sql_freeresult($result);
    if ($config['load_onlinetrack']) {
        if ($config['version'] < '3.0.3') {
            $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page
            FROM ' . SESSIONS_TABLE . "\r\r\n            WHERE session_user_id = {$user_id}\r\r\n            GROUP BY session_page\r\r\n            ORDER BY session_time DESC";
        } else {
            $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline, session_page, session_forum_id
            FROM ' . SESSIONS_TABLE . "\r\r\n            WHERE session_user_id = {$user_id}\r\r\n            GROUP BY session_page, session_forum_id\r\r\n            ORDER BY session_time DESC";
        }
        $result = $db->sql_query_limit($sql, 1);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $member['session_time'] = isset($row['session_time']) ? $row['session_time'] : 0;
        $member['session_viewonline'] = isset($row['session_viewonline']) ? $row['session_viewonline'] : 0;
        $member['session_page'] = isset($row['session_page']) ? $row['session_page'] : 0;
        $member['session_forum_id'] = isset($row['session_forum_id']) ? $row['session_forum_id'] : 0;
        unset($row);
    }
    if ($config['load_user_activity']) {
        display_user_activity($member);
    }
    // Do the relevant calculations
    $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
    $posts_per_day = $member['user_posts'] / $memberdays;
    $percentage = $config['num_posts'] ? min(100, $member['user_posts'] / $config['num_posts'] * 100) : 0;
    if ($member['user_sig']) {
        $member['user_sig'] = censor_text($member['user_sig']);
        if ($member['user_sig_bbcode_bitfield']) {
            include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx;
            $bbcode = new bbcode();
            $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
        }
        $member['user_sig'] = bbcode_nl2br($member['user_sig']);
        $member['user_sig'] = smiley_text($member['user_sig']);
    }
    $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
    // We need to check if the modules 'zebra' ('friends' & 'foes' mode),  'notes' ('user_notes' mode) and  'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links
    $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false;
    // Only check if the user is logged in
    if ($user->data['is_registered']) {
        if (!class_exists('p_master')) {
            include $phpbb_root_path . 'includes/functions_module.' . $phpEx;
        }
        $module = new p_master();
        $module->list_modules('ucp');
        $module->list_modules('mcp');
        $user_notes_enabled = $module->loaded('notes', 'user_notes') ? true : false;
        $warn_user_enabled = $module->loaded('warn', 'warn_user') ? true : false;
        $zebra_enabled = $module->loaded('zebra') ? true : false;
        $friends_enabled = $module->loaded('zebra', 'friends') ? true : false;
        $foes_enabled = $module->loaded('zebra', 'foes') ? true : false;
        unset($module);
    }
    $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));
    // Custom Profile Fields
    $profile_fields = array();
    if ($config['load_cpf_viewprofile']) {
        include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
        $cp = new custom_profile();
        $profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
        $profile_fields = isset($profile_fields[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
    }
    // If the user has m_approve permission or a_user permission, then list then display unapproved posts
    if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) {
        $sql = 'SELECT COUNT(post_id) as posts_in_queue
            FROM ' . POSTS_TABLE . '
            WHERE poster_id = ' . $user_id . '
                AND post_approved = 0';
        $result = $db->sql_query($sql);
        $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
        $db->sql_freeresult($result);
    } else {
        $member['posts_in_queue'] = 0;
    }
    $template->assign_vars(array('OCCUPATION' => !empty($member['user_occ']) ? censor_text($member['user_occ']) : '', 'INTERESTS' => !empty($member['user_interests']) ? censor_text($member['user_interests']) : '', 'SIGNATURE' => $member['user_sig'], 'POSTS_IN_QUEUE' => $member['posts_in_queue'], 'AVATAR_IMG' => $poster_avatar, 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=group'), 'S_GROUP_OPTIONS' => $group_options, 'S_CUSTOM_FIELDS' => isset($profile_fields['row']) && sizeof($profile_fields['row']) ? true : false, 'U_USER_ADMIN' => $auth->acl_get('a_user') ? append_sid("{$phpbb_root_path}adm/index.{$phpEx}", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '', 'U_USER_BAN' => $auth->acl_get('m_ban') && $user_id != $user->data['user_id'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '', 'U_MCP_QUEUE' => $auth->acl_getf_global('m_approve') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue', true, $user->session_id) : '', 'S_USER_NOTES' => $user_notes_enabled ? true : false, 'S_WARN_USER' => $warn_user_enabled ? true : false, 'S_ZEBRA' => $user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled ? true : false, 'U_ADD_FRIEND' => !$friend && !$foe && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_ADD_FOE' => !$friend && !$foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 'U_REMOVE_FRIEND' => $friend && $friends_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '', 'U_REMOVE_FOE' => $foe && $foes_enabled ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : ''));
    if (!empty($profile_fields['row'])) {
        $template->assign_vars($profile_fields['row']);
    }
    if (!empty($profile_fields['blockrow'])) {
        foreach ($profile_fields['blockrow'] as $field_data) {
            $template->assign_block_vars('custom_fields', $field_data);
        }
    }
    // Inactive reason/account?
    if ($member['user_type'] == USER_INACTIVE) {
        $user->add_lang('acp/common');
        $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
        switch ($member['user_inactive_reason']) {
            case INACTIVE_REGISTER:
                $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
                break;
            case INACTIVE_PROFILE:
                $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
                break;
            case INACTIVE_MANUAL:
                $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
                break;
            case INACTIVE_REMIND:
                $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
                break;
        }
        $template->assign_vars(array('S_USER_INACTIVE' => true, 'USER_INACTIVE_REASON' => $inactive_reason));
    }
    $custom_fields_list = get_custom_fields();
    if (!empty($member['user_sig'])) {
        $custom_fields_list[] = new xmlrpcval(array('name' => new xmlrpcval($user->lang['SIGNATURE'], 'base64'), 'value' => new xmlrpcval(basic_clean($member['user_sig']), 'base64')), 'struct');
    }
    if ($member['user_id'] == $user->data['user_id'] && push_table_exists()) {
        $sql = "SELECT * FROM " . $table_prefix . "tapatalk_users WHERE userid = '" . $member['user_id'] . "'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        if (!empty($row)) {
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Message', 'base64'), 'value' => new xmlrpcval($row['pm'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Quoted', 'base64'), 'value' => new xmlrpcval($row['quote'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Mentioned', 'base64'), 'value' => new xmlrpcval($row['tag'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - New Topic', 'base64'), 'value' => new xmlrpcval($row['newtopic'] ? 'On' : 'Off', 'base64')), 'struct'));
            array_push($custom_fields_list, new xmlrpcval(array('name' => new xmlrpcval('Notification - Replies', 'base64'), 'value' => new xmlrpcval($row['subscribe'] ? 'On' : 'Off', 'base64')), 'struct'));
        }
    }
    $user_avatar_url = get_user_avatar_url($member['user_avatar'], $member['user_avatar_type']);
    // Forum info
    $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
        FROM ' . FORUMS_TABLE . '
        ORDER BY left_id ASC';
    $result = $db->sql_query($sql, 600);
    $forum_data = array();
    while ($row = $db->sql_fetchrow($result)) {
        $forum_data[$row['forum_id']] = $row;
    }
    $db->sql_freeresult($result);
    // get user current activity
    preg_match('#^([a-z0-9/_-]+)#i', $member['session_page'], $on_page);
    if (!sizeof($on_page)) {
        $on_page[1] = '';
    }
    switch ($on_page[1]) {
        case 'index':
            $location = $user->lang['INDEX'];
            break;
        case 'adm/index':
            $location = $user->lang['ACP'];
            break;
        case 'posting':
        case 'viewforum':
        case 'viewtopic':
            $forum_id = $member['session_forum_id'];
            if ($forum_id && $auth->acl_get('f_list', $forum_id)) {
                $location = '';
                if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) {
                    $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']);
                    break;
                }
                switch ($on_page[1]) {
                    case 'posting':
                        preg_match('#mode=([a-z]+)#', $member['session_page'], $on_page);
                        $posting_mode = !empty($on_page[1]) ? $on_page[1] : '';
                        switch ($posting_mode) {
                            case 'reply':
                            case 'quote':
                                $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
                                break;
                            default:
                                $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']);
                                break;
                        }
                        break;
                    case 'viewtopic':
                        $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']);
                        break;
                    case 'viewforum':
                        $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']);
                        break;
                }
            } else {
                $location = $user->lang['INDEX'];
            }
            break;
        case 'search':
            $location = $user->lang['SEARCHING_FORUMS'];
            break;
        case 'faq':
            $location = $user->lang['VIEWING_FAQ'];
            break;
        case 'viewonline':
            $location = $user->lang['VIEWING_ONLINE'];
            break;
        case 'memberlist':
            $location = strpos($member['session_page'], 'mode=viewprofile') !== false ? $user->lang['VIEWING_MEMBER_PROFILE'] : $user->lang['VIEWING_MEMBERS'];
            break;
        case 'mcp':
            $location = $user->lang['VIEWING_MCP'];
            break;
        case 'ucp':
            $location = $user->lang['VIEWING_UCP'];
            // Grab some common modules
            $url_params = array('mode=register' => 'VIEWING_REGISTER', 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', 'i=profile&' => 'CHANGING_PROFILE', 'i=prefs&' => 'CHANGING_PREFERENCES');
            foreach ($url_params as $param => $lang) {
                if (strpos($member['session_page'], $param) !== false) {
                    $location = $user->lang[$lang];
                    break;
                }
            }
            break;
        case 'download/file':
            $location = $user->lang['DOWNLOADING_FILE'];
            break;
        case 'report':
            $location = $user->lang['REPORTING_POST'];
            break;
        case 'mobiquo/mobiquo':
            $location = 'On Tapatalk';
            break;
        default:
            $location = $user->lang['INDEX'];
            break;
    }
    $user_info = array('user_id' => new xmlrpcval($member['user_id']), 'username' => new xmlrpcval(basic_clean($member['username']), 'base64'), 'user_type' => check_return_user_type($member['username']), 'post_count' => new xmlrpcval($member['user_posts'], 'int'), 'reg_time' => new xmlrpcval(mobiquo_iso8601_encode($member['user_regdate']), 'dateTime.iso8601'), 'timestamp_reg' => new xmlrpcval($member['user_regdate'], 'string'), 'last_activity_time' => new xmlrpcval(mobiquo_iso8601_encode($template->_rootref['VISITED']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($template->_rootref['VISITED'], 'string'), 'is_online' => new xmlrpcval($template->_rootref['S_ONLINE'], 'boolean'), 'accept_pm' => new xmlrpcval($template->_rootref['U_PM'] ? true : false, 'boolean'), 'display_text' => new xmlrpcval('', 'base64'), 'icon_url' => new xmlrpcval($user_avatar_url), 'current_activity' => new xmlrpcval($location, 'base64'), 'custom_fields_list' => new xmlrpcval($custom_fields_list, 'array'));
    $xmlrpc_user_info = new xmlrpcval($user_info, 'struct');
    return new xmlrpcresp($xmlrpc_user_info);
}