搬运-蜘蛛php测试代码

可以通过php的gethostbyname功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function testbotip($ip,$agent) {
        $hostname gethostbyaddr($ip);
        if ($hostname==$ipreturn false;
        $rip gethostbyname($hostname); // we use long version because there could be multiple A records.
        print "Ip:$ip\tHostname: $hostname = $agent\t\t";
        if ($ip==$rip) {
                //host is not faked so now let's see if it is who it says it is via agent
                if(preg_match("/bing|msnbot/I",$agent)&&(preg_match("/msn\.com/I",$hostname))) return true;
                if(preg_match("/Google/I",$agent)&&(preg_match("/Google\.com/I",$hostname))) return true;
                if(preg_match("/yahoo/I",$agent)&&(preg_match("/yahoo\.com/I",$hostname))) return true;
                if(preg_match("/twittervir/I",$agent)&&(preg_match("/twttr\.com/I",$hostname))) return true;
                //ok done standard ones we know ... now we need to try generic test.
                //good bots will give a domain where they can be looked up.  This should match their reverse ip domain.
                preg_match("/([\w]+\.[\w]+)($|\.uk$)/",strtolower($hostname),$matches);
                $dom1 $matches[0];
                if (!(strpos($agent$dom1) !== false)) {
                        //echo "$dom1 NOT FOUND !!\n";
                        return false;
                }
                return true;
        }
        return false;
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据


Fatal error: Uncaught JSMin_UnterminatedStringException: JSMin: Unterminated String at byte 14193: "],b)?a:wb(a)} in /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/external/php/jsmin.php:212 Stack trace: #0 /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(150): JSMin->action() #1 /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(84): JSMin->min() #2 /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/autoptimizeScripts.php(843): JSMin::minify() #3 /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/autoptimizeScripts.php(402): autoptimizeScripts->minify_single() #4 /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/autoptimizeMain.php(591): autoptimizeScripts->read() #5 [internal function]: autoptimizeMain->end_buffering() #6 /www/wwwroot/178wz.net/wp-includes/functions.php(5349): ob_end_flush() #7 /www/wwwroot/178wz.net/wp-includes/class-wp-hook.php(310): wp_ob_end_flush_all() #8 /www/wwwroot/178wz.net/wp- in /www/wwwroot/178wz.net/wp-content/plugins/autoptimize/classes/external/php/jsmin.php on line 212