Current time: 03-20-2010, 06:15 AM Hello There, Guest! (LoginRegister)


Post Reply 
Calling MyBB engine from external script?
10-23-2008, 01:52 PM (This post was last modified: 10-23-2008 01:54 PM by siberianlaika.)
Post: #1
Question Calling MyBB engine from external script?
Hi!

I'm working now on Drupal bridge to MyBB. One of desirable features for this app is single sign-on (SSO). I made login from MyBB plugin to Drupal site and its works with such code:

PHP Code:
include('./includes/bootstrap.inc');
  
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  
user_authenticate(array('name' => $mybb->input['username'], 'pass' => $mybb->input['password'])); 

because Drupal allows to use it from other scripts. Just needed include bootstrap.inc and execute drupal_bootstrap(), then you may use Drupal functions - login, logout, save nodes, users etc.

But on other side I get in troubles Sad

I tried to initialize MyBB from Drupal module:

PHP Code:
global $db$lang$mybb$mybbgroups$time$cache$plugins$session$groupscache$displaygroupfields$templates;
  global 
$debug$templatecache$templatelist$maintimer$globaltime$parsetime;
  include(
"global.php");
  include(
MYBB_ROOT."inc/functions_post.php");
  include(
MYBB_ROOT."inc/functions_forumlist.php");
  include(
MYBB_ROOT."inc/class_parser.php"); 

No errors, init seems successfull, but I not found way how to login user to MyBB site from Drupal module. Dances around member.php not get me success. MyBB hooks also seems unuseful for this case. Fallback way is to imitate MyBB cookies and set them from Drupal directly, but I hope maybe another way exists?

Well... my questions are:
What is right way to include MyBB to external scripts and execute MyBB functions?
Is there method for external login/logut user to MyBB site?
Is ther methods for other operations like create/modify/delete threads/replies and so on?

Thank for any useful suggestions.
Visit this user's website Find all posts by this user
Quote this message in a reply
10-23-2008, 04:27 PM
Post: #2
RE: Calling MyBB engine from external script?
You shouldn't need to global all that stuff and just include global.php.

Try that. Unless you are executing functions from specific mybb includes there is no need to seperately include them. Login does not require more but the posting pages might.

Hope that helps.

Join MyBB Central for exclusive plugins. Downloads require a paid membership.
Do you need free Mybb Support?
[Image: mybbsig.php]
Visit this user's website Find all posts by this user
Quote this message in a reply
10-23-2008, 09:37 PM (This post was last modified: 10-24-2008 09:51 PM by siberianlaika.)
Post: #3
RE: Calling MyBB engine from external script?
Thank for directing me to right way. I digging code again and understand logic of MyBB (I hope). Sign-on works in both directions now Smile

For these who follows this topic later. Right piece of code for this task is:
PHP Code:
require_once("global.php");
      
$mybb->input['username'] = $username;
      
$mybb->input['password'] = $password;
      
$mybb->input['action'] = 'do_login';
      include(
MYBB_ROOT."member.php"); 
Visit this user's website Find all posts by this user
Quote this message in a reply
10-24-2008, 08:24 AM
Post: #4
RE: Calling MyBB engine from external script?
^ You might want to be careful with that. You're including global.php, then member.php will include it again. Easiest fix is to change "include" to "require_once".
Visit this user's website Find all posts by this user
Quote this message in a reply
10-24-2008, 09:30 AM
Post: #5
RE: Calling MyBB engine from external script?
(10-24-2008 08:24 AM)ZiNgA BuRgA Wrote:  ^ You might want to be careful with that. You're including global.php, then member.php will include it again. Easiest fix is to change "include" to "require_once".

You right, I fixed that, thanks.
Visit this user's website Find all posts by this user
Quote this message in a reply
10-24-2008, 07:12 PM
Post: #6
RE: Calling MyBB engine from external script?
How to get mybb settings in joomla?
I tried to include global.php but that didn't work
Find all posts by this user
Quote this message in a reply
10-25-2008, 01:58 AM
Post: #7
RE: Calling MyBB engine from external script?
(10-24-2008 07:12 PM)bombo Wrote:  How to get mybb settings in joomla?
I tried to include global.php but that didn't work
You'd probably need to manually map some things over. Including MyBB with Joombla doesn't mean that both scripts magically know how to interact with each other, unfortunately.
Visit this user's website Find all posts by this user
Quote this message in a reply
10-25-2008, 02:08 AM
Post: #8
RE: Calling MyBB engine from external script?
I wonder how hard it would be to create a bridge class. Does that even make sense?

Join MyBB Central for exclusive plugins. Downloads require a paid membership.
Do you need free Mybb Support?
[Image: mybbsig.php]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: