Version: 1.00, by Tigga
Developer Last Online: Nov 2023
Version: 2.3.x
Rating:
Released: 04-03-2003
Last Update: Never
Installs: 31
No support by the author.
A little while ago I ran into this problem... I like having a lot of statistics on my forum's homepage, but I don't like having a lot of queries on that page. That got me to start thinking of a better way to do it, hence the creation of this hack.
How does this hack work?
It's pretty simple really. Instead of counting every single thread, post, member and etc every time someone loads your forum, it only counts these after a specified amount of time and updates one table that the information will be pulled from. This hack is especially useful for high traffic sites and can reduce the time it takes to load your forum's homepage.
Statistics Included:
Total Threads
Threads Today
Total Posts
Posts Today
Total Members
Newest Member
Top Poster
Top Thread Starter
If you are an admin, it will show you the last time the stats were updated as well.
(Please note that some of these started as hacks from other members at vB.org. Most of them are so simple though I don't see much of a point in trying to figure out which one's I got from here X months ago. If your hack was included here and you would like credit given please post here and I will add it.)
Normally these stats would add 8 queries to your forum's homepage. With this hack installed it will only perform 1 query most of the time, and 9 queries when it needs to update the information. I have found this very useful to cut down on the number of queries on my homepage, decrease the page's loading time, and put less overall stress on my server.
Well that's about it. I hope some others will find this hack useful and if anyone has some suggestions for other stats they would like to include in the stats cache please let me know and I will try to implement them.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Yesterday at 05:23 PM Tiggasaid this in Post #39 Boofo - Actually the only thing that would affect is where it shows an admin the last time the cache was updated. The $datecut variable is what would need to be modified.
It was just a guess, and not a very good one it seems. I'll wait for your update then instead of messing it up.
04-24-03 at 06:23 PM Tiggasaid this in Post #39 Bofo - Actually the only thing that would affect is where it shows an admin the last time the cache was updated. The $datecut variable is what would need to be modified.
// members registered today
$datecut = mktime(0,0,0,date("m,$ourtimenow"), date("d,$ourtimenow"), date("y,$ourtimenow"));
$getmemstoday=$DB_site->query_first("SELECT count(*) AS count FROM user WHERE usergroupid=2 AND joindate>='$datecut'");
Actually you can just remove that 2nd instance of $datecut. They will both have the same result, so there's no point in having it there twice. I thought I had already taken that out, but I guess I forgot about it.
Thanks for pointing out the errors in the code. I guess I was more tired than I thought when I did that. I updated the file and the post above with the correct code though.
i set the user id to 0 as i hav the welcome hack installed and every time sum one registers a post is created to include the details of that person and the thread started is user id 0, so therefore the top thread starter is user id 0 but i get this error in index when adding 0 to where u said
PHP Code:
Invalid SQL: SELECT COUNT(*) AS count,postuserid,postusername FROM thread WHERE userid!='0' GROUP BY postuserid ORDER BY count DESC LIMIT 1
mysql error: Unknown column 'userid' in 'where clause'