Esempio n. 1
0
                $config_mchat['static_message'] = $config_mchat['static_message'];
                if (isset($user->lang[strtoupper('static_message')])) {
                    $config_mchat['static_message'] = $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($user->lang[strtoupper('mchat_rules')]) || !empty($config_mchat['rules'])) {
                if (isset($user->lang[strtoupper('mchat_rules')])) {
                    $config_mchat['rules'] = $user->lang[strtoupper('mchat_rules')];
                }
            }
            // a list of users using the chat
            if ($mchat_custom_page) {
                $mchat_users = mchat_users($mchat_session_time, true);
            } else {
                $mchat_users = mchat_users($mchat_session_time);
            }
            $template->assign_vars(array('MCHAT_USERS_COUNT' => $mchat_users['mchat_users_count'], 'MCHAT_USERS_LIST' => $mchat_users['online_userlist']));
        }
        break;
}
$copyright = base64_decode('JmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly9ybWNnaXJyODMub3JnIj5STWNHaXJyODM8L2E+');
add_form_key('mchat_posting');
// Template function...
$template->assign_vars(array('MCHAT_FILE_NAME' => append_sid("{$phpbb_root_path}mchat.{$phpEx}"), 'MCHAT_REFRESH_JS' => 1000 * $config_mchat['refresh'], 'MCHAT_ADD_MESSAGE' => $mchat_add_mess, 'MCHAT_READ_MODE' => $mchat_read_mode, 'MCHAT_ARCHIVE_MODE' => $mchat_archive_mode, 'MCHAT_INPUT_TYPE' => $user->data['user_mchat_input_area'], 'MCHAT_RULES' => $mchat_rules, 'MCHAT_ALLOW_SMILES' => $mchat_smilies, 'MCHAT_ALLOW_IP' => $mchat_ip, 'MCHAT_NOMESSAGE_MODE' => $mchat_no_message, 'MCHAT_ALLOW_BBCODES' => $mchat_allow_bbcode && $config['allow_bbcode'] ? true : false, 'MCHAT_ENABLE' => $config['mchat_enable'], 'MCHAT_ARCHIVE_URL' => append_sid("{$phpbb_root_path}mchat.{$phpEx}", 'mode=archive'), 'MCHAT_CUSTOM_PAGE' => $mchat_custom_page, 'MCHAT_INDEX_HEIGHT' => $config_mchat['index_height'], 'MCHAT_CUSTOM_HEIGHT' => $config_mchat['custom_height'], 'MCHAT_READ_ARCHIVE_BUTTON' => $mchat_read_archive, 'MCHAT_FOUNDER' => $mchat_founder, 'MCHAT_CLEAN_URL' => append_sid("{$phpbb_root_path}mchat.{$phpEx}", 'mode=clean&redirect=' . $on_page), 'MCHAT_STATIC_MESS' => !empty($config_mchat['static_message']) ? htmlspecialchars_decode($config_mchat['static_message']) : '', 'L_MCHAT_COPYRIGHT' => $copyright, 'MCHAT_WHOIS' => $config_mchat['whois'], 'MCHAT_MESSAGE_LNGTH' => $config_mchat['max_message_lngth'], 'MCHAT_MESS_LONG' => sprintf($user->lang['MCHAT_MESS_LONG'], $config_mchat['max_message_lngth']), 'MCHAT_USER_TIMEOUT' => $config_mchat['timeout'] ? 1000 * $config_mchat['timeout'] : false, 'MCHAT_WHOIS_REFRESH' => 1000 * $config_mchat['whois_refresh'], 'MCHAT_PAUSE_ON_INPUT' => $config_mchat['pause_on_input'] ? true : false, 'L_MCHAT_ONLINE_EXPLAIN' => mchat_session_time($mchat_session_time), 'MCHAT_REFRESH_YES' => sprintf($user->lang['MCHAT_REFRESH_YES'], $config_mchat['refresh']), 'L_MCHAT_WHOIS_REFRESH_EXPLAIN' => sprintf($user->lang['WHO_IS_REFRESH_EXPLAIN'], $config_mchat['whois_refresh']), 'S_MCHAT_AVATARS' => $mchat_avatars, 'S_MCHAT_LOCATION' => $config_mchat['location'], 'S_MCHAT_SOUND_YES' => $user->data['user_mchat_sound'], 'S_MCHAT_INDEX_STATS' => $user->data['user_mchat_stats_index'], 'U_MORE_SMILIES' => append_sid("{$phpbb_root_path}posting.{$phpEx}", 'mode=smilies'), 'U_MCHAT_RULES' => append_sid("{$phpbb_root_path}mchat.{$phpEx}", 'mode=rules')));
// Template
if (!$mchat_include_index) {
    page_header($user->lang['MCHAT_TITLE'], false);
    $template->set_filenames(array('body' => 'mchat_body.html'));
    page_footer();
}
Esempio n. 2
0
/**
* @param $session_time amount of time before a users session times out
*/
function mchat_users($session_time, $on_page = false)
{
    global $auth, $db, $template, $user;
    $check_time = time() - (int) $session_time;
    $sql = 'DELETE FROM ' . MCHAT_SESSIONS_TABLE . ' WHERE user_lastupdate < ' . $check_time;
    $db->sql_query($sql);
    // add the user into the sessions upon first visit
    if ($on_page && ($user->data['user_id'] != ANONYMOUS && !$user->data['is_bot'])) {
        mchat_sessions($session_time);
    }
    $mchat_user_count = 0;
    $mchat_user_list = '';
    $sql = 'SELECT m.user_id, u.username, u.user_type, u.user_allow_viewonline, u.user_colour
		FROM ' . MCHAT_SESSIONS_TABLE . ' m
		LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
		WHERE m.user_lastupdate > ' . $check_time . '
		ORDER BY u.username ASC';
    $result = $db->sql_query($sql);
    $can_view_hidden = $auth->acl_get('u_viewonline');
    while ($row = $db->sql_fetchrow($result)) {
        if (!$row['user_allow_viewonline']) {
            if (!$can_view_hidden) {
                continue;
            } else {
                $row['username'] = '******' . $row['username'] . '</em>';
            }
        }
        $mchat_user_count++;
        $mchat_user_online_link = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $user->lang['GUEST']);
        $mchat_user_list .= $mchat_user_list != '' ? $user->lang['COMMA_SEPARATOR'] . $mchat_user_online_link : $mchat_user_online_link;
    }
    $db->sql_freeresult($result);
    $refresh_message = mchat_session_time($session_time);
    if (!$mchat_user_count) {
        return array('online_userlist' => '', 'mchat_users_count' => $user->lang['MCHAT_NO_CHATTERS'], 'refresh_message' => $refresh_message);
    } else {
        return array('online_userlist' => $mchat_user_list, 'mchat_users_count' => $mchat_user_count > 1 ? sprintf($user->lang['MCHAT_ONLINE_USERS_TOTAL'], $mchat_user_count) : sprintf($user->lang['MCHAT_ONLINE_USER_TOTAL'], $mchat_user_count), 'refresh_message' => $refresh_message);
    }
}