Page 1 of 1

Showing pages in Who's Online outside of phpBB root

Posted: Thu Jan 28, 2010 9:45 pm
by imkingdavid
Ok, so the way my site is set up, I have ./ which is my site root. It runs on the phpBB engine just like any page inside the board root would. I then have ./board/ which is my site's root index the link points to the ./board/index.php page. What I am trying to do is make the Who's Online page show the page name when they are in that location. It current shows them as online, but they are shown to be on the Index page, rather then on the Home page.

In viewonline, I have tried the following:

Code: Select all

case '../index':
            $location = 'Home page';
            $location_url = append_sid("{$phpbb_root_path}../index.$phpEx");
        break; 
But it doesn't work because, as I have learned, the preg_match above is ignoring anything that has non-alpha-numeric characters at the start (I think).

So does anyone know of a way to make it recognize pages up one directory from the main phpBB root directory? Thanks for any help in advance.

Re: Showing pages in Who's Online outside of phpBB root

Posted: Fri Jan 29, 2010 2:07 pm
by imkingdavid
It's been six hours, so bump. :)

Re: Showing pages in Who's Online outside of phpBB root

Posted: Fri Jan 29, 2010 2:15 pm
by comkidwizzer3
:lol:

Hmm... House was trying to do with tools.php :roll: :P

Anyway, try deleting preg_match, simple enough :twisted:

Re: Showing pages in Who's Online outside of phpBB root

Posted: Fri Jan 29, 2010 3:04 pm
by imkingdavid
Hadn't thought of just deleting the preg_match. I'll try it and let you know. 8-)

EDIT: Hmm didn't work. If you just simply delete the preg_match(), $on_page doesn't get set so the switch() breaks. So I tried some complicated stuff using strpos() and str_split() to get everything before the last period. That worked as I had hoped, except for people who were on viewforum or viewtopic. So now I've reverted back to how it was and am at square one. :/

Re: Showing pages in Who's Online outside of phpBB root

Posted: Sat Jan 30, 2010 5:34 am
by imkingdavid
I didn't reply right away because of the 6 hour rule. Unfortunately, that means that you missed my followup. Here's what I said:
EDIT: Hmm didn't work. If you just simply delete the preg_match(), $on_page doesn't get set so the switch() breaks. So I tried some complicated stuff using strpos() and str_split() to get everything before the last period. That worked as I had hoped, except for people who were on viewforum or viewtopic. So now I've reverted back to how it was and am at square one. :/
Does anyone know exactly what I need to do to achieve this?

Re: Showing pages in Who's Online outside of phpBB root

Posted: Sun Jan 31, 2010 7:35 pm
by imkingdavid
I take it this isn't an easy thing to do, then? :S

Re: Showing pages in Who's Online outside of phpBB root

Posted: Sun Jan 31, 2010 7:54 pm
by Sam
I have had to do something similar.

At the top of each page that belongs to your website and NOT phpBB, add this code:

Code: Select all

define('IN_WEBSITE', true);
$website_path = '/'; // meaning index.php in your site root      
This needs to go before $user->session_start() is called.

Now, open board/includes/session.php
FIND:

Code: Select all

            if (isset($_COOKIE[$config['cookie_name'] . '_sid']) || isset($_COOKIE[$config['cookie_name'] . '_u'])) 
ADD BEFORE:

Code: Select all

        if (defined('IN_WEBSITE'))
        {
            global $website_path;
            $this->page['page'] = $website_path;
        } 
Next, open board/viewonline.php

FIND

Code: Select all

                $location = $user->lang['INDEX'];
                $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); 
REPLACE WITH

Code: Select all

            if(defined('IN_WEBSITE'))
            {
                $location = 'Site Home';
                $location_url = append_sid("/");                
            }
            else
            {
                $location = $user->lang['INDEX'];
                $location_url = append_sid("{$phpbb_root_path}index.$phpEx");
            } 
Now, in that same switch, add your other cases. Like if you had a page where you had $website_path = '/blog/'; Add the following case:

Code: Select all

        case '/blog/':
            $location = 'Viewing Blog';
            $location_url = append_sid("/blog/");        
        break; 
Credit goes to evil<3 for figuring a lot of this out.

Re: Showing pages in Who's Online outside of phpBB root

Posted: Sun Jan 31, 2010 9:32 pm
by DoYouSpeakWak
This might be a bit offtopic. But it seems to be related and might inspire you.

http://www.phpbb3bbcodes.com/viewtopic.php?f=40&t=3195
http://www.phpbb3bbcodes.com/viewtopic.php?f=40&t=4013

Re: Showing pages in Who's Online outside of phpBB root

Posted: Sun Jan 31, 2010 10:53 pm
by imkingdavid
Thanks Syntax, I'll try that out as soon as I have the chance. And thanks for the links DYSW. :D