コード例 #1
0
ファイル: hook_mchat.php プロジェクト: RMcGirr83-30/mChat
/**
 * 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
ファイル: ucp_mchat.php プロジェクト: RMcGirr83-30/mChat
    function main($id, $mode)
    {
        global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
        include $phpbb_root_path . 'includes/functions_mchat.' . $phpEx;
        $user->add_lang('mods/mchat_lang');
        $submit = !empty($_POST['submit']) ? true : false;
        $error = $data = array();
        switch ($mode) {
            case 'configuration':
                $data = array('user_mchat_index' => request_var('user_mchat_index', (bool) $user->data['user_mchat_index']), 'user_mchat_sound' => request_var('user_mchat_sound', (bool) $user->data['user_mchat_sound']), 'user_mchat_stats_index' => request_var('user_mchat_stats_index', (bool) $user->data['user_mchat_stats_index']), 'user_mchat_topics' => request_var('user_mchat_topics', (bool) $user->data['user_mchat_topics']), 'user_mchat_avatars' => request_var('user_mchat_avatars', (bool) $user->data['user_mchat_avatars']), 'user_mchat_input_area' => request_var('user_mchat_input_area', (bool) $user->data['user_mchat_input_area']));
                add_form_key('ucp_mchat');
                if ($submit) {
                    if (!check_form_key('ucp_mchat')) {
                        $error[] = 'FORM_INVALID';
                    }
                    if (!sizeof($error)) {
                        $sql_ary = array('user_mchat_index' => $data['user_mchat_index'], 'user_mchat_sound' => $data['user_mchat_sound'], 'user_mchat_stats_index' => $data['user_mchat_stats_index'], 'user_mchat_topics' => $data['user_mchat_topics'], 'user_mchat_avatars' => $data['user_mchat_avatars'], 'user_mchat_input_area' => $data['user_mchat_input_area']);
                        if (sizeof($sql_ary)) {
                            $sql = 'UPDATE ' . USERS_TABLE . '
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
								WHERE user_id = ' . (int) $user->data['user_id'];
                            $db->sql_query($sql);
                        }
                        meta_refresh(3, $this->u_action);
                        $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                        trigger_error($message);
                    }
                    // Replace "error" strings with their real, localised form
                    $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
                }
                if (($mchat_cache = $cache->get('_mchat_config')) === false) {
                    mchat_cache();
                }
                $mchat_cache = $cache->get('_mchat_config');
                $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_DISPLAY_MCHAT' => $data['user_mchat_index'], 'S_SOUND_MCHAT' => $data['user_mchat_sound'], 'S_STATS_MCHAT' => $data['user_mchat_stats_index'], 'S_TOPICS_MCHAT' => $data['user_mchat_topics'], 'S_AVATARS_MCHAT' => $data['user_mchat_avatars'], 'S_INPUT_MCHAT' => $data['user_mchat_input_area'], 'S_MCHAT_TOPICS' => $config['mchat_new_posts'], 'S_MCHAT_INDEX' => $config['mchat_on_index'] || $config['mchat_stats_index'] ? true : false, 'S_MCHAT_AVATARS' => $mchat_cache['avatars']));
                break;
        }
        $template->assign_vars(array('L_TITLE' => $user->lang['UCP_PROFILE_MCHAT'], 'S_UCP_ACTION' => $this->u_action));
        // Set desired template
        $this->tpl_name = 'ucp_mchat';
        $this->page_title = 'UCP_PROFILE_MCHAT';
    }
コード例 #3
0
ファイル: acp_mchat.php プロジェクト: RMcGirr83-30/mChat
 function configuration()
 {
     global $cache, $config, $db, $user, $auth, $template;
     global $phpbb_root_path, $phpEx, $phpbb_admin_path;
     // install file been run?
     if (!isset($config['mchat_version']) || isset($config['mchat_version']) && version_compare($config['mchat_version'], '1.3.5', '<')) {
         if ($user->data['user_type'] == USER_FOUNDER) {
             $installer = append_sid("{$phpbb_root_path}mchat_install.{$phpEx}");
             $message = sprintf($user->lang['MCHAT_WRONG_VERSION'], '<a href="' . $installer . '">', '</a>');
         } else {
             $message = $user->lang['MCHAT_NEEDS_UPDATING'];
         }
         trigger_error($message);
     }
     // something was submitted
     $submit = isset($_POST['submit']) ? true : false;
     $mchat_row = array('location' => request_var('mchat_location', 0), 'refresh' => request_var('mchat_refresh', 0), 'message_limit' => request_var('mchat_message_limit', 0), 'message_num' => request_var('mchat_message_num', 0), 'archive_limit' => request_var('mchat_archive_limit', 0), 'flood_time' => request_var('mchat_flood_time', 0), 'max_message_lngth' => request_var('mchat_max_message_lngth', 0), 'custom_page' => request_var('mchat_custom_page', 0), 'date' => request_var('mchat_date', '', true), 'whois' => request_var('mchat_whois', 0), 'whois_refresh' => request_var('mchat_whois_refresh', 0), 'bbcode_disallowed' => utf8_normalize_nfc(request_var('mchat_bbcode_disallowed', '', true)), 'prune_enable' => request_var('mchat_prune_enable', 0), 'prune_num' => request_var('mchat_prune_num', 0), 'index_height' => request_var('mchat_index_height', 0), 'custom_height' => request_var('mchat_custom_height', 0), 'static_message' => utf8_normalize_nfc(request_var('mchat_static_message', '', true)), 'override_min_post_chars' => request_var('mchat_override_min_post_chars', 0), 'override_smilie_limit' => request_var('mchat_override_smilie_limit', 0), 'timeout' => request_var('mchat_timeout', 0), 'pause_on_input' => request_var('mchat_pause_on_input', 0), 'rules' => utf8_normalize_nfc(request_var('mchat_rules', '', true)), 'avatars' => request_var('mchat_avatars', 0));
     if ($submit) {
         if (!function_exists('validate_data')) {
             include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
         }
         // validate the entries...most of them anyway
         $mchat_array = array('static_message' => array('string', false, 0, 255), 'index_height' => array('num', false, 50, 1000), 'custom_height' => array('num', false, 50, 1000), 'whois_refresh' => array('num', false, 30, 300), 'refresh' => array('num', false, 5, 60), 'message_limit' => array('num', false, 10, 30), 'message_num' => array('num', false, 10, 50), 'archive_limit' => array('num', false, 25, 50), 'flood_time' => array('num', false, 0, 30), 'max_message_lngth' => array('num', false, 0, 500), 'timeout' => array('num', false, 0, (int) $config['session_length']), 'rules' => array('string', false, 0, 255));
         $error = validate_data($mchat_row, $mchat_array);
         if (!check_form_key('acp_mchat')) {
             $error[] = 'FORM_INVALID';
         }
         // Replace "error" strings with their real, localised form
         $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
         if (!sizeof($error)) {
             foreach ($mchat_row as $config_name => $config_value) {
                 $sql = 'UPDATE ' . MCHAT_CONFIG_TABLE . "\n\t\t\t\t\t\tSET config_value = '" . $db->sql_escape($config_value) . "'\n\t\t\t\t\t\tWHERE config_name = '" . $db->sql_escape($config_name) . "'";
                 $db->sql_query($sql);
             }
             //update setting in config table for mod enabled or not
             set_config('mchat_enable', request_var('mchat_enable', 0));
             // update setting in config table for allowing on index or not
             set_config('mchat_on_index', request_var('mchat_on_index', 0));
             // update setting in config table to allow new posts to display or not
             set_config('mchat_new_posts', request_var('mchat_new_posts', 0));
             // update setting in config table for stats on index
             set_config('mchat_stats_index', request_var('mchat_stats_index', 0));
             // and an entry into the log table
             add_log('admin', 'LOG_MCHAT_CONFIG_UPDATE');
             // purge the cache
             $cache->destroy('_mchat_config');
             if (!function_exists('mchat_cache')) {
                 include $phpbb_root_path . 'includes/functions_mchat.' . $phpEx;
             }
             // rebuild the cache
             mchat_cache();
             trigger_error($user->lang['MCHAT_CONFIG_SAVED'] . adm_back_link($this->u_action));
         }
     }
     // let's get it on
     $sql = 'SELECT * FROM ' . MCHAT_CONFIG_TABLE;
     $result = $db->sql_query($sql);
     $mchat_config = array();
     while ($row = $db->sql_fetchrow($result)) {
         $mchat_config[$row['config_name']] = $row['config_value'];
     }
     $db->sql_freeresult($result);
     $mchat_enable = isset($config['mchat_enable']) ? $config['mchat_enable'] : 0;
     $mchat_on_index = isset($config['mchat_on_index']) ? $config['mchat_on_index'] : 0;
     $mchat_version = isset($config['mchat_version']) ? $config['mchat_version'] : '';
     $mchat_new_posts = isset($config['mchat_new_posts']) ? $config['mchat_new_posts'] : 0;
     $mchat_stats_index = isset($config['mchat_stats_index']) ? $config['mchat_stats_index'] : 0;
     $dateformat_options = '';
     foreach ($user->lang['dateformats'] as $format => $null) {
         $dateformat_options .= '<option value="' . $format . '"' . ($format == $mchat_config['date'] ? ' selected="selected"' : '') . '>';
         $dateformat_options .= $user->format_date(time(), $format, false) . (strpos($format, '|') !== false ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : '');
         $dateformat_options .= '</option>';
     }
     $s_custom = false;
     $dateformat_options .= '<option value="custom"';
     if (!isset($user->lang['dateformats'][$mchat_config['date']])) {
         $dateformat_options .= ' selected="selected"';
         $s_custom = true;
     }
     $dateformat_options .= '>' . $user->lang['MCHAT_CUSTOM_DATEFORMAT'] . '</option>';
     $template->assign_vars(array('MCHAT_ERROR' => isset($error) ? sizeof($error) ? implode('<br />', $error) : '' : '', 'MCHAT_VERSION' => $mchat_version, 'MCHAT_PRUNE' => !empty($mchat_row['prune_enable']) ? $mchat_row['prune_enable'] : $mchat_config['prune_enable'], 'MCHAT_PRUNE_NUM' => !empty($mchat_row['prune_num']) ? $mchat_row['prune_num'] : $mchat_config['prune_num'], 'MCHAT_ENABLE' => $mchat_enable ? true : false, 'MCHAT_ON_INDEX' => $mchat_on_index ? true : false, 'MCHAT_LOCATION' => !empty($mchat_row['location']) ? $mchat_row['location'] : $mchat_config['location'], 'MCHAT_REFRESH' => !empty($mchat_row['refresh']) ? $mchat_row['refresh'] : $mchat_config['refresh'], 'MCHAT_WHOIS_REFRESH' => !empty($mchat_row['whois_refresh']) ? $mchat_row['whois_refresh'] : $mchat_config['whois_refresh'], 'MCHAT_MESSAGE_LIMIT' => !empty($mchat_row['message_limit']) ? $mchat_row['message_limit'] : $mchat_config['message_limit'], 'MCHAT_MESSAGE_NUM' => !empty($mchat_row['message_num']) ? $mchat_row['message_num'] : $mchat_config['message_num'], 'MCHAT_ARCHIVE_LIMIT' => !empty($mchat_row['archive_limit']) ? $mchat_row['archive_limit'] : $mchat_config['archive_limit'], 'MCHAT_AVATARS' => !empty($mchat_row['avatars']) ? $mchat_row['avatars'] : $mchat_config['avatars'], 'MCHAT_FLOOD_TIME' => !empty($mchat_row['flood_time']) ? $mchat_row['flood_time'] : $mchat_config['flood_time'], 'MCHAT_MAX_MESSAGE_LNGTH' => !empty($mchat_row['max_message_lngth']) ? $mchat_row['max_message_lngth'] : $mchat_config['max_message_lngth'], 'MCHAT_CUSTOM_PAGE' => !empty($mchat_row['custom_page']) ? $mchat_row['custom_page'] : $mchat_config['custom_page'], 'MCHAT_DATE' => !empty($mchat_row['date']) ? $mchat_row['date'] : $mchat_config['date'], 'MCHAT_DEFAULT_DATEFORMAT' => $config['default_dateformat'], 'MCHAT_RULES' => !empty($mchat_row['rules']) ? $mchat_row['rules'] : $mchat_config['rules'], 'MCHAT_WHOIS' => !empty($mchat_row['whois']) ? $mchat_row['whois'] : $mchat_config['whois'], 'MCHAT_STATS_INDEX' => $mchat_stats_index ? true : false, 'MCHAT_BBCODE_DISALLOWED' => !empty($mchat_row['bbcode_disallowed']) ? $mchat_row['bbcode_disallowed'] : $mchat_config['bbcode_disallowed'], 'MCHAT_STATIC_MESSAGE' => !empty($mchat_row['static_message']) ? $mchat_row['static_message'] : $mchat_config['static_message'], 'MCHAT_INDEX_HEIGHT' => !empty($mchat_row['index_height']) ? $mchat_row['index_height'] : $mchat_config['index_height'], 'MCHAT_CUSTOM_HEIGHT' => !empty($mchat_row['custom_height']) ? $mchat_row['custom_height'] : $mchat_config['custom_height'], 'MCHAT_OVERRIDE_SMILIE_LIMIT' => !empty($mchat_row['override_smilie_limit']) ? $mchat_row['override_smilie_limit'] : $mchat_config['override_smilie_limit'], 'MCHAT_OVERRIDE_MIN_POST_CHARS' => !empty($mchat_row['override_min_post_chars']) ? $mchat_row['override_min_post_chars'] : $mchat_config['override_min_post_chars'], 'MCHAT_TIMEOUT' => !empty($mchat_row['timeout']) ? $mchat_row['timeout'] : $mchat_config['timeout'], 'MCHAT_NEW_POSTS' => $mchat_new_posts ? true : false, 'MCHAT_PAUSE_ON_INPUT' => !empty($mchat_row['pause_on_input']) ? $mchat_row['pause_on_input'] : $mchat_config['pause_on_input'], 'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($user->lang['MCHAT_BBCODES_DISALLOWED_EXPLAIN'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=bbcodes', true, $user->session_id) . '">', '</a>'), 'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($user->lang['MCHAT_USER_TIMEOUT_EXPLAIN'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=board&amp;mode=load', true, $user->session_id) . '">', '</a>', $config['session_length']), 'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'U_ACTION' => $this->u_action));
 }
コード例 #4
0
ファイル: mchat.php プロジェクト: RMcGirr83-30/mChat
        $message = sprintf($user->lang['MCHAT_NOT_INSTALLED'], '<a href="' . $installer . '">', '</a>');
    } else {
        $message = $user->lang['MCHAT_NOTINSTALLED_USER'];
    }
    trigger_error($message);
}
//  avatars
if (!function_exists('get_user_avatar')) {
    include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
}
// Get the config entries.
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');
// Access rights
$mchat_allow_bbcode = $config['allow_bbcode'] && $auth->acl_get('u_mchat_bbcode') ? true : false;
$mchat_smilies = $config['allow_smilies'] && $auth->acl_get('u_mchat_smilies') ? true : false;
$mchat_urls = $config['allow_post_links'] && $auth->acl_get('u_mchat_urls') ? true : false;
$mchat_ip = $auth->acl_get('u_mchat_ip') ? true : false;
$mchat_add_mess = $auth->acl_get('u_mchat_use') ? true : false;
$mchat_view = $auth->acl_get('u_mchat_view') ? true : false;
$mchat_no_flood = $auth->acl_get('u_mchat_flood_ignore') ? true : false;
$mchat_read_archive = $auth->acl_get('u_mchat_archive') ? true : false;
$mchat_founder = $user->data['user_type'] == USER_FOUNDER ? true : false;
$mchat_session_time = !empty($config_mchat['timeout']) ? $config_mchat['timeout'] : (!empty($config['load_online_time']) ? $config['load_online_time'] * 60 : $config['session_length']);
$mchat_rules = !empty($config_mchat['rules']) || isset($user->lang[strtoupper('mchat_rules')]) ? true : false;
$mchat_avatars = !empty($config_mchat['avatars']) && $user->optionget('viewavatars') && $user->data['user_mchat_avatars'] ? true : false;