1. 安装方法

    http://php.net/manual/en/geoip.installation.php
    geoip中的PHP函数介绍:
    http://php.net/manual/en/book.geoip.php
    若Centos安装提示没有程序包,请执行:
    rpm -ivh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm
    Cpanel中安装不成功请参考链接:
    http://infantiablue.tumblr.com/post/264539259/install-geoip-on-cpanel-centos-server

  2. 案例
    <?php
        $countryArray =array(
            'USA'   //United States
            ,'GBR'   //United Kingdom
            ,'AUT'   //Australia
            ,'DEU'   //Germany
            ,'ITA'   //Italy
            ,'CAN'   //Canada
            ,'FRA'   //France
            ,'NZL'   //New Zealand
            ,'JPN'   //Japan
            ,'ESP'   //Spain
            ,'CHN'   //China
        );
        
        $fileName = $_GET['fileName'];
        if(isset($fileName)){
           $country_code = geoip_country_code3_by_name($_SERVER["REMOTE_ADDR"]);
    
          if(in_array($country_code, $countryArray))
             header("Location: http://www.google.com/".$fileName);
          else
             header("Location: http://www.baidu.com/".$fileName);
    }
    ?>
    PHP for geoip

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2021-12-25
  • 2022-01-26
  • 2021-10-25
  • 2021-07-10
  • 2021-12-27
猜你喜欢
  • 2021-10-10
  • 2021-07-29
  • 2022-01-03
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案