dongpaipu8394 2014-10-25 00:49
浏览 150

CF_IPCountry标头指向Drupal中的所有请求

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.

  • 写回答

1条回答 默认 最新

  • dragonpeng200811111 2014-10-29 22:50
    关注

    Do you have something like the Drupal plugin installed or something like mod_cloudflare?

    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程