[Snippet] Force login before you see anything V1

Little Mods and Snips 2

[Snippet] Force login before you see anything V1

Postby Sekuro » 10 May 2012, 11:23

Force login before you see anything V1

Un-logged-in users see login-mask only.

Credit: BNa

Simple. Perfect. Cant be tricked out.

open

includes/functions.php

find

Code: Select all
        // The following assigns all _common_ variables that may be used at any point in a template.
        $template->assign_vars(array( 


before add

Code: Select all
        // "Force login before you see anything" for guests and bots / BNa / 2012
        $login_script_name = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);
        
        if 
(($login_script_name !== 'ucp') && (($user->data['user_id'] == ANONYMOUS) || ($user->data['is_bot'])))
        {
        redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=login")); return;
        }
        // "Force login before you see anything" for guests and bots / BNa / 2012         


Each guest or bot, who visit your site, see only the login mask. Registering is possible, if active, bcs. of ucp.php?mode=register.
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



[Snippet] Force login before you see anything V1 - Addition

Postby Sekuro » 10 May 2012, 11:24

Addition V1

For a positiv-list (at example faq.php, additional to ucp.php), the code must be different.

Code: Select all

    
// "Force login before you see anything" for guests and bots / BNa / 2012
    $login_script_name = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);

    if (($login_script_name == 'ucp') ||  ($login_script_name == 'faq'))
    {
    // do nothing
    }    
    else
{
    
    if 
(($user->data['user_id'] == ANONYMOUS) || ($user->data['is_bot']))
    {
    redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=login")); return;
    }

    }
    // "Force login before you see anything" for guests and bots / BNa / 2012                  

For more positiv-list entrys take a look at the syntax and the brackets

Code: Select all
    if (($login_script_name == 'ucp') ||  ($login_script_name == 'faq') || ($login_script_name == 'memberlist'))
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



Return to Snip Cl@ss II

Who is online

Users browsing this forum: No registered users and 1 guest

cron