PHP prohibits the IP access site of a certain area, does not filter the spider of the search engine

Source: Internet
Author: User

This inside of the code directly copies the OSC a friend, a little wait to paste the address. It's too slow to find it now.

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 ']== ' Hubei province ' &&!iscrawler ()) {exit (' http://www.lvtao.net ');
                        The 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 ARC
                        Hiver) "," Perl Tool "," Mj12bot "," Netcraft ",
                        "Msiecrawler", "WGet Tools", "Larbin",
 "Fish Search",               );
        if (In_array strtolower ($_server[' http_user_agent '), $spiderSite)) {return true;
        }else{return false; }///FETCH client 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; }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.