MyBB Community Forums

Full Version: Some notes on site integration (CMS)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hej all, I just thought it might be usefull for anybody so I'll post it over here...

I got a CMS up and running at my page (Zaiendo.de), featured by MyBB.

The CMS uses the MyBB CSS-files, so the skins are working properly for the whole site.
I'm also using the MyBB user management, UIDs, login and usergroups are the same.

I found some usefull stuff here at MyBBoard.net but some codes changed in new versions so I'll just repost if anyone is interested.

Starting with connection to MyBB
define("IN_MYBB", 1);
define("NO_ONLINE", 1); // Don't show site at "who's online"
require("../board/global.php"); //path to global.php
My CMS runs on another DB then MyBB so I won't do MySQL querys on MyBB database.
Next step is pulling user information from MyBB
//Nutzervariablen setzen
$userid = $mybb->user['uid']; //User ID
$username = $mybb->user['username']; //Username
$logoutkey = "{$mybb->user['logoutkey']}"; //Logoutkey
$usergroup = $mybb->usergroup['gid']; //Usergroup
$userstyle = "{$mybb->user['style']}"; //Custom skin if choosen
$themename = $theme['name'];
Themename is a bit difficult, I need it for images since I wasn't able to get the image dir ($theme[imgdir] wasn't working properly for me).
I now set the image folder name same as the theme name and use the theme name in image paths, for example:
<img src='board/images/$themename/something.gif'>

Setting up the site CSS was very easy, just put this line into your code:
echo $stylesheets;
Worked properly, just had some problems with overwriting CSS attributes, for example link color was overwritten a couple of times with the panel link color...

Logoutlink:
<a href='../board/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}'><strong>Logout</strong></a>

Login if user has no uid:
if(!$mybb->user['uid']){
echo "<form action='../board/member.php' method='post'>
Username: <input type='text' name='username' size='10' maxlength='30'><br />
Password: <input type='password' name='password' size='10'>
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='$url'>
<input type='submit' class='submit' name='submit' value='Login'></form><br />";
}
I set url to my siteurl so it'll redirect properly, PHP_SELF made problems Wink

I do check permissions with myBB aswell, here for example the admin.php check:
if($mybb->usergroup['gid'] != 4 && $mybb->usergroup['gid'] != 11){
echo "No permission to access this site!";
exit;
}
Group ID 11 is custom one, 4 is admin.

Some plugins and variables are also accessible from the CMS, for example the "random slogan" plugin by Nickman (Mybbsource):
echo"{$myslogan}";

You can get almost every user information easily with including the global.php, it's stunning Wink
$autor = get_user(45);
echo $autor['usertitle'];
45 is a userid. Will output the user title.

I guess this can be improved in a lot of ways, feel free to add your opinion, suggestions and comments and of course use this for your own pages.

Thanks to the MyBB team, I never integrated a selfmade CMS that easily with a board (PhpBB and others are horrible in this aspect Big Grin ).

Regards and happy easter evryone!