Cloudflare IP support

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Get Involved
User avatar
Lumpy Burgertushie
Registered User
Posts: 69228
Joined: Mon May 02, 2005 3:11 am

Re: Cloudflare IP support

Post by Lumpy Burgertushie »

I do believe that is because their instructions are for 3.0 not 3.1

robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
BigDrago
Registered User
Posts: 366
Joined: Fri Dec 10, 2004 5:16 pm
Location: Norway

Re: Cloudflare IP support

Post by BigDrago »

Lumpy Burgertushie wrote:I do believe that is because their instructions are for 3.0 not 3.1

robert
That was what I said :)
fulgan
Registered User
Posts: 73
Joined: Wed Jun 02, 2004 12:46 pm

Re: Cloudflare IP support

Post by fulgan »

BigDrago wrote:
Lumpy Burgertushie wrote:I do believe that is because their instructions are for 3.0 not 3.1

robert
That was what I said :)
Then you're in the wrong forum, pal : this is for 3.1.x :)
fulgan
Registered User
Posts: 73
Joined: Wed Jun 02, 2004 12:46 pm

Re: Cloudflare IP support

Post by fulgan »

Ok. I got 5 minutes to look into this again and here is a quick and dirty fix:

In phpbb\session.php around line 280, you'll see this line:

Code: Select all

$this->ip = htmlspecialchars_decode($request->server('REMOTE_ADDR'));
replace it with

Code: Select all

		if ($request->server('HTTP_CF_CONNECTING_IP') != '') 
		{
			$this->ip = htmlspecialchars_decode($request->server('HTTP_CF_CONNECTING_IP'));
		}
		else
		{
			$this->ip = htmlspecialchars_decode($request->server('REMOTE_ADDR'));
		};
BTW, in PHP 5.5+, you can't use

Code: Select all

!empty($request->server('HTTP_CF_CONNECTING_IP'))
BigDrago
Registered User
Posts: 366
Joined: Fri Dec 10, 2004 5:16 pm
Location: Norway

Re: Cloudflare IP support

Post by BigDrago »

Nice work! Thank you very much! Seems to be working. Using PHP Version 5.4.36
BigDrago
Registered User
Posts: 366
Joined: Fri Dec 10, 2004 5:16 pm
Location: Norway

Re: Cloudflare IP support

Post by BigDrago »

Hmmm... doesn't seem to work...
Getting "The submitted form was invalid. Try submitting again." when posting as guest.

Have to disable this:
ACP - security settings - disabled "Tie forms to guest sessions".
fulgan
Registered User
Posts: 73
Joined: Wed Jun 02, 2004 12:46 pm

Re: Cloudflare IP support

Post by fulgan »

Well, I don't allow guest posting so I really can't tell (why do that, anyway ? You're really in that much need for Russian counterfeit "enhancement" pills ?). Sounds like a minor issue, though.
BigDrago
Registered User
Posts: 366
Joined: Fri Dec 10, 2004 5:16 pm
Location: Norway

Re: Cloudflare IP support

Post by BigDrago »

fulgan wrote:Well, I don't allow guest posting so I really can't tell (why do that, anyway ? You're really in that much need for Russian counterfeit "enhancement" pills ?). Sounds like a minor issue, though.
Well. It is not just only posting. But guests can't register.
fulgan
Registered User
Posts: 73
Joined: Wed Jun 02, 2004 12:46 pm

Re: Cloudflare IP support

Post by fulgan »

BigDrago wrote:
fulgan wrote:Well, I don't allow guest posting so I really can't tell (why do that, anyway ? You're really in that much need for Russian counterfeit "enhancement" pills ?). Sounds like a minor issue, though.
Well. It is not just only posting. But guests can't register.

Ah, that's more annoying, I admit. I'll look into it tomorrow
BigDrago
Registered User
Posts: 366
Joined: Fri Dec 10, 2004 5:16 pm
Location: Norway

Re: Cloudflare IP support

Post by BigDrago »

Got an reply from Cloudflare support. They couldn´t help us :/
SugarD-x
Registered User
Posts: 46
Joined: Mon Jun 19, 2006 12:42 am
Location: Sacramento, California USA

Re: Cloudflare IP support

Post by SugarD-x »

Did anyone ever come up with a cleaner fix?
fulgan
Registered User
Posts: 73
Joined: Wed Jun 02, 2004 12:46 pm

Re: Cloudflare IP support

Post by fulgan »

SugarD-x wrote:Did anyone ever come up with a cleaner fix?
Nope, but on the other hand, I tested guest user registration and, at least on my board, it worked just fine no matter what settings I used for the "Tie forms to guest sessions" parameter.

It's hard to know what to fix when it just seems to work. I'd have loved for PHPBB to properly support reverse proxy but not enough to cook up the necessary code myself and submit it.
SugarD-x
Registered User
Posts: 46
Joined: Mon Jun 19, 2006 12:42 am
Location: Sacramento, California USA

Re: Cloudflare IP support

Post by SugarD-x »

I may give it a try then. I noticed you mentioned issues with PHP 5.5+. Is the fix in that post above the mentioned issue still working in PHP 5.5+, or is it affected too?
fulgan
Registered User
Posts: 73
Joined: Wed Jun 02, 2004 12:46 pm

Re: Cloudflare IP support

Post by fulgan »

I have only tested my fix on PHP 5.4.36-0 (which is what is provided by my hoster).

That being said, the only comment I see related to PHP 5.5 is the one where I comment on another suggested fix (which does not work). The code I provided should be compatible with both 5.4 and 5.5
SugarD-x
Registered User
Posts: 46
Joined: Mon Jun 19, 2006 12:42 am
Location: Sacramento, California USA

Re: Cloudflare IP support

Post by SugarD-x »

Awesome, thank you! I'll give it a try and see what happens. :)

Return to “Extension Requests”