Topic: Using SSI (extern.php I guess?)

Hello,

I am trying to incorporate some functionality into my homepage that would check if the user has logged into the forum or not; if not it shows a login box and if so shows their user information (similar to how the forum works).

Do I have to use extern.php or is there a function I can use?

Thanks,
Chris

Edit: I guess this would work for checking if they are logged in?

define('FORUM_ROOT', './fluxbb/');
require FORUM_ROOT.'include/common.php';
$forum_user['is_guest']

Last edited by crhayes (2008-11-05 01:52:02)

Re: Using SSI (extern.php I guess?)

Yes what you mentioned above would be the best way. Though you may want to look at a few special constants you may wish to define before requiring common.php, for example you probably don't want your homepage displaying the maintenance message if the forums are put into maintenance mode, so should define FORUM_TURN_OFF_MAINT.

Re: Using SSI (extern.php I guess?)

Okay thanks!

I used this code as a test

<?php
define('FORUM_ROOT', './forum/');
require FORUM_ROOT.'include/common.php';
if($forum_user['is_guest'])
{
    echo "login please";
}
else
{
    echo "you are logged in";
}
?>

and I got this error:

Fatal error: Call to a member function query_build() on a non-object in C:\wamp\www\discoverthehammer\forum\include\functions.php on line 246

Do you know what would cause this?

EDIT: I am using Kohana PHP framework, and this code didn't work from on of the views. However I created my own page and it worked fine....so I'm just going to have to tinker around and see what the problem is.

Last edited by crhayes (2008-11-05 02:12:42)

Re: Using SSI (extern.php I guess?)

Well I think I have narrowed down my problem. I am trying to use this code

<?php
define('FORUM_ROOT', './forum/');
require FORUM_ROOT.'include/common.php';
if($forum_user['is_guest'])
{
    echo "login please";
}
else
{
    echo "you are logged in";
}
?>

within the Kohana framework. I have found (through echoing some info) that at line 84 in common.php, when

cookie_login($forum_user);

is called $forum_db is no longer an object.

 echo is_object($forum_db);

right before this line of code shows that $forum_db is an object, however if I include the same line of code in the cookie_login() function right after $forum_db is defined then it does not work.

Any idea what the problem could be?

Re: Using SSI (extern.php I guess?)

I have no idea how the Kohana framework works, but it sounds like it's now allowing the use of global variables?

Re: Using SSI (extern.php I guess?)

Yeah that is what I was thinking....I narrowed it down to the point where the information from $forum_config is placed in the $forum_user array.

Using this code

<?php
global $forum_db;
global $forum_user;
global $forum_config;

define('FORUM_ROOT', './forum/');
require FORUM_ROOT.'include/common.php';
if($forum_user['is_guest'])
{
    echo "login please";
}
else
{
    echo "you are logged in";
}
?>

allowed it to display "login please"...but it displays that even after logging in.

Edit: I got it to work by defining all of the variables as global within Kohana....do you think there is a problem with that? The code looks like

<?php
global $forum_db, $forum_user, $forum_config, $db_type, $forum_config, $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $forum_time_formats, $forum_date_formats;

define('FORUM_ROOT', './forum/');
require FORUM_ROOT.'include/common.php';
if($forum_user['is_guest'])
{
    echo "login please";
}
else
{
    echo "you are logged in";
}
?>

Last edited by crhayes (2008-11-05 22:01:06)

Re: Using SSI (extern.php I guess?)

Well it looks like it kinda defeats the purpose of using Kohana, but I doubt it will cause any problems.

Re: Using SSI (extern.php I guess?)

I don't think it defeats the purpose. My site is going to have a number of features, all of which will be coded using Kohana (with the exception of the forum). However, since the member system is already complete with FluxBB I am going to integrate that into my website (and therefore only use one member table). This is just kind of hacking Kohana in order to allow the FluxBB code to work within it..

I think it has something to do with the way Kohana uses MVC... somehow it messes with the variables in Flux and the scope gets messed up.