global $sourcedir; global $smcFunc, $boarddir; //Call SSI.php require_once $boarddir . '/SSI.php'; //Total Stats $totals = array(); //Ultimate Portal use SMF Cache data... UP it's the best, only "UP", can create this feature if (!empty($ultimateportalSettings['up_reduce_site_overload'])) { if (cache_get_data('bk_site_stats_totals', 1800) === NULL) { $totals = ssi_boardStats('array'); cache_put_data('bk_site_stats_totals', $totals, 1800); } else { $totals = cache_get_data('bk_site_stats_totals', 1800); } } else { $totals = ssi_boardStats('array'); } //Last Member from SSI.php $latestMember = array(); //Ultimate Portal use SMF Cache data... UP it's the best, only "UP", can create this feature if (!empty($ultimateportalSettings['up_reduce_site_overload'])) { if (cache_get_data('bk_site_stats_lastmember', 1800) === NULL) { $latestMember = ssi_latestMember('array'); //return $context['common_stats']['latest_member'] cache_put_data('bk_site_stats_lastmember', $latestMember, 1800); } else { $latestMember = cache_get_data('bk_site_stats_lastmember', 1800); } } else { $latestMember = ssi_latestMember('array'); //return $context['common_stats']['latest_member']
function sp_boardStats($parameters, $id, $return_parameters = false) { global $smcFunc, $scripturl, $modSettings, $txt; $block_parameters = array('averages' => 'check'); if ($return_parameters) { return $block_parameters; } $averages = !empty($parameters['averages']) ? 1 : 0; loadLanguage('Stats'); $totals = ssi_boardStats('array'); if ($averages) { $result = $smcFunc['db_query']('', ' SELECT SUM(posts) AS posts, SUM(topics) AS topics, SUM(registers) AS registers, SUM(most_on) AS most_on, MIN(date) AS date, SUM(hits) AS hits FROM {db_prefix}log_activity', array()); $row = $smcFunc['db_fetch_assoc']($result); $smcFunc['db_free_result']($result); $total_days_up = ceil((time() - strtotime($row['date'])) / (60 * 60 * 24)); $totals['average_posts'] = comma_format(round($row['posts'] / $total_days_up, 2)); $totals['average_topics'] = comma_format(round($row['topics'] / $total_days_up, 2)); $totals['average_members'] = comma_format(round($row['registers'] / $total_days_up, 2)); $totals['average_online'] = comma_format(round($row['most_on'] / $total_days_up, 2)); } echo ' <ul class="sp_list"> <li>', sp_embed_image('stats'), ' ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a></li> <li>', sp_embed_image('stats'), ' ', $txt['total_posts'], ': ', comma_format($totals['posts']), '</li> <li>', sp_embed_image('stats'), ' ', $txt['total_topics'], ': ', comma_format($totals['topics']), '</li> <li>', sp_embed_image('stats'), ' ', $txt['total_cats'], ': ', comma_format($totals['categories']), '</li> <li>', sp_embed_image('stats'), ' ', $txt['total_boards'], ': ', comma_format($totals['boards']), '</li> <li>', sp_embed_image('stats'), ' ', $txt['most_online'], ': ', comma_format($modSettings['mostOnline']), '</li> </ul>'; if ($averages) { echo ' <hr /> <ul class="sp_list"> <li>', sp_embed_image('averages'), ' ', $txt['sp-average_posts'], ': ', comma_format($totals['average_posts']), '</li> <li>', sp_embed_image('averages'), ' ', $txt['sp-average_topics'], ': ', comma_format($totals['average_topics']), '</li> <li>', sp_embed_image('averages'), ' ', $txt['sp-average_members'], ': ', comma_format($totals['average_members']), '</li> <li>', sp_embed_image('averages'), ' ', $txt['sp-average_online'], ': ', comma_format($totals['average_online']), '</li> </ul>'; } }
/** * Board Stats block, shows count of users online names * * @param mixed[] $parameters * 'averages' => Will calculate the daily average (posts, topics, registrations, etc) * @param int $id - not used in this block * @param boolean $return_parameters if true returns the configuration options for the block */ function sp_boardStats($parameters, $id, $return_parameters = false) { global $scripturl, $modSettings, $txt; $block_parameters = array('averages' => 'check'); if ($return_parameters) { return $block_parameters; } $averages = !empty($parameters['averages']) ? 1 : 0; loadLanguage('Stats'); // Basic totals are easy $totals = ssi_boardStats('array'); // Get the averages from the activity log, its the most recent snapshot if ($averages) { require_once SUBSDIR . '/Stats.subs.php'; $averages = getAverages(); // The number of days the forum has been up... $total_days_up = ceil((time() - strtotime($averages['date'])) / (60 * 60 * 24)); $totals += array('average_members' => comma_format(round($averages['registers'] / $total_days_up, 2)), 'average_posts' => comma_format(round($averages['posts'] / $total_days_up, 2)), 'average_topics' => comma_format(round($averages['topics'] / $total_days_up, 2)), 'average_online' => comma_format(round($averages['most_on'] / $total_days_up, 2))); } echo ' <ul class="sp_list"> <li ', sp_embed_class('portalstats'), '>', $txt['total_members'], ': <a href="', $scripturl . '?action=memberlist">', comma_format($totals['members']), '</a></li> <li ', sp_embed_class('portalstats'), '>', $txt['total_posts'], ': ', comma_format($totals['posts']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['total_topics'], ': ', comma_format($totals['topics']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['total_cats'], ': ', comma_format($totals['categories']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['total_boards'], ': ', comma_format($totals['boards']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['most_online'], ': ', comma_format($modSettings['mostOnline']), '</li> </ul>'; // And the averages if required if ($averages) { echo ' <hr /> <ul class="sp_list"> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_posts'], ': ', comma_format($totals['average_posts']), '</li> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_topics'], ': ', comma_format($totals['average_topics']), '</li> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_members'], ': ', comma_format($totals['average_members']), '</li> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_online'], ': ', comma_format($totals['average_online']), '</li> </ul>'; } }
ssi_recentEvents(); flush(); ?> </div> </div> <!-- MISCELLANEOUS --> <div class="ssi_preview" id="ssi_boardStats"> <h2>Forum Stats</h2> <p>Shows some basic forum stats: total members, posts, topics, boards, etc.</p> <h3>Code</h3> <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_boardStats(); ?></code> <h3>Result</h3> <div class="ssi_result"><?php ssi_boardStats(); flush(); ?> </div> </div> <div class="ssi_preview" id="ssi_news"> <h2>News Function</h2> <p>Shows random forum news.</p> <h3>Code</h3> <div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code"><?php ssi_news(); ?></code> <h3>Result</h3> <div class="ssi_result"><?php ssi_news(); flush();
/** * Short description * * Long description * * @param * @return */ protected function show_boardStats() { try { $this->loadSSI(); } catch (Exception $e) { throw new \Exception($e->getMessage()); } if ('echo' == $this->output_method) { ob_start(); ssi_boardStats($this->output_method); $this->data = ob_get_contents(); ob_end_clean(); } else { $this->data = ssi_boardStats($this->output_method); } }