Группы для общения в чате

Группы для общения в чате 1.0.0

Нет прав для скачивания
Совместимость
не проверялся на совместимость
Изменения в БД
требуются
Дополнительные требования
модификация чата
Автор
frost444
Общественное достояние
да
Описание: дополнение к

Please Login or Register to view hidden text.

. Группы для общения в чате.

Возможности:
  • Позволяет создавать группы для общения в чате. Создавать группу могут только администраторы, также можно добавлять права на просмотр и написания текста пользователям в определенные группы
  • Позволяет просматривать все сообщения чата в виде темы, с навигацией и прочими функциями
Инструкция по установке
PHP:
//////////////////////////////////////////////////////
//// Передустановкой рекомендуется удалить прошлый чат.
//// только php код и данныйе из tpl
//////////////////////////////////////////////////////

Автор мода: frost444

//-----[Обновления]-----\\

|--(18.01.2013)
   1) измененный код: admin_board.php, admin_groups.php, admin_board.tpl, admin_groups.tpl, page_header.php, config.php, lang_main.php, выбраного_вами.tpl
   2) изменен код в прилагаемых файлах: chat.php, chat.php(ajax), chat.tpl
   3) Добавлены 3 запроса в БД
   info: (1) Улучшена работа мода
         (2) Добавлен ббкод (корректный), ссылка на лс, ссылка на профиль, пол пользователя.
         (3) Добавлено закрытие окна редактирования, при добавлении нового сообщения или переходе в другую группу
         (4) Добавлена интеграция с модом рекламы в чат
         (5) Опции перенесены в админ панель
         (6) Прочие мелкие доработки
 
\\-----[Обновления]-----//

####[ВЫПОЛНИТЬ]-----SQL

CREATE TABLE IF NOT EXISTS `bb_chat_group` (
  `group_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `group_name` varchar(150) NOT NULL DEFAULT '',
  `group_desc` text NOT NULL,
  `group_status` tinyint(4) NOT NULL DEFAULT '0',
  `group_posts` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `group_order` smallint(5) unsigned NOT NULL DEFAULT '1',
  `group_auth_view` tinyint(2) NOT NULL DEFAULT '0',
  `group_auth_reply` tinyint(2) NOT NULL DEFAULT '0',
  `group_auth_edit` tinyint(2) NOT NULL DEFAULT '0',
  `group_auth_delete` tinyint(2) NOT NULL DEFAULT '0',
  `group_dost` text NOT NULL,
  PRIMARY KEY (`group_id`),
  KEY `group_order` (`group_order`),
  KEY `group_id` (`group_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

ALTER TABLE `bb_chat` ADD `group_id` int(11) default '1' NOT NULL AFTER `id`;
ALTER TABLE `bb_groups` ADD `group_reed_chat` tinyint(1) unsigned NOT NULL DEFAULT '0';
INSERT INTO `bb_chat_group` (`group_id`, `group_name`, `group_desc`, `group_status`, `group_posts`, `group_order`, `group_auth_view`, `group_auth_reply`, `group_auth_edit`, `group_auth_delete`, `group_dost`) VALUES
(1, 'Основная', 'Стандартная группа, отображаемая первой в чате', 0, 0, 10, 0, 1, 1, 3, '');

INSERT INTO bb_config (config_name, config_value) VALUES ('chat_bbcode_on', '1');
INSERT INTO bb_config (config_name, config_value) VALUES ('chat_message', '50');
INSERT INTO bb_config (config_name, config_value) VALUES ('chat_on', '1');

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Если стоял мой старый мод, от 18.01.2013 и старее, !
! то выполните sql ниже, соблюдая порядок действий   !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

DELETE FROM `bb_chat` WHERE group_id = 1;
UPDATE `bb_chat` SET group_id = 1 WHERE group_id = 0;
UPDATE `bb_chat_group` SET group_name = "Основная", group_desc = "Стандартная группа, отображаемая первой в чате", group_status = 0, group_posts = 0, group_order = 0, group_auth_view = 0, group_auth_reply = 1, group_auth_edit = 1, group_auth_delete = 3 WHERE group_id = 1;
ALTER TABLE `bb_chat_group` ADD `group_dost` text NOT NULL;

####[КОНЕЦ]-----SQL


####[ОТКРЫТЬ]----- init_bb.php

-----[найти]-----

define('BB_PRIVMSGS_TEXT',        'bb_privmsgs_text');

-----[добавить после]-----

//CHAT
define('BB_CHAT',              'bb_chat');
//CHAT
//CHAT ADDON MODE
define('BB_CHAT_GROUP',              'bb_chat_group');
//CHAT ADDON MODE

-----[найти]-----

require(INC_DIR .'db/mysql.php');

-----[добавить после]-----

require(INC_DIR .'functions_chat.php');

-----[найти]-----

$ads = new ads_common();

-----[добавить после]-----

$chat = new Chat();

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- functions.php

-----[найти]-----

$bf['forum_perm'] = array(
    'auth_view'        => AUTH_VIEW,
    'auth_read'        => AUTH_READ,
    'auth_mod'         => AUTH_MOD,
    'auth_post'        => AUTH_POST,
    'auth_reply'       => AUTH_REPLY,
    'auth_edit'        => AUTH_EDIT,
    'auth_delete'      => AUTH_DELETE,
    'auth_sticky'      => AUTH_STICKY,
    'auth_announce'    => AUTH_ANNOUNCE,
    'auth_vote'        => AUTH_VOTE,
    'auth_pollcreate'  => AUTH_POLLCREATE,
    'auth_attachments' => AUTH_ATTACH,
    'auth_download'    => AUTH_DOWNLOAD,
);

-----[добавить после]-----

$bf['group_chat_perm'] = array(
    'group_auth_view'        => AUTH_VIEW,
    'group_auth_mod'         => AUTH_MOD,
    'group_auth_reply'       => AUTH_REPLY,
    'group_auth_edit'        => AUTH_EDIT,
    'group_auth_delete'      => AUTH_DELETE,
);

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- lang_main.php

-----[в самый конец добавить]-----

//CHAT
$lang['CHAT'] = 'Мини чат';
$lang['MAX_SMILE'] = 'Слишком много смайлов, максимум 3';
$lang['DUBLE_POST'] = 'Дабл пост.';
$lang['TIME_FLUD'] = 'Тайм флуд.';
$lang['NULL_POST'] = 'Нахер постить пустое сообщение?';
$lang['UPDATE_CHAT'] = 'Обновить чат';
$lang['SUBMIT_CHAT'] = 'Оправить (Ctrl+Enter)';
$lang['CLEAR'] = 'Очистить';
$lang['SMILES'] = 'Смайлы';
//CHAT

//CHAT ADDON MODE
$lang['GROUP_AUTH_VIEW'] = 'Видеть';
$lang['GROUP_AUTH_READ'] = 'Читать';
$lang['GROUP_AUTH_POST'] = 'Создавать темы';
$lang['GROUP_AUTH_POST_VIEW'] = 'Смотреть комментарии';
$lang['GROUP_AUTH_REPLY'] = 'Отвечать';
$lang['GROUP_AUTH_EDIT'] = 'Редактировать';
$lang['GROUP_AUTH_DELETE'] = 'Удалить';
$lang['GROUP_REED_CHAT'] = 'Разрешено модерировать чат';
$lang['CHAT_CFG'] = 'Настройка чата';
$lang['CHAT_ON'] = 'Чат';
$lang['CHAT_TITLE'] = 'История чата';
$lang['CHAT_BBCODE'] = 'BB-коды в чате';
$lang['CHAT_MESS'] = 'Кол-во сообщений';
$lang['CHAT_GROUP_GAFAULT_NAME'] = 'Основная';
//CHAT ADDON MODE

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- lang_admin.php

-----[в самый конец добавить]-----

//CHAT ADDON MODE
$lang['GROUP_AUTH_VIEW'] = 'Видеть';
$lang['GROUP_AUTH_READ'] = 'Читать';
$lang['GROUP_AUTH_POST'] = 'Создавать темы';
$lang['GROUP_AUTH_POST_VIEW'] = 'Смотреть комментарии';
$lang['GROUP_AUTH_REPLY'] = 'Отвечать';
$lang['GROUP_AUTH_EDIT'] = 'Редактировать';
$lang['GROUP_AUTH_DELETE'] = 'Удалить';
//CHAT ADDON MODE

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- build_cat_forums.php

-----[найти]-----

$this->store('cat_forums', $data);

-----[добавить после]-----

//
// cat_chat
//
$data = array(
    'group_not_auth' => array(
        'group_guest_view' => array(),
        'group_guest_read' => array(),
        'group_user_view'  => array(),
        'group_user_read'  => array(),
    ),
    'group_title_html'  => array(),
    'group_name_html' => array(),
    'c' => array(),                // also has $data['c']['cat_id']['forums'] key
);

// Store only these fields from BB_FORUMS in $data['f']
$forum_store_fields += array_flip(array(
  'group_id',
  'group_name',
  'group_desc',
  'group_status',
  'group_posts',
));

// Categories
$sql = "SELECT * FROM ". BB_CHAT_GROUP ." ORDER BY group_order";

foreach(DB()->fetch_rowset($sql) as $row)
{
    $data['c'][$row['group_id']] = $row;
    $data['group_title_html'][$row['group_id']] = htmlCHR($row['group_name']);
}

foreach (DB()->fetch_rowset($sql) as $row)
{
    $fid = $row['group_id'];
    $not_auth =& $data['group_not_auth'];

    // Find not auth forums
    if ($row['group_auth_view'] != AUTH_ALL)
    {
        $not_auth['group_guest_view'][] = $fid;
    }
    if ($row['group_auth_view'] != AUTH_ALL && $row['group_auth_view'] != AUTH_REG)
    {
        $not_auth['group_user_view'][] = $fid;
    }

    $data['forum'][$fid] = $row;

    // Store forums data

    $data['group_name_html'][$fid] = htmlCHR($row['group_name']);

    // Forum ids in cat
    $data['c'][$row['group_id']]['forums'][] = $fid;
}
foreach ($data['group_not_auth'] as $key => $val)
{
    $data['group_not_auth'][$key] = join(',', $val);
}

$this->store('group_chat', $data);

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- common.php

-----[найти]-----

        'cat_forums'             => 'build_cat_forums.php',

-----[добавить после]-----

        'group_chat'             => 'build_cat_forums.php',

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- sessions.php

-----[найти]-----

    /**
    *  Enqueue ads
    */

-----[выше добавить]-----

    function get_not_auth_group_chat ($auth_type)
    {
        global $datastore, $chat;

        if (IS_ADMIN) return '';

        if (!$forums = $datastore->get('group_chat'))
        {
            $datastore->update('group_chat');
            $forums = $datastore->get('group_chat');
        }

        if ($auth_type == AUTH_VIEW)
        {
            if (IS_GUEST)
            {
                return $forums['group_not_auth']['group_guest_view'];
            }
        }
        if ($auth_type == AUTH_READ)
        {
            if (IS_GUEST)
            {
                return $forums['group_not_auth']['group_guest_read'];
            }
        }

        $auth_field_match = array(
            AUTH_VIEW       => 'group_auth_view',
            AUTH_REPLY      => 'group_auth_reply',
            AUTH_EDIT       => 'group_auth_edit',
            AUTH_DELETE     => 'group_auth_delete',
        );

        $not_auth_forums = array();
        $auth_field = $auth_field_match[$auth_type];
        $is_auth_ary = $chat->auth($auth_type, AUTH_LIST_ALL, $this->data);
        foreach ($is_auth_ary as $forum_id => $is_auth)
        {
            if (!$is_auth[$auth_field])
            {
                $not_auth_forums[] = $forum_id;
            }
        }

        return join(',', $not_auth_forums);
    }

    function get_excluded_group_chat ($auth_type, $return_as = 'csv')
    {
        $excluded = array();

        if ($not_auth = $this->get_not_auth_group_chat($auth_type))
        {
            $excluded[] = $not_auth;
        }
      
        switch ($return_as)
        {
            case   'csv': return join(',', $excluded);
            case 'array': return $excluded;
            case  'flip': return array_flip(explode(',', $excluded));
        }
    }

/////////////////////////////////////////////////////////
//// Так, дальше я не нашел оригинальный инсталл чата.
//// Так что остальные правки делаются,
//// с полной заменой. Если у вас есть старые наработки,
//// то сразу подготовьте их для переноса.
//// Повторюсь, действия выполнять с заменой старого кода!
//////////////////////////////////////////////////////////

####[ОТКРЫТЬ]----- config.php

-----[в самый низ добавить]-----

$page_cfg['show_chat'] = array(
#    BB_SCRIPT => true
    'index'  => true,
);

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- page_header.php

-----[найти]-----

global $page_cfg, $userdata, $user, $ads, $bb_cfg, $template, $lang, $images

-----[в строке добавить]-----

, $datastore, $chat

-----[найти]-----

// Report [END]

-----[ниже добавить]-----


if($bb_cfg['chat_on'] && !empty($page_cfg['show_chat'][BB_SCRIPT]))
{
    $groupOn = (isset($_GET['group_chat']) || isset($_POST['group_chat'])) ? true : false;
    if($groupOn)
    {
        $group = (!empty($_POST['group_chat'])) ? $_POST['group_chat'] : $_GET['group_chat'];
        if(isset($group) && $group > 0)
        {
            $checkGroup = DB()->fetch_row("SELECT * FROM ".BB_CHAT_GROUP." WHERE group_id = {$group} LIMIT 1");
            if(count($checkGroup)<= 0)
            {
                bb_die('Такой группы не существует');
            }else{
                $groupSqlWhere = "
                    WHERE c.group_id = $group
                ";
              
                $groupNum = $checkGroup['group_id'];
            }
        }else{  
            bb_die('Такой группы не существует');
        }  
    }else{
        $groupSqlWhere = "
            WHERE c.group_id = 1
        ";
        $groupNum = "1";
    }
    if (!$group_chat = $datastore->get('group_chat'))
    {
        $datastore->update('group_chat');
        $group_chat = $datastore->get('group_chat');
    }
    if($groupNum > 0)
    {
        if (!$groupNum OR !$chat_data = @$group_chat['c'][$groupNum])
        {
            bb_die($lang['FORUM_NOT_EXIST']);
        }

        $is_auth_chat = $chat->auth(AUTH_ALL, $groupNum, $userdata, $chat_data);
      
        if (!$is_auth_chat['group_auth_view'])
        {
            $message = sprintf($lang['SORRY_AUTH_VIEW'], $is_auth_chat['group_auth_view_type']);
            bb_die($message);
        }
    }
    if (!$sql_ch = CACHE('bb_cache')->get('chat['.$groupNum.']'))
    {
        $sql_ch = DB()->fetch_rowset("SELECT c.*, u.username, u.user_rank, u.user_avatar, u.user_avatar_type, u.user_opt, u.user_gender
            FROM ".BB_CHAT." c
            LEFT JOIN ". BB_USERS ." u ON(u.user_id = c.user_id)
            $groupSqlWhere
            ORDER BY c.id DESC
            LIMIT {$bb_cfg['chat_message']}");
        CACHE('bb_cache')->set('chat['.$groupNum.']', $sql_ch);
    }

    foreach($sql_ch as $row)
    {
        switch($row['user_gender'])
        {
            case MALE:
                $gender = '&nbsp;<b>&#0183;</b>&nbsp;<img src="'. $images['icon_male'] .'" alt="" title="'. $lang['GENDER_SELECT'][1] .'" border="0" />';
                break;
            case FEMALE:
                $gender = '&nbsp;<b>&#0183;</b>&nbsp;<img src="'. $images['icon_female'] .'" alt="" title="'. $lang['GENDER_SELECT'][2] .'" border="0" />';
                break;
            default:
                $gender = '';
                break;          
      
        }
        $profile_img = ($bb_cfg['text_buttons']) ? $lang['READ_PROFILE_TXTB'] : '<img src="'. $images['icon_profile'] .'" alt="'. $lang['READ_PROFILE_TXTB'] .'" title="'. $lang['READ_PROFILE'] .'" />';
        $pm_img = ($bb_cfg['text_buttons']) ? $lang['SEND_PM_TXTB'] : '<img src="'. $images['icon_pm'] .'" alt="'. $lang['SEND_PM_TXTB'] .'" title="'. $lang['SEND_PRIVATE_MESSAGE'] .'" />';
        $profile_url = ($row['user_id'] == ANONYMOUS || $row['user_id'] == BOT_UID) ? '' : '&nbsp;<b>&#0183;</b>&nbsp;<a href="'. PROFILE_URL . $row['user_id'].'">'.$profile_img.'</a>';
        $pm_url      = ($row['user_id'] == ANONYMOUS || $row['user_id'] == BOT_UID) ? '' : '&nbsp;<b>&#0183;</b>&nbsp;<a href="'. PM_URL .$row['user_id'].'">'.$pm_img.'</a>';
        $orig_word = array();
        $replacement_word = array();
        obtain_word_list($orig_word, $replacement_word);
        $messages = ($row['user_id'] == BOT_UID) ? $row['text_html'] : str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $row['text_html'] . '<'), 1, -1));
        $message = '<div class="post_body" style="margin: 0px"><div class="post_wrap">';
        $message .= '<div class="row1 chat-comment" id="pp_'. $row['id'] .'"><div style="min-height: 32px;">';
        $message .= ($row['user_id'] == ANONYMOUS || $row['user_id'] == BOT_UID) ? '' : '<a href="'. PROFILE_URL . $row['user_id'] .'">';
        $message .= str_replace('<img', '<img align="left" style="padding-right: 3px;"', get_avatar($row['user_avatar'], $row['user_avatar_type'], !bf($row['user_opt'], 'user_opt', 'allow_avatar'), '32', '32'));
        $message .= ($row['user_id'] == ANONYMOUS || $row['user_id'] == BOT_UID) ? '' : '</a>';
        $message .= ($row['user_id'] != BOT_UID && $is_auth_chat['group_auth_delete'] && ($row['user_id'] == $userdata['user_id'] || $is_auth_chat['group_chat_mod'] || IS_ADMIN)) ? '<input onclick="set_hid_chbox('. $row['id'] .');" class="floatR chat-post" type="checkbox" value="'. $row['id'] .'" />':'';
        $message .= ($row['user_id'] != BOT_UID && $is_auth_chat['group_auth_edit'] && ($row['user_id'] == $userdata['user_id'] || $is_auth_chat['group_chat_mod'] || IS_ADMIN)) ? '<span onclick="edit_comment('. $row['id'] .'); return false;" class="txtb floatR">[p]</span>': '';
        $title_ip = (IS_ADMIN) ? decode_ip($row['ip']) : 'Ник в чат';
        $message .= '<a href="#" class="bold" title="'. $title_ip .'" onclick="add_nick(\'[n]'. $row['username'] .'[/n]\'); return false;">'. str_replace('title="', 'data="', profile_url(array('username' => $row['username'], 'user_rank' => $row['user_rank']))) .'</a>'.$profile_url.$pm_url.$gender.'<div class="small">'. bb_date($row['time']) .'</div></div>';
        $message .= '<div class="spacer_2"></div><span style="font-size: 11px;">'. $messages .'</span></div>';
        $message .= ($row['user_id'] != BOT_UID && $is_auth_chat['group_auth_edit'] && ($row['user_id'] == $userdata['user_id'] || $is_auth_chat['group_chat_mod'] || IS_ADMIN)) ? '<span id="pe_'. $row['id'] .'"></span>' : '';                  
        $message .= '</div></div>';
      
        $template->assign_block_vars('chat', array(
            'TEXT'        => $message,
        ));
    }
  
    $excluded_group_chat_csv = $user->get_excluded_group_chat(AUTH_VIEW);
    $whereSqlCG = ($excluded_group_chat_csv) ? "
        WHERE group_id NOT IN($excluded_group_chat_csv)
    " : '';


    $sql = 'SELECT group_id, group_name
        FROM '. BB_CHAT_GROUP ."
            $whereSqlCG
        ORDER BY group_order, group_id";

    if (!$result = DB()->sql_query($sql))
    {
        message_die(GENERAL_ERROR, "Couldn't get list of Categories".$excluded_group_chat_csv."", "", __LINE__, __FILE__, $sql);
    }
    $max_group_rows        = 100;
    $max_group_len        = 200;
    $rowset = DB()->sql_fetchrowset($result);

    $opt = '';
    $search_in_forums_fary = array();
    if ($groupOn)
    {
        if($groupNum)
        {
            foreach ($rowset as $c_data_id)
            {
                $allowed_cat[] = $c_data_id['group_id'];
            }
            $categoryArr = (array) $groupNum;
            array_deep($categoryArr, 'intval');
            $valid_forums = array_intersect($categoryArr, $allowed_cat);
            $cat_val = join(',', $valid_forums);
        }
        if ($cat_val)
        {
            $search_in_cat_ary  = explode(',', $cat_val);
            $search_in_cat_fary = array_flip($search_in_cat_ary);
        }
    }

    foreach ($rowset as $c_data)
    {
        $group_chat_name = $c_data['group_name'];
        $group_chat_name = str_short($group_chat_name, $max_group_len);
        $selected = (isset($search_in_cat_fary[$c_data['group_id']])) ? HTML_SELECTED : '';
        $opt .= '<option id="'. $c_data['group_id'] .'" value="'. $c_data['group_id'] .'"'. $selected .'>'. $group_chat_name ."&nbsp;</option>\n";
    }

    $catSelect = "\n".'<select class="textCtrl" style="width: 100%;" name="group_chat">'. $opt ."</select>\n";
    $template->assign_vars(array(
        'CHAT_ID'            => (int) @$sql_ch[0]['id'],
        'GROUP_ID'            => ($groupOn) ? $group : $groupNum,
        'GROUP_CHAT'        => $catSelect,
        'CHAT_BBCODE_ON'    => $bb_cfg['chat_bbcode_on'],
        'CHAT_ON'            => $bb_cfg['chat_on'],
    ));
}

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- любой.tpl

-----[в удобное для вас место, добавить]-----

<!-- IF CHAT_ON -->
<link rel="stylesheet" href="{TPL_DIR}/chat.css?v={$bb_cfg['css_ver']}" type="text/css">
<h3></h3>
<div class="spacer">&nbsp;</div>
<div class="post_body_m">
    <table width="100%" cellpadding="3">
        <tr>
            <td>
                <a class="footeri" >{L_CHAT}</a> [<a href="chat.php" >История</a>]
                <div align="center" class="hrs"></div>
            </td>
        </tr>
        <tr>
            <td style="max-width: 250px;">
                <div class="tCenter" >
                    <form id="QuickChat" name="post">
                    <!-- IF LOGGED_IN -->
                    {GROUP_CHAT}
                    <textarea id="message" class="chat_message w90" onkeydown="submit_click(event)"></textarea>
                    <!-- IF CHAT_BBCODE_ON -->
                    <div class="buttons mrg_4">
                        <input type="button" value="B" name="codeB" title="{L_BOLD}" style="font-weight: bold; width: 30px;" />
                        <input type="button" value="i" name="codeI" title="{L_ITALIC}" style="width: 30px; font-style: italic;" />
                        <input type="button" value="u" name="codeU" title="{L_UNDERLINE}" style="width: 30px; text-decoration: underline;" />
                        <input type="button" value="s" name="codeS" title="{L_STRIKEOUT}" style="width: 30px; text-decoration: line-through;" />&nbsp;&nbsp;
                        <input type="button" value="{L_QUOTE}" name="codeQuote" title="{L_QUOTE_TITLE}" style="width: 57px;" />
                        <input type="button" value="Img" name="codeImg" title="{L_IMG_TITLE}" style="width: 40px;" />
                        <input type="button" value="{L_URL}" name="codeUrl" title="{L_URL_TITLE}" style="width: 63px; text-decoration: underline;" />
                        <input type="hidden" name="codeUrl2" />&nbsp;
                        <input type="button" value="{L_CODE}" name="codeCode" title="{L_CODE_TITLE}" style="width: 43px;" />
                        <input type="button" value="{L_LIST}" name="codeList" title="{L_LIST_TITLE}" style="width: 60px;" />
                        <input type="button" value="1." name="codeOpt" title="{L_LIST_ITEM}" style="width: 30px;" />&nbsp;
                        <input type="button" value="{L_QUOTE_SEL}" name="quoteselected" title="{L_QUOTE_SELECTED}" onmouseout="bbcode.refreshSelection(false);" onmouseover="bbcode.refreshSelection(true);" onclick="bbcode.onclickQuoteSel();" />&nbsp;
                    </div>
                    <script type="text/javascript">
                        var bbcode = new BBCode("message");
                        var ctrl = "ctrl";

                        bbcode.addTag("codeB", "b", null, "B", ctrl);
                        bbcode.addTag("codeI", "i", null, "I", ctrl);
                        bbcode.addTag("codeU", "u", null, "U", ctrl);
                        bbcode.addTag("codeS", "s", null, "S", ctrl);

                        bbcode.addTag("codeQuote", "quote", null, "Q", ctrl);
                        bbcode.addTag("codeImg", "img", null, "R", ctrl);
                        bbcode.addTag("codeUrl", "url", "/url", "", ctrl);
                        bbcode.addTag("codeUrl2", "url=", "/url", "W", ctrl);

                        bbcode.addTag("codeCode", "code", null, "K", ctrl);
                        bbcode.addTag("codeList",  "list", null, "L", ctrl);
                        bbcode.addTag("codeOpt", "*", "", "0", ctrl);
                    </script>
                    <!-- ENDIF -->
                    <div class="floatR pad_4 cmh_mask_links">                      
                        <span class="button_a" title="{L_SUBMIT_CHAT}" id="submit_chat" onclick="submit_chat(); return false;">{L_SUBMIT}</span>
                        <span class="button_a" title="{L_CLEAR}" id="submit_chat" onclick="$('.chat_message').attr('value', ''); $('.chat_message').focus();">&nbsp;X&nbsp;</span>
                        <span class="button_a" title="{L_SMILES}" id="submit_chat" onclick="window.open('posting.php?mode=smilies', '_smilies', 'height=540, resizable=yes, scrollbars=yes ,width=620, left=360, top=60'); return false;">&nbsp;:)&nbsp;</span>
                        <span class="button_a" title="{L_DELETE_MARKED}" id="submit_chat" onclick="del_message_chat();">&#8224;</span>
                        <img title="{L_UPDATE_CHAT}" onclick="get_message_chat(1);" src="{SITE_URL}images/pic_loading.gif">
                    </div>
                    <!-- ELSE -->
                    Зарегистрируйтесь для общения в чате.
                    <!-- ENDIF -->
                    <div class="clear"></div>
                    <div class="spacer_2"></div>
                    <div class="tLeft w100" id="chat">
                        <!-- BEGIN chat -->{chat.TEXT}<!-- END chat -->
                    </div>
                    </form>
                </div>
            <div class="cat_separator"></div>
            </td>
        </tr>
    </table>
</div>
<!-- IF LOGGED_IN -->
<script type="text/javascript">
var id = {CHAT_ID};
var group = {GROUP_ID};  
var lastgroup = {GROUP_ID};  

$('select[name="group_chat"]').change(function (){
    lastgroup = group;
    group = $(this).val();
    get_message_chat(0);
    $('span.activeEditChat').removeClass('activeEditChat').hide();
});  

ajax.callback.chat = function(data) {
    if(data.up) $('#chat').scrollTop(0);
  
    if(data.clear) {
        $('.chat_message').attr('value', '');
        get_message_chat(1);
    }
    else if(data.del) {
        for(i=0; i < data.del.length; i++) {
            $('#pp_'+ data.del[i]).hide();
        }
    }else if(data.html){
        $('#pp_'+ data.post_id).show().html(data.html);
        initPostBBCode('#pp_'+ data.post_id);
        $('#pe_'+ data.post_id).hide();
        ajax.open = false;
    } else if(data.text){
        ajax.open = data.post_id;
        $('#pe_'+ data.post_id).html(data.text);
    }
    else {
        if(data.message) $('#chat').prepend(data.message);
    }
  
    if(data.insert) {
        $('span.activeEditChat').removeClass('activeEditChat').hide();
        ajax.open = false;
        initPostBBCode('#pp_'+ data.post_id);
    }
  
    if(data.update) {
        $('#chat').html(data.message);
        initPostBBCode('#chat');
    }
    if(data.id) id = data.id;
    if(data.group) group = data.group;
    if(data.lastgroup) lastgroup = data.lastgroup;  
};
setInterval(function(){ get_message_chat(0); }, 25000);

function get_message_chat(up){
    ajax.exec({action : 'chat', mode: 'select', id: id, group: group, lastgroup: lastgroup, up: up});
}
function submit_click(e) {
    e = e || window.event;
    if (e.keyCode == 13 && e.ctrlKey) {
        submit_chat();
    };
}
function submit_chat(){
    var message = $('.chat_message').val();
    if (message.length < 3) {
        alert('Вы должны ввести текст сообщения');
        $('.chat_message').focus();
        return false;
    }
    ajax.exec({action : 'chat', mode: 'insert', group: group, lastgroup: lastgroup, message: message});
}
function add_nick(text){
    var message = $('.chat_message').val();
    $('.chat_message').attr('value', message + text +' ');
    $('.chat_message').focus();
}
ajax.open = false;
function edit_comment (post_id, text, type) {
    if(ajax.open && ajax.open != post_id) {
        alert('У вас уже открыто одно быстрое редактирование!');
    } else{
        if(ajax.open && !text){
            $('#pp_'+ post_id).show();
            $('#pe_'+ post_id).hide().removeClass('activeEditChat');
        } else{
            $('#pp_'+ post_id).hide();
            $('#pe_'+ post_id).show().addClass('activeEditChat');

            ajax.exec({
                action  : 'chat',
                mode    : 'edit',
                post_id : post_id,
                text    : text,
                group    : group,
                lastgroup: lastgroup,
                type    : type
            });
        }
        ajax.open = false;
    }
}
function del_message_chat(){
    if(!confirm('Вы уверены, что хотите удалить эти сообщения?')) return false;
    var ids = 0;
    $('input.chat-post:checked').each(function(){
        ids += ','+ this.value;
    });
    if(!ids) alert('Вы не выбрали сообщения.');
    else ajax.exec({action : 'chat', mode: 'delete', group: group, ids: ids});
}
function set_hid_chbox(id)
{
    $('#pp_'+ id).toggleClass('hl-selected-post');
    return false;
}
</script>
<!-- ENDIF -->
<!-- ENDIF -->

####[СОХРАНИТЬ_ФАЙЛ]####


####[ОТКРЫТЬ]----- admin_board.php

-----[найти]-----

            'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'],

-----[ниже добавить]-----

            'CHAT_ON' => ($new['chat_on']) ? true : false,
            'CHAT_BBCODE_ON' => ($new['chat_bbcode_on']) ? true : false,
            'CHAT_MESSAGE' => $new['chat_message'],

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- admin_board.tpl

-----[найти]-----

<tr>
    <td><h4>{L_DESIGNER}</h4></td>
    <td>
        <label><input type="radio" name="new_tpls" value="1" <!-- IF NEW_TPLS -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
        <label><input type="radio" name="new_tpls" value="0" <!-- IF not NEW_TPLS -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
    </td>
</tr>

-----[ниже добавить]-----

<tr class="row3 med">
    <td class="bold tCenter" colspan="2">{L_CHAT_CFG}</td>
</tr>
<tr>
    <td><h4>{L_CHAT_ON}</h4></td>
    <td>
        <label><input type="radio" name="chat_on" value="1" <!-- IF CHAT_ON -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
        <label><input type="radio" name="chat_on" value="0" <!-- IF not CHAT_ON -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
    </td>
</tr>
<tr>
    <td><h4>{L_CHAT_BBCODE}</h4></td>
    <td>
        <label><input type="radio" name="chat_bbcode_on" value="1" <!-- IF CHAT_BBCODE_ON -->checked="checked"<!-- ENDIF --> />{L_ENABLED}</label>&nbsp;&nbsp;
        <label><input type="radio" name="chat_bbcode_on" value="0" <!-- IF not CHAT_BBCODE_ON -->checked="checked"<!-- ENDIF --> />{L_DISABLED}</label>
    </td>
</tr>
<tr>
    <td><h4>{L_CHAT_MESS}</h4><h6>{L_CHAT_MESS_EXPLAIN}</h6></td>
    <td><input class="post" type="text" size="3" maxlength="4" name="chat_message" value="{CHAT_MESSAGE}" /></td>
</tr>

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- admin_groups.php

-----[найти]-----

            'group_type'        => $row['group_type'],

-----[ниже добавить]-----

            'group_reed_chat'   => $row['group_reed_chat'],

-----[найти]-----

            'group_type'        => GROUP_OPEN,

-----[ниже добавить]-----

            'group_reed_chat'   => 0,

-----[найти]-----

        'S_HIDDEN_FIELDS'        => $s_hidden_fields,

-----[ниже добавить]-----

        'S_GROUP_REED_CHAT_YES'     => ($group_info['group_reed_chat']) ? ' checked="checked"' : '',
        'S_GROUP_REED_CHAT_NO'     => (!$group_info['group_reed_chat']) ? ' checked="checked"' : '',

-----[найти]-----

        $group_moderator = isset($_POST['username']) ? $_POST['username'] : '';

-----[ниже добавить]-----

        $group_reed_chat = (isset($_POST['group_reed_chat'])) ? intval($_POST['group_reed_chat']) : 0;

-----[найти]-----

            'group_single_user' => 0,

-----[ниже добавить]-----

            'group_reed_chat'   => $group_reed_chat,

####[СОХРАНИТЬ_ФАЙЛ]####

####[ОТКРЫТЬ]----- admin_groups.tpl

-----[найти]-----

<tr>
    <td>{L_GROUP_STATUS}:</td>
    <td class="row2 med">
        <div><input type="radio" name="group_type" value="{S_GROUP_OPEN_TYPE}" {S_GROUP_OPEN_CHECKED} /> {L_GROUP_OPEN}</div>
        <div><input type="radio" name="group_type" value="{S_GROUP_CLOSED_TYPE}" {S_GROUP_CLOSED_CHECKED} />    {L_GROUP_CLOSED}</div>
        <div><input type="radio" name="group_type" value="{S_GROUP_HIDDEN_TYPE}" {S_GROUP_HIDDEN_CHECKED} />    {L_GROUP_HIDDEN}</div>
    </td>
</tr>

-----[ниже добавить]-----

<tr>
    <td class="row1" width="38%"><span class="gen">{L_GROUP_REED_CHAT}:</span></td>
    <td class="row2" width="62%">
    <input type="radio" name="group_reed_chat" value="1" {S_GROUP_REED_CHAT_YES} /> {L_YES} &nbsp;&nbsp;<input type="radio" name="group_reed_chat" value="0" {S_GROUP_REED_CHAT_NO} /> {L_NO}</td>
</tr>

####[СОХРАНИТЬ_ФАЙЛ]####

|||||||||||||||||||||||||||||||||||||
|        ЗАПУСТИТЕ CRON ЗАДАЧУ        |
|                И                    |
|           ОЧИСТИТЕ КЕШ!!!!!        |
|||||||||||||||||||||||||||||||||||||
  • Снимок.JPG
    Снимок.JPG
    55.7 KB · Просмотры: 172
  • Мне нравится
Реакции: boko
Автор
Exile
Скачивания
42
Просмотры
104
Первый выпуск
Обновление
Оценка
5.00 звёзд 1 оценок

Другие ресурсы пользователя Exile

Сверху