MyBB Community Forums

Full Version: Update forum stats from an external site/script?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Well I am making an adoptables script right now, which features a MyBB forum bridge. A user account is automatically created in MyBB forum after he/she registers on the adoptables site.

So far I have been successful with user registration and cookie settings, but there's still a problem. The forum stat wont update automatically, so admins have to go to ACP to do this themselves. I have tried to find ways to implement this, no luck so far.

In fact, there are two functions in myBB's rebuild_forum_stats() and update_stats() functions that I need to look up. One of them requires database update in table mybbprefix__stats, which I actually have found a way to accomplish. The problem is with cache, I have no idea how cache works and how to use it with MyBB. It appears to be calling this method: $cache->update("stats", $stats, "dateline"), and its just so confusing what it does internally.

Can anyone please explain this to me? And if you do not mind answering, is there an easier way to rebuild MyBB's forum stats from a third party script or an external site? Please help.
This is fine as long as the script does what you want it to do.
function my_update_stats() {
global $cache;
$cache->update("stats", $stats, "dateline")
}
Is that what you tried already or something similar? Because you need to specify the $cache global if you are not including global.php
(2012-11-21, 08:44 PM)JordanMussi Wrote: [ -> ]This is fine as long as the script does what you want it to do.
function my_update_stats() {
global $cache;
$cache->update("stats", $stats, "dateline")
}
Is that what you tried already or something similar? Because you need to specify the $cache global if you are not including global.php

I see, so all I need is to include the global.php file in my external script and then call $cache->update() to rebuild stats? I will give a try, hopefully it works. Thanks for answering.

Sorry for doubleposting, but looks to me that your method wont work because of these lines in global.php file:

$working_dir = dirname(__FILE__);
if(!$working_dir)
{
	$working_dir = '.';
}

// Load main MyBB core file which begins all of the magic
require_once $working_dir."/inc/init.php";

So the $working_dir is not the same from an external script to mybb's root directory. For this reason init.php wont be loaded, and subsequent actions will all result in errors...

Can anyone please, help?