1 (edited by PHPAuctionsites.com 2006-01-19 21:20)

Topic: New Pages Login?

Hi Guys

Thanks for your help on my previous posts.

I am now ineed of some rather urgentish help please,  I would like to use the punbb forum registration, login, profile and logout system for the whole of my site.

For ref if this helps www.phpauctionsites.com/phpforum/

I would like to create new pages within any part of the domain (not just within /phpforum/ ) but would like to be able to make some pages available to logged in users only.

maybe some kind of include (Ex logincheck.php) file,  at the header of the new pages that checks if the user is logged in or not and send them either to the login page if not and if they are allow access to the requested page.

Is this best done by cookies or Sessions?

Can you guys show me the path to success?

I have read the integration forum, but was getting very confussed with the ammount of jargin and confiliting views of users and posts.:/

Kind Regards
Roger

I appreciate the help!! wink

Re: New Pages Login?

The simple skeleton of a punbb page looks like:

<?php

define('PUN_ROOT', './');

require PUN_ROOT.'include/common.php';

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

// your page code goes here

$db->close();

?>

This will check they are logged in (assuming your boards require guests to be logged in), and only output your code you add (eg. no punbb headers or footer etc).

If you wish a punbb intergrated page with punbb styles and headers etc you can use:

<?php

define('PUN_ROOT', './');

require PUN_ROOT.'include/common.php';

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

$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / My Intergrated Page');

require PUN_ROOT.'header.php';

// your page code goes here

require PUN_ROOT.'footer.php';

?>

Re: New Pages Login?

Hi Reines,

Thank you very very much, that has helped me loads as it also pulls the header and footer theme i have created. in mail.tbl

I have 3 problems now, 2 small and 1 big

The two small probs are fixed by changing the  define('PUN_ROOT', './'); to define('PUN_ROOT', './phpforum/');

and the other was the CSS Style was not beeing read, so in header.php i changed the following


<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />

TO

<link rel="stylesheet" type="text/css" href="http://phpauctionsites.com/phpforum/style/<?php echo $pun_user['style'].'.css' ?>" />

Now the only thing  i have a problem with is the the login in bit,

I would like the the forums to be read by guests (no login)  but the new pages i create be accessed by logged in members only.

I hope you understand what im getting at?

Thanks Guys
Roger

4 (edited by Dr.Jeckyl 2006-01-19 18:56)

Re: New Pages Login?

some tips regarding pun_root:

1:
http://punbb.org/forums/viewtopic.php?pid=57957#p57957

2:
i find putting

<?php
 //add ../ for each folder past the root
define('PUN_ROOT', './');

makes making pun pages a bit easier

3:
add the

<base href="<?php echo $pun_config['o_base_url'] ?>/" />

helps with the stylesheet issue too.

did this make sense?

~James
FluxBB - Less is more

Re: New Pages Login?

Thats great have changed the url for the style css  and all still works fine but for the pun_root  i cant change as the new pages i plan to create will alter directory folders above and below the forum instalation directory.

My only problem is restricting some pages to logged in members and some open to all.

The previous post has given me away to to this but by altering the the guests user group "Read Boards" to NO and i would like guests to has read for the forums still

Regards
Roger

Re: New Pages Login?

I have just spent a few hours trying some of the sugestion in the integration forum, so far nothing works and im now at a loss.

Is there anyone how can help me, im sure its a simple thing for those that know punbb inside n out.

All i need is a way to restrict access to new web pages i create to logged in members only.

Realy appreciate the help so far

Kind Regards
Rog

7 (edited by Reines 2006-01-19 21:40)

Re: New Pages Login?

you can change

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

to

if ($pun_user['is_guest'] === true)
    message($lang_common['No view']);

then no guests can view it.

Re: New Pages Login?

Reines, you are a star.

If only i new the $pun_user options, any more you know of that will help me. One i could do with is the $? to echo the username of the logged in member

Otherwise, Thank you so much

Kind Regards to all
Roger

Re: New Pages Login?

$pun_user['username']

The array is populated with the details of the user, taken from the user, groups and online tables (i think).

you could simply add a print_r($pun_user); somewhere to print out everything it contains if you need to know exactly.