2016-09-21, 10:43 PM
Hello
I have a little problem, tries plugin dvz shoutbox call statistics top shouter by writing code in the plug-in file
Let's start connecting hook in the plugin
Then at the end of the file I wrote a piece of code responsible for statistics
Unfortunately, after all those steps forum returns an error on the home page and do not work statistics
I have a little problem, tries plugin dvz shoutbox call statistics top shouter by writing code in the plug-in file
Let's start connecting hook in the plugin
$plugins->add_hook('index_end', ['dvz_shoutbox_stats', 'load_window']); // Hook stats
Then at the end of the file I wrote a piece of code responsible for statistics
// Statystyki
function dvz_shoutbox_stats()
{
global $db, $mybb, $templates, $theme, $wpisy, $users, $top_spamer, $users_online_o, $top_spamer_noformatted, $shshshs, $our_shouts, $timesearch, $shouts, $username, $user, $users_online, $anon_online, $invisiblemark, $onlinemembers, $guests_online, $spiders, $cache, $bots_online;
$query = $db->query("SELECT count(id) as id FROM ".TABLE_PREFIX."dvz_shoutbox");
// Wpisy
$row = $db->fetch_array($query);
$wpisy = $row['id'];
$query3 = $db->query("SELECT d.uid, u.username, u.usergroup, u.displaygroup, u.uid, u.avatar, count(*) as shouters
FROM ".TABLE_PREFIX."dvz_shoutbox d
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=d.uid)
GROUP BY d.uid
ORDER BY shouters
DESC LIMIT 1");
$row3 = $db->fetch_array($query3);
// Najwiekszy spamer
$shouts = $row3['shouters'];
$top_spamer_noformatted = $row3['username'];
$top_spamer = build_profile_link(format_name($row3['username'], $row3['usergroup'], $row3['displaygroup']), $row3['uid']);
// Wpisy uzytkownika
$query4 = $db->query("SELECT count(id) as id, uid FROM ".TABLE_PREFIX."dvz_shoutbox WHERE uid='".$mybb->user['uid']."'");
$our_shouts = $db->fetch_field($query4, "id");
}
He then proceeded to edit the template dvz shoutbox, adding the variables that are responsible for displaying statistics<div id="shoutbox" class="front{$classes}">
<div class="head">
<strong>{$lang->dvz_sb_shoutbox}</strong>
<p class="right"><a href="{$mybb->settings['bburl']}/index.php?action=shoutbox_archive">« {$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">
{$html}
</div>
</div>
</div>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/dvz_shoutbox.js"></script>
{$javascript}
</div>
<div class="shoutbox-stats">
<ul class="grid group" style="min-height: 20px;">
<li class="col-1-3"><span class="stat">Twoich shoutów: <span class="block">{$our_shouts}</span></span></li>
<li class="col-1-3"><span class="stat">Wszystkich shoutów: <span class="block">{$wpisy}</span></span></li>
<li class="col-1-3"><span class="stat">Największy spamer: <span class="block">{$top_spamer_noformatted} ({$shouts})</span></span></li>
</ul>
</div>
Unfortunately, after all those steps forum returns an error on the home page and do not work statistics
Warning [2] call_user_func_array() expects parameter 1 to be a valid callback, class 'dvz_shoutbox_stats' not found - Line: 133 - File: inc/class_plugins.php PHP 5.6.24 (Linux)
File Line Function
[PHP] errorHandler->error
/inc/class_plugins.php 133 call_user_func_array
/index.php 387 pluginSystem->run_hooks
[/php]