28, May 2012

[Modification] Statistics with average values per month - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web site promotion  >  Promoting & building a forum  >  SMF moding & promoting
Topic: [Modification] Statistics with average values per month
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: [Modification] Statistics with average values per month  (Read 2204 times)
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« on: Sep 11, 2006, 07:07:23 pm »

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 Smiley )

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__);

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__);

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
);

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, ',', '')
)
);

-------------------------------------------------------------------------------------------------------------------

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>';

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>';
« Last Edit: Sep 12, 2006, 11:06:29 am by Nikolas »

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Sep 13, 2006, 08:02:07 am »

Nick do you have this feature on this site too?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #2 on: Sep 13, 2006, 09:26:47 am »

Sure Smiley

index.php?action=stats

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4043
Tags : forums Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web site promotion  >  Promoting & building a forum  >  SMF moding & promoting
Topic: [Modification] Statistics with average values per month
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 04:27:31 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.