Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2005, 11:15 PM
Death_Octimus's Avatar
Death_Octimus Death_Octimus is offline
 
Join Date: Jan 2005
Location: UK
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default remote info

Hello I'm looking how to get my forum stats on to my website but i'm very lost.... :ermm:

Can anyone help me.
Reply With Quote
  #2  
Old 01-19-2005, 11:24 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Give us some details, in what way if your website coded? Flat html or php, or maybe somthing else?

Its very simple to get the stats, we just need to know where you want them placed and what enviroment you are working with.
Reply With Quote
  #3  
Old 01-19-2005, 11:28 PM
Death_Octimus's Avatar
Death_Octimus Death_Octimus is offline
 
Join Date: Jan 2005
Location: UK
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad.loo
Give us some details, in what way if your website coded? Flat html or php, or maybe somthing else?

Its very simple to get the stats, we just need to know where you want them placed and what enviroment you are working with.
I'm working with php and mysql I just want total posts and total members on my front page and perhaps last poster. Pritty simple stuff i'm sure but vbulletin tends to confuse me lol plus i'm only basic in php.
Reply With Quote
  #4  
Old 01-20-2005, 04:37 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I think this is right, I coded it rather quickly so it may not work, maybe you can spot an error. In other words, its untested, use at own risk

Fill in the chdir right as per comment

PHP Code:
// ###########################################
// Enter the path to your vB folder below
// Example: /root/mysitename/public_html/forum
// ############################################

chdir('./root/mysitename/public_html/forum');

// ##########################################
// Connect to mysql server with vB config.php
// ##########################################

// this might not be needed, but I put it here to make sure anyway! :)
unset($usepconnect$servername$dbusername$dbpassword$dbname$dbcom$dbcom_db); // think I got em all...
require_once('./includes/config.php');
define('TABLE_PREFIX'$tableprefix);

// connect to vB mysql database
if (!empty($dbpassword))
{
    if (
$usepconnect == 1)
    {
        
$dbcom = @mysql_pconnect($servername$dbusername$dbpassword);
    }
    else
    {
        
$dbcom = @mysql_connect($servername$dbusername$dbpassword);
    }
}
else
{
    if (
$usepconnect == 1)
    {
        
$dbcom = @mysql_pconnect($servername$dbusername);
    }
    else
    {
        
$dbcom = @mysql_connect($servername$dbusername);
    }
}

// Check connection and error out if there is not one cause we turned off mysql_connect's ability to error out
if (!$dbcom)
{
    die(
'could not connect to mySQL');
}

if (!empty(
$dbname))
{
    
$dbcom_dn = @mysql_select_db($dbname$dbcom);
}
else
{
    die(
'no database name entered in vBs config.php file!');
}

// make sure we connected to database
if (!$dbcom_dn)
{
    die(
'could not connect to database');
}

// if we got this far the connection works!  so lets get some stats from memory
$sql_getstats = array();
$userstats = array();
$forumcache = array();
$sql_getstats = array('userstats, forumcache');

// query stats
if (!empty($sql_getstats))
{
    
$temp_sql mysql_query("SELECT title, data FROM " TABLE_PREFIX "datastore WHERE title IN ('" implode("', '"$sql_getstats) . "')"$dbcom);
    if (!
$temp_sql)
    {
        die(
'query to database for stats failed');
    }
}
else
{
    die(
'could not retrive stats, nothing enters in getstats array');
}
unset(
$sql_getstats);

// fetch arrays and unserialize data from cache
while ($stats = @mysql_fetch_array($temp_sqlMYSQL_ASSOC))
{
    switch(
$stats['title'])  // if's are better for two items but the switch will be easier to expand upon if you want more then 2 down the line
    
{
        
// user stats
        
case 'userstats':
        {
            
$userstats unserialize($stats['data']);
        }
        break;

        case 
'forumcache':
        {
            
$forumcache unserialize($stats['data']);
        }
        break;
    }
}
unset(
$stats);
@
mysql_free_result($temp_sql);

// finnaly time to get that important data in a form we can place into html :)

// get total posts/threads from forumcache
$postcount 0;
$threadcount 0;

if (!
is_array($forumcache))
{
    foreach(
$forumcache AS $poststats)
    {
        
$threadcount += $poststats['threadcount'];
        
$postcount += $poststats['replycount'];
    }
}
$threadcount number_format($threadcount);
$postcount number_format($postcount);

// get newest members's userid and name from userstats, and the total number of members
$membercount number_format($userstats['numbermembers']);
$newmember_username $userstats['newusername'];
$newmember_userid $userstats['newuserid']; 
Stats it will get:

$threadcount = Total number of threads based on results from forumcache
$postcount = Total number of posts based on forumcache
$membercount = Total number of members from userstat cache
$newmember_username = Username of the last member to register (userstat cache)
$newmember_userid = Userid of the last member to register (userstat cache)

Have fun, hope it works for you
Reply With Quote
  #5  
Old 01-20-2005, 12:36 PM
Death_Octimus's Avatar
Death_Octimus Death_Octimus is offline
 
Join Date: Jan 2005
Location: UK
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it almost works I've fixed it up and run it but the results are

0 Total number of threads based on results from forumcache
0 Total number of posts based on forumcache
0 Total number of members from userstat cache
Username of the last member to register (userstat cache)
Userid of the last member to register (userstat cache)

PHP Code:
<?php
// ###########################################
// Enter the path to your vB folder below
// Example: /root/mysitename/public_html/forum
// ############################################

chdir('/home/octimax6/public_html/forum/');

// ##########################################
// Connect to mysql server with vB config.php
// ##########################################

// this might not be needed, but I put it here to make sure anyway! :)
unset($usepconnect$servername$dbusername$dbpassword$dbname$dbcom$dbcom_db); // think I got em all...
require_once('./includes/config.php');

// connect to vB mysql database
if (!empty($dbpassword))
{
if (
$usepconnect == 1)
{
$dbcom = @mysql_pconnect($servername$dbusername$dbpassword);
}
else
{
$dbcom = @mysql_connect($servername$dbusername$dbpassword);
}
}
else
{
if (
$usepconnect == 1)
{
$dbcom = @mysql_pconnect($servername$dbusername);
}
else
{
$dbcom = @mysql_connect($servername$dbusername);
}
}

// Check connection and error out if there is not one cause we turned off mysql_connect's ability to error out
if (!$dbcom)
{
die(
'could not connect to mySQL');
}

if (!empty(
$dbname))
{
$dbcom_dn = @mysql_select_db($dbname$dbcom);
}
else
{
die(
'no database name entered in vBs config.php file!');
}

// make sure we connected to database
if (!$dbcom_dn)
{
die(
'could not connect to database');
}

// if we got this far the connection works!  so lets get some stats from memory
$sql_getstats = array();
$userstats = array();
$forumcache = array();
$sql_getstats = array('userstats, forumcache');

// query stats
if (!empty($sql_getstats))
{
$temp_sql mysql_query("SELECT title, data FROM vb3_datastore WHERE title IN ('" implode("', '"$sql_getstats) . "')"$dbcom);
if (!
$temp_sql)
{
die(
'query to database for stats failed');
}
}
else
{
die(
'could not retrive stats, nothing enters in getstats array');
}
unset(
$sql_getstats);

// fetch arrays and unserialize data from cache
while ($stats = @mysql_fetch_array($temp_sqlMYSQL_ASSOC))
{
switch(
$stats['title'])  // if's are better for two items but the switch will be easier to expand upon if you want more then 2 down the line
{
// user stats
case 'userstats':
{
$userstats unserialize($stats['data']);
}
break;

case 
'forumcache':
{
$forumcache unserialize($stats['data']);
}
break;
}
}
unset(
$stats);
@
mysql_free_result($temp_sql);

// finnaly time to get that important data in a form we can place into html :)

// get total posts/threads from forumcache
$postcount 0;
$threadcount 0;

if (!
is_array($forumcache))
    {
    foreach(
$forumcache AS $poststats)
        {
        
$threadcount += $poststats['threadcount'];
        
$postcount += $poststats['replycount'];
        }
    
$threadcount number_format($threadcount);
    
$postcount number_format($postcount);
    }
// get newest members's userid and name from userstats, and the total number of members
$membercount number_format($userstats['numbermembers']);
$newmember_username $userstats['newusername'];
$newmember_userid $userstats['newuserid'];


function 
stats(){
global 
$threadcount,$postcount,$membercount,$newmember_username,$newmember_userid;
echo 
$threadcount " Total number of threads based on results from forumcache<br />";
echo 
$postcount " Total number of posts based on forumcache<br />";
echo 
$membercount " Total number of members from userstat cache<br />";
echo 
$newmember_username " Username of the last member to register (userstat cache)<br />";
echo 
$newmember_userid " Userid of the last member to register (userstat cache)<br />";
}
?>
So i'm guessing the mysql query is wrong but I don't understand it.....

update

I've been running querys and been debugging and theres a problem in the mysql query.

SELECT title, data FROM vb3_datastore WHERE title IN (userstats,forumcache)

#1054 - Unknown column 'userstats' in 'where clause'

its there of course.

ok it gets worse.....

SELECT title, data FROM vb3_datastore WHERE userstats

don't even work.

help! :ermm:
Reply With Quote
  #6  
Old 01-21-2005, 04:25 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Change:

PHP Code:
$sql_getstats = array('userstats, forumcache'); 
To

PHP Code:
$sql_getstats = array('userstats''forumcache'); 
Sorry bout that
Reply With Quote
  #7  
Old 01-21-2005, 09:00 PM
Death_Octimus's Avatar
Death_Octimus Death_Octimus is offline
 
Join Date: Jan 2005
Location: UK
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If half works now but i'm happy thanks for yuor help.
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 10:31 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.06228 seconds
  • Memory Usage 2,282KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete