Follow vBSEO on Twitter
vBulletin Modifications
  • Forums
  • Add-Ons
  • Template Modifications
  • Styles
  • Graphics
  • Tutorials
  • Support Center
  • Register
  • vBulletin SEO

Member Log In

Site Navigation

  • Register
  • Members List
  • Social Groups
  • Search
  • Today's Posts
  • Mark Forums Read

Latest Modifications

  • [vB 3.8.4] THX - Hack for VB. 3.8.4
    By: bluedog
  • [vB 3.8.4] Cyb - Chatbox V.2.3
    By: bluedog
  • [vB 4.0.x] PHPKD - Advanced Quick...
    By: PHPKD
  • [vB 3.6.x] StopSpam
    By: flappi282
  • [vB 3.8.x] vBulletin Chat Addon for...
    By: 123flashchat

Latest Template Mods

  • [vB 4.0.x] Remove My Profile Link...
    By: Ak Worm
  • [vB 3.8.x] Images DownloadBox...
    By: cRs!MP
  • [vB 3.8.x] Adviertise Mod On Forum...
    By: MG4
  • [vB 3.8.4] Images PassWordBox...
    By: cRs!MP
  • [vB 3.8.4] Footer Follow Ups
    By: Ak Worm

Latest Styles

  • [vB 4.0.x] 4.0.3 - VB4STYLE-TWEETA...
    By: Belon
  • [vB 4.0.x] [4.0.3] vbdesigns.de...
    By: Belon
  • [vB 3.8.4] CompletevB - Skylight
    By: DreadKnight
  • [vB 3.8.3] [vB 3.8.4] Barcelona...
    By: hoiquantinhoc.com
  • [vB 3.8.3] Natures Walk by vBSkin...
    By: Chri5

Latest Graphics

  • [vB ] [anim.]Team Ranks
    By: cRs!MP
  • [vB ] Abstract Circles (3...
    By: cRs!MP
  • [vB ] PlayStation Rank Images
    By: cRs!MP
  • [vB 3.6.12] Heavy Stroked Button...
    By: Shelley
  • [vB ] Minature Ranks.
    By: Shelley
vBulletin Modifications » Support Center » vBulletin Support » vBulletin Management Discussion » How do I fetch info from datastore inside a plugin?
Reply

 

  • Thread Tools
Old 07-18-2006, 01:26 AM   #1
Kriminal
vB Newbie

Activity Longevity
0/20 17/20
Today Posts
0/3 ssssssss2
Kriminal is on a distinguished road
Status: Offline Default How do I fetch info from datastore inside a plugin?
I want to show stats from my board, like it's explained in this mod: http://www.vbulletin.org/forum/showthread.php?t=95493
But, I want to save 3 of the 5 queries, refreshing stats every 5 minutes.
So, the only two stats whose stays "live" are the "online now"; the other 3 (total threads, total posts and total members) will be updated every 5 minutes and saved in datastore.

I did the following steps:
1) Create a ministats.php inside cron folder:
PHP Code:
  $numbersmembers = $vbulletin->db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");  
  
$ministats['numbermembers']= number_format($numbersmembers['users']);  
  
  
$counter = $vbulletin->db->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post"); 
  
$ministats['totalposts']=number_format($counter['posts']);  

  
$countthreads = $vbulletin->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread"); 
  
$ministats['totalthreads']=number_format($countthreads['threads']);

  
build_datastore('ministats', serialize($ministats)); 
2) Create a cron task to execute the php. I noticed that it works (the stats are saved in datastore table)

3) Create a plugin that:
a - execute a sql query to fetch the online members
b - retrieve info from datastore

The plugins is allocated in "global_start" hook, and this is the code:
PHP Code:
// online users  
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];  
$headerguests=$db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "session WHERE userid=0 AND lastactivity>$datecut");  
$headerusers=$db->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM " . TABLE_PREFIX . "session WHERE " . TABLE_PREFIX . "session.userid>0 AND " . TABLE_PREFIX . "session.lastactivity>$datecut");  
$headerguests=$headerguests[count];  
$headerusers=$headerusers[count];  
$totalonline=$headerguests+$headerusers;  

// info from datastore
$ministats = unserialize($vbulletin->ministats);
$numbermembers = $ministats['numbermembers'];
$totalposts = $ministats['totalposts'];
$totalthreads = $ministats['totalthreads']; 
The online members info retrieves correctly, but the info from datastore not.
So, my question is: how I do to fetch that info in the plugin?

Thanks in advance,
Reply With Quote

Reply

« Product code changes in 3.6 | I'm a user who wants access to a "mods only" forum on 3.0.2 »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cache System Explanation (datastore) Ken Iovino vBulletin Modification Tutorials 19 05-13-2006 07:56 PM



All times are GMT. The time now is 05:43 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Transverse Styles
  • Top
  • Archive
  • vBSEO
  • Contact Us
LinkBack
LinkBack URL LinkBack URL
About LinkBacks About LinkBacks
Bookmark & Share
Digg this Thread! Digg this Thread!
Add Thread to del.icio.us Add Thread to del.icio.us
Bookmark in Technorati Bookmark in Technorati
Furl this Thread! Furl this Thread!