22, November 2008

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

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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



« on: Sep 11, 2006, 08: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, 12:06:29 PM by Nikolas »

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

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6439
39458 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Sep 13, 2006, 09:02:07 AM »

Nick do you have this feature on this site too?


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #2 on: Sep 13, 2006, 10:26:47 AM »

Sure Smiley

index.php?action=stats

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

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4043
Tags : forums Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Nov 22, 2008, 05:07:09 AM





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!


Forum Statistics
Total Posts: 37.733
Total Topics: 7.649
Total Members: 4.393
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: 2bi4ll5

33 Guests, 4 Users online :

16 users online today:



Readers

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