【问题标题】:Rotate Links Using Geoplugin使用 Geoplugin 旋转链接
【发布时间】:2015-10-05 18:04:00
【问题描述】:

我是 geoplugin.class,用于将 CA 用户重定向到特定链接。

现在代码只允许我将用户重定向到 1 个网站。我想修改此代码,以便可以将用户重定向到任一

link1.com

link2.com

link3.com

有人对此有快速修改吗?

提前谢谢你。

<?php

    require_once('geoplugin.class.php');
    $geoplugin = new geoPlugin();
    $geoplugin->locate();


    $geo_region = $geoplugin->region;  

    switch($geo_region) {
        case 'CA':
             header('Location: http://www.link1.com');
             exit; 



        default: // exceptions
               header('Location: http://www.everyoneelsegoeshere.com');
               exit;

         }

 ?>

【问题讨论】:

    标签: php geolocation


    【解决方案1】:

    试试这个:

    require_once('geoplugin.class.php');
    $geoplugin = new geoPlugin();
    $geoplugin->locate();
    $geo_region = $geoplugin->region;
    
    
    
    switch($geo_region) {
        case 'CA':
        $links = array('link1.com','link2.com','link3.com');
        header('Location: http://'.$links[array_rand($links)]);
        exit; 
        default: // exceptions
        header('Location: http://www.everyoneelsegoeshere.com');
        exit;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-26
      相关资源
      最近更新 更多