站群检测ip归属地,如果不是当前显示地域提示切换分站

    检测IP归属地参见以往文章

    <?php
    $wcity=ipcityindex();//检测IP归属地
    if($city=="长沙"){
    if($wcity==$city){//是当前显示地域
    }else{
    $fancha = $bw->selectOnly('*', 'bw_config', "city ='".$wcity."'", '');
    $tiaozhuan=$fancha["id"];
    $newid=$quanzhanconfig['domain'];
    if(!empty($tiaozhuan)  and $_COOKIE["qiehuan"]!=1){
    echo" <script>
    var boo = confirm('您可能在$wcity ,确认切换到$wcity 站吗?')
    if(boo){
    setCookie('qiehuan', '1', '1');
    self.location.href='http://m.$newid/city$tiaozhuan.html';
    }else{
    setCookie('qiehuan', '1', '1');
    }
    function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    console.log(cname + '/' + cvalue + '/' + exdays)
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = 'expires=' + d.toGMTString();
    document.cookie = cname + '=' + escape(cvalue) + '; ' + expires;
    console.log(document.cookie);
    }
    </script>";
    }
    }
    }
    ?>

    本博客所有文章如无特别注明均为原创。
    复制或转载请以超链接形式注明转自魏枫伦的博客,原文地址《站群检测ip归属地,如果不是当前显示地域提示切换分站
    标签:
    分享:

还没有人抢沙发呢~