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_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'];
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: