一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP禁止個別IP訪問網站

想不讓某個IP訪問網站,可以封他的IP,下面就提供這個方法。看下面的代碼。
復制代碼 代碼如下:
function get_ip_data(){  
    $ip=file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".get_client_ip());
    $ip = json_decode($ip);
    if($ip->code){
        return false;
    }
    $data = (array) $ip->data;
    if($data['region']=='湖北省' && !isCrawler()){
        exit('http://www.a.NET');
    }
}

function isCrawler() {
        $spiderSite= array(
                        "TencentTraveler",
                        "Baiduspider+",
                        "BaiduGame",
                        "Googlebot",
                        "msnbot",
                        "Sosospider+",
                        "Sogou web spider",
                        "ia_archiver",
                        "Yahoo! Slurp",
                        "YoudaoBot",
                        "Yahoo Slurp",
                        "MSNBot",
                        "Java (Often spam bot)",
                        "BaiDuSpider",
                        "Voila",
                        "Yandex bot",
                        "BSpider",
                        "twiceler",
                        "Sogou Spider",
                        "Speedy Spider",
                        "Google AdSense",
                        "Heritrix",
                        "Python-urllib",
                        "Alexa (IA Archiver)",
                        "Ask",
                        "Exabot",
                        "Custo",
                        "OutfoxBot/YodaoBot",
                        "yacy",
                        "SurveyBot",
                        "legs",
                        "lwp-trivial",
                        "Nutch",
                        "StackRambler",
                        "The web archive (IA Archiver)",
                        "Perl tool",
                        "MJ12bot",
                        "NETcraft",
                        "MSIECrawler",
                        "WGet tools",
                        "larbin",
                        "Fish search",
                );
        if(in_array(strtolower($_SERVER['HTTP_USER_AGENT']),$spiderSite)){
            return true;
        }else{
            return false;
        }
}

//取客戶端 ip
function get_client_ip()
{
    if (isset($_SERVER)){
            if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
                $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
                $realip = $_SERVER["HTTP_CLIENT_IP"];
            } else {
                $realip = $_SERVER["REMOTE_ADDR"];
            }
    } else {
            if (getenv("HTTP_X_FORWARDED_FOR")){
                $realip = getenv("HTTP_X_FORWARDED_FOR");
            } else if (getenv("HTTP_CLIENT_IP")) {
                $realip = getenv("HTTP_CLIENT_IP");
            } else {
                $realip = getenv("REMOTE_ADDR");
            }
        }
    return $realip;
}

php技術PHP禁止個別IP訪問網站,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲一区二区三区视频 | 女人张腿给男人桶视频免费版 | 久久精品爱国产免费久久 | 黄色视视频 | 天天摸天天爽视频69视频 | 中文字幕日韩女同互慰视频 | 精品日韩一区二区三区 | 高清视频黄色录像免费 | 久久久精品免费国产四虎 | 在线播放亚洲美女视频网站 | 一区免费在线观看 | 综合激情网站 | 都市激情综合 | 精品视频免费观看 | 久久久中文字幕日本 | 欧美特级视频 | 狠狠亚洲婷婷综合色香 | 久久久99精品久久久 | 亚洲综合网国产福利精品一区 | 欧美九九视频 | 中文字幕一区二区三区在线播放 | 欧美三级视频在线观看 | 国产91精品露脸国语对白 | 国产91在线精品福利 | 国产麻豆网站 | 小明日韩在线看看永久区域 | 久久老色鬼天天综合网观看 | 日韩有色 | 亚洲第一激情 | 91九色视频在线观看 | 91网页版| 欧美日韩一区二区三区视频 | 99午夜视频| 四虎久久 | 国产精品女同一区二区久久夜 | 久久综合爱 | 国产一区二区三区在线看 | 国产女主播福利在线 | 中文字幕日韩欧美一区二区三区 | 国语自产自拍秒拍在线视频 | 久久久久久极精品久久久 |