MyBB Community Forums

Full Version: require_once global.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I created a file in my web root called "testing.php" to test a few things before I pull them into my website proper. I added the following content, and saved it:

<?php
define("IN_MYBB", false);
require_once "forum/global.php";
?>

When I loaded it into my browser, I was greeted by my forum homepage (sans images). Logging in does not work, everything seems to point to my web root. I scanned global.php, nothing should be outputted.

The offending page: http://seabtech.empirehostings.net/testing.php
My forum: http://seabtech.empirehostings.net/forum

My main question is, why is this being outputted?
Dude, if you want to add a custom page :
follow this tut : http://community.mybb.com/thread-116225.html
The page you created has no call back function to the template , hence your board images and elements are errored.
First create page accordingly and then you recheck whether the error is gone or it still prersists Smile
hope this helps,
regards
I know that, it is not a custom page in MyBB. I don't want breadcrumbs or anything.

E.G my homepage is http://seabtech.empirehostings.net/index.php. Once I have this error resolved, I want to be able to use MyBB variables outside of MyBB as it were. I don't want to have templates from MyBB showing on the index.
Such as
if(!$mybb->user['uid'])
{
echo "<div class=\"alert alert-error\"><strong>Hi guest, you're not logged in.</strong></div>";
}
else
{
echo "<div class=\"alert alert-success\"><strong>Hi " . $mybb->user['username'] . "</strong></div>";
}

I do have the MyBB Integrator by from phpdave.com.
What about not defining IN_MYBB at all?

Just a blind shot.
It says:

Quote:Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.

(Most of mybb's internal files have that)
Good point.
Could you post the whole code? The below should work and show the current user name:

<?php

define('IN_MYBB', 1);
require dirname(__FILE__).'/forums/global.php';

echo "Hello, {$mybb->user['username']}";


Also, going to move this to plugins & modifications support as it's not directly related to the MyBB core.
Seabody Wrote:When I loaded it into my browser, I was greeted by my forum homepage (sans images)
Quote:My main question is, why is this being outputted?
it should not happen with the given code alone. it doesn't do that on a local test board.
(2013-04-07, 06:12 AM)Seabody Wrote: [ -> ]It says:

Quote:Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.

(Most of mybb's internal files have that)
You do not seem to have defined IN_MYBB. Follow Euan's code.
I did define IN_MYBB in the OP, I removed it following a suggestion.

@euan, I just added that, nothing changed. That is all my code, nothing else was in the file. See, I've had trouble requiring it in the past (mainly it always failed, I could never get the path right), so I tried just that to see if the path was correct.
Pages: 1 2