ecshop判断搜索引擎是否为蜘蛛
<?php /** * 判断是否为搜索引擎蜘蛛 * * @access public * @return string */ function is_spider($record = true) { static $spider = NULL; if ($spider !== NULL) { return $spider; } if (empty($_SERVER['HTTP_USER_AGENT'])) { $spider = ''; return ''; } $searchengine_bot = array( 'googlebot', 'mediapartners-google', 'baiduspider+', 'msnbot', 'yodaobot', 'yahoo! slurp;', 'yahoo! slurp china;', 'iaskspider', 'sogou web spider', 'sogou push spider' ); $searchengine_name = array( 'GOOGLE', 'GOOGLE ADSENSE', 'BAIDU', 'MSN', 'YODAO', 'YAHOO', 'Yahoo China', 'IASK', 'SOGOU', 'SOGOU' ); $spider = strtolower($_SERVER['HTTP_USER_AGENT']); foreach ($searchengine_bot AS $key => $value) { if (strpos($spider, $value) !== false) { $spider = $searchengine_name[$key]; if ($record === true) { $GLOBALS['db']->autoReplace($GLOBALS['ecs']->table('searchengine'), array('date' => local_date('Y-m-d'), 'searchengine' => $spider, 'count' => 1), array('count' => 1)); } return $spider; } } $spider = ''; return ''; } ?>