MyBB Community Forums

Full Version: Integrating MyBB into your website. (Login Form)
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 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Cant explain much this piece of code but i use it and integrated mybb into a torrent community(with some help)

    $mybb = mysql_query("SELECT uid, loginkey FROM ".TABLE_PREFIX."users WHERE uid = ".sqlesc($id));
    if (mysql_num_rows($mybb) >= 1) {
        $mybbuser = mysql_fetch_array($mybb);
        my_setcookiee("mybbuser", $mybbuser['uid']."_".$mybbuser['loginkey'], null, true);
    }
And many other functions u need and u r finsihed!
But torrent site is diff from an ordenary php site
Everything works fine but I get this at the top of my page.

Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.
You need to make sure to have this before you require global.php
define("IN_MYBB", 1);
Anyone know? :/
I am trying to use this code in my site, but I have a problem.
When I add the following code to the start of my site's index.php which is the site's main code, under public_html. It chdirs to forum directory, gets the user and session info.

<?php
define("IN_MYBB", 1);
$cwd = getcwd();
chdir('forum'); // path to MyBB
include './global.php';

if($mybb->user['uid'] > 0){
$user = $mybb->user;
echo "Hi, ".$user['username'];
}

chdir($cwd);

include("foo.php"); //needed for the site index
include("bar.php"); //needed for the site index
?>

also I have this in the code to put the links to the site's index.php

<?php
if($mybb->user['uid'] > 0){
echo '<td><a href=forum/member.php?action=logout&uid='.$user['uid'].'&sid='.$session->sid.'>Logout</a></td>';
}else{echo '<td><a href=forum/member.php?action=login>Login</a></td>';}
?>

When I login and logout as admin user it works. But when a normal user clicks to login he is directed to the member.php as normal and he logins and when he is redirected he gets the message below. He is seen to be logged in to forum, because he is able to see and use the logout link of mybb. Loguot link work normal at first, then ends in the same message as the following. But these never happen to admin user.
---Message--------
You do not have permission to access this page. This could be because of one of the following reasons:
Your account has either been suspended or you have been banned from accessing this resource.
You do not have permission to access this page. Are you trying to access administrative pages or a resource that you shouldn't be? Check in the forum rules that you are allowed to perform this action.
Your account may still be awaiting activation or moderation. (Resend Activation Code)

You are currently logged in with the username: xxxxx
-----------
There ise one category with one forum in mybb with category permissions; Can View Forum: Yes, Can View Threads Within Forum:Yes, Can Download Attachments: Yes.

Where can be the problem. Or What I am missing?
Any help will be appreciated.
thegreenblob Wrote:Anyone know? :/

did you put
define("IN_MYBB", 1);
in the block or in the page.tpl (or whatever you use)?[/code]
Yeah, I put that in. I seem to get the error any time I include the global.php :/
thegreenblob Wrote:Yeah, I put that in. I seem to get the error any time I include the global.php :/

by yes, is it in the block or in page.tpl.php before
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

I can't think of anywhere else it would/could go. [/code]
Its in the block.
put the define part in your theme's page.tpl.php file and see if that works.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48