I'm starting a blog in Drupal and using Cloudflare DNS. They act as a 'proxy' and all my visitors have their ip. They offer an IP Geolocation option to show real users IP:
Once enabled, we will then add a header called "CF-IPCountry" to all requests we make to your website. Here are a couple of examples of how to access/store this value:
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; // to access in PHP
$country_code = $ENV{"HTTP_CF_IPCOUNTRY"}; # to access in Perl
The question is: how can I use this?
I'm a html/css/js person and making now my first steps into php. I searched this last two days and didn't found a single example how to implement this option. I tried this in the "template.php" file:
function TEMPLATE_drupal_add_http_header() {
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
}
But nothing happens and ip's still from Cloudflare. Can anyone help here? Is it so simple that it doesn't need any explanations (hence I didn't found one)?
Thank you.