Kolor rangi w nicku na shoutboxie

Założony przez  mateusztb.

wersja skryptu MyBB: 1.6.12
adres forum: www.OnlyFrags.pl/forum/
na czym polega problem (screen, opis, komunikaty, nazwa stylu/theme/szablonu): Nie wiem co jest ... Nie działa mi to : https://webboard.pl/attachment.php?aid=7366

dvz_shoutbox.php
<?php
/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2012
released under Creative Commons BY-NC-SA 3.0 license: http://creativecommons.org/licenses/by-nc-sa/3.0/ */
/* Adproof version */

$plugins->add_hook('global_end', 'dvz_sb_init');
$plugins->add_hook('xmlhttp', 'dvz_sb_xmlhttp');
$plugins->add_hook('index_end', 'dvz_shoutbox');

function dvz_shoutbox_info ()
{
    return array(
        'name'           => 'DVZ Shoutbox',
        'description'    => 'Lightweight AJAX chat',
        'website'        => 'http://devilshakerz.com/',
        'author'         => 'Tomasz \'Devilshakerz\' Młyński',
        'authorsite'     => 'http://devilshakerz.com/',
        'version'        => '1.0',
        'guid'           => 'a54d9c66ae174f090b6345ce19e7a063',
        'compatibility'  => '16*',
    );
}

function dvz_shoutbox_is_installed () {
        global $db;
        $query = $db->simple_select('settinggroups', '*', 'name=\'dvz_shoutbox\'');
        return $db->num_rows($query);
}

function dvz_shoutbox_install () {
    global $db;

    // table
    $db->write_query("CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."dvz_shoutbox` (
      `id` int(11) NOT NULL auto_increment,
      `uid` int(11) NOT NULL,
      `text` text NOT NULL,
      `date` int(11) NOT NULL,
      `ip` varchar(15) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM");

    $db->write_query("INSERT INTO ".TABLE_PREFIX."dvz_shoutbox VALUES (NULL, 1, 'DVZ Shoutbox!', ".time().", '127.0.0.1')");

    // settings
    $db->write_query("INSERT INTO `".TABLE_PREFIX."settinggroups` VALUES (NULL, 'dvz_shoutbox', 'DVZ Shoutbox', 'Settings for DVZ Shoutbox.', 1, 0)");
    $sgID = $db->insert_id();

    $db->write_query("INSERT INTO `".TABLE_PREFIX."settings` VALUES
        (NULL, 'dvz_sb_num', 'Shouts to display', 'Number of last posted shouts displayed in the Shoutbox window.', 'text', '20', 1, $sgID, 0),
        (NULL, 'dvz_sb_num_archive', 'Shouts on archive view', 'Shouts to display per page on archive view.', 'text', '15', 2, $sgID, 0),
        (NULL, 'dvz_sb_height', 'Shoutbox height', 'Height of the Shoutbox window in pixels.', 'text', '200', 3, $sgID, 0),
        (NULL, 'dvz_sb_interval', 'Refresh interval', 'Maximum number of seconds before new posted shouts are displayed in the window (lower values provide better synchronization, although cause higher server load).', 'text', '5', 4, $sgID, 0),
        (NULL, 'dvz_sb_away', 'Away mode', 'Number of seconds after last user action (e.g. click) after which auto-refreshing will be disabled to prevent unnecessary usage of server resources. Set 0 to disable.', 'text', '600', 5, $sgID, 0),
        (NULL, 'dvz_sb_antiflood', 'Anti-flood protection', 'Minimum number of seconds before user can post next shout (this does not apply to moderators).', 'text', '5', 6, $sgID, 0),
        (NULL, 'dvz_sb_minposts', 'Minimum posts to shout', 'Set 0 to allow everyone.', 'text', '0', 7, $sgID, 0),
        (NULL, 'dvz_sb_blocked_users', 'Banned users', 'Comma-separated list of user IDs that are banned from posting.', 'textarea', '', 8, $sgID, 0),
        (NULL, 'dvz_sb_groups_view', 'Groups access', 'Comma-separated list of user groups that can view Shoutbox. Leave unfilled to let everyone view (including guests).', 'text', '', 9, $sgID, 0),
        (NULL, 'dvz_sb_groups_post', 'Groups post access', 'Comma-separated list of user groups that can post messages in Shoutbox. Leave unfilled to let everyone post (excluding guests).', 'text', '', 10, $sgID, 0),
        (NULL, 'dvz_sb_groups_mod', 'Moderator groups', 'Comma-separated list of users groups that can moderate the Shoutbox (edit and delete messages).', 'text', '', 11, $sgID, 0),
        (NULL, 'dvz_sb_supermods', 'Supermods as Shoutbox moderators', 'Automatically allow board super moderators to moderate Shoutbox either.', 'yesno', '1', 12, $sgID, 0)
    ");

    rebuild_settings();

    // templates
    $template_shoutbox = '
<div class="tablehead">Shoutbox<p class="right"><a href="{$mybb->settings[bburl]}/index.php?action=shoutbox_archive">&laquo; {$lang->dvz_sb_archivelink}</a></p></div>
<div id="shoutbox">
<div class="panel-away" style="display:none"><button class="button" onclick="dvz_shoutbox.setBack()">{$lang->dvz_sb_away_button}</button>{$lang->dvz_sb_away}</div>
{$dvz_shoutbox_panel}
<div id="shoutbox_data" style="height:{$mybb->settings[dvz_sb_height]}px; overflow:auto;"></div>
</div>

<script type="text/javascript" src="jscripts/dvz_shoutbox.js"></script>
<script>
now = new Date;
dvz_shoutbox.userLastAction = now.getTime();
dvz_shoutbox.interval = {$mybb->settings[dvz_sb_interval]};
dvz_shoutbox.antiflood = {$mybb->settings[dvz_sb_antiflood]};
dvz_shoutbox.maxShouts = {$mybb->settings[dvz_sb_num]};
dvz_shoutbox.awayTimeout = {$mybb->settings[dvz_sb_away]}*1000;
dvz_shoutbox.lang = [\'{$lang->dvz_sb_delete_confirm}\', \'{$lang->dvz_sb_antiflood}\'];
{$dvz_shoutbox_js}
dvz_shoutbox.checkForMessages();
</script>';

    $template_archive = '<html>
<head>
<title>{$lang->dvz_sb_archive}</title>
{$headerinclude}
</head>
<body>
{$header}

<script type="text/javascript" src="jscripts/dvz_shoutbox.js"></script>
{$dvz_shoutbox_js}

{$multipage}

<div class="tablehead">{$lang->dvz_sb_archive}</div>
<div id="shoutbox">
{$messagesList}
</div>
<br />

{$multipage}

{$footer}
</body>
</html>';

    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox', '".$db->escape_string($template_shoutbox)."', '-1', '1', '', '".time()."')");
    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox_archive', '".$db->escape_string($template_archive)."', '-1', '1', '', '".time()."')");

}

function dvz_shoutbox_activate () {
}

function dvz_shoutbox_deactivate () {
}

function dvz_shoutbox_uninstall () {
    global $db;

    $sgID = $db->simple_select('settinggroups', 'gid', 'name=\'dvz_shoutbox\'');
    $sgID = $db->fetch_field($sgID, 'gid');

    $db->delete_query('settinggroups', 'name=\'dvz_shoutbox\'');
    $db->delete_query('settings', 'gid='.$sgID);
    $db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title IN('dvz_shoutbox', 'dvz_shoutbox_archive')");
    $db->query("DROP TABLE ".TABLE_PREFIX.'dvz_shoutbox');
}

function dvz_sb_init () {
    global $mybb, $lang;
    $lang->load("dvz_shoutbox");
    if ($mybb->input['action'] == 'shoutbox_archive') {
        return dvz_sb_show_archive();
    }
}

function dvz_shoutbox ($page_data) {
    global $templates, $dvz_shoutbox, $lang, $mybb;

    $dvz_shoutbox = null;
    $dvz_shoutbox_js = null;
    $dvz_shoutbox_panel = null;

    if (dvz_sb_access_view()) {
        if ($mybb->user['uid']) {
            if (dvz_sb_user_blocked()) {
                $dvz_shoutbox_panel = '<div class="panel-blocked">'.$lang->dvz_sb_user_blocked.'</div>';
            }
            elseif (!dvz_sb_access_minposts() && !dvz_sb_access_mod()) {
                $text = str_replace('{MINPOSTS}', $mybb->settings['dvz_sb_minposts'], $lang->dvz_sb_minposts);
                $dvz_shoutbox_panel = '<div class="panel-minposts">'.$text.'</div>';
            }
            else if (dvz_sb_access_post()) {
                $dvz_shoutbox_panel = '<div class="panel"><form onsubmit="dvz_shoutbox.shout();return false"><input type="text" id="shout_text" placeholder="'.$lang->dvz_sb_default.'" autocomplete="off" /><input type="submit" value="'.$lang->dvz_sb_button.' &raquo;" id="shout_button" /><img src="'.$mybb->settings['bburl'].'/images/loading-mini.gif" style="display:none" id="dvz_sb_loading" /></form></div>';
            }
            if (dvz_sb_access_mod()) {
                $dvz_shoutbox_js = 'dvz_shoutbox.godMode = true;';
            }
        }

        eval('$dvz_shoutbox = "'.$templates->get('dvz_shoutbox').'";');
    }
}

function dvz_sb_xmlhttp () {
    global $mybb, $lang, $charset;

    $lang->load("dvz_shoutbox");

    header('Content-type: text/html; charset='.$charset);

    switch ($mybb->input['action']) {
        case 'dvz_sb_check':
            if (!dvz_sb_access_view()) exit;
            echo '##SB##'; // Adproof
            dvz_sb_xmlhttp_get_messages(intval($mybb->input['from']));
            echo '##SB##'; // Adproof
            exit;
        break;
        case 'dvz_sb_post':
            if (!verify_post_check($mybb->input['key'], true)) exit;
            echo dvz_sb_shout($mybb->input['text']);
            exit;
        break;
        case 'dvz_sb_edit_get':
            if (!dvz_sb_access_mod()) exit;
            if (!verify_post_check($mybb->input['key'], true)) exit;
            echo '##SB##'; // Adproof
            echo dvz_sb_get(intval($mybb->input['id']));
            echo '##SB##'; // Adproof
            exit;
        break;
        case 'dvz_sb_edit_save':
            if (!dvz_sb_access_mod()) exit;
            if (!verify_post_check($mybb->input['key'], true)) exit;
            dvz_sb_update(intval($mybb->input['id']), $mybb->input['text']);
            exit;
        break;
    }
}

function dvz_sb_xmlhttp_get_messages ($from=0) {
    global $mybb;

    $entries = 0;

    $data = dvz_sb_messages("WHERE s.id > $from ORDER by s.id DESC LIMIT {$mybb->settings[dvz_sb_num]}", true);

    if (!empty($data['html'])) echo json_encode($data);
}

function dvz_sb_show_archive () {
    global $db, $mybb, $templates, $lang, $footer, $headerinclude, $header, $charset;

    if (!dvz_sb_access_view()) return false;

    if (dvz_sb_access_mod()) {
        $dvz_shoutbox_js = '<script>dvz_shoutbox.godMode = true;</script>';

        if ($mybb->input['delete']) {
            if (verify_post_check($mybb->input['key'], true))
            {
                dvz_sb_delete($mybb->input['delete']);
            }
        }
    }

    header('Content-type: text/html; charset='.$charset);

    $messages = $db->simple_select('dvz_shoutbox', 'COUNT(*) as messages');
    $messages = $db->fetch_field($messages, 'messages');

    $pageNum = intval($mybb->input['page']);
    $perPage = $mybb->settings['dvz_sb_num_archive'];
    $pages = ceil($messages / $perPage);

    if (!$pageNum || $pageNum < 1 || $pageNum > $pages) $pageNum = 1;

    $start = ($pageNum - 1) * $perPage;

    if ($messages > $perPage) {
        $multipage = multipage($messages, $perPage, $pageNum, 'index.php?action=shoutbox_archive');
    }
    add_breadcrumb($lang->dvz_sb_shoutbox, "index.php?action=shoutbox_archive");

    $messagesList = dvz_sb_messages("ORDER by s.id DESC LIMIT $start,$perPage", false, 'archive');

    eval('$content = "'.$templates->get("dvz_shoutbox_archive").'";');

    output_page($content);
    exit;
}

function dvz_sb_messages ($queryClauses, $dataArray=false, $mode=false) {
    global $db, $mybb, $lang;

    require_once MYBB_ROOT.'inc/class_parser.php';
    $parser = new postParser;

    $html = '';
    $lastMessageID = 0;

    // , u.avatar
    $query = $db->query("
        SELECT s.*, u.username, u.usergroup, u.displaygroup, u.avatar
        FROM ".TABLE_PREFIX."dvz_shoutbox s LEFT JOIN ".TABLE_PREFIX."users u ON u.uid = s.uid
        $queryClauses
    ");

    while ($entry = $db->fetch_array($query)) {
        $parser_options = array(
                'allow_mycode' => 1,
                'allow_smilies' => 1,
                'allow_imgcode' => 0,
                'me_username' => $entry['username']
        );

        $messageID = $entry['id'];
        $message = $parser->parse_message($entry['text'], $parser_options);
        $avatarURL = empty($entry['avatar']) ? 'images/default_avatar.gif' : $entry['avatar'];
        $avatarIMG = '<img src="'.$avatarURL.'" class="avatar" alt="avatar" />';
        $usernameFormatted = format_name($entry['username'], $entry['usergroup'], $entry['displaygroup']);
        $username = '<a href="member.php?action=profile&uid='.intval($entry['uid']).'">'.$avatarIMG.' '.$usernameFormatted.'</a>';
        $date_time = my_date('d/m H:i', $entry['date']);

        $insertArrow = '<span title="'.$lang->dvz_sb_insert_name.'" class="insUser" onclick="dvz_shoutbox.insertUsername(\''.'[gid='.$entry['usergroup'].']'.$entry['username'].'[/gid]'.'\')">@</span>';  
        if (dvz_sb_access_mod()) {
            if ($mode == 'archive') {
                $modOptions = '<a href="javascript:dvz_shoutbox.edit('.$messageID.')" title="'.$lang->dvz_sb_edit.'" class="mod">E</a> <a onclick="return confirm(\''.$lang->dvz_sb_delete_confirm.'\')" href="index.php?action=shoutbox_archive&delete='.$messageID.'&key='.$mybb->post_code.'" title="'.$lang->dvz_sb_delete.'" class="mod dvz_sb_del">X</a>';
            } else {
                $modOptions = '<a href="javascript:dvz_shoutbox.edit('.$messageID.')" title="'.$lang->dvz_sb_edit.'" class="mod">E</a> <a onclick="return dvz_shoutbox.delConfirm(this)" href="index.php?action=shoutbox_archive&delete='.$messageID.'" title="'.$lang->dvz_sb_delete.'" class="mod dvz_sb_del">X</a>';
            }
        }

        $class = alt_trow();

        $html .= "<div class='sbentry $class' id='shout-$messageID'><p class='userdata'>$insertArrow $username:</p><p class='info'><span class='date'>$date_time</span>$modOptions</p><p class='text'>$message</p><div class='clear'></div></div>\r\n";

        if ($lastMessageID == 0) $lastMessageID = $messageID;
    }

    return $dataArray ?
        array (
            'html' => $html,
            'last_id' => $lastMessageID
        )
    : $html;

}

// actions
function dvz_sb_shout ($text) {
    global $db, $mybb;

    if (!dvz_sb_access_post()) return false;

    if ($mybb->settings['dvz_sb_antiflood'] && !dvz_sb_access_mod()) {
        $lastShoutTime = $db->fetch_field(
            $db->simple_select('dvz_shoutbox', 'date', 'uid='.$mybb->user['uid'], array(
                'order_by' => 'date',
                'order_dir' => 'desc',
                'limit' => 1
        )), 'date');
        $timeBetween = time() - $lastShoutTime;
        if ($timeBetween <= $mybb->settings['dvz_sb_antiflood']) die('antiflood');
    }

    $shout_data = array(
            'uid' => $mybb->user['uid'],
            'text' => $db->escape_string($text),
            'date' => time(),
            'ip' => get_ip()
    );
    $db->insert_query('dvz_shoutbox', $shout_data);

    exit;
}
function dvz_sb_get ($id) {
    global $db;
    return $db->fetch_field( $db->simple_select('dvz_shoutbox', 'text', 'id='.intval($id)) , 'text');
}
function dvz_sb_update ($id, $text) {
    global $db;
    return $db->update_query('dvz_shoutbox', array('text' => $text), 'id='.intval($id));
}
function dvz_sb_delete ($id) {
    global $db;
    return $db->delete_query('dvz_shoutbox', 'id='.intval($id));
}

// permissions
function dvz_sb_access_view () {
    global $mybb;
    $allowedGroups = dvz_sb_getcsv('groups_view');
    return (
        empty($allowedGroups) ||
        dvz_sb_memberOf($allowedGroups)
    );
}
function dvz_sb_access_post () {
    global $mybb;
    $allowedGroups = dvz_sb_getcsv('groups_post');
    return (
        !($mybb->user['usergroup'] == 1 && $mybb->user['uid'] < 1) &&
        (
            dvz_sb_access_mod() ||
            (
                dvz_sb_access_view() &&
                !dvz_sb_user_blocked() &&
                dvz_sb_access_minposts() &&
                (
                    empty($allowedGroups) ||
                    dvz_sb_memberOf($allowedGroups)
                )
            )
        )
    );
}
function dvz_sb_access_mod () {
    global $mybb;
    $allowedGroups = dvz_sb_getcsv('groups_mod');
    return (
        dvz_sb_memberOf($allowedGroups) ||
        ($mybb->settings['dvz_sb_supermods'] && $mybb->usergroup['issupermod'])
    );
}
function dvz_sb_user_blocked () {
    global $mybb;
    $blockedUsers = dvz_sb_getcsv('blocked_users');
    return in_array($mybb->user['uid'], $blockedUsers);
}
function dvz_sb_access_minposts () {
    global $mybb;
    return $mybb->user['postnum'] >= $mybb->settings['dvz_sb_minposts'];
}

// library
function dvz_sb_memberOf ($groupsArray) {
    global $mybb, $dvz_sb_userGroups;
    if (!isset($dvz_sb_userGroups)) {
        $dvz_sb_userGroups = explode(',', $mybb->user['additionalgroups']);
        $dvz_sb_userGroups[] = $mybb->user['usergroup'];
    }
    return array_intersect($dvz_sb_userGroups, $groupsArray);
}
function csv2array ($input){
    if (function_exists('str_getcsv')) return str_getcsv($input);

    $fields = explode(',', $input);
    if (!$fields) $fields = array($input);

    return($fields);
}
function dvz_sb_getcsv ($name) {
    global $mybb;
    $groups = csv2array($mybb->settings['dvz_sb_'.$name]);
    if (count($groups) == 1 && $groups[0] == '') return Array();
    return $groups;
}

?>

Wyrażenie regularne * w mycode
\[gid=(.*?)\](.*?)\[/gid\]

Zamiana *
<span class="gid_$1">$2</span>

końcówka global.css
.gid_4 {
color: #FF0000;
font-weight: bold;
}

.gid_6 {
color: #008000;
font-weight: bold;
}

gid 4 to administrator , gid 6 to moderator ,a nadal na shoutboxie jest tylko pogrubienie ,a nie ma koloru :(
Co Ci dokładniej nie działa, bo nie opisałeś problemu, nie dałeś żadnych screenów, apo wejściu na forum nawet shoutboxa nie widać.
Twój problem polega na tym, że nie koloruje Ci ników użytkowników w shoutach, czy że nie działa Ci na shoutboxie twój własny MyCode?
:: Akcja DZIĘKUJĘ ZA POMOC ::
Pomocy udzielam jedynie na forum. Wszystkie rzeczy wykraczające poza tą dziedzinę wykonuję odpłatnie.
Jemu chodzi o to że nie koloruje mu nikców jakie ma grupa... Ja też mam z tym problem...
A wykonaliście poniższy krok ?

W pliku inc/plugins/dvz_shoutbox.php wyszukujemy linię:

$insertArrow = '<span title="'.$lang->dvz_sb_insert_name.'" class="insUser" onclick="dvz_shoutbox.insertUsername(\''.$entry['username'].'\')">&raquo;</span>';

zamieniamy na:

$insertArrow = '<span title="'.$lang->dvz_sb_insert_name.'" class="insUser" onclick="dvz_shoutbox.insertUsername(\''.'[gid='.$entry['usergroup'].']'.$entry['username'].'[/gid]'.'\')">&raquo;</span>';


Daje kod w razie czego:

<?php
/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2012
released under Creative Commons BY-NC-SA 3.0 license: http://creativecommons.org/licenses/by-nc-sa/3.0/ */

$plugins->add_hook('global_end', 'dvz_sb_init');
$plugins->add_hook('xmlhttp', 'dvz_sb_xmlhttp');
$plugins->add_hook('index_end', 'dvz_shoutbox');

function dvz_shoutbox_info ()
{
    return array(
        'name'           => 'DVZ Shoutbox',
        'description'    => 'Lightweight AJAX chat',
        'website'        => 'http://devilshakerz.com/',
        'author'         => 'Tomasz \'Devilshakerz\' Młyński',
        'authorsite'     => 'http://devilshakerz.com/',
        'version'        => '1.0',
        'guid'           => '',
        'compatibility'  => '16*',
    );
}

function dvz_shoutbox_is_installed () {
        global $db;
        $query = $db->simple_select('settinggroups', '*', 'name=\'dvz_shoutbox\'');
        return $db->num_rows($query);
}



function dvz_shoutbox_install () {
    global $db;

    // table
    $db->write_query("CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."dvz_shoutbox` (
      `id` int(11) NOT NULL auto_increment,
      `uid` int(11) NOT NULL,
      `text` text NOT NULL,
      `date` int(11) NOT NULL,
      `ip` varchar(15) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM");

    $db->write_query("INSERT INTO ".TABLE_PREFIX."dvz_shoutbox VALUES (NULL, 1, 'DVZ Shoutbox!', ".time().", '127.0.0.1')");

    // settings
    $db->write_query("INSERT INTO `".TABLE_PREFIX."settinggroups` VALUES (NULL, 'dvz_shoutbox', 'DVZ Shoutbox', 'Settings for DVZ Shoutbox.', 1, 0)");
    $sgID = $db->insert_id();

    $db->write_query("INSERT INTO `".TABLE_PREFIX."settings` VALUES
        (NULL, 'dvz_sb_num', 'Shouts to display', 'Number of last posted shouts displayed in the Shoutbox window.', 'text', '20', 1, $sgID, 0),
        (NULL, 'dvz_sb_num_archive', 'Shouts on archive view', 'Shouts to display per page on archive view.', 'text', '15', 2, $sgID, 0),
        (NULL, 'dvz_sb_height', 'Shoutbox height', 'Height of the Shoutbox window in pixels.', 'text', '200', 3, $sgID, 0),
        (NULL, 'dvz_sb_interval', 'Refresh interval', 'Maximum number of seconds before new posted shouts are displayed in the window (lower values provide better synchronization, although cause higher server load).', 'text', '5', 4, $sgID, 0),
        (NULL, 'dvz_sb_away', 'Away mode', 'Number of seconds after last user action (e.g. click) after which auto-refreshing will be disabled to prevent unnecessary usage of server resources. Set 0 to disable.', 'text', '600', 5, $sgID, 0),
        (NULL, 'dvz_sb_antiflood', 'Anti-flood protection', 'Minimum number of seconds before user can post next shout (this does not apply to moderators).', 'text', '5', 6, $sgID, 0),
        (NULL, 'dvz_sb_minposts', 'Minimum posts to shout', 'Set 0 to allow everyone.', 'text', '0', 7, $sgID, 0),
        (NULL, 'dvz_sb_blocked_users', 'Banned users', 'Comma-separated list of user IDs that are banned from posting.', 'textarea', '', 8, $sgID, 0),
        (NULL, 'dvz_sb_groups_view', 'Groups access', 'Comma-separated list of user groups that can view Shoutbox. Leave unfilled to let everyone view (including guests).', 'text', '', 9, $sgID, 0),
        (NULL, 'dvz_sb_groups_post', 'Groups post access', 'Comma-separated list of user groups that can post messages in Shoutbox. Leave unfilled to let everyone post (excluding guests).', 'text', '', 10, $sgID, 0),
        (NULL, 'dvz_sb_groups_mod', 'Moderator groups', 'Comma-separated list of users groups that can moderate the Shoutbox (edit and delete messages).', 'text', '', 11, $sgID, 0),
        (NULL, 'dvz_sb_supermods', 'Supermods as Shoutbox moderators', 'Automatically allow board super moderators to moderate Shoutbox either.', 'yesno', '1', 12, $sgID, 0)
    ");

    rebuild_settings();

    // templates
    $template_shoutbox = '
<div class="tablehead">Shoutbox<p class="right"><a href="{$mybb->settings[bburl]}/index.php?action=shoutbox_archive">&laquo; {$lang->dvz_sb_archivelink}</a></p></div>
<div id="shoutbox">
<div class="panel-away" style="display:none"><button class="button" onclick="dvz_shoutbox.setBack()">{$lang->dvz_sb_away_button}</button>{$lang->dvz_sb_away}</div>
{$dvz_shoutbox_panel}
<div id="shoutbox_data" style="height:{$mybb->settings[dvz_sb_height]}px; overflow:auto;"></div>
</div>

<script type="text/javascript" src="jscripts/dvz_shoutbox.js"></script>
<script>
now = new Date;
dvz_shoutbox.userLastAction = now.getTime();
dvz_shoutbox.interval = {$mybb->settings[dvz_sb_interval]};
dvz_shoutbox.antiflood = {$mybb->settings[dvz_sb_antiflood]};
dvz_shoutbox.maxShouts = {$mybb->settings[dvz_sb_num]};
dvz_shoutbox.awayTimeout = {$mybb->settings[dvz_sb_away]}*1000;
dvz_shoutbox.lang = [\'{$lang->dvz_sb_delete_confirm}\', \'{$lang->dvz_sb_antiflood}\'];
{$dvz_shoutbox_js}
dvz_shoutbox.checkForMessages();
</script>';

    $template_archive = '<html>
<head>
<title>{$lang->dvz_sb_archive}</title>
{$headerinclude}
</head>
<body>
{$header}

<script type="text/javascript" src="jscripts/dvz_shoutbox.js"></script>
{$dvz_shoutbox_js}

{$multipage}

<div class="tablehead">{$lang->dvz_sb_archive}</div>
<div id="shoutbox">
{$messagesList}
</div>
<br />

{$multipage}

{$footer}
</body>
</html>';

    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox', '".$db->escape_string($template_shoutbox)."', '-1', '1', '', '".time()."')");
    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox_archive', '".$db->escape_string($template_archive)."', '-1', '1', '', '".time()."')");

}

function dvz_shoutbox_activate () {
}

function dvz_shoutbox_deactivate () {
}

function dvz_shoutbox_uninstall () {
    global $db;

    $sgID = $db->simple_select('settinggroups', 'gid', 'name=\'dvz_shoutbox\'');
    $sgID = $db->fetch_field($sgID, 'gid');

    $db->delete_query('settinggroups', 'name=\'dvz_shoutbox\'');
    $db->delete_query('settings', 'gid='.$sgID);
    $db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title IN('dvz_shoutbox', 'dvz_shoutbox_archive')");
    $db->query("DROP TABLE ".TABLE_PREFIX.'dvz_shoutbox');
}

function dvz_sb_init () {
    global $mybb, $lang;
    $lang->load("dvz_shoutbox");
    if ($mybb->input['action'] == 'shoutbox_archive') {
        return dvz_sb_show_archive();
    }
}

function dvz_shoutbox ($page_data) {
    global $templates, $dvz_shoutbox, $lang, $mybb;

    $dvz_shoutbox = null;
    $dvz_shoutbox_js = null;
    $dvz_shoutbox_panel = null;

    if (dvz_sb_access_view()) {
        if ($mybb->user['uid']) {
            if (dvz_sb_user_blocked()) {
                $dvz_shoutbox_panel = '<div class="panel-blocked">'.$lang->dvz_sb_user_blocked.'</div>';
            }
            elseif (!dvz_sb_access_minposts() && !dvz_sb_access_mod()) {
                $text = str_replace('{MINPOSTS}', $mybb->settings['dvz_sb_minposts'], $lang->dvz_sb_minposts);
                $dvz_shoutbox_panel = '<div class="panel-minposts">'.$text.'</div>';
            }
            else if (dvz_sb_access_post()) {
                $dvz_shoutbox_panel = '<div class="panel"><form onsubmit="dvz_shoutbox.shout();return false"><input type="text" id="shout_text" placeholder="'.$lang->dvz_sb_default.'" autocomplete="off" /><input type="submit" value="'.$lang->dvz_sb_button.' &raquo;" id="shout_button" /><img src="'.$mybb->settings['bburl'].'/images/loading-mini.gif" style="display:none" id="dvz_sb_loading" /></form></div>';
            }
            if (dvz_sb_access_mod()) {
                $dvz_shoutbox_js = 'dvz_shoutbox.godMode = true;';
            }
        }

        eval('$dvz_shoutbox = "'.$templates->get('dvz_shoutbox').'";');
    }
}

function dvz_sb_xmlhttp () {
    global $mybb, $lang, $charset;

    $lang->load("dvz_shoutbox");

    header('Content-type: text/html; charset='.$charset);

    switch ($mybb->input['action']) {
        case 'dvz_sb_check':
            if (!dvz_sb_access_view()) exit;
            dvz_sb_xmlhttp_get_messages(intval($mybb->input['from']));
            exit;
        break;
        case 'dvz_sb_post':
            if (!verify_post_check($mybb->input['key'], true)) exit;
            echo dvz_sb_shout($mybb->input['text']);
            exit;
        break;
        case 'dvz_sb_edit_get':
            if (!dvz_sb_access_mod()) exit;
            if (!verify_post_check($mybb->input['key'], true)) exit;
            echo dvz_sb_get(intval($mybb->input['id']));
            exit;
        break;
        case 'dvz_sb_edit_save':
            if (!dvz_sb_access_mod()) exit;
            if (!verify_post_check($mybb->input['key'], true)) exit;
            dvz_sb_update(intval($mybb->input['id']), $mybb->input['text']);
            exit;
        break;
    }
}

function dvz_sb_xmlhttp_get_messages ($from=0) {
    global $mybb;

    $entries = 0;

    $data = dvz_sb_messages("WHERE s.id > $from ORDER by s.id DESC LIMIT {$mybb->settings[dvz_sb_num]}", true);

    if (!empty($data['html'])) echo json_encode($data);
}

function dvz_sb_show_archive () {
    global $db, $mybb, $templates, $lang, $footer, $headerinclude, $header, $charset;

    if (!dvz_sb_access_view()) return false;

    if (dvz_sb_access_mod()) {
        $dvz_shoutbox_js = '<script>dvz_shoutbox.godMode = true;</script>';

        if ($mybb->input['delete']) {
            if (verify_post_check($mybb->input['key'], true))
            {
                dvz_sb_delete($mybb->input['delete']);
            }
        }
    }

    header('Content-type: text/html; charset='.$charset);

    $messages = $db->simple_select('dvz_shoutbox', 'COUNT(*) as messages');
    $messages = $db->fetch_field($messages, 'messages');

    $pageNum = intval($mybb->input['page']);
    $perPage = $mybb->settings['dvz_sb_num_archive'];
    $pages = ceil($messages / $perPage);

    if (!$pageNum || $pageNum < 1 || $pageNum > $pages) $pageNum = 1;

    $start = ($pageNum - 1) * $perPage;

    if ($messages > $perPage) {
        $multipage = multipage($messages, $perPage, $pageNum, 'index.php?action=shoutbox_archive');
    }
    add_breadcrumb($lang->dvz_sb_shoutbox, "index.php?action=shoutbox_archive");

    $messagesList = dvz_sb_messages("ORDER by s.id DESC LIMIT $start,$perPage", false, 'archive');

    eval('$content = "'.$templates->get("dvz_shoutbox_archive").'";');

    output_page($content);
    exit;
}

function dvz_sb_messages ($queryClauses, $dataArray=false, $mode=false) {
    global $db, $mybb, $lang;

    require_once MYBB_ROOT.'inc/class_parser.php';
    $parser = new postParser;

    $html = '';
    $lastMessageID = 0;

    // , u.avatar
    $query = $db->query("
        SELECT s.*, u.username, u.usergroup, u.displaygroup, u.avatar
        FROM ".TABLE_PREFIX."dvz_shoutbox s LEFT JOIN ".TABLE_PREFIX."users u ON u.uid = s.uid
        $queryClauses
    ");

    while ($entry = $db->fetch_array($query)) {
        $parser_options = array(
                "allow_videocode" => 1,
                'allow_mycode' => 1,
                'allow_smilies' => 1,
                'allow_imgcode' => 1,
                'me_username' => $entry['username']
        );
$message = preg_replace('/https?:\/\/[\w\-\.!~?&+\*\'"(),\/]+/','<a href="$0">$0</a>', $message);
        $messageID = $entry['id'];
        $message = $parser->parse_message($entry['text'], $parser_options);
        $avatarURL = empty($entry['avatar']) ? 'images/default_avatar.gif' : $entry['avatar'];
        $avatarIMG = '<img src="'.$avatarURL.'" class="avatar" alt="avatar" />';
        $usernameFormatted = format_name($entry['username'], $entry['usergroup'], $entry['displaygroup']);
        $username = '<a href="member.php?action=profile&uid='.intval($entry['uid']).'">'.$avatarIMG.' '.$usernameFormatted.'</a>';
        $date_time = my_date('d/m H:i', $entry['date']);

      $insertArrow = '<span title="'.$lang->dvz_sb_insert_name.'" class="insUser" onclick="dvz_shoutbox.insertUsername(\''.'[gid='.$entry['usergroup'].']'.$entry['username'].'[/gid]'.'\')">✛</span>';

        if (dvz_sb_access_mod()) {
            if ($mode == 'archive') {
                $modOptions = '<a href="javascript:dvz_shoutbox.edit('.$messageID.')" title="'.$lang->dvz_sb_edit.'" class="mod">E</a> <a onclick="return confirm(\''.$lang->dvz_sb_delete_confirm.'\')" href="index.php?action=shoutbox_archive&delete='.$messageID.'&key='.$mybb->post_code.'" title="'.$lang->dvz_sb_delete.'" class="mod dvz_sb_del">X</a>';
            } else {
                $modOptions = '<a href="javascript:dvz_shoutbox.edit('.$messageID.')" title="'.$lang->dvz_sb_edit.'" class="mod">E</a> <a onclick="return dvz_shoutbox.delConfirm(this)" href="index.php?action=shoutbox_archive&delete='.$messageID.'" title="'.$lang->dvz_sb_delete.'" class="mod dvz_sb_del">X</a>';
            }
        }

        $class = alt_trow();

        $html .= "<div class='sbentry $class' id='shout-$messageID'><p class='userdata'>$insertArrow $username:</p><p class='info'><span class='date'>$date_time</span>$modOptions</p><p class='text'>$message</p><div class='clear'></div></div>\r\n";

        if ($lastMessageID == 0) $lastMessageID = $messageID;
    }

    return $dataArray ?
        array (
            'html' => $html,
            'last_id' => $lastMessageID
        )
    : $html;

}

// actions
function dvz_sb_shout ($text) {
    global $db, $mybb;

    if (!dvz_sb_access_post()) return false;

    if ($mybb->settings['dvz_sb_antiflood'] && !dvz_sb_access_mod()) {
        $lastShoutTime = $db->fetch_field(
            $db->simple_select('dvz_shoutbox', 'date', 'uid='.$mybb->user['uid'], array(
                'order_by' => 'date',
                'order_dir' => 'desc',
                'limit' => 1
        )), 'date');
        $timeBetween = time() - $lastShoutTime;
        if ($timeBetween <= $mybb->settings['dvz_sb_antiflood']) die('antiflood');
    }

    $shout_data = array(
            'uid' => $mybb->user['uid'],
            'text' => $db->escape_string($text),
            'date' => time(),
            'ip' => get_ip()
    );
    $db->insert_query('dvz_shoutbox', $shout_data);

    exit;
}
function dvz_sb_get ($id) {
    global $db;
    return $db->fetch_field( $db->simple_select('dvz_shoutbox', 'text', 'id='.intval($id)) , 'text');
}
function dvz_sb_update ($id, $text) {
    global $db;
    return $db->update_query('dvz_shoutbox', array('text' => $text), 'id='.intval($id));
}
function dvz_sb_delete ($id) {
    global $db;
    return $db->delete_query('dvz_shoutbox', 'id='.intval($id));
}

// permissions
function dvz_sb_access_view () {
    global $mybb;
    $allowedGroups = dvz_sb_getcsv('groups_view');
    return (
        empty($allowedGroups) ||
        dvz_sb_memberOf($allowedGroups)
    );
}
function dvz_sb_access_post () {
    global $mybb;
    $allowedGroups = dvz_sb_getcsv('groups_post');
    return (
        !($mybb->user['usergroup'] == 1 && $mybb->user['uid'] < 1) &&
        (
            dvz_sb_access_mod() ||
            (
                dvz_sb_access_view() &&
                !dvz_sb_user_blocked() &&
                dvz_sb_access_minposts() &&
                (
                    empty($allowedGroups) ||
                    dvz_sb_memberOf($allowedGroups)
                )
            )
        )
    );
}
function dvz_sb_access_mod () {
    global $mybb;
    $allowedGroups = dvz_sb_getcsv('groups_mod');
    return (
        dvz_sb_memberOf($allowedGroups) ||
        ($mybb->settings['dvz_sb_supermods'] && $mybb->usergroup['issupermod'])
    );
}
function dvz_sb_user_blocked () {
    global $mybb;
    $blockedUsers = dvz_sb_getcsv('blocked_users');
    return in_array($mybb->user['uid'], $blockedUsers);
}
function dvz_sb_access_minposts () {
    global $mybb;
    return $mybb->user['postnum'] >= $mybb->settings['dvz_sb_minposts'];
}

// library
function dvz_sb_memberOf ($groupsArray) {
    global $mybb, $dvz_sb_userGroups;
    if (!isset($dvz_sb_userGroups)) {
        $dvz_sb_userGroups = explode(',', $mybb->user['additionalgroups']);
        $dvz_sb_userGroups[] = $mybb->user['usergroup'];
    }
    return array_intersect($dvz_sb_userGroups, $groupsArray);
}
function csv2array ($input){
    if (function_exists('str_getcsv')) return str_getcsv($input);

    $fields = explode(',', $input);
    if (!$fields) $fields = array($input);

    return($fields);
}
function dvz_sb_getcsv ($name) {
    global $mybb;
    $groups = csv2array($mybb->settings['dvz_sb_'.$name]);
    if (count($groups) == 1 && $groups[0] == '') return Array();
    return $groups;
}

?>
Nie mam czegoś takiego w dvz_shoutbox.php


<?php
/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2014
released under Creative Commons BY-NC-SA 3.0 license: http://creativecommons.org/licenses/by-nc-sa/3.0/ */

$plugins->add_hook('global_end', 'dvz_shoutbox_global_end'); // load language file, catch archive page
$plugins->add_hook('xmlhttp', 'dvz_shoutbox_xmlhttp');      // xmlhttp.php listening
$plugins->add_hook('index_end', 'dvz_shoutbox');           // load Shoutbox window to {$dvz_shoutbox} variable

// MyBB handling
function dvz_shoutbox_info () {
    return array(
        'name'           => 'DVZ Shoutbox',
        'description'    => 'Lightweight AJAX chat.',
        'website'        => 'http://devilshakerz.com/',
        'author'         => 'Tomasz \'Devilshakerz\' Mlynski',
        'authorsite'     => 'http://devilshakerz.com/',
        'version'        => '2.0',
        'guid'           => 'a54d9c66ae174f090b6345ce19e7a063',
        'compatibility'  => '16*',
    );
}
function dvz_shoutbox_install () {
    global $db;

    // table
    $db->write_query("
        CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."dvz_shoutbox` (
            `id` int(11) NOT NULL auto_increment,
            `uid` int(11) NOT NULL,
            `text` text NOT NULL,
            `date` int(11) NOT NULL,
            `ip` varchar(15) NOT NULL,
            PRIMARY KEY (`id`)
        ) ENGINE=MyISAM ".$db->build_create_table_collation()."
    ");

    // example shout
    $db->write_query("INSERT INTO ".TABLE_PREFIX."dvz_shoutbox VALUES (NULL, 1, 'DVZ Shoutbox!', ".time().", '127.0.0.1')");

    // settings
    $db->write_query("INSERT INTO `".TABLE_PREFIX."settinggroups` VALUES (NULL, 'dvz_shoutbox', 'DVZ Shoutbox', 'Settings for DVZ Shoutbox.', 1, 0)");
    $sgID = $db->insert_id();

    $db->write_query("INSERT INTO `".TABLE_PREFIX."settings` VALUES
        (NULL, 'dvz_sb_num', 'Shouts to display', 'Number of shouts displayed in the Shoutbox window.', 'text', '20', 1, $sgID, 0),
        (NULL, 'dvz_sb_num_archive', 'Shouts to display on archive', 'Number of shouts to display per page on archive view.', 'text', '15', 2, $sgID, 0),
        (NULL, 'dvz_sb_reversed', 'Reversed order', 'Reverse the order of displaying shouts in the Shoutbox window so that new ones appear on the bottom. You might also want to move the <b>{\$panel}</b> variable below window in the <i>dvz_shoutbox</i> template.', 'yesno', '0', 3, $sgID, 0),
        (NULL, 'dvz_sb_height', 'Shoutbox height', 'Height of the Shoutbox window in pixels.', 'text', '160', 4, $sgID, 0),
        (NULL, 'dvz_sb_dateformat', 'Date format', 'Format of the date displayed. This format uses the PHP <a href=\"http://php.net/manual/en/function.date.php\">date()</a> function.', 'text', 'd M H:i', 5, $sgID, 0),

        (NULL, 'dvz_sb_mycode', 'Parse MyCode', '', 'yesno', '1', 6, $sgID, 0),
        (NULL, 'dvz_sb_smilies', 'Parse smilies', '', 'yesno', '1', 7, $sgID, 0),
        (NULL, 'dvz_sb_interval', 'Refresh interval', 'Number of seconds before new posted shouts are displayed in the window (lower values provide better synchronization but cause higher server load). Set 0 to disable the auto-refreshing feature.', 'text', '5', 8, $sgID, 0),
        (NULL, 'dvz_sb_away', 'Away mode', 'Number of seconds after last user action (e.g. click) after which shoutbox will be minimized to prevent unnecessary usage of server resources. Set 0 to disable this feature.', 'text', '600', 9, $sgID, 0),
        (NULL, 'dvz_sb_antiflood', 'Anti-flood interval', 'Minimum number of seconds before user can post next shout (this does not apply to Shoutbox moderators).', 'text', '5', 10, $sgID, 0),
        (NULL, 'dvz_sb_lazyload', 'Lazy load', 'Start loading data only when the Shoutbox window is actually being displayed on the screen (the page is scrolled to the Shoutbox position).', 'select
off=Disabled
start=Check if on display to start
always=Always check if on display to refresh', 'off', 11, $sgID, 0),
        (NULL, 'dvz_sb_status', 'Shoutbox default status', 'Choose whether Shoutbox window should be expanded or collapsed by default.', 'onoff', '1', 12, $sgID, 0),

        (NULL, 'dvz_sb_minposts', 'Minimum posts required to shout', 'Set 0 to allow everyone.', 'text', '0', 13, $sgID, 0),

        (NULL, 'dvz_sb_groups_view', 'Group permissions: View', 'Comma-separated list of user groups that can view Shoutbox. Leave empty to let everyone view (including guests).', 'text', '', 14, $sgID, 0),
        (NULL, 'dvz_sb_groups_shout', 'Group permissions: Shout', 'Comma-separated list of user groups that can post shouts in Shoutbox. Leave empty to let everyone post (that does not include guests).', 'text', '', 15, $sgID, 0),
        (NULL, 'dvz_sb_groups_refresh', 'Group permissions: Auto-refresh', 'Comma-separated list of user groups that shoutbox will be refreshing for. Leave empty to let Shoutbox refresh for everyone.', 'text', '', 16, $sgID, 0),
        (NULL, 'dvz_sb_groups_mod', 'Group permissions: Moderate', 'Comma-separated list of users groups that can moderate the Shoutbox (edit and delete shouts).', 'text', '', 17, $sgID, 0),
        (NULL, 'dvz_sb_groups_mod_own', 'Group permissions: Moderate own shouts', 'Comma-separated list of users groups that can edit and delete own shouts.', 'text', '', 18, $sgID, 0),

        (NULL, 'dvz_sb_supermods', 'Super moderators are Shoutbox moderators', 'Automatically allow forum super moderators to moderate Shoutbox as well.', 'yesno', '1', 19, $sgID, 0),


        (NULL, 'dvz_sb_blocked_users', 'Banned users', 'Comma-separated list of user IDs that are banned from posting messages.', 'textarea', '', 20, $sgID, 0)
    ");

    rebuild_settings();

    // templates
    $template_panel = '
<div class="panel">
<form>
<input type="text" class="text" placeholder="{$lang->dvz_sb_default}" autocomplete="off" />
<input type="submit" style="display:none" />
</form>
</div>';

    $template_shoutbox = '
<div id="shoutbox" class="front{$classes}">

<div class="thead">
{$lang->dvz_sb_shoutbox}
<p class="right"><a href="{$mybb->settings[\'bburl\']}/index.php?action=shoutbox_archive">&laquo; {$lang->dvz_sb_archivelink}</a></p>
</div>

<div class="body">

{$panel}

<div class="window" style="height:{$mybb->settings[\'dvz_sb_height\']}px">
<div class="data"></div>
</div>

</div>

<script type="text/javascript" src="{$mybb->settings[\'bburl\']}/jscripts/dvz_shoutbox.js"></script>
{$javascript}

</div>';

    $template_archive = '<html>
<head>
<title>{$lang->dvz_sb_archive}</title>
{$headerinclude}
</head>
<body>
{$header}

<script type="text/javascript" src="{$mybb->settings[\'bburl\']}/jscripts/dvz_shoutbox.js"></script>
{$javascript}

{$multipage}

<br />

<div id="shoutbox">

{$modoptions}

<div class="thead">{$lang->dvz_sb_archive}</div>

<div class="data">
{$archive}
</div>
</div>

<br />

{$multipage}

{$footer}
</body>
</html>';

    $template_archive_modoptions = '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr><td class="thead" colspan="2"><strong>{$lang->dvz_sb_mod}</strong></td></tr>
<tr><td class="tcat">{$lang->dvz_sb_mod_banlist}</td><td class="tcat">{$lang->dvz_sb_mod_clear}</td></tr>
<tr>
<td class="trow1">
<form action="" method="post">
<input type="text" class="textbox" style="width:80%" name="banlist" value="{$blocked_users}"></textarea>
<input type="hidden" name="postkey" value="{$mybb->post_code}" />
<input type="submit" class="button" value="{$lang->dvz_sb_mod_banlist_button}" />
</form>
</td>
<td class="trow1">
<form action="" method="post">
<select name="days">
<option value="2">2 {$lang->days}</option>
<option value="7">7 {$lang->days}</option>
<option value="30">30 {$lang->days}</option>
<option value="90">90 {$lang->days}</option>
<option value="all">* {$lang->dvz_sb_mod_clear_all} *</option>
</select>
<input type="hidden" name="postkey" value="{$mybb->post_code}" />
<input type="submit" class="button" value="{$lang->dvz_sb_mod_clear_button}" />
</form>
</td>
</tr>
</table>
<br />';

    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox_panel', '".$db->escape_string($template_panel)."', '-1', '1', '', '".time()."')");
    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox', '".$db->escape_string($template_shoutbox)."', '-1', '1', '', '".time()."')");
    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox_archive', '".$db->escape_string($template_archive)."', '-1', '1', '', '".time()."')");
    $db->write_query("INSERT INTO `".TABLE_PREFIX."templates` VALUES (NULL, 'dvz_shoutbox_archive_modoptions', '".$db->escape_string($template_archive_modoptions)."', '-1', '1', '', '".time()."')");

}
function dvz_shoutbox_uninstall () {
    global $db;

    $groupID = $db->fetch_field(
        $db->simple_select('settinggroups', 'gid', "name='dvz_shoutbox'"),
        'gid'
    );

    // delete settings
    $db->delete_query('settinggroups', "name='dvz_shoutbox'");
    $db->delete_query('settings', 'gid='.$groupID);

    // delete templates
    $db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title IN('dvz_shoutbox', 'dvz_shoutbox_panel', 'dvz_shoutbox_archive', 'dvz_shoutbox_archive_modoptions')");

    // delete data
    $db->query("DROP TABLE ".TABLE_PREFIX.'dvz_shoutbox');
}
function dvz_shoutbox_is_installed () {
        global $db;
        $query = $db->simple_select('settinggroups', '*', "name='dvz_shoutbox'");
        return $db->num_rows($query);
}
function dvz_shoutbox_activate () {
}
function dvz_shoutbox_deactivate () {
}

// hooks
function dvz_shoutbox_global_end () {
    global $mybb, $lang;

    $lang->load('dvz_shoutbox');

    if ($mybb->input['action'] == 'shoutbox_archive') {
        return dvz_shoutbox::show_archive();
    }
}
function dvz_shoutbox_xmlhttp () {
    global $mybb, $db, $lang, $charset;

    switch ($mybb->input['action']) {

        case 'dvz_sb_get_shouts':

            $permissions = (
                (dvz_shoutbox::access_view() && !isset($mybb->input['from']) ) ||
                dvz_shoutbox::access_refresh()
            );

            $handler = function() use ($mybb, $db) {
                $data = dvz_shoutbox::get_multiple("WHERE s.id > " . (int)$mybb->input['from'] . " ORDER BY s.id DESC LIMIT " . (int)$mybb->settings['dvz_sb_num']);

                $html = null; // JS-handled empty response
                $lastId = 0;

                while ($row = $db->fetch_array($data)) {
                    if ($lastId == 0) {
                        $lastId = $row['id'];
                    }
                    $shout = dvz_shoutbox::render_shout($row);
                    $html  = $mybb->settings['dvz_sb_reversed']
                        ? $shout . $html
                        : $html  . $shout
                    ;
                }

                if ($html != null) {
                    echo json_encode(array(
                        'html' => $html,
                        'last' => $lastId,
                    ));
                }
            };

        break;
        case 'dvz_sb_shout':

            $permissions = (
                dvz_shoutbox::access_shout() &&
                verify_post_check($mybb->input['key'], true)
            );

            $handler = function() use ($mybb) {
                if (!dvz_shoutbox::antiflood_pass() && !dvz_shoutbox::access_mod()) die('A'); // JS-handled error (Anti-flood)

                dvz_shoutbox::shout(array(
                    'uid'  => $mybb->user['uid'],
                    'text' => $mybb->input['text'],
                    'ip'   => get_ip(),
                ));
            };

        break;
        case 'dvz_sb_get':

            $data = dvz_shoutbox::get($mybb->input['id']);

            $permissions = (
                (
                    dvz_shoutbox::access_mod() ||
                    (dvz_shoutbox::access_mod_own() && $data['uid'] == $mybb->user['uid'] && dvz_shoutbox::access_shout())
                ) &&
                verify_post_check($mybb->input['key'], true)
            );

            $handler = function() use ($data) {
                echo json_encode(array(
                    'text' => $data['text'],
                ));
            };

        break;
        case 'dvz_sb_update':

            $permissions = (
                dvz_shoutbox::can_mod($mybb->input['id']) &&
                verify_post_check($mybb->input['key'], true)
            );

            $handler = function() use ($mybb) {
                dvz_shoutbox::update($mybb->input['id'], $mybb->input['text']);
                echo dvz_shoutbox::parse($mybb->input['text'], dvz_shoutbox::get_username($mybb->input['id']));

            };

        break;
        case 'dvz_sb_delete':

            $permissions = (
                dvz_shoutbox::can_mod($mybb->input['id']) &&
                verify_post_check($mybb->input['key'], true)
            );

            $handler = function() use ($mybb) {
                dvz_shoutbox::delete($mybb->input['id']);
            };

        break;

    }

    if (isset($permissions)) {

        if ($permissions == false) {
            echo 'P'; // JS-handled error (Permissions)
        } else {

            $lang->load("dvz_shoutbox");
            header('Content-type: text/plain; charset='.$charset);
            header('Cache-Control: no-store'); // Chrome request caching issue
            $handler();

        }
    }

}
function dvz_shoutbox () {
    return dvz_shoutbox::load_window();
}

class dvz_shoutbox {

    // internal cache
    static $userGroups = false;

    // immediate output
    static function load_window () {
        global $templates, $dvz_shoutbox, $lang, $mybb, $theme;

        // MyBB template
        $dvz_shoutbox = null;

        // dvz_shoutbox template
        $javascript   = null;
        $panel        = null;
        $classes      = null;

        if (dvz_shoutbox::access_view()) {

            if (dvz_shoutbox::is_user()) {

                // message: blocked
                if (dvz_shoutbox::is_blocked()) {
                    $panel = '<div class="panel blocked"><p>' . $lang->dvz_sb_user_blocked . '</p></div>';
                }
                // message: minimum posts
                else if (!dvz_shoutbox::access_minposts() && !dvz_shoutbox::access_mod()) {
                    $panel = '<div class="panel minposts"><p>' . str_replace('{MINPOSTS}', $mybb->settings['dvz_sb_minposts'], $lang->dvz_sb_minposts) . '</p></div>';
                }
                // shout form
                else if (dvz_shoutbox::access_shout()) {
                    eval('$panel = "' . $templates->get('dvz_shoutbox_panel') . '";');
                }

            }

            $js = null;

            // configuration
            $js .= 'dvz_shoutbox.interval   = ' . (dvz_shoutbox::access_refresh() ? (float)$mybb->settings['dvz_sb_interval'] : 0) . ';' . PHP_EOL;
            $js .= 'dvz_shoutbox.antiflood  = ' . (dvz_shoutbox::access_mod() ? 0 : (float)$mybb->settings['dvz_sb_antiflood']) . ';' . PHP_EOL;
            $js .= 'dvz_shoutbox.maxShouts  = ' . (int)$mybb->settings['dvz_sb_num'] . ';' . PHP_EOL;
            $js .= 'dvz_shoutbox.awayTime   = ' . (float)$mybb->settings['dvz_sb_away'] . '*1000;' . PHP_EOL;
            $js .= 'dvz_shoutbox.lang       = [\'' . $lang->dvz_sb_delete_confirm . '\', \'' . str_replace('{ANTIFLOOD}', $mybb->settings['dvz_sb_antiflood'], $lang->dvz_sb_antiflood) . '\', \''.$lang->dvz_sb_permissions.'\'];' . PHP_EOL;

            // reversed order
            if ($mybb->settings['dvz_sb_reversed']) {
                $js .= 'dvz_shoutbox.reversed   = true;' . PHP_EOL;
            }

            // lazyload
            if ($mybb->settings['dvz_sb_lazyload']) {
                $js .= 'dvz_shoutbox.lazyMode   = \'' . $mybb->settings['dvz_sb_lazyload'] . '\';' . PHP_EOL;
                $js .= 'jQuery(window).bind(\'scroll resize\', dvz_shoutbox.checkVisibility);' . PHP_EOL;
            }

            // away mode
            if ($mybb->settings['dvz_sb_away']) {
                $js .= 'jQuery(window).on(\'mousemove click dblclick keydown scroll\', dvz_shoutbox.updateActivity);' . PHP_EOL;
            }

            // shoutbox status
            $status = isset($_COOKIE['dvz_sb_status'])
                ? (bool)$_COOKIE['dvz_sb_status']
                : (bool)$mybb->settings['dvz_sb_status']
            ;
            $js .= 'dvz_shoutbox.status     = ' . (int)$status . ';' . PHP_EOL;

            if ($status == false) {
                $classes .= ' collapsed';
            }

            $javascript = '
<script>
' . $js . '
dvz_shoutbox.updateActivity();
dvz_shoutbox.loop();
</script>';

            eval('$dvz_shoutbox = "' . $templates->get('dvz_shoutbox') . '";');

        }

    }
    static function show_archive () {
        global $db, $mybb, $templates, $lang, $theme, $footer, $headerinclude, $header, $charset;

        if (!dvz_shoutbox::access_view()) return false;

        header('Content-type: text/html; charset='.$charset);

        add_breadcrumb($lang->dvz_sb_shoutbox, "index.php?action=shoutbox_archive");

        // moderation panel
        if (dvz_shoutbox::access_mod()) {

            if (isset($mybb->input['banlist']) && verify_post_check($mybb->input['postkey'])) {
                dvz_shoutbox::banlist_update($mybb->input['banlist']);
            }

            if (isset($mybb->input['days']) && verify_post_check($mybb->input['postkey'])) {
                if ($mybb->input['days'] == 'all') {
                    dvz_shoutbox::clear();
                } else {
                    $allowed = array(2, 7, 30, 90);
                    if (in_array($mybb->input['days'], $allowed)) {
                        dvz_shoutbox::clear($mybb->input['days']);
                    }
                }
            }

            $blocked_users = htmlspecialchars($mybb->settings['dvz_sb_blocked_users']);
            eval('$modoptions = "'.$templates->get("dvz_shoutbox_archive_modoptions").'";');

        } else {
            $modoptions = null;
        }

        // pagination
        $shoutsTotal = dvz_shoutbox::count();
        $pageNum     = (int)$mybb->input['page'];
        $perPage     = (int)$mybb->settings['dvz_sb_num_archive'];
        $pages       = ceil($shoutsTotal / $perPage);

        if (!$pageNum || $pageNum < 1 || $pageNum > $pages) $pageNum = 1;

        $start = ($pageNum - 1) * $perPage;

        if ($shoutsTotal > $perPage) {
            $multipage = multipage($shoutsTotal, $perPage, $pageNum, 'index.php?action=shoutbox_archive');
        }

        $data = dvz_shoutbox::get_multiple("ORDER by s.id DESC LIMIT $start,$perPage");

        $archive = null;

        while ($row = $db->fetch_array($data)) {
            $archive .= dvz_shoutbox::render_shout($row, true);
        }

        $javascript = '
<script>
dvz_shoutbox.lang = [\'' . $lang->dvz_sb_delete_confirm . '\', \'' . str_replace('{ANTIFLOOD}', $mybb->settings['dvz_sb_antiflood'], $lang->dvz_sb_antiflood) . '\', \''.$lang->dvz_sb_permissions.'\'];
</script>';

        eval('$content = "'.$templates->get("dvz_shoutbox_archive").'";');

        output_page($content);

        exit;

    }
    static function render_shout ($data, $static = false) {
        global $mybb, $lang;

        $id     = $data['id'];
        $text   = dvz_shoutbox::parse($data['text'], $data['username']);
        $date   = my_date($mybb->settings['dvz_sb_dateformat'], $data['date']);

        $avatar = '<img src="' . (empty($data['avatar']) ? 'images/default_avatar.gif' : $data['avatar']) . '" alt="avatar" />';
        $user   = '<a href="member.php?action=profile&uid=' . (int)$data['uid'] . '">' . format_name($data['username'], $data['usergroup'], $data['displaygroup']) . '</a>';


        $notes = null;
        $attributes = null;

        $own = $data['uid'] == $mybb->user['uid'];

        if ($static) {
            if (dvz_shoutbox::access_mod()) {
                $notes .= '<span class="ip">'.$data['ip'].'</span>';
            }

            if (
                dvz_shoutbox::access_mod() ||
                (dvz_shoutbox::access_mod_own() && $own)
            ) {
                $notes .= '<a href="" class="mod edit">E</a><a href="" class="mod del">X</a>';
            }
        }

        if (
            dvz_shoutbox::access_mod() ||
            (dvz_shoutbox::access_mod_own() && $own)
        ) {
            $attributes .= ' data-mod';
        }

        if ($own) {
            $attributes .= ' data-own';
        }

        return '
<div class="entry" data-id="'.$id.'" data-username="'.$data['username'].'"'.$attributes.'>
    <div class="avatar">'.$avatar.'</div>
    <div class="user">'.$user.':</div>
    <div class="text">'.$text.'</div>
    <div class="info"><span class="date">'.$date.'</span>'.$notes.'</div>
</div>';

    }

    // data manipulation
    static function get ($id) {
        global $db;
        return $db->fetch_array( $db->simple_select('dvz_shoutbox', '*', 'id=' . (int)$id) );
    }
    static function get_multiple ($clauses) {
        global $db;
        return $db->query("
            SELECT
                s.*, u.username, u.usergroup, u.displaygroup, u.avatar
            FROM
                ".TABLE_PREFIX."dvz_shoutbox s
                LEFT JOIN ".TABLE_PREFIX."users u ON u.uid = s.uid
            ".$clauses."
        ");
    }
    static function get_username ($id) {
        global $db;
        return $db->fetch_field( $db->query("SELECT username FROM ".TABLE_PREFIX."users u, ".TABLE_PREFIX."dvz_shoutbox s WHERE u.uid=s.uid AND s.id=" . (int)$id), 'username');
    }
    static function user_last_shout_time ($uid) {
        global $db;
        return $db->fetch_field(
            $db->simple_select('dvz_shoutbox', 'date', 'uid=' . (int)$uid, array(
                'order_by'  => 'date',
                'order_dir' => 'desc',
                'limit'     => 1
        )), 'date');
    }
    static function count () {
        global $db;
        return $db->fetch_field(
            $db->simple_select('dvz_shoutbox', 'COUNT(*) as n'),
            'n'
        );
    }
    static function shout ($data) {
        global $db;

        foreach ($data as &$item) {
            $item = $db->escape_string($item);
        }

        $data['date'] = time();

        return $db->insert_query('dvz_shoutbox', $data);
    }
    static function update ($id, $text) {
        global $db;
        return $db->update_query('dvz_shoutbox', array('text' => $db->escape_string($text)), 'id=' . (int)$id);
    }
    static function banlist_update ($new) {
        global $db;
        $db->update_query('settings', array('value' => $db->escape_string($new)), "name='dvz_sb_blocked_users'");
        rebuild_settings();
    }
    static function delete ($id) {
        global $db;
        return $db->delete_query('dvz_shoutbox', 'id=' . (int)$id);
    }
    static function clear ($days = false) {
        global $db;
        if ($days) {
            $where = 'date < '.( time()-((int)$days*86400) );
        } else {
            $where = false;
        }
        return $db->delete_query('dvz_shoutbox', $where);
    }

    // permissions
    static function is_user () {
        global $mybb;
        return !($mybb->user['usergroup'] == 1 && $mybb->user['uid'] < 1);
    }
    static function is_blocked () {
        global $mybb;
        $array = dvz_shoutbox::settings_get_csv('blocked_users');
        return in_array($mybb->user['uid'], $array);
    }
    static function access_view () {
        global $mybb;

        $array = dvz_shoutbox::settings_get_csv('groups_view');

        return (
            empty($array) ||
            dvz_shoutbox::member_of($array)
        );
    }
    static function access_refresh () {
        global $mybb;

        $array = dvz_shoutbox::settings_get_csv('groups_refresh');

        return (
            empty($array) ||
            dvz_shoutbox::member_of($array)
        );
    }
    static function access_shout () {
        global $mybb;

        $array = dvz_shoutbox::settings_get_csv('groups_shout');

        return (
            dvz_shoutbox::is_user() &&
            !dvz_shoutbox::is_blocked() &&
            (
                dvz_shoutbox::access_mod() ||
                (
                    dvz_shoutbox::access_view() &&
                    dvz_shoutbox::access_minposts() &&
                    (
                        empty($array) ||
                        dvz_shoutbox::member_of($array)
                    )
                )
            )
        );
    }
    static function access_mod () {
        global $mybb;

        $array = dvz_shoutbox::settings_get_csv('groups_mod');
        return (
            dvz_shoutbox::member_of($array) ||
            ($mybb->settings['dvz_sb_supermods'] && $mybb->usergroup['issupermod'])
        );
    }
    static function access_mod_own () {
        global $mybb;

        if ($mybb->settings['dvz_sb_groups_mod_own']) {
            $array = dvz_shoutbox::settings_get_csv('groups_mod_own');
            return dvz_shoutbox::member_of($array);
        } else {
            return false;
        }
    }
    static function access_minposts () {
        global $mybb;
        return $mybb->user['postnum'] >= $mybb->settings['dvz_sb_minposts'];
    }
    static function can_mod ($shoutId) {
        global $mybb;

        if (dvz_shoutbox::access_mod()) {
            return true;
        } else if (dvz_shoutbox::access_mod_own() && dvz_shoutbox::access_shout()) {

            $data = dvz_shoutbox::get($shoutId);

            if ($data['uid'] == $mybb->user['uid']) {
                return true;
            }

        }

        return false;

    }

    // core
    static function parse ($message, $me_username) {
        global $mybb;

        require_once MYBB_ROOT.'inc/class_parser.php';

        $parser = new postParser;
        $options = array(
            'allow_mycode'  => $mybb->settings['dvz_sb_mycode'],
            'allow_smilies' => $mybb->settings['dvz_sb_smilies'],
            'allow_imgcode' => 0,
            'me_username'   => $me_username,
        );

        return $parser->parse_message($message, $options);

    }
    static function antiflood_pass () {
        global $mybb;

        return (
            !$mybb->settings['dvz_sb_antiflood'] ||
            ( time() - dvz_shoutbox::user_last_shout_time($mybb->user['uid']) ) > $mybb->settings['dvz_sb_antiflood']
        );

    }
    static function member_of ($groupsArray) {
        global $mybb;

        if (dvz_shoutbox::$userGroups == false) {
            dvz_shoutbox::$userGroups = explode(',', $mybb->user['additionalgroups']);
            dvz_shoutbox::$userGroups[] = $mybb->user['usergroup'];
        }

        return array_intersect(dvz_shoutbox::$userGroups, $groupsArray);
    }
    static function settings_get_csv ($name) {
        global $mybb;

        $items = explode(',', $mybb->settings['dvz_sb_'.$name]);

        if (count($items) == 1 && $items[0] == '') {
            return array();
        } else

        return $items;
    }

}

?>
Skopiuj cały kod który wstawiłem i wklej
johnysamoa napisał(a):Skopiuj cały kod który wstawiłem i wklej
Ty podałeś rozwiązanie do wersji 1.0, a @Jolten posiada wersję 2.0. Jak podmieni pliki to mu się Sb wysypie...
Nikt nie mówił o wersji, kolega na samej górze z tego co widzę jeszcze jedzie' na starej także problem powinien zostać rozwiązany - i nie patrzyłem na to jak wygląda kod Joltena z gruntu założyłem ze mówimy o starej wersji co było błędem ale tak to już bywa :)
A da się zrobić żeby na 2.0 to działało ?
A ja inaczej zapytam czy jest jakiś problem aby zrobić sobie downgrade do wersji 1.0 :)
Daniel Praźmo napisał 08.09.2014, 09:28:
A czy coś stoi Ci na przeszkodzie byś nagle zaczął używać Windowsa 95? Nie używa się starych, nieaktualnych skryptów po pierwsze ze względu na bezpieczeństwo, po drugie ze względu na wsparcie.



Użytkownicy przeglądający ten wątek:

1 gości