Thread Rating:
  • 17 Vote(s) - 4.35 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MyBB Integrator / MyBB SDK (Version 1.3)
I really like the MyBB, good work!!!!

create user and login works perfectly for me.
Just have problem with the $MyBBI->logout();

Even though it seems to successfully logout but when I go to the forum link i am still login.
Also, the isLogin() always says not login even when I am login.


Does anybody able to help me on this?

Thanks,
Nelson
Reply
The script (where your trying to logout and check isLogin) got access to the MyBB cookies?
Reply
I have also created a strip down version scripts.
First the login script:

$MyBBI->mybb->input['name']=$user;
$MyBBI->mybb->input['password']=$pwd;
$login_status = $MyBBI->login($MyBBI->mybb->input['name'], $MyBBI->mybb->input['password']);
if ($login_status == true)
{
echo 'You were successfully logged in';
header( 'Location: forum/index.php' ) ;
}
else
{
echo 'The login routine failed';
}

Logout script:
define("IN_MYBB", 1);
define("NO_ONLINE", 1); // Don't show site at "who's online"
define('THIS_SCRIPT', 'default.php');
require_once "forum/global.php";
require_once 'forum/class.MyBBIntegrator.php';
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);


/******* logout ***********/
if ($MyBBI->logout())
{
echo 'You were successfully logged out';
} else {
echo 'You are NOT logged out';
}

After calling the login script, I do see the forum and login (this works fine!!).
Then I call the Logout.php script which says it is successful. And when type in the url to the forum/index.php, I still see the forum with the same user still login.

I am running on my local machine, so the domain is localhost. I have to leave it blank. FYI, If I put in ".localhost", I won't be able to login to the forum. The cleared the cookie and the same issue.

Any help will be highly appreciated.

Thanks,
Nelson
Reply
I'm running MyBB for test purposes on my localhost as well.
Here are my WORKING cookie settings:
domain: localhost
path: localhost/
prefix: (this is empty)

About your script:
Where does $user come from?
Where does $pwd come from?
Where is your MyBBIntegator in relation to your script?
People have experienced that there seems to be a problem, when the class is outside your script, so put it into the same directory
Reply
According to the document and cookie generator,
the domain should be left blank (empty) or .localhost and the path should be the path after the localhost.
So my path will be /MyTestSite/forum since my full url is http://localhost/MyTestSite/forum.
I will try your suggestion and see what happen.

The $user and $pwd will come from my own login screen. for the sake of testing, I have hardcoded the values for those variables.
MyBBIntegrator class is in the same directory as the forum but not in the directory where the calling page is coming from.

My login page is in http://localhost/MyTestSite/ and MyBBIntegrator class in http://localhost/MyTestSite/forum.

i will try to put the class in http://localhost/MyTestSite/ and see what happen.

Thanks,
Nelson

(2009-09-17, 07:59 AM)No0oB Wrote: I'm running MyBB for test purposes on my localhost as well.
Here are my WORKING cookie settings:
domain: localhost
path: localhost/
prefix: (this is empty)

About your script:
Where does $user come from?
Where does $pwd come from?
Where is your MyBBIntegator in relation to your script?
People have experienced that there seems to be a problem, when the class is outside your script, so put it into the same directory

Want to you some updates.
After applying what was suggested, I can't get in to the admin and other members can't login either. I cleared the cookie and the same.

The only way i can get back in, is to change the setting back to my original settings.

Anybody has any other suggestions?
Reply
I am kind of frustrated right now.
I have tried all differrent thing and still not working.

BTW, I am using the MyBB version 1.4 (the latest).

Do I need to send a sid or lock key? If so, how to I apply to this script:
if ($MyBBI->logout())
{
echo 'You were successfully logged out';
} else {
echo 'You are NOT logged out';
}

P.S. Do I need to post this somewhere else since it relates to 1.4. The reason I post this here was because the issue brought up here relates to my problem.

Thanks,
Nelson
Reply
Use:

example.com?logoutkey=$MyBBI->mybb->user['logoutkey']

as logout link
Reply
Sar,

Thanks. But where do I put that statement?

So, when I call the script say logout.php will I call logout.php?logoutkey=$MyBBI->mybb->user['logoutkey']
Reply
Yeh, you need to have somekind of link like:

<a href='http://www.YOUSITE.com/logout.php?logoutkey=<?=$MyBBI->mybb->user['logoutkey']?>'>Logout</a>

Owh, and @No0oB:
I am using your class for some time now, and made my own function to insert custom userfield values into the database to. So if a user has made a new custom userfield in the mybb admin, he can now insert the values into the db with a form on the website.

This is the function if you are interested:
function updateUserFields($data){
	$query = $this->db->query('
				SELECT *
				FROM '.TABLE_PREFIX.'profilefields');
	while ($row = $this->db->fetch_array($query)){
		$this->db->update_query("userfields", array("fid".$row['fid'] => $data[$row['name']]), 'ufid=\''.$this->mybb->user['uid'].'\'');
	}
}

This is how I get the userfield inputforms at the option page:
$query = $MyBB->db->query('
						SELECT *
						FROM '.TABLE_PREFIX.'profilefields
						ORDER BY disporder DESC
					');	
					
while ($row = $MyBB->db->fetch_array($query)){
	/*** Get the field types ***/
	$types = nl2br($row['type']);
	$types = explode("<br />", $types);
	
	/*** If fieldtype = text (eg. <input type='text'>)***/
	if($types['0'] == "text")
		echo "<label for='opt_".$row['name']."'>".$row['name']."</label><input id='opt_".$row['name']."' name='opt_".$row['name']."' type='".$types['0']."' value='".$data['fid'.$row['fid']]."' /><br />";

	/*** If fieldtype = select (eg. <select></select>)***/
	if($types['0'] == "select"){
		echo "<label for='opt_".$row['name']."'>".$row['name'].":</label> <select id='opt_".$row['name']."' name='opt_".$row['name']."'>";
		for($i=1; $i<count($types); $i++){
			echo "<option value='".$types[$i]."'";
			echo (trim($data['fid'.$row['fid']]) == trim($types[$i])) ? "selected='selected'" : "";
			echo ">".$types[$i]."</option>";
		}
		echo "</select><br />";
	}
	
	/*** If fieldtype = textarea (eg. <textarea></textarea>)***/
	if($types['0'] == "textarea")
		echo "<label for='opt_".$row['name']."'>".$row['name']."</label> <textarea id='opt_".$row['name']."' name='opt_".$row['name']."' />".$data['fid'.$row['fid']]."</textarea><br />";

	/*** If fieldtype = checkbox or radiobutton (eg. <input type='radio'>)***/
	if($types['0'] == "radio" OR $types['0'] == "checkbox"){
		echo "<label for='opt_".$row['name']."'>".$row['name'].":</label> ";
		for($i=1; $i<count($types); $i++){
			echo "<input type='".$types['0']."' value='".$types[$i]."'";
			echo (trim($data['fid'.$row['fid']]) == trim($types[$i])) ? ($types['0'] == "radio") ? "selected='selected'" : "checked='checked'" : "";
			echo "> ".$types[$i]." ";
		}
		echo "<br />";
	}
}

How I call the function:
$q = $MyBB->db->query('
						SELECT *
						FROM '.TABLE_PREFIX.'profilefields
						ORDER BY disporder DESC
					');		
					
while ($input = $MyBB->db->fetch_array($q))	
	$data[$input['name']] = $_POST['opt_'.$input['name']];
$MyBB->updateUserFields($data);

And finally, how I put the values in my profile page:
$q = $MyBB->db->query('
						SELECT *
						FROM '.TABLE_PREFIX.'profilefields
						ORDER BY disporder DESC
					');
					
while ($row = $MyBB->db->fetch_array($q)){
	echo $row['name'] .":". $data['fid'.$row['fid']]."<br />";
}

Well, let me know what you think, and please give me some credits if you use it Wink! Thanks!
Reply
Sar,

Thank you. I got it.

Nelson
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)