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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.