Nikolas
Mon 11 September 2006, 08:07 pm GMT +0300
This time I though to write this modification and this thread in the same time (otherwise I wouldn't remember later to post the modification :) )
This modification will display in the statistics of your forum, the dailly average registers, new topics and new posts that made in your forum for every month.
So let's start. The first file you have to modify is the /Sources/Stats.php
Find :
and replace it with :
Then find this :
and replace it with :
-------------------------------------------------------------------------------------------------------------------
Then open the /Themes/default/Stats.Template.php and find this code :
and replace it with :
This modification will display in the statistics of your forum, the dailly average registers, new topics and new posts that made in your forum for every month.
So let's start. The first file you have to modify is the /Sources/Stats.php
Find :
Code:
// Activity by month.
$months_result = db_query("
SELECT
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts,
MAX(mostOn) AS mostOn
FROM {$db_prefix}log_activity
GROUP BY stats_year, stats_month", __FILE__, __LINE__);
$months_result = db_query("
SELECT
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts,
MAX(mostOn) AS mostOn
FROM {$db_prefix}log_activity
GROUP BY stats_year, stats_month", __FILE__, __LINE__);
and replace it with :
Code:
// Activity by month.
$months_result = db_query("
SELECT
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, AVG(registers) AS registersAVG, AVG(topics) AS topicsAVG, AVG(posts) AS postsAVG,
MAX(mostOn) AS mostOn
FROM {$db_prefix}log_activity
GROUP BY stats_year, stats_month", __FILE__, __LINE__);
$months_result = db_query("
SELECT
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, AVG(registers) AS registersAVG, AVG(topics) AS topicsAVG, AVG(posts) AS postsAVG,
MAX(mostOn) AS mostOn
FROM {$db_prefix}log_activity
GROUP BY stats_year, stats_month", __FILE__, __LINE__);
Then find this :
Code:
$context['monthly'][$ID_MONTH] = array(
'date' => array(
'month' => str_pad($row_months['stats_month'], 2, '0', STR_PAD_LEFT),
'year' => $row_months['stats_year']
),
'href' => $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH,
'link' => '<a href="' . $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH . '">' . $months[$row_months['stats_month']] . ' ' . $row_months['stats_year'] . '</a>',
'month' => $months[$row_months['stats_month']],
'new_topics' => $row_months['topics'],
'new_posts' => $row_months['posts'],
'new_members' => $row_months['registers'],
'most_members_online' => $row_months['mostOn'],
'hits' => $row_months['hits'],
'days' => array(),
'expanded' => $expanded
);
'date' => array(
'month' => str_pad($row_months['stats_month'], 2, '0', STR_PAD_LEFT),
'year' => $row_months['stats_year']
),
'href' => $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH,
'link' => '<a href="' . $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH . '">' . $months[$row_months['stats_month']] . ' ' . $row_months['stats_year'] . '</a>',
'month' => $months[$row_months['stats_month']],
'new_topics' => $row_months['topics'],
'new_posts' => $row_months['posts'],
'new_members' => $row_months['registers'],
'most_members_online' => $row_months['mostOn'],
'hits' => $row_months['hits'],
'days' => array(),
'expanded' => $expanded
);
and replace it with :
Code:
$context['monthly'][$ID_MONTH] = array(
'date' => array(
'month' => str_pad($row_months['stats_month'], 2, '0', STR_PAD_LEFT),
'year' => $row_months['stats_year']
),
'href' => $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH,
'link' => '<a href="' . $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH . '">' . $months[$row_months['stats_month']] . ' ' . $row_months['stats_year'] . '</a>',
'month' => $months[$row_months['stats_month']],
'new_topics' => $row_months['topics'],
'new_posts' => $row_months['posts'],
'new_members' => $row_months['registers'],
'most_members_online' => $row_months['mostOn'],
'hits' => $row_months['hits'],
'days' => array(),
'expanded' => $expanded,
'AVG' => array(
'topics' => number_format($row_months['topicsAVG'], 2, ',', ''),
'posts' => number_format($row_months['postsAVG'], 2, ',', ''),
'registers' => number_format($row_months['registersAVG'], 2, ',', '')
)
);
'date' => array(
'month' => str_pad($row_months['stats_month'], 2, '0', STR_PAD_LEFT),
'year' => $row_months['stats_year']
),
'href' => $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH,
'link' => '<a href="' . $scripturl . '?action=stats;' . ($expanded ? 'collapse' : 'expand') . '=' . $ID_MONTH . '#' . $ID_MONTH . '">' . $months[$row_months['stats_month']] . ' ' . $row_months['stats_year'] . '</a>',
'month' => $months[$row_months['stats_month']],
'new_topics' => $row_months['topics'],
'new_posts' => $row_months['posts'],
'new_members' => $row_months['registers'],
'most_members_online' => $row_months['mostOn'],
'hits' => $row_months['hits'],
'days' => array(),
'expanded' => $expanded,
'AVG' => array(
'topics' => number_format($row_months['topicsAVG'], 2, ',', ''),
'posts' => number_format($row_months['postsAVG'], 2, ',', ''),
'registers' => number_format($row_months['registersAVG'], 2, ',', '')
)
);
-------------------------------------------------------------------------------------------------------------------
Then open the /Themes/default/Stats.Template.php and find this code :
Code:
foreach ($context['monthly'] as $month)
{
echo '
<tr class="windowbg2" valign="middle">
<th align="left">
<a name="', $month['date']['year'], $month['date']['month'], '" href="', $month['href'], '"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" /></a> ', $month['link'], '
</th>
<th align="center">', $month['new_topics'], '</th>
<th align="center">', $month['new_posts'], '</th>
<th align="center">', $month['new_members'], '</th>
<th align="center">', $month['most_members_online'], '</th>';
{
echo '
<tr class="windowbg2" valign="middle">
<th align="left">
<a name="', $month['date']['year'], $month['date']['month'], '" href="', $month['href'], '"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" /></a> ', $month['link'], '
</th>
<th align="center">', $month['new_topics'], '</th>
<th align="center">', $month['new_posts'], '</th>
<th align="center">', $month['new_members'], '</th>
<th align="center">', $month['most_members_online'], '</th>';
and replace it with :
Code:
foreach ($context['monthly'] as $month)
{
echo '
<tr class="windowbg2" valign="middle">
<th align="left">
<a name="', $month['date']['year'], $month['date']['month'], '" href="', $month['href'], '"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" /></a> ', $month['link'], '
</th>
<th align="center">', $month['new_topics'], ' / ', $month['AVG']['topics'] , '</th>
<th align="center">', $month['new_posts'], ' / ', $month['AVG']['posts'] , '</th>
<th align="center">', $month['new_members'], ' / ', $month['AVG']['registers'] , '</th>
<th align="center">', $month['most_members_online'], '</th>';
{
echo '
<tr class="windowbg2" valign="middle">
<th align="left">
<a name="', $month['date']['year'], $month['date']['month'], '" href="', $month['href'], '"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" /></a> ', $month['link'], '
</th>
<th align="center">', $month['new_topics'], ' / ', $month['AVG']['topics'] , '</th>
<th align="center">', $month['new_posts'], ' / ', $month['AVG']['posts'] , '</th>
<th align="center">', $month['new_members'], ' / ', $month['AVG']['registers'] , '</th>
<th align="center">', $month['most_members_online'], '</th>';