Esempio n. 1
0
 }
 $id_cache[] = $poster_id;
 $user_cache_data = array('user_type' => $row['user_type'], 'user_inactive_reason' => $row['user_inactive_reason'], 'joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => isset($row['user_warnings']) ? $row['user_warnings'] : 0, 'sig' => $user_sig, 'sig_bbcode_uid' => !empty($row['user_sig_bbcode_uid']) ? $row['user_sig_bbcode_uid'] : '', 'sig_bbcode_bitfield' => !empty($row['user_sig_bbcode_bitfield']) ? $row['user_sig_bbcode_bitfield'] : '', 'viewonline' => $row['user_allow_viewonline'], 'allow_pm' => $row['user_allow_pm'], 'avatar' => $user->optionget('viewavatars') ? src_get_user_avatar($row) : '', 'age' => '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'contact_user' => $user->lang('CONTACT_USER', get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['username'])), 'online' => false, 'jabber' => $config['jab_enable'] && $row['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$src_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$poster_id}") : '', 'search' => $config['load_search'] && $auth->acl_get('u_search') ? append_sid("{$src_root_path}search.{$phpEx}", "author_id={$poster_id}&sr=posts") : '', 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']));
 /**
  * Modify the users' data displayed with their posts
  *
  * @event core.viewtopic_cache_user_data
  * @var	array	user_cache_data	Array with the user's data
  * @var	int		poster_id		Poster's user id
  * @var	array	row				Array with original user and post data
  * @since 3.1.0-a1
  */
 $vars = array('user_cache_data', 'poster_id', 'row');
 extract($src_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars)));
 $user_cache[$poster_id] = $user_cache_data;
 $user_rank_data = src_get_user_rank($row, $row['user_posts']);
 $user_cache[$poster_id]['rank_title'] = $user_rank_data['title'];
 $user_cache[$poster_id]['rank_image'] = $user_rank_data['img'];
 $user_cache[$poster_id]['rank_image_src'] = $user_rank_data['img_src'];
 if (!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail') || $auth->acl_get('a_email')) {
     $user_cache[$poster_id]['email'] = $config['srcrd_email_form'] && $config['email_enable'] ? append_sid("{$src_root_path}memberlist.{$phpEx}", "mode=email&u={$poster_id}") : ($config['srcrd_hide_emails'] && !$auth->acl_get('a_email') ? '' : 'mailto:' . $row['user_email']);
 } else {
     $user_cache[$poster_id]['email'] = '';
 }
 if ($config['allow_birthdays'] && !empty($row['user_birthday'])) {
     list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
     if ($bday_year) {
         $diff = $now['mon'] - $bday_month;
         if ($diff == 0) {
             $diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
         } else {
Esempio n. 2
0
/**
* Get user information (only for message display)
*/
function get_user_information($user_id, $user_row)
{
    global $db, $auth, $user, $cache;
    global $src_root_path, $phpEx, $config;
    if (!$user_id) {
        return array();
    }
    if (empty($user_row)) {
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $user_id;
        $result = $db->sql_query($sql);
        $user_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
    }
    // Some standard values
    $user_row['online'] = false;
    $user_row['rank_title'] = $user_row['rank_image'] = $user_row['rank_image_src'] = $user_row['email'] = '';
    // Generate online information for user
    if ($config['load_onlinetrack']) {
        $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
			FROM ' . SESSIONS_TABLE . "\n\t\t\tWHERE session_user_id = {$user_id}\n\t\t\tGROUP BY session_user_id";
        $result = $db->sql_query_limit($sql, 1);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $update_time = $config['load_online_time'] * 60;
        if ($row) {
            $user_row['online'] = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? true : false;
        }
    }
    $user_row['avatar'] = $user->optionget('viewavatars') ? src_get_user_avatar($user_row) : '';
    if (!function_exists('src_get_user_rank')) {
        include $src_root_path . 'includes/functions_display.' . $phpEx;
    }
    $user_rank_data = src_get_user_rank($user_row, $user_row['user_posts']);
    $user_row['rank_title'] = $user_rank_data['title'];
    $user_row['rank_image'] = $user_rank_data['img'];
    $user_row['rank_image_src'] = $user_rank_data['img_src'];
    if (!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail') || $auth->acl_get('a_email')) {
        $user_row['email'] = $config['srcrd_email_form'] && $config['email_enable'] ? append_sid("{$src_root_path}memberlist.{$phpEx}", "mode=email&amp;u={$user_id}") : ($config['srcrd_hide_emails'] && !$auth->acl_get('a_email') || empty($user_row['user_email']) ? '' : 'mailto:' . $user_row['user_email']);
    }
    return $user_row;
}
Esempio n. 3
0
    /**
     * Handles warning the user
     */
    function mcp_warn_user_view($action)
    {
        global $phpEx, $src_root_path, $config, $module;
        global $template, $db, $user, $auth, $src_dispatcher;
        $user_id = request_var('u', 0);
        $username = request_var('username', '', true);
        $notify = isset($_REQUEST['notify_user']) ? true : false;
        $warning = utf8_normalize_nfc(request_var('warning', '', true));
        $sql_where = $user_id ? "user_id = {$user_id}" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE ' . $sql_where;
        $result = $db->sql_query($sql);
        $user_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$user_row) {
            trigger_error('NO_USER');
        }
        // Prevent someone from warning themselves
        if ($user_row['user_id'] == $user->data['user_id']) {
            trigger_error('CANNOT_WARN_SELF');
        }
        $user_id = $user_row['user_id'];
        if (strpos($this->u_action, "&amp;u={$user_id}") === false) {
            $this->p_master->adjust_url('&amp;u=' . $user_id);
            $this->u_action .= "&amp;u={$user_id}";
        }
        // Check if can send a notification
        if ($config['allow_privmsg']) {
            $auth2 = new \src\auth\auth();
            $auth2->acl($user_row);
            $s_can_notify = $auth2->acl_get('u_readpm') ? true : false;
            unset($auth2);
        } else {
            $s_can_notify = false;
        }
        // Prevent against clever people
        if ($notify && !$s_can_notify) {
            $notify = false;
        }
        if ($warning && $action == 'add_warning') {
            if (check_form_key('mcp_warn')) {
                $s_mcp_warn_user = true;
                /**
                 * Event for before warning a user from MCP.
                 *
                 * @event core.mcp_warn_user_before
                 * @var array	user_row		The entire user row
                 * @var string	warning			The warning message
                 * @var bool		notify			If true, we notify the user for the warning
                 * @var bool		s_mcp_warn_user If true, we add the warning else we omit it
                 * @since 3.1.0-b4
                 */
                $vars = array('user_row', 'warning', 'notify', 's_mcp_warn_user');
                extract($src_dispatcher->trigger_event('core.mcp_warn_user_before', compact($vars)));
                if ($s_mcp_warn_user) {
                    add_warning($user_row, $warning, $notify);
                    $message = $user->lang['USER_WARNING_ADDED'];
                    /**
                     * Event for after warning a user from MCP.
                     *
                     * @event core.mcp_warn_user_after
                     * @var array	user_row	The entire user row
                     * @var string	warning		The warning message
                     * @var bool		notify		If true, the user was notified for the warning
                     * @var string	message		Message displayed to the moderator
                     * @since 3.1.0-b4
                     */
                    $vars = array('user_row', 'warning', 'notify', 'message');
                    extract($src_dispatcher->trigger_event('core.mcp_warn_user_after', compact($vars)));
                }
            } else {
                $message = $user->lang['FORM_INVALID'];
            }
            if (!empty($message)) {
                $redirect = append_sid("{$src_root_path}mcp.{$phpEx}", "i=notes&amp;mode=user_notes&amp;u={$user_id}");
                meta_refresh(2, $redirect);
                trigger_error($message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
            }
        }
        // Generate the appropriate user information for the user we are looking at
        if (!function_exists('src_get_user_rank')) {
            include $src_root_path . 'includes/functions_display.' . $phpEx;
        }
        $user_rank_data = src_get_user_rank($user_row, $user_row['user_posts']);
        $avatar_img = src_get_user_avatar($user_row);
        // OK, they didn't submit a warning so lets build the page for them to do so
        $template->assign_vars(array('U_POST_ACTION' => $this->u_action, 'RANK_TITLE' => $user_rank_data['title'], 'JOINED' => $user->format_date($user_row['user_regdate']), 'POSTS' => $user_row['user_posts'] ? $user_row['user_posts'] : 0, 'WARNINGS' => $user_row['user_warnings'] ? $user_row['user_warnings'] : 0, 'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'USERNAME_COLOUR' => get_username_string('colour', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $user_rank_data['img'], 'S_CAN_NOTIFY' => $s_can_notify));
        return $user_id;
    }
Esempio n. 4
0
 /**
  * Get rank
  *
  * @param int $user_id User ID of the user you want to retreive the rank for
  * @param bool $query Should we query the database if this user has not yet been loaded?
  * 						Typically this should be left as false and you should make sure
  * 						you load users ahead of time with load_users()
  * @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src'
  */
 public function get_rank($user_id, $query = false)
 {
     if (!($user = $this->get_user($user_id, $query))) {
         return '';
     }
     if (!function_exists('src_get_user_rank')) {
         include $this->src_root_path . 'includes/functions_display.' . $this->php_ext;
     }
     $rank = array('rank_title', 'rank_img', 'rank_img_src');
     $user_rank_data = src_get_user_rank($user, $user['user_id'] == ANONYMOUS ? false : $user['user_posts']);
     $rank['rank_title'] = $user_rank_data['title'];
     $rank['rank_img'] = $user_rank_data['img'];
     $rank['rank_img_src'] = $user_rank_data['img_src'];
     return $rank;
 }
Esempio n. 5
0
/**
* Prepare profile data
*/
function src_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true)
{
    global $config, $auth, $user, $phpEx, $src_root_path, $src_dispatcher;
    $username = $data['username'];
    $user_id = $data['user_id'];
    $user_rank_data = src_get_user_rank($data, $user_id == ANONYMOUS ? false : $data['user_posts']);
    if (!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail') || $auth->acl_get('a_user')) {
        $email = $config['srcrd_email_form'] && $config['email_enable'] ? append_sid("{$src_root_path}memberlist.{$phpEx}", 'mode=email&amp;u=' . $user_id) : ($config['srcrd_hide_emails'] && !$auth->acl_get('a_user') ? '' : 'mailto:' . $data['user_email']);
    } else {
        $email = '';
    }
    if ($config['load_onlinetrack']) {
        $update_time = $config['load_online_time'] * 60;
        $online = time() - $update_time < $data['session_time'] && (isset($data['session_viewonline']) && $data['session_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false;
    } else {
        $online = false;
    }
    if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) {
        $last_active = !empty($data['session_time']) ? $data['session_time'] : $data['user_lastvisit'];
    } else {
        $last_active = '';
    }
    $age = '';
    if ($config['allow_birthdays'] && $data['user_birthday']) {
        list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
        if ($bday_year) {
            $now = $user->create_datetime();
            $now = src_gmgetdate($now->getTimestamp() + $now->getOffset());
            $diff = $now['mon'] - $bday_month;
            if ($diff == 0) {
                $diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
            } else {
                $diff = $diff < 0 ? 1 : 0;
            }
            $age = max(0, (int) ($now['year'] - $bday_year - $diff));
        }
    }
    if (!function_exists('src_get_banned_user_ids')) {
        include $src_root_path . 'includes/functions_user.' . $phpEx;
    }
    // Can this user receive a Private Message?
    $can_receive_pm = $check_can_receive_pm && ($data['user_type'] != USER_IGNORE && ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) && sizeof($auth->acl_get_list($user_id, 'u_readpm')) && !sizeof(src_get_banned_user_ids($user_id, false)) && ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_') || $data['user_allow_pm']));
    // Dump it out to the template
    $template_data = array('AGE' => $age, 'RANK_TITLE' => $user_rank_data['title'], 'JOINED' => $user->format_date($data['user_regdate']), 'LAST_ACTIVE' => empty($last_active) ? ' - ' : $user->format_date($last_active), 'POSTS' => $data['user_posts'] ? $data['user_posts'] : 0, 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']), 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']), 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']), 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), 'AVATAR_IMG' => src_get_user_avatar($data), 'ONLINE_IMG' => !$config['load_onlinetrack'] ? '' : ($online ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => $config['load_onlinetrack'] && $online ? true : false, 'RANK_IMG' => $user_rank_data['img'], 'RANK_IMG_SRC' => $user_rank_data['img_src'], 'S_JABBER_ENABLED' => $config['jab_enable'] ? true : false, 'S_WARNINGS' => $auth->acl_getf_global('m_') || $auth->acl_get('m_warn') ? true : false, 'U_SEARCH_USER' => $auth->acl_get('u_search') ? append_sid("{$src_root_path}search.{$phpEx}", "author_id={$user_id}&amp;sr=posts") : '', 'U_NOTES' => $user_notes_enabled && $auth->acl_getf_global('m_') ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $user_id, true, $user->session_id) : '', 'U_WARN' => $warn_user_enabled && $auth->acl_get('m_warn') ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $user_id, true, $user->session_id) : '', 'U_PM' => $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm ? append_sid("{$src_root_path}ucp.{$phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '', 'U_EMAIL' => $email, 'U_JABBER' => $data['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$src_root_path}memberlist.{$phpEx}", 'mode=contact&amp;action=jabber&amp;u=' . $user_id) : '', 'USER_JABBER' => $config['jab_enable'] ? $data['user_jabber'] : '', 'USER_JABBER_IMG' => $config['jab_enable'] && $data['user_jabber'] ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username));
    /**
     * Preparing a user's data before displaying it in profile and memberlist
     *
     * @event core.memberlist_prepare_profile_data
     * @var	array	data				Array with user's data
     * @var	array	template_data		Template array with user's data
     * @since 3.1.0-a1
     */
    $vars = array('data', 'template_data');
    extract($src_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
    return $template_data;
}
Esempio n. 6
0
             if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id']) {
                 trigger_error('NO_GROUP');
             }
             break;
         case GROUP_SPECIAL:
             $group_row['l_group_type'] = 'SPECIAL';
             break;
         case GROUP_FREE:
             $group_row['l_group_type'] = 'FREE';
             break;
     }
     $avatar_img = src_get_group_avatar($group_row);
     // ... same for group rank
     $user_rank_data = array('title' => null, 'img' => null, 'img_src' => null);
     if ($group_row['group_rank']) {
         $user_rank_data = src_get_user_rank($group_row, false);
         if ($user_rank_data['img']) {
             $user_rank_data['img'] .= '<br />';
         }
     }
     $template->assign_vars(array('GROUP_DESC' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), 'GROUP_NAME' => $group_row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'], 'GROUP_COLOR' => $group_row['group_colour'], 'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']], 'GROUP_RANK' => $user_rank_data['title'], 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $user_rank_data['img'], 'RANK_IMG_SRC' => $user_rank_data['img_src'], 'U_PM' => $auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm'] ? append_sid("{$src_root_path}ucp.{$phpEx}", 'i=pm&amp;mode=compose&amp;g=' . $group_id) : ''));
     $sql_select = ', ug.group_leader';
     $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
     $order_by = 'ug.group_leader DESC, ';
     $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = {$group_id}";
     $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = {$group_id}";
 }
 // Sorting and order
 if (!isset($sort_key_sql[$sort_key])) {
     $sort_key = $default_key;
 }
Esempio n. 7
0
/**
* Get user rank title and image
*
* @param int $user_rank the current stored users rank id
* @param int $user_posts the users number of posts
* @param string &$rank_title the rank title will be stored here after execution
* @param string &$rank_img the rank image as full img tag is stored here after execution
* @param string &$rank_img_src the rank image source is stored here after execution
*
* @deprecated 3.1.0-RC5 (To be removed: 3.3.0)
*
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
*/
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
{
    global $src_root_path, $phpEx;
    if (!function_exists('src_get_user_rank')) {
        include $src_root_path . 'includes/functions_display.' . $phpEx;
    }
    $rank_data = src_get_user_rank(array('user_rank' => $user_rank), $user_posts);
    $rank_title = $rank_data['title'];
    $rank_img = $rank_data['img'];
    $rank_img_src = $rank_data['img_src'];
}