I'm trying to edit the phpbb source to make it so only people I give "permission" to see a page, can see the page. How I'm trying to do this is using the code that they're using to check to see if the user is authorized to view certain forums.
There is a forum, who permits the same people who can view the pages I'm trying to permit, to view it. This forum's id in the database is "3"
For this example, I'm trying to make it so search.php is only viewable to people who are authorized to view forum 3. If they're not authorized, it will say so, just like if they're not authorized to view a forum they try to access.
Here is the authorizing code before I edited it
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
{
if ( !$userdata['session_logged_in'] )
{
$redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
}
//
// The user is not authed to read this forum ...
//
$message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
message_die(GENERAL_MESSAGE, $message);
}
Here it is after I edited it
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$is_auth = array();
$is_auth = auth(AUTH_ALL, 3, $userdata, $forum_row);
if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
{
if ( !$userdata['session_logged_in'] )
{
redirect(append_sid("search.php", true));
}
//
// The user is not authed to read this forum ...
//
$message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
message_die(GENERAL_MESSAGE, $message);
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
I'm pretty sure I did nothing right. What this does is just constantly redirect the user back to search.php where it executes the redirection code again non-stop. Like a never ending loop.
I don't understand how their redirection code works. How is it redirecting the user to another page without having to authorize the user again?
I'm pretty clueless as to how to get this working. Anything helps. I'm getting desperate.