Add a login redirect for users not logged in who attempt to visit restricted forums ... also shows a forum/post doesn't exist for hidden forums/topics/posts if user is logged in but not authed to view them

git-svn-id: file:///svn/phpbb/trunk@2079 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-02-11 02:16:28 +00:00
parent bd6bd36d48
commit 67d9802335
2 changed files with 28 additions and 21 deletions

View file

@ -77,11 +77,10 @@ else
// If the query doesn't return any rows this isn't a valid forum. Inform // If the query doesn't return any rows this isn't a valid forum. Inform
// the user. // the user.
// //
if( !$total_rows = $db->sql_numrows($result) ) if( !($forum_row = $db->sql_fetchrow($result)) )
{ {
message_die(GENERAL_MESSAGE, 'Forum_not_exist'); message_die(GENERAL_MESSAGE, 'Forum_not_exist');
} }
$forum_row = $db->sql_fetchrow($result);
// //
// Start session management // Start session management
@ -100,10 +99,15 @@ $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
if( !$is_auth['auth_read'] || !$is_auth['auth_view'] ) if( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
{ {
if ( !$userdata['session_logged_in'] )
{
$redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : "" );
header("Location: " . append_sid("posting.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
}
// //
// The user is not authed to read this forum ... // The user is not authed to read this forum ...
// //
$message = sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']); $message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
message_die(GENERAL_MESSAGE, $message); message_die(GENERAL_MESSAGE, $message);
} }

View file

@ -160,16 +160,15 @@ $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.top
WHERE $join_sql WHERE $join_sql
AND f.forum_id = t.forum_id AND f.forum_id = t.forum_id
$order_sql"; $order_sql";
if( !$result = $db->sql_query($sql) ) if( !($result = $db->sql_query($sql)) )
{ {
message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql);
} }
if( !$total_rows = $db->sql_numrows($result) ) if( !($forum_row = $db->sql_fetchrow($result)) )
{ {
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', "", __LINE__, __FILE__, $sql); message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
} }
$forum_row = $db->sql_fetchrow($result);
$forum_id = $forum_row['forum_id']; $forum_id = $forum_row['forum_id'];
@ -182,6 +181,29 @@ init_userprefs($userdata);
// End session management // End session management
// //
//
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
{
if ( !$userdata['session_logged_in'] )
{
$redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
$redirect .= ( isset($start) ) ? "&start=$start" : "";
header("Location: " . append_sid("posting.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
}
$message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
message_die(GENERAL_MESSAGE, $message);
}
//
// End auth check
//
$forum_name = $forum_row['forum_name']; $forum_name = $forum_row['forum_name'];
$topic_title = $forum_row['topic_title']; $topic_title = $forum_row['topic_title'];
$topic_id = $forum_row['topic_id']; $topic_id = $forum_row['topic_id'];
@ -192,25 +214,6 @@ if(!empty($post_id))
$start = floor(($forum_row['prev_posts'] - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page']; $start = floor(($forum_row['prev_posts'] - 1) / $board_config['posts_per_page']) * $board_config['posts_per_page'];
} }
//
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
{
//
// The user is not authed to read this forum ...
//
$message = sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
message_die(GENERAL_MESSAGE, $message);
}
//
// End auth check
//
// //
// Is user watching this thread? This could potentially // Is user watching this thread? This could potentially
// be combined into the above query but the LEFT JOIN causes // be combined into the above query but the LEFT JOIN causes