Nie bardzo wiem, gdzie to wstawić.. Spróbowałem w ten sposób, to wyskakuje błąd (strona się wczytuje normalnie) nad logiem, oraz nie wczytuje się SB.
Kod:
<?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' => '18*',
);
}
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 = '
<head>
<style>
.tablehead {
background: #4774a2; /* Old browsers */
background: -moz-linear-gradient(top, #4774a2 0%, #396594 50%, #2c5687 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4774a2), color-stop(50%,#396594), color-stop(100%,#2c5687)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #4774a2 0%,#396594 50%,#2c5687 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #4774a2 0%,#396594 50%,#2c5687 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #4774a2 0%,#396594 50%,#2c5687 100%); /* IE10+ */
background: linear-gradient(to bottom, #4774a2 0%,#396594 50%,#2c5687 100%); /* W3C */
color: #ffffff;
line-height:36px;
height:36px;
font-size: 16px;
font-weight: 300;
box-shadow: inset 0px 1px 0 #528cbc;
border-top: 1px solid #316897;
border-left: 1px solid #316897;
border-right: 1px solid #316897;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
overflow: hidden;
}
.tablehead img { padding-top 10x;}
.tablehead .right { float: right; margin: 0; padding-top: 1px; font-size: 13px; }
.tablehead a { color: #FFF !important; text-decoration: none; }
#shoutbox_data { font: 13px Cursive; }
#shoutbox { margin-bottom: 5px; }
#shoutbox .panel { padding: 2px; }
#shoutbox .panel-blocked { margin: 1px 0; padding: 5px; background: #FCEFEF; font-size: 11px; color: #543A3A; }
#shoutbox .panel-away { margin: 1px 0; padding: 5px; background: #EDEDED; font-size: 11px; color: #7A7A7A; }
#shoutbox .panel-away button { margin-right: 5px; padding: 5px; font-family: Cursive; color: #FFF; font-size: 11px; font-weight: bold; text-align: center; text-shadow: 0 -1px 0 #297318; border-radius: 5px; background: #962725; border: none; border-radius: 3px; }
#shoutbox .panel-minposts { margin: 1px 0; padding: 5px; background: #FFFED8; font-size: 11px; color: #727250; }
img#dvz_sb_loading { position: relative; top: 3px; left: 5px; }
input#shout_text { margin-right: 2px; padding: 5px 6px 6px 6px; width: 90%; background: #FFF; border: 1px solid #898989; border-radius: 2px; font-family: Tahoma, sans-serif; font-size: 12px; color: #000; }
input#shout_button { padding: 5px; font-family: Cursive; color: #FFF; font-size: 11px; font-weight: bold; text-align: center; text-shadow: 0 -1px 0 #297318; border-radius: 5px; background: #499338; border: solid 1px #499338; border-radius: 3px; }
.sbentry { padding: 0; }
#shoutbox .userdata { margin: 0; padding: 6px; float: left; text-align: right; }
#shoutbox .text { margin: 0; padding: 6px; color: #333333; }
#shoutbox .insUser { cursor: pointer; color: #AAAAAA; }
#shoutbox .info { float: right; margin-top: 5px; margin-right: 5px; font-size: 11px; color: #888888; }
#shoutbox .info .date { margin-right: 5px; }
#shoutbox .info .ip { margin-right: 5px; color: #CECECE; }
#shoutbox .mod { padding: 2px 5px; background: #333333; border-radius: 3px; font-size: 10px; font-weight: bold; color: #FFF; text-decoration: none; }
#shoutbox .dvz_sb_del { background-color: #6B0100; }
#shoutbox img.avatar { float: left; display: inline-block; margin-top: -1px; margin-right: 5px; max-height: 16px; max-width: 16px; border: solid 1px #FFF; box-shadow: 0 0 2px #E0E0E0; }
#shoutbox .trow1 {
background: #ffffff;
border-bottom: 1px solid #f3f3f3;
color: #5a5a5a;
}
#shoutbox .trow2 {
background: #ffffff;
border-bottom: 1px solid #f3f3f3;
color: #5a5a5a;
}
.ogloszenie_sb {
background: #ebfcdf;
padding: 10px;
border: 1px solid #a4cfa4;
color: #0e440e;
line-height: 1.6;
font-size: 12px;
font-weight:bold;
}
.sb_1 {
margin: auto auto;
border: 9px solid #ebf0f3;
background: #dbe4ef;
padding: 1px;
}
.sb_2 {
margin: auto auto;
background: #FFF;
padding: 4px;
}
.sb_3{
border-left: 1px solid #d5dde5;
border-right: 1px solid #d5dde5;
border-bottom: 6px solid #dbe2ec;
}
#shoutbox .trow1 {
background-color: #f1f6f9;
border-top: 1px solid #d5dde5;
}
#shoutbox .trow2 {
background-color: #f1f6f9;
border-top: 1px solid #d5dde5;
}
</style>
</head>
<div class="tablehead"> Shoutbox<a href="{$mybb->settings[bburl]}/index.php?action=shoutbox_archive"><img src="images/cmsstyle/popup.png" alt="Otwórz w nowym oknie"/></a> </div>
<div id="shoutbox" class="sb_1">
<div class="sb_2">
<div class="ogloszenie_sb">Shoutbox zmodyfikowany przez DjHeHe to ogłoszenie możesz zmienić w szablonach globalnych</div>
<div class="panel-away" style="display:none"><button id="button" onclick="dvz_shoutbox.setBack()">{$lang->dvz_sb_away_button}</button>{$lang->dvz_sb_away}</div>
{$dvz_shoutbox_panel}
<div class="sb_3" id="shoutbox_data" style="height:{$mybb->settings[dvz_sb_height]}px; overflow:auto;"></div>
</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}
<style>
.tablehead {
background: #4774a2; /* Old browsers */
background: -moz-linear-gradient(top, #4774a2 0%, #396594 50%, #2c5687 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4774a2), color-stop(50%,#396594), color-stop(100%,#2c5687)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #4774a2 0%,#396594 50%,#2c5687 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #4774a2 0%,#396594 50%,#2c5687 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #4774a2 0%,#396594 50%,#2c5687 100%); /* IE10+ */
background: linear-gradient(to bottom, #4774a2 0%,#396594 50%,#2c5687 100%); /* W3C */
color: #ffffff;
line-height:36px;
height:36px;
font-size: 16px;
font-weight: 300;
box-shadow: inset 0px 1px 0 #528cbc;
border-top: 1px solid #316897;
border-left: 1px solid #316897;
border-right: 1px solid #316897;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
overflow: hidden;
}
.tablehead img { padding-top 10x;}
.tablehead .right { float: right; margin: 0; padding-top: 1px; font-size: 13px; }
.tablehead a { color: #FFF !important; text-decoration: none; }
#shoutbox_data { font: 13px Cursive; }
#shoutbox { margin-bottom: 5px; }
#shoutbox .panel { padding: 2px; }
#shoutbox .panel-blocked { margin: 1px 0; padding: 5px; background: #FCEFEF; font-size: 11px; color: #543A3A; }
#shoutbox .panel-away { margin: 1px 0; padding: 5px; background: #EDEDED; font-size: 11px; color: #7A7A7A; }
#shoutbox .panel-away button { margin-right: 5px; padding: 5px; font-family: Cursive; color: #FFF; font-size: 11px; font-weight: bold; text-align: center; text-shadow: 0 -1px 0 #297318; border-radius: 5px; background: #962725; border: none; border-radius: 3px; }
#shoutbox .panel-minposts { margin: 1px 0; padding: 5px; background: #FFFED8; font-size: 11px; color: #727250; }
img#dvz_sb_loading { position: relative; top: 3px; left: 5px; }
input#shout_text { margin-right: 2px; padding: 5px 6px 6px 6px; width: 90%; background: #FFF; border: 1px solid #898989; border-radius: 2px; font-family: Tahoma, sans-serif; font-size: 12px; color: #000; }
input#shout_button { padding: 5px; font-family: Cursive; color: #FFF; font-size: 11px; font-weight: bold; text-align: center; text-shadow: 0 -1px 0 #297318; border-radius: 5px; background: #499338; border: solid 1px #499338; border-radius: 3px; }
.sbentry { padding: 0; }
#shoutbox .userdata { margin: 0; padding: 6px; float: left; text-align: right; }
#shoutbox .text { margin: 0; padding: 6px; color: #333333; }
#shoutbox .insUser { cursor: pointer; color: #AAAAAA; }
#shoutbox .info { float: right; margin-top: 5px; margin-right: 5px; font-size: 11px; color: #888888; }
#shoutbox .info .date { margin-right: 5px; }
#shoutbox .info .ip { margin-right: 5px; color: #CECECE; }
#shoutbox .mod { padding: 2px 5px; background: #333333; border-radius: 3px; font-size: 10px; font-weight: bold; color: #FFF; text-decoration: none; }
#shoutbox .dvz_sb_del { background-color: #6B0100; }
#shoutbox img.avatar { float: left; display: inline-block; margin-top: -1px; margin-right: 5px; max-height: 16px; max-width: 16px; border: solid 1px #FFF; box-shadow: 0 0 2px #E0E0E0; }
#shoutbox .trow1 {
background: #ffffff;
border-bottom: 1px solid #f3f3f3;
color: #5a5a5a;
}
#shoutbox .trow2 {
background: #ffffff;
border-bottom: 1px solid #f3f3f3;
color: #5a5a5a;
}
.ogloszenie_sb {
background: #ebfcdf;
padding: 10px;
border: 1px solid #a4cfa4;
color: #0e440e;
line-height: 1.6;
font-size: 12px;
font-weight:bold;
}
.sb_1 {
margin: auto auto;
border: 9px solid #ebf0f3;
background: #dbe4ef;
padding: 1px;
}
.sb_2 {
margin: auto auto;
background: #FFF;
padding: 4px;
}
.sb_3{
border-left: 1px solid #d5dde5;
border-right: 1px solid #d5dde5;
border-bottom: 6px solid #dbe2ec;
}
#shoutbox .trow1 {
background-color: #f1f6f9;
border-top: 1px solid #d5dde5;
}
#shoutbox .trow2 {
background-color: #f1f6f9;
border-top: 1px solid #d5dde5;
}
</style>
</head>
<body>
{$header}
<script type="text/javascript" src="jscripts/dvz_shoutbox.js"></script>
{$dvz_shoutbox_js}
{$multipage}
<div class="tablehead"> Shoutbox{$lang->dvz_sb_archive} </div>
<div id="shoutbox" class="sb_1">
<div class="sb_2">
<div class="ogloszenie_sb">Shoutbox zmodyfikowany przez DjHeHe to ogłoszenie możesz zmienić w szablonach globalnych</div>
{$messagesList}
</div>
</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.'." 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_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.'" '.\t.' class="insUser" onclick="dvz_shoutbox.insertUsername(\''.$entry['username'].'\')">@ </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;
}
?>
w ten sposób nie działa.