MyBB Community Forums

Full Version: include mybb functions with my website
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
so i wanna integrate my website with yours a single login
same functions ...
Ex:
$mybb->user['uid'] == 0 << Guest

how can includ this functios and for my website if i am using a totally different code (simple php ..)
include global.php and you'll have all the main MyBB stuff.
but if i dont need all your functiuon but only if user is logged or not ... ? or something else
+ lets say i wanna do next script

IF uid > 0 welcome User esle welcome Guest ?

how i write this in mybb ?!
here:
<?php
if ($Mybb->User['username'] = "") {
echo "Hello guest, please sign up";
} else {
echo "Hello ".$mybb->user['username'];
}
?>
Pardon my PHP syntax, i havent coded in it for a while Toungue
when i try to include require_once "/forum/global.php";

Warning: require_once(.forum/global.php) [function.require-once]: failed to open stream: No such file or directory in /home/site/public_html/theme/xtreme/html.php on line 4

Fatal error: require_once() [function.require]: Failed opening required '.forum/global.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/site/public_html/theme/xtreme/html.php on line 4

and now i get next error :

Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.
p.s (my site link is www.site.com forum link www.site.com/forum)
i included next :

include "/home/site/public_html/forum/global.php";

so why i am not able to include functions or i need to include forum and site in a single folder
Try this;
chdir("./forum");
define("IN_MYBB", 1);
require("./global.php");
chdir("./");

But add this code to top of /home/site/public_html/index.php or header.php instead of /home/site/public_html/theme/xtreme/html.php

Then you can use all board functions on your site.

For details : http://community.mybb.com/thread-60422.html
(2010-11-27, 03:00 PM)krky Wrote: [ -> ]Try this;
chdir("./forum");
define("IN_MYBB", 1);
require("./global.php");
chdir("./");

But add this code to top of /home/site/public_html/index.php or header.php instead of /home/site/public_html/theme/xtreme/html.php

Then you can use all board functions on your site.

For details : http://community.mybb.com/thread-60422.html


txn , but i get this error :
Fatal error: Cannot redeclare error() (previously declared in /home/site/public_html/includes/incglobal.php:203) in /home/site/public_html/forum/inc/functions.php on line 675


but is this posible without include global.php ?!
(2010-12-18, 10:35 AM)Evollution Wrote: [ -> ]
(2010-11-27, 03:00 PM)krky Wrote: [ -> ]Try this;
chdir("./forum");
define("IN_MYBB", 1);
require("./global.php");
chdir("./");

But add this code to top of /home/site/public_html/index.php or header.php instead of /home/site/public_html/theme/xtreme/html.php

Then you can use all board functions on your site.

For details : http://community.mybb.com/thread-60422.html


txn , but i get this error :
Fatal error: Cannot redeclare error() (previously declared in /home/site/public_html/includes/incglobal.php:203) in /home/site/public_html/forum/inc/functions.php on line 675


but is this posible without include global.php ?!

It is possible without global.php but it ends up being more work than necessary.

Try this using global include:

define("IN_MYBB", 1);
/* 
Set the location to your global.php file here in the include_once
// Assuming your current layout of the site located at /forum and your script at 
/theme/xtreme/html.php then your include would be 
"../../../forum/global.php" 
The one I'm using below is assuming your forum is at /forum and your script is at /
*/
include_once("forum/global.php");
print_r($mybb);
if ($mybb->user['uid'] == 0)
{
	echo "Guest";
}
else
{
	echo "User";
}

EDIT: You'll also have to make sure the script is in a location that is included in the cookie path
http://www.fifago.com/ Sad the same error
(2010-12-18, 12:54 PM)Evollution Wrote: [ -> ]http://www.fifago.com/ Sad the same error

I don't see the same error, the error you're getting now is concerning headers which means something in your script is not right. Post your script here or PM me and let me have a look at it.
Pages: 1 2