MyBB Community Forums

Full Version: MyBB Integrator / MyBB SDK (Version 1.3)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
login and register
I have had a look at it and login and register are working fine.
The only error I have found is in the documentation of logout().

Here is an excerpt from the new documentation!
Quote:This function logs a user out. There is no parameter expected, since we do not want to be able to log other users out (e.g. expecting a variable like $user_id). logout returns the boolean status. If logout succeeds, it returns true, otherwise false.
However, in orde to logout, you need to add either a GET or POST parameter.
sid: Adding the sid as GET-Parameter - example.com?sid=THE_SID_OF_THE_USER
You can access the sid (session_id) with $MyBBI->mybb->session->sid.

logoutkey: Adding the logoutkey as GET-Parameter - example.com?logoutkey=THE_LOGOUTKEY_OF_THE_USER
You can access the logoutkey with $MyBBI->mybb->user['logoutkey']
hmm i have the class and my file inside mybb folder.
i have deactivated the registration from the forum
i don't have any public forum
and i login or create the user account depending if the user visits or not
the forum

every time i run my file i get the login screen

my file looks like this
<?php
session_start();
define('IN_MYBB',1);
require_once 'global.php';
require_once 'integrator.php';
if (($_SESSION['username']<>'') and ($_SESSION['password']<>''))
{
	$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang);
	$login_status = $MyBBI->login($_SESSION['username'],$_SESSION['password']);
	if ($login_status == true)
	{
	    header("Location: index.php");
		exit;
	}
	else
	{
	    $info = array(
	    'username' => $_SESSION['username'],
	    'password' => $_SESSION['password'],
	    'password2' => $_SESSION['password'],
	    'email' => $_SESSION['email'],
	    'email2' => $_SESSION['email'],
	    'hideemail' => 1,
	    'invisible' => 0,
	    'receivepms' => 0
		);
		$register_status = $MyBBI->register($info);
		if (is_array($register_status))
		{
	    	echo 'error : 1';
		}
		else
		{
	    	$login_status = $MyBBI->login($_SESSION['username'],$_SESSION['password']);
			if ($login_status == true)
			{
	    		header("Location: index.php");
				exit;
			}
			else
			{
				echo 'error : 2';
			}
		}
	}
}
else
{
	header("Location: ../index.php");
	exit;
}
?>

any sugestions ?
Why aren't you using the functions from the Integrator itself?
You can get the status if being used by using the function isLoggedIn()
This might be the fix you are looking for..., so get rid of your if structure, and replace
if (($_SESSION['username']<>'') and ($_SESSION['password']<>''))
with
if (!$MyBBI->isLoggedIn())

In order to get this to work, the $MyBBI objects needs to be created before going into that if structure of course - so you should put
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang);
after the following line [code]require_once 'integrator.php';

Have you tried to debug a little?
After the $MyBBI object is created, try to add following line afterwards:
echo '<pre>'; print_r($MyBBI); echo '</pre>';

If a lot of variables are displayed then the Integrator should run fine.
i use the session values to see if the user is logged in my site but that is not a problem.
the problem is that after require_once 'global.php'; it just loads the first page so it never get's to the rest of the code.
if i don't use the line require_once 'global.php'; the code fails with
Warning: MyBBIntegrator::require_once(MYBB_ROOTinc/class_parser.php) [mybbintegrator.require-once]: failed to open stream: No such file or directory
You have to load the global file, otherwise the Integrator doesn't work - as you have pointed out yourself.
What exactly do you mean with "first page".
Do you know in which part of the if-structure your code goes?
You should build in a view debug echos, which are followed by die or exit commands, so you can specify, what the code is exactly doing.
Then we might find the error.
Point is that the Integrator works fine for me at version 1.4.6
i solved the problem.
i had to let the guests view the forum and everything works as expected.
one small question
i run the registration like this
$info = array(
	    'username' => $_SESSION['name'],
	    'password' => $_SESSION['pas'],
	    'password2' => $_SESSION['pas'],
	    'email' => $_SESSION['email'],
	    'email2' => $_SESSION['email'],
	    'timezone'=>'3',
	    'dstcorrection'=>0,
	    'hideemail' => 1,
	    'invisible' => 0,
	    'receivepms' => 0
		);
		$register_status = $MyBBI->register($info);
but the time zone is not inserted corectly
everything else is ok
More information about "not inserted correctly" would be very nice.




I have just released the new version (1.2) of the Integrator!
Check http://phpdave.com/MyBBIntegrator for more information
i mean is not inserted at all. should be 3 no ? or i'm missing something ?
I have found an error in the register routine, it works now.
Therefore, there is a new - fixed - MyBBIntegrator version --> 1.2.1

http://phpdave.com/MyBBIntegrator
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15