Prohibit IP addresses in a region from accessing the website, and do not filter the search engine's spider php code.
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 ') ;}} 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 ;}// obtain the client ipfunction get_client_ip () {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 ;}