MyBB Community Forums

Full Version: [Tutorial] Integrating Your Site With MyBB (Advanced)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Well I kinda like creating tutorials to share my knowledge with everyone. Lets move on, the basics of this tutorial is how to integrate your website with mybb. There are only few requirements to understand this tutorial, and that is

Intern PHP Knowledge
Intern MySQL Coding Knowledge

So at your login page you should have a drop down box that will enable users to select whether they'll use the Main account database or the MyBB Database.

In my website I specified here
<select name=\"accm\"><option value=\"mybb\">MyBB Account</option><option value=\"main\">Main Account</option></select>

The select id is "accm" which means account method. The first one is the "Mybb Account" method. Once the form is submitted the database will choose MyBB as the account renderer. Secondly if the user chooses the "Main Account" it will use the main database to be its account renderer

MyBB Password Encryption Method
Well I kinda cracked this method in less than 30 minutes. I just analyzed the file "functions_user.php" well after analyzing much I end up successfully. Here is the encryption method used by MyBB

$hashed_password = md5($plaintext_password);
$encrypted_password = md5(md5($salt).$hashed_password);

Now how do we get the information from the mybb database if the connected database is a different one. Simple lets use a default mode of mysql database table connection

$query = mysql_query("SELECT * FROM `database`.`mybb_users` WHERE `username` = '$username' LIMIT 1");

After that we will need to reprogram your "login.php"(as an example)

if($_POST['accm'] == 'main') {
//argument
}
if($_POST['accm'] == 'mybb') {
//argument
}

Edit: I will show you how the script works for your mybb integration [December 17, 2009]
$hashed_password = md5($_POST['password']); /* For MyBB its $mybb->input['password'] */


$query = mysql_query("SELECT * FROM `database`.`mybb_users` WHERE `username` = '$username' LIMIT 1");
$row = mysql_fetch_array($query);

$encrypted_password = md5(md5($row['salt']).$hashed_password);
if($encrypted_password == $row['password']) {
/* Sessions-Cookies-Redirect */
}

HTML Form
/* written in PHP and NoN-PHP */

/* NoN-PHP */
<form action="script.php" method="post">
Username:<br>
<input type="text" name="username" /><br>
Password:<br>
<input type="password" name="password" /><br>
Account Method:<br>
<select name="server"><option value="main">Main</option><option value="mybb">MyBB</option></select>
</form>

/* PHP */
<form action=\"script.php\" method=\"post\">
Username:<br>
<input type=\"text\" name=\"username\" /><br>
Password:<br>
<input type=\"password\" name=\"password\" /><br>
Account Method:<br>
<select name=\"accm\"><option value=\"main\">Main</option><option value=\"mybb\">MyBB</option></select>

After all the hardwork you're ready to go! You can even use this to integrate with several PHP Applications such as

Drupal = Tested
Wordpress = Tested
Plain Custom Site = Tested

The tutorial only shows how to integrate your site with the MyBB login system. I will still make a new tutorial regarding on sessions and cookies.

The new version of this tutorial will have
User Profile in Your Site -> Kinda Integrate a little
Sessions & Cookies -> For both Forum and Main sites <- I will study how MyBB Sessions and Cookies work and I will create a tutorial about this
Limiting MyBB Accounts Against Main Accounts -> How to limit MyBB accounts on your site against the Main accounts

Till Then,
- n1tr0b, Core Developer - SynFyre
http://synfyre.net/
Thanks for the tutorial
But wich salt do you use/where do you take it?
(2009-12-29, 02:04 PM)joplayer Wrote: [ -> ]Thanks for the tutorial
But wich salt do you use/where do you take it?

The salt is from "mybb_users"
Thanks for the answer and the tutorial
(2009-12-30, 05:51 PM)joplayer Wrote: [ -> ]Thanks for the answer and the tutorial

No probs! ;D

Updated the tutorial
thread updated
So this works with the latest build too?
I hope it does, also how about a good and seamless wordpress integration? Any tutorial for that?
(2010-05-19, 12:30 PM)vids Wrote: [ -> ]So this works with the latest build too?
I hope it does, also how about a good and seamless wordpress integration? Any tutorial for that?

Yes it should, and no, there is a plugin, it only works for some people though. Its called WordBB.
(2010-05-19, 05:13 PM)41shots Wrote: [ -> ]
(2010-05-19, 12:30 PM)vids Wrote: [ -> ]So this works with the latest build too?
I hope it does, also how about a good and seamless wordpress integration? Any tutorial for that?

Yes it should, and no, there is a plugin, it only works for some people though. Its called WordBB.
WordBB has many more issues.
Hi

I have written a small function for my phpfox which gets the logged in username, id and password. i dont want to use the login form/page but just post this credentials to mybb. How do i go about that?
Pages: 1 2 3