Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Homepage Statistics Cache Details »»
Homepage Statistics Cache
Version: 1.00, by Tigga Tigga is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

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.

Comments
  #42  
Old 04-25-2003, 09:01 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Yesterday at 05:23 PM Tigga said 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.
Reply With Quote
  #43  
Old 04-25-2003, 10:05 AM
Sanjiyan's Avatar
Sanjiyan Sanjiyan is offline
 
Join Date: Jan 2002
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you get this to cache the front page stats on vbhome lite?

Heres the link to the stats listed:

www.theborg.cjb.net

the stats are along the left hand side.

thanks
Reply With Quote
  #44  
Old 05-13-2003, 03:17 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
04-24-03 at 06:23 PM Tigga said 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.
Tigga, did you get a chance to look at this yet?
Reply With Quote
  #45  
Old 05-18-2003, 10:09 AM
corsacrazy's Avatar
corsacrazy corsacrazy is offline
 
Join Date: May 2002
Location: london
Posts: 854
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

mate how can i exempt a certain user id out of the Top Thread Starter ?
Reply With Quote
  #46  
Old 05-18-2003, 10:38 PM
Tigga's Avatar
Tigga Tigga is offline
 
Join Date: Dec 2001
Location: Atlanta
Posts: 1,061
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Boofo - Actually I did. I just updated the text file with the new code. For anyone who's already installed this, you can just look for this code:
PHP Code:
$datecut mktime(0,0,0,date("m"), date("d"), date("y")); 
And replace it with this:
PHP Code:
$datecut mktime(0,0,0,date('m',"$ourtimenow"), date('d',"$ourtimenow"), date('y',"$ourtimenow")); 
There's no good way to have it go by the user's time offset, but this does at least go by your forum's default time.



corsacrazy - You would just need to look for this code:
PHP Code:
$topposter=$DB_site->query_first("SELECT username,posts,userid FROM user ORDER BY posts desc LIMIT 1"); 
And replace it with this:
PHP Code:
$topposter=$DB_site->query_first("SELECT username,posts,userid FROM user WHERE userid!='XX' ORDER BY posts desc LIMIT 1"); 
(Replace XX in that query with the user's id)
Reply With Quote
  #47  
Old 05-18-2003, 10:57 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could you use that here, too?

PHP Code:
// 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'"); 
Reply With Quote
  #48  
Old 05-18-2003, 11:11 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Shouldn't this:

PHP Code:
$datecut mktime(0,0,0,date("m,$ourtimenow"), date("d,$ourtimenow"), date("y,$ourtimenow")); 
be like this?

PHP Code:
$datecut mktime(0,0,0,date("m",$ourtimenow), date("d",$ourtimenow), date("y",$ourtimenow)); 
Reply With Quote
  #49  
Old 05-18-2003, 11:27 PM
Tigga's Avatar
Tigga Tigga is offline
 
Join Date: Dec 2001
Location: Atlanta
Posts: 1,061
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #50  
Old 05-19-2003, 06:09 AM
corsacrazy's Avatar
corsacrazy corsacrazy is offline
 
Join Date: May 2002
Location: london
Posts: 854
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

mysql error number1054 
Reply With Quote
  #51  
Old 05-19-2003, 01:42 PM
Tigga's Avatar
Tigga Tigga is offline
 
Join Date: Dec 2001
Location: Atlanta
Posts: 1,061
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Blah, sorry about that. Try replacing userid with postuserid.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:19 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04674 seconds
  • Memory Usage 2,333KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (8)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete