Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Oct 2006
Posts: 21
Newbie
Newbie
Offline
Joined: Oct 2006
Posts: 21
From the posts in the last 24 hours topic, here , someone asked about having an average daily post count...so I quickly whipped this up. It needs a small bit of polish to remove the decimals...but, here we go.

In /cache_builders/forum_stats.php
Find:
Code

$smarty->assign("maxonline",$maxonline);

add before:

Code

$days = 30;

$today = $html -> get_date();
$limittime = ($today - ($days * 86400));


$query = "
SELECT count(POST_ID)
FROM {$config['TABLE_PREFIX']}POSTS
WHERE POST_POSTED_TIME > $limittime
";

$sth = $dbh->do_query($query);
list($total_posts) = $dbh->fetch_array( $sth );
$avg_posts = ($total_posts / $days);

$smarty->assign("avgposts", $avg_posts);

You may set the time period to be whatever number of days you're wishing to average over. Also, if someone could give me the better division method to remove decimals, that'd be great. Anyway, on to the rest...

In /languages/english/portal_islands.php
Find:
Code

$ubbt_lang['TOP_POSTERS'] = "Top Posters";

Add after:
Code

$ubbt_lang['AVG_POSTS'] = " is the daily post average";


Or however you'd like to phrase that.

In /templates/default/island_forum_stats.tpl
Find:
Code

<b>{$posts}</b> <?php echo $ubbt_lang['POSTS'] ?>

Add after:
Code

<b>{$avgposts}</b> <?php echo $ubbt_lang['AVG_POSTS'] ?>

Hmm...I may have a quick update to this after I check out some thoughts on how best to use mod...I'm thinking maybe I should check to see if the mod is greater than 0, and if it is, then subtract the mod value from the total posts value, THEN divide it by the days so that I always end up with integer value....will post the revised code if that works.

Yes, that works, so use the code I have above for forum_stats if you want decimal values. If you don't want decimal values, and just want whole integer values....

In /cache_builders/forum_stats.php
Find:
Code

$smarty->assign("maxonline",$maxonline);

add before:

Code

$days = 30;

$today = $html -> get_date();
$limittime = ($today - ($days * 86400));


$query = "
SELECT count(POST_ID)
FROM {$config['TABLE_PREFIX']}POSTS
WHERE POST_POSTED_TIME > $limittime
";

$sth = $dbh->do_query($query);
list($total_posts) = $dbh->fetch_array( $sth );
$avg_posts_mod = ($total_posts % $days);
$total_posts = ($total_posts - $avg_posts_mod);
$avg_posts = ($total_posts / $days);

$smarty->assign("avgposts", $avg_posts);

Last edited by Carte Blanche; 05/31/2008 7:21 AM. Reason: epiphany
Sponsored Links
Joined: Mar 2000
Posts: 21,080
Likes: 3
I type like Navaho
I type like Navaho
Joined: Mar 2000
Posts: 21,080
Likes: 3
Very nice Carte Blanche - thank you for sharing thumbsup


- Allen wavey
- What Drives You?
Joined: Apr 2007
Posts: 42
User
User
Offline
Joined: Apr 2007
Posts: 42
Thank you so much!

smile


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Shock Hosting
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,583
Posts293,955
Members13,824
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 7368
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 7
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20260108)