[2.0.15] Redirect anonymous users to login

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
102
73%
Very Good
25
18%
Good
3
2%
Fair
1
1%
Poor
8
6%
 
Total votes: 139

TalkGwinnett
Registered User
Posts: 12
Joined: Tue Sep 28, 2004 2:47 am
Location: Gwinnett County, GA
Contact:

I apologize for the continued confusion....

Post by TalkGwinnett »

When I modify memberlist.php and then try to access the page as an anonymous user, I receive the following error:

Code: Select all

Parse error: parse error, unexpected $end in \\nas-001\winspace\10-talkgwinnett.com\www\memberlist.php on line 314
I have the permissions set for most forums at View=All, Read=All and Post=Reg.

I have read in this topic where the permissions must be set at Reg for all; however, I have also read that some forums can be View / Read = All.

Do all of the forums need to be set at Reg for View/Read/Post to install the Mod, and then the forums can be changed back later? Or must all permissions for all forums stay at Reg?

StefanKausL
Registered User
Posts: 36
Joined: Fri Jul 09, 2004 7:20 pm
Location: Germany
Contact:

Re: I apologize for the continued confusion....

Post by StefanKausL »

TalkGwinnett wrote: When I modify memberlist.php and then try to access the page as an anonymous user, I receive the following error:

Code: Select all

Parse error: parse error, unexpected $end in \\nas-001\winspace\10-talkgwinnett.com\www\memberlist.php on line 314

Maybe you copied the code without the closing parenthesis!?

Code: Select all

if ($userdata['user_id'] == ANONYMOUS)
{
	redirect(append_sid('login.'.$phpEx));
}
TalkGwinnett wrote: Do all of the forums need to be set at Reg for View/Read/Post to install the Mod, ...?

No. You can install and use it with all settings. But it makes not much sense to install it if all forums are set to All. :wink:

spool32
Registered User
Posts: 11
Joined: Mon Oct 04, 2004 10:49 pm
Contact:

very good mod

Post by spool32 »

this mod is a big help securing the forum

User avatar
Chappster
Registered User
Posts: 5
Joined: Tue Oct 19, 2004 2:21 pm
Location: Fremont, NE

Need a little help here!

Post by Chappster »

I have a class reunion web site that I maintain. I host with a company offers this for a message board. Pure beginner here - :oops: - This mod sound like what I have been trying to do. I want to make my board so only classmates will be able to use or see anything on it. I have found other things that people have posted on other boards and tried them with no success. I have actually ran into some problems, my register link is now gone so classmates couldn't register but I swiched styles and I have it back. I'll try figuring out that one later on, but to install this mod, where do I put it? At the very beginning of the memberlist.php ( and the other .php ) code or after something in the code? I really like this board and I think my classmates would like it also. If I can get this stuff figured out, I may even add it to one of my other web sites. I read all the post but didn't get a good idea where this code needed to be. I'd appriciate any help I could get on this.

Chappster

StefanKausL
Registered User
Posts: 36
Joined: Fri Jul 09, 2004 7:20 pm
Location: Germany
Contact:

Post by StefanKausL »

Last edited by StefanKausL on Wed Nov 24, 2004 4:56 pm, edited 1 time in total.

User avatar
Chappster
Registered User
Posts: 5
Joined: Tue Oct 19, 2004 2:21 pm
Location: Fremont, NE

Easier than I thought!

Post by Chappster »

GREAT! Thanks, This will be pretty easy to install even for me! I'm just starting to get into this and I really like it! It's a great program! Thanks Again!

narusegawa
Registered User
Posts: 52
Joined: Mon Feb 16, 2004 5:05 pm

Changes...

Post by narusegawa »

Thanks for this MOD. I've customized it for my needs, but going to post my changes here for anyone else that might want them.

Use this line instead of the redirect line in your mod

Code: Select all

if ($userdata['user_id'] == ANONYMOUS)
{
redirect(append_sid('login.'.$phpEx.'?redirect='.ereg_replace("^.+/", "", $_SERVER['PHP_SELF'])));
}
What this does it that when a user then tries to access a page that they aren't allowed to, by following a bookmark or a link, they get redirected to the login page. But then once they log in, they are further redirected to the page that they originally tried to get to.

I don't use the above method myself as my login is outsite the phpBB folder, all I do for that is ommit the ere_replace section. But this works great. And tested with a fresh 2.0.11 install.

narusegawa
Registered User
Posts: 52
Joined: Mon Feb 16, 2004 5:05 pm

Post by narusegawa »

Hmm... seems the code I pasted above only works with faq.php on my system. Weird. Might be just mine as I use logins outside the normal phpbb_root_folder.

I think my own method is better but I'm not sure if login_body.tpl can include php script.

Code: Select all

if ($userdata['user_id'] == ANONYMOUS)
{
	session_start();
	$_SESSION['http_referrer'] = ereg_replace("^.+/", "", $_SERVER['PHP_SELF']);
  redirect(append_sid('login.'.$phpEx));
}
Just need to get login.php to add that session value to a hidden input box on login_body.tpl
Last edited by narusegawa on Wed Nov 24, 2004 4:21 pm, edited 1 time in total.

narusegawa
Registered User
Posts: 52
Joined: Mon Feb 16, 2004 5:05 pm

Post by narusegawa »

Right... add the above code instead of the redirect(...) line that you have.

On login.php find

Code: Select all

		$s_hidden_fields = '<input type="hidden" name="redirect" value="' . $forward_page . '" />';
and just BEFORE it add

Code: Select all

		if ($forward_page == '') {
			session_start();
			if (!empty($_SESSION['http_referrer'])){
				$forward_page = $_SESSION['http_referrer'];
			} else {
				$forward_page = '';
			}
		}

Stacy
Registered User
Posts: 141
Joined: Sat Oct 04, 2003 9:36 pm
Location: St Louis
Contact:

Post by Stacy »

Thanks for this mod!

kdaddy
Registered User
Posts: 129
Joined: Wed Jan 14, 2004 5:51 am
Contact:

Thank you

Post by kdaddy »

I just wanted to Thank you for the simple mod. It will help me with an annoying anonymous infestation.

Again Thanks
kdaddy

PeanutFarmer
Registered User
Posts: 33
Joined: Mon Oct 11, 2004 1:11 pm

Post by PeanutFarmer »

I applied this mod to 2.0.11 and it work flawlessly except for the profile page. While it does block anon. browsers from viewing the information, it seems to interfere with the "confirmation code" .gif during the registration process. The image appears broken.

Has anyone else reported this? I'm not very proficient with PHP so I'm not sure how to troubleshoot it.

StefanKausL
Registered User
Posts: 36
Joined: Fri Jul 09, 2004 7:20 pm
Location: Germany
Contact:

Post by StefanKausL »

If upgraded from 2.0.10 to 2.0.11 with "confirmation code" active and the MOD works without modifications.

Joe Belmaati
Registered User
Posts: 2110
Joined: Sun Sep 28, 2003 7:35 pm
Location: Denmark

Post by Joe Belmaati »

Really nice MOD! Perhaps a more comprehensive way or more of a "teaser" version would be to show guests one thing, i.e. "This page contains information about our members - please register or login to view the memberlist" or some sort message. This can be done very simply by putting

Code: Select all

<!-- BEGIN switch_user_logged_out -->
Some info to guests
<!-- END switch_user_logged_out -->
around the info that only guests should see and

Code: Select all

<!-- BEGIN switch_user_logged_in -->
Your regular memberlist html
<!-- END switch_user_logged_in-->
around the info that your logged in members get, instead of the if statement for each of the php files you are MOD'ing.

Lastly, you can avoid touching the php-files by putting this:

Code: Select all

<!-- BEGIN switch_user_logged_out -->
<script language="javascript">
    window.location.href=("login.php");
</script>
<!-- END switch_user_logged_out -->
at the top of every template file that should redirect guests to login, in this case memberlist_body.tpl, groupcp_user_body.tpl, profile_view_body.tpl. Theoretically, my method should be slightly less taxing on performance, as it is using code that is already there in a standard phpbb distribution.

Nothing in the world wrong with this MOD - simply suggesting a simple alternative.. :D

PeanutFarmer
Registered User
Posts: 33
Joined: Mon Oct 11, 2004 1:11 pm

Post by PeanutFarmer »

StefanKausL wrote: If upgraded from 2.0.10 to 2.0.11 with "confirmation code" active and the MOD works without modifications.



How do I modify it to fit with 2.0.11? I'm very new at php.

Post Reply

Return to “[2.0.x] MOD Database Cleanup”