Force Login on index.php

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
User avatar
sam_8085
Registered User
Posts: 93
Joined: Wed Mar 25, 2009 4:28 am

Re: Force Login on index.php

Postby sam_8085 » Fri Mar 12, 2010 10:21 am

I have tried it on phpBB 3.0.7 PL1 its working smooth, Just few seconds to insall this mod.

Thanks for this !!!

Have a question .... How can I use Force Login on custom pages: ?

urkomurko
Registered User
Posts: 26
Joined: Wed May 28, 2008 10:20 am

Re: Force Login on index.php

Postby urkomurko » Tue Mar 16, 2010 9:08 am

urkomurko wrote:I know it should work, because I have made fresh installation of Phpbb 3.0.7, DB and Force login 1.0.10 and it worked strait away.

I eliminated the possibility of an error in Phpbb files and DB structure. I have compared DB structure of fresh DB and current DB in BeyondCompare and I did not any differences. I have also tried to connect with fresh Phpbb 3.0.7 installation on my current DB and it also did not work. So that left me, that the problem lays in data. Can you give me a tip, where is configuration about automatic logon is stored?


BR,

Uroš


I have found the solution for my problem :D . Coockie domain parameter was not properly set.

nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: Force Login on index.php

Postby nouveau » Tue Mar 16, 2010 10:11 am

Glad you got it sorted urkomurko :)
Formerly known as xceler8shun

nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: Force Login on index.php

Postby nouveau » Tue Mar 16, 2010 10:15 am

sam_8085 wrote:Have a question .... How can I use Force Login on custom pages: ?


Quickest way is to add the following after the session information in your custome php file, then enable it in the settings in the ACP. Ofcourse if you add it to more than 1 page then the ACP option will control all the custom pages you add this code to.

Code: Select all

// ----- Start mod - Force Login ------ //
if ($config['allow_force_login'])
   {
      if ($config['allow_force_login_bots'])
         {
            if ($config['allow_force_login_custom'] && $user->data['user_id'] == ANONYMOUS || $user->data['is_bot'])
               {   
                  login_box();
               }
         }
      else if ($config['allow_force_login_custom'] && $user->data['user_id'] == ANONYMOUS)
         {
            login_box();
         }       
   }   
// ----- End mod - Force Login -------- //
Formerly known as xceler8shun

samh5678
Registered User
Posts: 5
Joined: Wed Apr 19, 2006 2:30 pm

Re: Force Login on index.php

Postby samh5678 » Wed Apr 14, 2010 10:43 pm

I've installed this and it's good but two things:

- The force login page on the ACP doesn't seem to work, it is activated whether it is set to yes or no in the control panel.

- Is there a way to put a message on the index page telling them they have to login to see the forum? As some of my members got confused.

Thanks,

nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: Force Login on index.php

Postby nouveau » Thu Apr 15, 2010 7:16 am

samh5678 wrote:I've installed this and it's good but two things:

- The force login page on the ACP doesn't seem to work, it is activated whether it is set to yes or no in the control panel.

- Is there a way to put a message on the index page telling them they have to login to see the forum? As some of my members got confused.

Thanks,


Not too sure what you have done there.

How did you install the MOD, did you use auto mod, and are you using version 1.0.10 and what pages does the MOD malfunction on (all or some)?

So, basically on your board, when in "force login settings" in the ACP, if you set the MOD to disable it will still force users to login?
Formerly known as xceler8shun

samh5678
Registered User
Posts: 5
Joined: Wed Apr 19, 2006 2:30 pm

Re: Force Login on index.php

Postby samh5678 » Thu Apr 15, 2010 10:23 am

Hi, I'm using 1.0.10 and yep you've got it in one, it still forces them to login even when its disabled. I just copied the files across and did the file edits, same as any other mod.

Anyway not too bothered about it if there's a way to put a message on the index page instead of displaying 'no forums' as this confuses users.
Thanks,

nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: Force Login on index.php

Postby nouveau » Fri Apr 16, 2010 10:25 am

samh5678 wrote:Hi, I'm using 1.0.10 and yep you've got it in one, it still forces them to login even when its disabled. I just copied the files across and did the file edits, same as any other mod.

Anyway not too bothered about it if there's a way to put a message on the index page instead of displaying 'no forums' as this confuses users.
Thanks,


Have you run the install script?

The MOD wont display "no forums", the MOD will redirect users to the login page.

Can you post the code of you index.php file up here?
Formerly known as xceler8shun

samh5678
Registered User
Posts: 5
Joined: Wed Apr 19, 2006 2:30 pm

Re: Force Login on index.php

Postby samh5678 » Fri Apr 16, 2010 1:44 pm

Hi, I have run the install script, here is the index code:

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

// ----- Start mod - Force Login ------ //
if ($config['allow_force_login'])
   {
      if ($config['allow_force_login_bots'])
         {
            if ($config['allow_force_login_index'] && $user->data['user_id'] == ANONYMOUS || $user->data['is_bot'])
               {   
                  login_box();
               }
         }
      else if ($config['allow_force_login_index'] && $user->data['user_id'] == ANONYMOUS)
         {
            login_box();
         }       
   }   
// ----- End mod - Force Login -------- //


display_forums('', $config['load_moderators']);

// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts   = $config['num_posts'];
$total_topics   = $config['num_topics'];
$total_users   = $config['num_users'];

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
   $sql = 'SELECT group_id, group_name, group_colour, group_type
      FROM ' . GROUPS_TABLE . '
      WHERE group_legend = 1
      ORDER BY group_name ASC';
}
else
{
   $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
      FROM ' . GROUPS_TABLE . ' g
      LEFT JOIN ' . USER_GROUP_TABLE . ' ug
         ON (
            g.group_id = ug.group_id
            AND ug.user_id = ' . $user->data['user_id'] . '
            AND ug.user_pending = 0
         )
      WHERE g.group_legend = 1
         AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
      ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);

$legend = array();
while ($row = $db->sql_fetchrow($result))
{
   $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
   $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

   if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
   {
      $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
   }
   else
   {
         // www.phpBB-SEO.com SEO TOOLKIT BEGIN
      $phpbb_seo->prepare_url('group', $row['group_name'], $row['group_id']);
      // www.phpBB-SEO.com SEO TOOLKIT END
      $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
   }
}
$db->sql_freeresult($result);

$legend = implode(', ', $legend);

// Generate birthday list if required ...
$birthday_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
   $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
   $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
      FROM ' . USERS_TABLE . ' u
      LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
      WHERE (b.ban_id IS NULL
         OR b.ban_exclude = 1)
         AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
         AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
   $result = $db->sql_query($sql);

   while ($row = $db->sql_fetchrow($result))
   {
      $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

      if ($age = (int) substr($row['user_birthday'], -4))
      {
         $birthday_list .= ' (' . ($now['year'] - $age) . ')';
      }
   }
   $db->sql_freeresult($result);
}

// Assign index specific vars
$template->assign_vars(array(
   'TOTAL_POSTS'   => sprintf($user->lang[$l_total_post_s], $total_posts),
   'TOTAL_TOPICS'   => sprintf($user->lang[$l_total_topic_s], $total_topics),
   'TOTAL_USERS'   => sprintf($user->lang[$l_total_user_s], $total_users),
   'NEWEST_USER'   => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

   'LEGEND'      => $legend,
   'BIRTHDAY_LIST'   => $birthday_list,

   'FORUM_IMG'            => $user->img('forum_read', 'NO_NEW_POSTS'),
   'FORUM_NEW_IMG'         => $user->img('forum_unread', 'NEW_POSTS'),
   'FORUM_LOCKED_IMG'      => $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
   'FORUM_NEW_LOCKED_IMG'   => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),

   'S_LOGIN_ACTION'         => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
   'S_DISPLAY_BIRTHDAY_LIST'   => ($config['load_birthdays']) ? true : false,

   'U_MARK_FORUMS'      => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
   'U_MCP'            => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '')
);

// Output page
page_header($user->lang['INDEX']);

$template->set_filenames(array(
   'body' => 'index_body.html')
);

page_footer();

?>


Many thanks,

nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: Force Login on index.php

Postby nouveau » Sat Apr 17, 2010 12:27 pm

If the Board is displaying "no forums", it would be more of a permissions issue as the MOD won't cause that to be displayed in any instance, where as incorrect permissions for a user / group will.
Formerly known as xceler8shun


Return to “[3.0.x] MOD Database Releases”

Who is online

Users browsing this forum: No registered users and 8 guests