Topic: External script, how can I check that user is logged?

Hi,
I've made some external scripts, but I dont know how to check that user is logged on my forum.
Is there any function that returns 1 (or username) if user is logged and returns 0 if not?
Reactor.

Re: External script, how can I check that user is logged?

I've tried this:

f (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';

($hook = get_hook('in_start')) ? eval($hook) : null;

if ($forum_user['g_read_board'] == '0')
    message($lang_common['No view']);

// Load the index.php language file
require FORUM_ROOT.'lang/'.$forum_user['language'].'/index.php';


// Get list of forums and topics with new posts since last visit
if (!$forum_user['is_guest'])
{
  die('You are logged in !');
}
else
die('No permission');

... but it dont work. It need load of external includes, lang, cache. Still do not work.
I know that must be simple, but... help please.

Re: External script, how can I check that user is logged?

This method will not work correctly, because of the punbb cookie. What is the structure of your site? Where do you want to perform this check, and where is your forum located?

Re: External script, how can I check that user is logged?

My forum site is located at: www.pcmod.pl
My script site is located at: www.obrazki.pcmod.pl

I want to perform check inside od www.obrazki.pcmod.pl/index.php

Re: External script, how can I check that user is logged?

Slavok, so what about it?

6 (edited by Slavok 2009-02-24 09:50)

Re: External script, how can I check that user is logged?

This code should solve your problem. If it does not work, you should change the value of $cookie_domain variable to '.pcmod.pl'. Also don't forget to change PATH_TO_FORUM in this part of code:

if (!defined('FORUM_ROOT'))
   define('FORUM_ROOT', '<PATH_TO_FORUM>');
require FORUM_ROOT.'include/common.php';
if (!$forum_user['is_guest'])
  die('You are logged in !');
else
  die('No permission');