Jump to content

Creating "secret" pages for people logged in only.


ad_williams

Recommended Posts

Well ive got phbb3 foums set up on my site. Ive already made it so that you can use your forum login anywhere on the site. My next step is setting up secure pages that only people who are in a certain group on the forums can access. So far i have done this (the code below) but it comes up with this error when used on a webpage "[an error occurred while processing this directive] "

 

<?php 
define('IN_PHPBB', true); 
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forums/'; // Please change this to match the path of your installation. 
$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx); // This calls out the common PHPBB3 files, which we can use to easily verify users. 
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); // This calls out the PHPBB3 functions, which we can use to manipulate users. 
$user->session_begin(); 
$auth->acl($user->data); 
$user->setup(); 

if($user->data['is_registered'])
{
echo '<p>yes</p>';
}
else
{
echo '<p>no</p>'; //User's login failed
}
?>

 

The yes, no bit is just to make it simpler when testing

 

Any help will be appreciated.

 

Adam

ok thanks mate. Is there anyway i can make it so dreamweaver tells me when i do something wrong when writing it - like it does with HTML??

 

Sorry if its a bit off topic - just saves me asking for stupid reasons.

 

I doubt any IDE can really do that, atleast not with something like PHP. Anyway, Doesn't PHPBB allow you to only let certain groups view a forum? It's an admin configuration, I doubt it even needs you to touch the code, if I understand what you're asking.

your best bet at this point IMO is to try adding die() statements in there to see where it is actually killing the script. So you could do this:

 

<?php 
define('IN_PHPBB', true); 
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : 'forums/'; // Please change this to match the path of your installation. 
$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx) or die('could not include'); // This calls out the common PHPBB3 files, which we can use to easily verify users. 
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); // This calls out the PHPBB3 functions, which we can use to manipulate users. 
$user->session_begin(); 
$auth->acl($user->data); 
$user->setup(); 

if($user->data['is_registered'])
{
echo '<p>yes</p>';
}
else
{
echo '<p>no</p>'; //User's login failed
}
?>

if you noticed i added a die() statement to the include so that you can see if it is dying there or after it. best bet is to figure out where it is actually stopping at and then troubleshoot it. you could also just add echo statements before and after stuff to see if it echos it or not.

Thanks for helping guys - Problem solved

 

... Doesn't PHPBB allow you to only let certain groups view a forum? It's an admin configuration, I doubt it even needs you to touch the code, if I understand what you're asking.

 

Oni - just to clear it up, i mean for the pages on my website not certain forums. Thanks though :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.