How to get the HTTP_REFERER

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
trandoductin
Registered User
Posts: 76
Joined: Mon Sep 26, 2016 4:11 am

How to get the HTTP_REFERER

Post by trandoductin »

I am trying to get $_SERVER['HTTP_REFERER']
and i have tried
request_var('HTTP_REFERER', '', true, \phpbb\request\request_interface::SERVER);
and request->server('HTTP_REFERER','');
none of which seem to work so far.
I keep getting blank for the first one and some thing call on null error for the 2nd call.
Thanks in advance.
Last edited by trandoductin on Mon Aug 28, 2017 2:50 pm, edited 2 times in total.
User avatar
_Vinny_
Style Customisations
Style Customisations
Posts: 9580
Joined: Tue Aug 11, 2009 12:45 am
Location: Brazil
Name: Marcus Vinicius
Contact:

Re: How to get the HTTP_REFERER

Post by _Vinny_ »

This can help you: viewtopic.php?f=71&t=587207
Fodboldman
Registered User
Posts: 2
Joined: Thu Aug 17, 2017 11:05 am
Name: Christian Dyring Poulsen
Contact:

Re: How to get the HTTP_REFERER

Post by Fodboldman »

Try this

$http_referer = (isset($_SERVER['HTTP_REFERER'])) ? trim($_SERVER['HTTP_REFERER']) : trim(getenv('HTTP_REFERER'));
set_var($http_referer, $http_referer, 'string');
Christian Dyring
CEO at
https://fodboldoplevelser.dk
JEFFJOHNSON
I've Been Banned!
Posts: 4
Joined: Fri Oct 13, 2017 9:14 pm

Re: How to get the HTTP_REFERER

Post by JEFFJOHNSON »

If you're behind a load balancer sometimes the original referrer is masked and you have to use

X-Forwarded-For
User avatar
orynider
Translator
Posts: 271
Joined: Wed Nov 16, 2005 12:48 pm
Location: Arad, România
Name: Florin-Ciprian Bodin
Contact:

Re: How to get the HTTP_REFERER

Post by orynider »

Fodboldman wrote: Thu Aug 17, 2017 11:23 am Try this

$http_referer = (isset($_SERVER['HTTP_REFERER'])) ? trim($_SERVER['HTTP_REFERER']) : trim(getenv('HTTP_REFERER'));
set_var($http_referer, $http_referer, 'string');
For phpBB 3.1+ You must use the request class to access input data, so this will not work.
Post Reply

Return to “phpBB Custom Coding”