Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[TIP] Real_IP() function improvment
  • Hey guys, we have been using fuel for some time and only recently we update to 1.3 from 1.0
    saw a very nice change int he real_ip() function and now it can finally handle multi level proxies and get the deepest IP address. sometimes users have their own proxy cache running at home meaning the 'real ip' will be an internal private IP (http://en.wikipedia.org/wiki/Private_network) which is useless if you wanna block, also some squid proxy configs have the ability to mask the HTTP_X forwarder header. leaving it as 'unknown' My suggestion is to do a simple regular expression to check that the deepest IP as in fact in an IPV4/6 format AND also check that its not a private IP, if it then go one level up. Also you might in what kind of scenario a user will be using a multi level proxy. in my case my webserver run on reverse proxy so everyone is automatic on single proxy level there already to begin with, (revergse proxy /load balancers web server are very popular by the way)
    sorry if this doesnt make too much sense, English is not first language
    if you have question regarding what I mean please do ask I will try to explain better

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!