Cause that’s what present in the server header when using Cloudflare.
Check the visitor_ip()
function
public function visitor_ip() {
$ipArr = array();
foreach ( array( 'HTTP_CF_CONNECTING_IP', 'HTTP_X_ORIGINATING_IP', 'HTTP_X_REMOTE_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
if ( array_key_exists( $key, $_SERVER ) === true ) {
foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
$ip = trim( $ip ); // just to be safe
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
array_push($ipArr, $ip);
//return $ip;
}
}
}
}
$currentIP = '';
$actualIP = '';
foreach ($ipArr as $ip) {
if($ip !== $_SERVER['SERVER_ADDR']) {
if($currentIP !== $ip) {
$currentIP = $ip;
$actualIP = $ip;
}
}
}
return $actualIP;
}