vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   vB3 Forumhome Stats Cache Serialize hack v2.2 (https://vborg.vbsupport.ru/showthread.php?t=61420)

Boofo 02-10-2004 10:00 PM

vB3 Forumhome Stats Cache Serialize hack v2.2
 
vB3 Forumhome Stats Cache Serialize hack
Version 2.2
(By Boofo)

What does this hack do?
This hack will add some forum statistics to your forumhome that will be cached (to reduce the query load) for a certain amount of time that can be set to whatever you want. This covers most of the stats any forum Admin would use on his site.

Note: This is the setting for the time interval (in minutes) that you want the cache to be updated on. The default value is 10 minutes. The following code is in the index.php part of this hack.

$updatetime = 10;

Once you install the Admin CP setting (at the end of this file), you will be able to update this from the Admin CP vBulletin Options settings.

Credits:
I want to thank Tigga for the original Forumhome Statistics Cache hack for vB2, partly on what this hack is based. I also want to thank EvilLS1 for his time and patience in helping put this hack together. Another thank you goes out to Mike Gaidin for testing this thoroughly while I was putting together this install file. And, finally, thank you goes out to NTLDR, for helping me track down a very stupid mistake on my part which I had overlooked. ;)

Version 2.0 credits go out to g-force2k2 for getting me started on the datastore version of this hack and guiding me through some of the rough parts in the beginning. And also to KirbyDE for answering all of my dummy questions while writing this version and verifying the code when I figured out all of my mistakes. This is my first attempt at using the datastore function but it seems to work better and be easier to code than the older way of doing things. ;)

Version Information:
Version 1.0
--Initial release
Version 2.0 --Completely rewritten using the datastore function for vB3. It now uses "serialize" to store the data and "unserialize" to retrieve the data. There is also now 1 less query when reading from the cache.
Version 2.1 --Combined the "new threads since last visit" and "new posts since last visit" queries into 1 query, thus eliminating another query on cache hits. Thanks goes out to g_force2k2 for this one. ;) Also added Admin CP setting code so you can change the time interval between cache updates via the Forum Display Option setting in the vBulletin Option in the Admin CP. That code to add is at the end of this file.
Version 2.2 --Added "Top Reputation" statistic (requested by rinkrat ) and totally re-did the template. It looks cleaner now.

New Installation:
Do all of the steps in this file.

To Update Version 1.0 to Version 2.0:
To update this hack you will need to do everything in this file over again except the second query (Query #2). After you have this hack up and running again and you have made sure it is running to your satisfaction, you can drop the statscache table (from version one of this hack) completely. It is no longer needed.

To Update Version 2.0 to Version 2.1:
You will need to re-add the code for the index.php and go to the end of this file and add the setting for the Admin CP.

To Update Version 2.1 to Version 2.2:
You will need to re-add the code for the index.php and replace the code for the forumhome template.

Installation overview:
Queries to run:
(2)
Files to edit: (2)
--index.php
--member.php
Templates to edit: (1)
--forumhome
Settings to add: (1)
--forumhomecachetime

vB3 Arcade hack stats addon:
https://vborg.vbsupport.ru/showpost....&postcount=262

The first attachment shows the Guest loggedin and the second attachment show the Registered Member and above loggedin.

Scrub 02-11-2004 04:45 AM

Awsome. :)

Allan 02-11-2004 09:50 AM

Good bad ..

Thank Boofo ;)

Boofo 02-11-2004 10:01 AM

What does Good Bad mean?

You forgot the install button here, too. ;)

Allan 02-11-2004 10:07 AM

oupss, I wanted to say, pretty work, you it is to it well :D

yes, I click ILLIKO ;)

Dan 02-11-2004 10:30 AM

nice hack Boofo

Natch 02-11-2004 10:34 AM

Sweet work Boofo - clean and simple :)

NyCwill 02-11-2004 12:05 PM

sweet hack :)

g-force2k2 02-11-2004 12:19 PM

Nice work Boofo, just some ideas for future vb3 stats hack, I would personally have used a datastore column instead of a new table ( special template ) and also would have used a cron job, but these are just some ideas. Nonetheless good work Boofo.

Cheers,
g-force2k2

Boofo 02-11-2004 12:21 PM

Quote:

Originally Posted by g-force2k2
Nice work Boofo, just some ideas for future vb3 stats hack, I would personally have used a datastore column instead of a new table ( special template ) and also would have used a cron job, but these are just some ideas. Nonetheless good work Boofo.

Cheers,
g-force2k2

Maybe we can get together and you can show me what you mean. The datastore is new to me. The cron job, I thought about but I wasn't sure I really needed to go that route. That is new to me in vB3, also. ;)

gmarik 02-11-2004 06:18 PM

Why this looks nice. Could add latest attachment as an option as well ...

Gio Takahashi 02-11-2004 07:08 PM

Will install! Good job.

Mike Gaidin 02-11-2004 08:19 PM

Nice one Bob. Glad to see you finally released it. :)

[high]* Mike Gaidin clicks install.[/high]

rinkrat 02-11-2004 08:57 PM

Can it say Top Reputation?

Boofo 02-12-2004 12:10 AM

You can add whatever you want to it. The possibilities are endless. ;)

Boofo 02-12-2004 07:41 PM

Ok, all you query junkies! ;) New version uploaded to first post. One more query deleted from this hack. Now uses serialize to store the data. ;)

Mike Gaidin 02-12-2004 08:50 PM

Upgraded. Good job Bob. :)

Boofo 02-12-2004 09:15 PM

Thanks, Mike! ;)

Alien 02-13-2004 03:05 AM

Quote:

Originally Posted by Boofo
You can add whatever you want to it. The possibilities are endless. ;)

Awesome work. How do the queries work overall? I understand it just grabs data at intervals or whatever, but after it does and someone loads the forumhome how many queries max extra are they running at that particular moment? :) Just curious!

[high]* Alien clicks install.[/high]

Boofo 02-13-2004 03:20 AM

This hack will add 1 query to what you already have (for the new threads and new posts since you last logged on). This can't be cached because it is per user. If you have 10 you will now have 11 when reading from the cache. Since the cache is serialized, there is no query there. So the update to the hack dropped one query. When it updates the cache, it will add 9 queries for all of the stats being updated. So you would then have 20 queries. But the 20 queries only runs at whatever interval you have set (default is 10 minutes). Once the cache is updated, you are back down to 11 queries until the next update. This way you can have numerous stats on your forumhome and not have to worry about a lot of server load at all times. With the serialzation, you can use these same stats on other ares of the board by just including the statscache in the special templates section of the file you want to use them in and you won't have you worry about any queries there (if I understand serialization, right, anyway). ;)

Does that help to understand this a little better. ;)

Mike Gaidin 02-15-2004 09:00 PM

Nice addition to the latest version Bob. :)

Moosehunter 02-24-2004 09:21 PM

I have a vbrc3 tables prefix that i edited it to the queries. Now i get this message:

Invalid SQL:
SELECT COUNT(*) AS referrals, user.username, user.userid
FROM vb3_user AS users
LEFT JOIN vb3_user ON (users.referrerid = user.userid)
WHERE users.referrerid <> 0
GROUP BY users.referrerid
ORDER BY referrals DESC
LIMIT 1

mysql error: Unknown table 'user' in field list

mysql error number: 1109

Is there anything to edit to get rid of this message?

Boofo 02-24-2004 09:46 PM

Try this:

PHP Code:

 $ref $DB_site->query_first("
   SELECT COUNT(*) AS referrals, user.username, user.userid
   FROM " 
TABLE_PREFIX "user AS users
   LEFT JOIN " 
TABLE_PREFIX "user ON (users.referrerid = user.userid)
   WHERE users.referrerid <> 0
   GROUP BY users.referrerid
   ORDER BY referrals
   DESC LIMIT 1
  "
); 


Moosehunter 02-24-2004 10:55 PM

Thanks for the quick reply. That never worked. So i took that whole referrer thing out and it is now working. I do not use the referer system anyways. Once again boofo thanks for the quick reply.

Boofo 02-24-2004 11:20 PM

That's strange. Optimize your tables in the Admin CP and try it again. There is no way that that shouldn't work unless you have a table a little messed up.

No problem on the reply. I just try to support my hacks as best I can. ;)

Don't forget to click install. ;)

Steve123 03-04-2004 10:40 AM

Hey Boofo thanks for the hack :)..

To tell you the truth i was thinking of making something like this a few days ago (with my limited php knowlege tho) hehe..

With my header i display total posts, members and threads on the forum.

Instead of adding statscache to every file (pain in the ass) i was thinking maybe adding that code (main code) to the phpinclude or even trying to add statscache to the specialtemplates using the phpinclude (possible?), im not to sure with this new vb3 where the phpincludes comes into play so yeh dunno if it would be possible...(havnt had time to look)

What do you guys and gals think?

Thanks

Boofo 03-04-2004 10:49 AM

I would leave it on the forumhome. You'd be adding a lot of unneccessay queries when the cache updates to all of your pages. ;)

But if you wanted to add the stats themselves to different pages and have the forumhome updated them as needed, then all you have the do is add $statscache to the specialtemplates of whatever page you want them on and do un unserialize and it would do no queries that way. ;)

Steve123 03-04-2004 10:59 AM

I would perfer it to be on the header, same way as i had it on vb2... (used to it now hehe)

The only parts i use are total threads, posts and members. Ive edited the rest out of your script.

I was going to set it to update every 20mins, therefor it would only run thoes 3-4 queries every 20mins, which isent so bad considering they are only quick ones..

im just trying to think of the best way of doing it ?.

Wow you do reply fast ;)

Steve123 03-04-2004 11:00 AM

==================

thats good and all, but if its in my header.. well thats alot of files.. hehe

Boofo 03-04-2004 11:07 AM

Give it a shot and let me know how it goes. I've never tried doing it that way before. ;)

If I was going to add it to my header, I would run the hack on the forumhome and let it do all of the updating and then just unserialize it. But to tell you the truth, I'm not sure what file I would have to do that in. Maybe init.php?

Steve123 03-04-2004 11:21 AM

yeh ill give it a go, im just rebuilding my forums atm (upgrading to vb3)...

Still tho, what i mite do is make it so it just updates on forumhome and thats it..

But how would i add statscache to the specialtemplate files without editing all the .php files by them selfs..

Just worked a 13hour shift and havnt used php for a while now, kinda forgot..(brains dead)

im sure its something like, (add to phpinclude)

$specialtemplate = ."',statscache'";

i think? heh..

Boofo 03-04-2004 05:03 PM

I'm not sure. I've never tried doing it like that. Let me know what you find out and if it works, I'll add it to the instructions. ;)

Ky Kiske 03-04-2004 06:37 PM

Rock On...I have been looking for this *installs*

djohn 03-04-2004 08:51 PM

Hello, i'd like to install this hack, but i don't need some of it's features, such as Top Referer, and most viewed profile. Is there a way to not to add them without using up the db queries? Also, could you please add a feature to show how many threads new messages were created in since your last visit? For example, instead of "There have been 1 new post since your last visit" it would say" There have been 6 new posts in 2 threads since your last visit. Would greatly appreciate that feature.

Boofo 03-04-2004 09:55 PM

Quote:

Originally Posted by djohn
Hello, i'd like to install this hack, but i don't need some of it's features, such as Top Referer, and most viewed profile. Is there a way to not to add them without using up the db queries? Also, could you please add a feature to show how many threads new messages were created in since your last visit? For example, instead of "There have been 1 new post since your last visit" it would say" There have been 6 new posts in 2 threads since your last visit. Would greatly appreciate that feature.

The new threads and posts since your last visit is already installed in this hack. But I do it as new posts and new threads since your last visit.

As far as taking out what you don't need, that is easy. Just take out the queries and the statscache variables for them and it shouled work fine.

Steve123 03-05-2004 12:33 AM

Hey Boofo

I think ive figured it out, had a good night sleep so my brain is awake again.. hah..

=====

Add stats to any page and header

OPEN: includes/init.php
FIND:
PHP Code:

        // add default special templates
        
$specialtemplates array_merge(array(
            
'options',
            
'cron',
            
'forumcache',
            
'usergroupcache',
            
'stylecache'
        
), $specialtemplates); 

REPLACE
PHP Code:

        // add default special templates
        
$specialtemplates array_merge(array(
            
'options',
            
'cron',
            
'forumcache',
            
'usergroupcache',
            
'stylecache',
                                                
'statscache'
        
), $specialtemplates); 

Edit Template PHPINCLUDE

ADD:
PHP Code:

$statscache unserialize($datastore['statscache']); 

================

It seems to be working, this will only update on forumhome but you can use the $statscache vars on any template with no extra queries.

(will work out a good way to make it update every 10mins no matter what page later on)

Boofo 03-05-2004 12:55 AM

I see my initial guess of the init.php was correct. ;)

As long as the board is fairly busy, even with guests, it should be ok updating on the forumhome. Can you post a screenshot of the stats in the header? I would like to seee how you've made it look. I might do this myself. ;)

Steve123 03-05-2004 02:09 AM

Keep in mind that i am in the process of upgrading to vb3 from vb2.

This is what ive done so far..

Boofo 03-05-2004 02:15 AM

Looks good. You moved the navbar into the header, right? Maybe you can help me to do that? ;)

Steve123 03-05-2004 02:29 AM

Yeh, i didn't like the navbar where it was..

So i cut the menu out of the navbar and stuck it there.. easy as that :).. no coding needed.

Ive made my own little welcome panel, like the one in vb2 for my forum home, then just had a small little navbar for the rest of the forum.. (shows where u are) and flashes with new pm if u have a new pm.. :)


All times are GMT. The time now is 04:49 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01522 seconds
  • Memory Usage 1,840KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete