Пример #1
0
/**
 * This hook displays the mchat functions
 *
 * @param hook_mchat $hook
 * @return void
 */
function hook_mchat(&$hook)
{
    global $auth, $cache, $config, $db, $template, $user;
    global $phpbb_root_path, $phpEx;
    // cause no errors during update of forum software
    if (defined('IN_INSTALL')) {
        return;
    }
    $mchat_installed = !empty($config['mchat_version']) && !empty($config['mchat_enable']) && $auth->acl_get('u_mchat_view') ? true : false;
    $page_name = substr($user->page['page_name'], 0, strpos($user->page['page_name'], '.'));
    if ($mchat_installed) {
        // Add lang file
        $user->add_lang('mods/mchat_lang');
        if (!function_exists('mchat_cache')) {
            include $phpbb_root_path . 'includes/functions_mchat.' . $phpEx;
        }
        if (($config_mchat = $cache->get('_mchat_config')) === false) {
            mchat_cache();
        }
        $config_mchat = $cache->get('_mchat_config');
        $template->assign_vars(array('S_MCHAT_ENABLE' => true, 'U_MCHAT' => $config_mchat['custom_page'] ? append_sid("{$phpbb_root_path}mchat.{$phpEx}") : ''));
        if ($page_name == 'index' || $page_name == 'mchat') {
            // check the users page
            if ($page_name == 'index' && $user->data['user_mchat_index']) {
                // mod included on index page?
                if (!defined('MCHAT_INCLUDE') && $config['mchat_on_index']) {
                    define('MCHAT_INCLUDE', true);
                    $mchat_include_index = true;
                    include $phpbb_root_path . 'mchat.' . $phpEx;
                }
            }
            // show index stats
            if (!empty($config['mchat_stats_index']) && !empty($user->data['user_mchat_stats_index'])) {
                // stats display
                $mchat_session_time = !empty($config_mchat['timeout']) ? $config_mchat['timeout'] : $config['session_length'];
                $mchat_stats = mchat_users($mchat_session_time);
                $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']));
            }
            $template->assign_vars(array('S_MCHAT_ON_INDEX' => $config['mchat_on_index'] && !empty($user->data['user_mchat_index']) ? true : false, 'S_MCHAT_VERSION' => !empty($config['mchat_version']) ? $config['mchat_version'] : 0));
        }
    }
}
Пример #2
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();
}