Make phpBB Sessions Work on Pages Outside of phpBB Root

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Tom » Sun Feb 17, 2008 9:59 pm

Is there a way to make it where you can use session management for a phpBB forum on an area of a site that is outside of a phpBB root directory?

Well, I am trying to make it where my home page (i.e. http://www.example.com/index.php) has a login box where users can login to the forums. The forum's root directory is like this (i.e. http://www.example.com/phpbb). I was able to make the login box on the home page work and login a user when he fills out the login box. However, I want it to be that, once the user is logged into the forum, the login box disappears. I know that I can use the <!-- BEGIN_session_user_logged_in --> tags but the problem is that I cannot use those tags on PHP files that are outside of the forum's root directory.

So, my question is how can I get the session tags to work on PHP files that are outside of the forum's directory?
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Lumpy Burgertushie
Registered User
Posts: 66848
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Lumpy Burgertushie » Sun Feb 17, 2008 10:19 pm

if you want a page outside of phpbb to use phpbb's sessions, then you have to add the following to the code at the very top of the outstide page.
If it is not already a php file, then add the opening and closing php tags

Code: Select all

<?php

and

?>

Code: Select all


define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Tom » Sun Feb 17, 2008 11:07 pm

Well, when I add that to a page outside of the phpBB directory, I got this error:

Code: Select all

Warning: include(./extension.inc) [function.include]: failed to open stream: No such file or directory in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 4

Warning: include(./extension.inc) [function.include]: failed to open stream: No such file or directory in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 4

Warning: include() [function.include]: Failed opening './extension.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 4

Warning: include(./common.) [function.include]: failed to open stream: No such file or directory in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 5

Warning: include(./common.) [function.include]: failed to open stream: No such file or directory in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 5

Warning: include() [function.include]: Failed opening './common.' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 5

Fatal error: Call to undefined function session_pagestart() in /home/tcatullo/public_html/generalgamingplanet.com/index.php on line 10
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Lumpy Burgertushie
Registered User
Posts: 66848
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Lumpy Burgertushie » Sun Feb 17, 2008 11:38 pm

you don't have the phpbb root path correct.

it would be ../yourphpbb if it is one level up from your phpbb folder.

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
Dog Cow
Registered User
Posts: 2495
Joined: Fri Jan 28, 2005 12:14 am
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Dog Cow » Mon Feb 18, 2008 12:37 am

In that code he posted above, change the part where it says

Code: Select all

$phpbb_root_path = './';
to reflect where your phpBB files are.

For example, if you have phpBB in forums/ and another part of your site is gallery/, then change it to read

Code: Select all

$phpbb_root_path = '../forums/';
Moof!
Mac GUI Vault: Retro Apple II & Macintosh computing archive.
Inside Allerton bookMac GUIMac 512K Blog

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by drathbun » Mon Feb 18, 2008 5:15 am

When you're looking for coding help the best place to go is the MOD Writers forum on this board. There is also a KB article that you might find helpful.

http://www.phpbb.com/kb/article/phpbb2- ... tegration/

Moving now... have fun with your project. :)
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

User avatar
Dog Cow
Registered User
Posts: 2495
Joined: Fri Jan 28, 2005 12:14 am
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Dog Cow » Mon Feb 18, 2008 8:29 pm

Yes, you can have phpBB interlaced into your entire web site and run off of one set of files, and the trick is to first add what Lumpy Burgertushie posted to all of your files, then make sure the phpbb_root_path variable is set correctly. :)
Moof!
Mac GUI Vault: Retro Apple II & Macintosh computing archive.
Inside Allerton bookMac GUIMac 512K Blog

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Tom » Tue Feb 19, 2008 12:34 am

Thanks for your help, guys.

I did what you said and I have a few problems. First of all, it shows my forum's header and footer at the bottom of the page (the page outside of phpBB installation). And, the second problem is that I keep getting this error (which I think ties into my first problem about how the header and footer of my forum is showing up at the bottom of the page):
Warning: Cannot modify header information - headers already sent by (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27) in /home/tcatullo/public_html/generalgamingplanet.com/bb/includes/sessions.php on line 254

Warning: Cannot modify header information - headers already sent by (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27) in /home/tcatullo/public_html/generalgamingplanet.com/bb/includes/sessions.php on line 255

Warning: Cannot modify header information - headers already sent by (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27) in /home/tcatullo/public_html/generalgamingplanet.com/bb/includes/functions.php on line 1008

Warning: Cannot modify header information - headers already sent by (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27) in /home/tcatullo/public_html/generalgamingplanet.com/bb/includes/page_header.php on line 505

Warning: Cannot modify header information - headers already sent by (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27) in /home/tcatullo/public_html/generalgamingplanet.com/bb/includes/page_header.php on line 507

Warning: Cannot modify header information - headers already sent by (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27) in /home/tcatullo/public_html/generalgamingplanet.com/bb/includes/page_header.php on line 508
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Lumpy Burgertushie
Registered User
Posts: 66848
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Lumpy Burgertushie » Tue Feb 19, 2008 5:37 am

need to see the page that gives these errors.

paste the code for the page here in the code tags.

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51874
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Brf » Tue Feb 19, 2008 12:27 pm

legohalflife2man wrote: (output started at /home/tcatullo/public_html/generalgamingplanet.com/internal/php/forumbar.php:27)
Your forumbar.php is creating some HTML before the phpBB sessions code is run. The phpBB code has to be at the very top of your file, so it executes before anything else.

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Tom » Wed Feb 20, 2008 3:08 am

OK, I fixed that problem, but now I have another problem.

I made a login link on the index.php page. Here is a picture of where the login box is on that page: http://img352.imageshack.us/img352/5162/error1kh8.jpg . You can see the "Member Login" title there. Well, my first problem is that when you go to enter your login information for my forum in there, when you submit it, it brings you to a page that looks like this: http://img229.imageshack.us/img229/584/error2nx5.jpg . I noticed that instead of the address bar reading "www.mysite.com/forum/etc..." it says "www.mysite.com/etc..." and excludes the forum's directory. That's why I think this error is happening, but I'm not sure. Also, it keeps looking for phpBB's template images in the root directory of my web site instead of in the /forums/ directory (which I think kind of leads to this problem).

Also, when I use the <!-- BEGIN switch_user_logged_in --> tags on the index.php page (which is outside of my forum's directory), the tags don't really work for sessions and just act as HTML comments instead.

Does anyone have any ideas to help me?
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51874
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Brf » Wed Feb 20, 2008 3:19 am

For your login form, you have

Code: Select all

<input type="hidden" name="redirect" value=""><br>
<input type="hidden" name="redirect" value="">
so it is probably confusing it with redirect being an array. You should probably take both of those out, since you do not have a value in there anyway.

As for the template switches, those will only work within a phpBB template, not in a regular HTML file.

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Tom » Thu Feb 21, 2008 12:40 am

I got rid of what you said but it still won't work with the sessions. It's still treating the <!-- BEGIN switch_user_logged_out --> tags like HTML comments.
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Lumpy Burgertushie
Registered User
Posts: 66848
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Lumpy Burgertushie » Thu Feb 21, 2008 2:18 am

legohalflife2man wrote:I got rid of what you said but it still won't work with the sessions. It's still treating the <!-- BEGIN switch_user_logged_out --> tags like HTML comments.
you don't use switches in the php files. you only use them in the tpl files.

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Make phpBB Sessions Work on Pages Outside of phpBB Root

Post by Tom » Thu Feb 21, 2008 3:25 am

Well, is there a way to use session switches in a php file?
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

Post Reply

Return to “[2.0.x] MOD Writers Discussion”