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_sql, MYSQL_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