MyBB Community Forums

Full Version: MyBB Integrator login redirect issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Following my previous thread, I've been working with the integrator but I've ended up getting stuck with the global.php login redirect.

Basically MyBB is installed here:
www.mywebsite.com

The script I use in the MyBB integrator is located here:
www.mywebsite.com/somedir/test.php

Inside test.php I have this code:
define('IN_MYBB', NULL);
require_once '../global.php';
require_once 'class.MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

$loginResult = $MyBBI->login($_POST['username'],$_POST['password']);
If ($loginResult)
{
        Echo "Login Success";
}

Now the problem is if I logout of the MyBB forum using the normal interface/url then it logs out like normal but whenever I access test.php it redirects me to the login screen right after it runs:
require_once '../global.php';

So it doesn't run the MyBB integrator code, it just looks at global.php and realizes I'm not logged in so instead of logging me in through the integrator, it redirects me to the login page. This is getting very frustrating for me as I'm trying to make the login built into test.php so that I can POST the login details to test.php and it can run the whole script in one go without any redirects, but I keep on getting stuck as it keeps on redirecting.

Could anyone help me sort out this problem or does anyone know a work around? I guess the solution would be to login before the script starts and to create the correct MyBB sessions, but I don't know how MyBB works or how to do that.
No sure about it, but try writing this:
define('ALLOWABLE_PAGE, 1);

After:
define('IN_MYBB', NULL);

Probably will not work, but give it a try.
Thanks for the suggestion mate, but after trying it the same thing happens Confused.

Edit:

Is there any way I can login before I do the callouts for global.php and the MyBB integrator? Like create the sessions and stuff, I think that will be the only viable solution unless you guys have better ideas.
(2012-07-16, 06:06 PM)KillerKlient Wrote: [ -> ]Thanks for the suggestion mate, but after trying it the same thing happens Confused.

Edit:

Is there any way I can login before I do the callouts for global.php and the MyBB integrator? Like create the sessions and stuff, I think that will be the only viable solution unless you guys have better ideas.

Yes, there is solution as always, but you have to edit global.php

Find in /global.php (line 654):
if($mybb->usergroup['canview'] != 1)

and change it to:
if($mybb->usergroup['canview'] != 1 && (!defined('MYSECRET_HOOK') || MYSECRET_HOOK!== true))

then before include /global.php just:
define('MYSECRET_HOOK', true);
can anybody re-upload the MyBB integrator ?
i need this, and on the original site is 'Not Found' error.
(2013-08-30, 10:46 AM)yonelkent Wrote: [ -> ]can anybody re-upload the MyBB integrator ?
i need this, and on the original site is 'Not Found' error.

Its outdated and doesn't work bug-free with the current MyBB release. I'd rather advice you not to use it anymore.