Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 10 Years, 8 Months, 2 Weeks ago 2 PHP Questions (Matt)
#1
Solved: 10 Years, 8 Months, 2 Weeks ago
This is more directed toward Matt, since he is a PHP guru. Wink

1) If I place a file, say test.php in / and in /forum and put this at the beginning:
<?php
define('IN_MYBB', 1); // (1a)
require "./global.php";
?>
And then write <?php {$mybb->user['username']} ?> in both files, the one in / will not output anything. The one in /forum will. (If you're logged in of course).
So, I'm trying to figure out how to make it work.

2) I can't figure out this unexpected $end in one of my MyBB files I'm making. I'll link you to the files over PM.

3) (Sorry, I lied). When placing a login box on the site, for some reason, when you click "Login", it goes to http://www.jammingames.tk/member.php instead of /forum/member.php

So, thanks to Matt, or anyone else who can help me. Smile
[Image: sU7dBPH.png]
#2
Solved: 10 Years, 8 Months, 2 Weeks ago
This is normal because the line 'require "./global.php";' is requiring the global.php file in the actual directory.

If your directory change to another one than the one containing global.php then it will not find it.

Either you give the complete path to the global.php file or you change your directory to the proper one before executing this.


Edit : Syntax errors...
MyBBCodes.com owner/administrator
Cool " It is not what you know that matters, it is what you do or do not do!"
We have currently 175+ MyBB Exclusive Plugins, 80+ MyBB Compatible MyCodes
#3
Solved: 10 Years, 8 Months, 2 Weeks ago
Sorry, I forgot to mention, the file in the / directory uses
<?php
define('IN_MYBB', 1); // (1a)
require "forum/global.php";
?>
[Image: sU7dBPH.png]
#4
Solved: 10 Years, 8 Months, 2 Weeks ago
require "./forum/global.php";
No longer involved in the MyBB project.
#5
Solved: 10 Years, 8 Months, 2 Weeks ago
Nope, that didn't fix it.
[Image: sU7dBPH.png]
#6
Solved: 10 Years, 8 Months, 2 Weeks ago
1. Looks like it thinks you're a guest, it can't access the cookie when accessed from the parent folder. If you echo the uid instead of the username, you'll see it echoes 0 when you're in /

2. Make sure you've closed all {} [] etc. Is this working locally or on a localhost?? I often get an unexpected $end when uploading via FTP and I either reload the page before it's finished uploading, or the upload stops; it's basically an incomplete file.

3. Looks like the javascript for the quick login box doesn't like being used in a different folder to the forum. It doesn't take into account the directory of the forum, there's no way for it to know where the forum actually is in relation to the page it's currently on.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
#7
Solved: 10 Years, 8 Months, 2 Weeks ago
1. I'll just move the site to /forum won't be too hard.

2. No, it's not working on localhost. I'll PM you the link to the file with the error, and the full file (with includes).

3. The directory is /forum and it goes to / I don't know why.
[Image: sU7dBPH.png]
#8
Solved: 10 Years, 8 Months, 2 Weeks ago
(2010-09-12, 07:17 PM)MattRogowski Wrote: 1. Looks like it thinks you're a guest, it can't access the cookie when accessed from the parent folder. If you echo the uid instead of the username, you'll see it echoes 0 when you're in /

2. Make sure you've closed all {} [] etc. Is this working locally or on a localhost?? I often get an unexpected $end when uploading via FTP and I either reload the page before it's finished uploading, or the upload stops; it's basically an incomplete file.

3. Looks like the javascript for the quick login box doesn't like being used in a different folder to the forum. It doesn't take into account the directory of the forum, there's no way for it to know where the forum actually is in relation to the page it's currently on.
If mybb actually used setcookie instead of http cookies this problems would not exist

#9
Solved: 10 Years, 8 Months, 2 Weeks ago
set the cookie path to / and the domain to .yourdomain.com and clear your cookies in your browser.

for files outside the forum root, I always use

/**
 * set the realtive path to your forums directory from where this script is (without trailing slash)
 */

$forumdir = "./forum";

//end editing

define("IN_MYBB", 1);

if(substr($_SERVER['SCRIPT_NAME'],0,1) == "/")
{
	define('THIS_SCRIPT', substr($_SERVER['SCRIPT_NAME'],1));
}
else
{
	define('THIS_SCRIPT', $_SERVER['SCRIPT_NAME']);
}
$current_dir = getcwd();

//change working directory to allow board includes to work
$forumdirslash = $forumdir."/";
$change_dir = "./";

if([email protected]($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}

//include board files
require_once $change_dir."/global.php";

//change directory back to current where script is
@chdir($current_dir);

Then when I need to include a MyBB file I can use MYBB_ROOT from anywhere

require_once MYBB_ROOT."inc/functions.php";

Hope that helps
(2010-09-12, 07:17 PM)MattRogowski Wrote: 3. Looks like the javascript for the quick login box doesn't like being used in a different folder to the forum. It doesn't take into account the directory of the forum, there's no way for it to know where the forum actually is in relation to the page it's currently on.

this i true. I posted a fix at http://community.mybb.com/thread-56660.h...quicklogin which is a very simple thing to edit but it is a core file fix, which never makes it into a release. two lines to edit in one JS file
Lost interest, sold my sites, will browse here once in a while. It's been fun.
#10
Solved: 10 Years, 8 Months, 2 Weeks ago
(2010-09-12, 07:22 PM)lichtheman Wrote: 2. No, it's not working on localhost. I'll PM you the link to the file with the error, and the full file (with includes).

Works fine for me without the includes, don't know what's in those included files though.

You've also got an error in your SQL syntax.

WHERE `fid` = '2', `replyto` = '0'

should be:

WHERE `fid` = '2' AND `replyto` = '0'
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.


Forum Jump:


Users browsing this thread: 1 Guest(s)