get ip of client. $_SERVER variable

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
blackshtormx
Registered User
Posts: 5
Joined: Fri Nov 30, 2018 1:06 pm

get ip of client. $_SERVER variable

Post by blackshtormx » Tue Dec 11, 2018 12:39 pm

I am trying to get client IP in phpbb3. but i can't, because it doesn't allow using $_SERVER[]. What are the ways i can get client IP? How to enable $_SERVER variables in phpbb3?

User avatar
ViolaF
Registered User
Posts: 1425
Joined: Tue Aug 14, 2012 11:52 pm

Re: get ip of client. $_SERVER variable

Post by ViolaF » Tue Dec 11, 2018 1:05 pm


User avatar
ViolaF
Registered User
Posts: 1425
Joined: Tue Aug 14, 2012 11:52 pm

Re: get ip of client. $_SERVER variable

Post by ViolaF » Tue Dec 11, 2018 1:07 pm

btw.: Cool function to detect IP's in 2018

https://stackoverflow.com/a/52059045

blackshtormx
Registered User
Posts: 5
Joined: Fri Nov 30, 2018 1:06 pm

Re: get ip of client. $_SERVER variable

Post by blackshtormx » Tue Dec 11, 2018 1:10 pm

ViolaF wrote:
Tue Dec 11, 2018 1:05 pm

Code: Select all

getenv('REMOTE_ADDR'); 
http://php.net/manual/de/function.getenv.php
Thanks worked.

StevieWonderer
Registered User
Posts: 24
Joined: Wed Oct 12, 2011 1:06 am

Re: get ip of client. $_SERVER variable

Post by StevieWonderer » Tue Dec 11, 2018 1:21 pm

I guess phpBB way would be

Code: Select all

$user->ip
or if you really need REMOTE_ADDR then

Code: Select all

$request->server('REMOTE_ADDR')
session.php:293 has lots of code after $request->server('REMOTE_ADDR') so maybe it would be better to check why it's so.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 16 guests