CloudFlare IPs

6 months 2 weeks ago #4180 by Theodore Hildebrandt
Topic Author
Theodore Hildebrandt's Avatar
Posts: 10
Hello,

I'm really happy so far with all the progress made with this component.  It's really come a long way in a couple of years.

Something that we noticed recently is that people weren't able to vote because it said they had already voted.  Checking into it, we had the IP checker on, and we use CloudFlare.  CloudFlare routes all traffic through localized cached distribution, so the IP address in $_SERVER is always a CloudFlare IP shared by millions of end users.

When using CloudFlare, the code needs to check for the end users' IP addresses with: $_SERVER["HTTP_CF_CONNECTING_IP"] to get a user's unique IP.

I don't know how you want to handle that from a coding perspective, but it would sure help out those of us who use CloudFlare.

6 months 2 weeks ago - 6 months 2 weeks ago #4181 by Dmitrijs
Dmitrijs's Avatar
Posts: 1058
Replied by Dmitrijs on topic CloudFlare IPs
Hi Theodore.

Thank you for your kind words.

In case when the users have the same IP you can use "IP + Fingerprint" option. So in case when IP is found for vote, the fingerprint will be checked additionally.

Another way is to change the code of getIp() function of the component that is located under administrator/components/com_competition/helpers/utility.php and add $_SERVER["HTTP_CF_CONNECTING_IP"] to the list of checked environment variables. Probably like this:
if (!empty(getenv('REMOTE_ADDR')))
{
    $ipaddress = getenv('REMOTE_ADDR');
}
elseif (!empty(getenv('HTTP_X_FORWARDED_FOR')))
{
    $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
}
elseif (!empty(getenv('HTTP_CLIENT_IP')))
{
    $ipaddress = getenv('HTTP_CLIENT_IP');
}
elseif (!empty(getenv('HTTP_CF_CONNECTING_IP')))
{
    $ipaddress = getenv('HTTP_CF_CONNECTING_IP');
}

return filter_var($ipaddress, FILTER_VALIDATE_IP);

Best regards,
Dmitry

Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!
Last edit: 6 months 2 weeks ago by Dmitrijs.

6 months 2 weeks ago #4182 by Theodore Hildebrandt
Topic Author
Theodore Hildebrandt's Avatar
Posts: 10
Replied by Theodore Hildebrandt on topic CloudFlare IPs
Thanks Dmitry,

I know how I would change this, but I thought you should have a heads-up to change the source code properly for CloudFlare users. ;)

6 months 2 weeks ago #4183 by Dmitrijs
Dmitrijs's Avatar
Posts: 1058
Replied by Dmitrijs on topic CloudFlare IPs
Sure we will add it to the future versions.

Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!

You can get our help: Monday - Friday / 09:00 to 17:00 (GMT+2). but not limited. Our staff will be pleased to provide Premium support to every paid subscriber asap, but sometimes you should be ready to wait for our reply for up to 3 days. In case of free extensions we do the best to develop and maintain them either, but their support is not necessary.

Follow us in social media