Thread: remote info
View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01115 seconds
  • Memory Usage 1,824KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete