MyBB Community Forums

Full Version: MyBB 1.6.4 CloudFlare user ip fix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is just a fix for getting a users actual IP instead of CloudFlare's ip on MyBB 1.6.4 as the 1.6.3 fix doesn't work on 1.6.4

1. Go to /inc/ in your MyBB directory and open up functions.php

2. Go to line 2889 and edit the following:

Replace:
    if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
    {
        $ip = $_SERVER['REMOTE_ADDR'];
    }

with:
    if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['HTTP_CF_CONNECTING_IP']))
    {
        $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
    }

Reupload the file and enjoy!
tooooo hard to dd code


my pc hanged
Pretty sure 1.6.4 has a fix for this already Wink It's under Server & Optimisation settings I believe.

I could be entirely wrong though as I haven't used cloudflare for a while.
Thank you Richard :p
Does it work for 1.6.8 too?
Not needed for 1.6.8: ACP > Config > Settings > Server and Optimization Options > Scrutinize User's IP address? = Yes