FriendsOfFlarum I tryed ban my self but not any changes. Extension still works?
Yannic i tryed to test ban my self :') I not checked extension code but for supporting Cloudflare, should use this server header: HTTP_CF_CONNECTING_IP
Note: Sorry for my bad English xD I try explain why:
Cloudflare using Proxy for protect your website from attacks and hidding your server real IP address. But your server (or PHP application) starts see wrong client IP address.
This page works under Cloudflare proxy: https://test.teteos.net/
First Line: Is my real IP address. Detected by $_SERVER['HTTP_CF_CONNECTING_IP']
.
Second Line: <?php echo $_SERVER['REMOTE_ADDR']; ?>
This page using this my PHP code for detect client ip. This code checks server headers and works fine with Cloudflare!
function Client_IP(){
# $_SERVER Header List
$headers = array(
'HTTP_CF_CONNECTING_IP', // Cloudflare
/* Proxy Servers - Start */
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_REAL_IP',
'HTTP_CLIENT_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'HTTP_REAL_IP',
'HTTP_CLUSTER_CLIENT_IP',
'X_FORWARDED_FOR',
'X_PROXYUSER_IP',
'FORWARDED_FOR',
'FORWARDED',
'REAL_IP',
'CLIENT_IP',
'CLUSTER_CLIENT_IP',
'CLIENTIP',
/* Proxy Servers - End */
'REMOTE_ADDR'
);
# Try get IP address with cheacking headers.
foreach ($headers as $index) {
if (isset($_SERVER[$index]) && filter_var($_SERVER[$index], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return $_SERVER[$index];
}
}
# If IP is ::1, accept this ipv6 address as 127.0.0.1.
if ( isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] == "::1" ){
return "127.0.0.1";
}
# Detection failed. Return null.
return null;
}
?>```