View Full Version : remote info
Death_Octimus
01-19-2005, 11:15 PM
Hello I'm looking how to get my forum stats on to my website but i'm very lost.... :ermm:
Can anyone help me.
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. :)
Death_Octimus
01-19-2005, 11:28 PM
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.
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
// ###########################################
// 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 :)
Death_Octimus
01-20-2005, 12:36 PM
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
// ###########################################
// 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_us ername,$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:
Change:
$sql_getstats = array('userstats, forumcache');
To
$sql_getstats = array('userstats', 'forumcache');
Sorry bout that ;)
Death_Octimus
01-21-2005, 09:00 PM
If half works now but i'm happy thanks for yuor help.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.