検索エンジンロボット/Webクローラ判別 PHP関数

ユーザーエージェントから検索エンジンロボット/Webクローラを判別するPHP関数を下記に記載します。

<?php
 #-------------------------------------------------------------------------------------------------
 $UserAgent = getenv('HTTP_USER_AGENT'); #ユーザーエージェント取得
 #-------------------------------------------------------------------------------------------------
 function isRobot($UserAgent) {
  if(!$UserAgent) $UserAgent = $_SERVER['HTTP_USER_AGENT'];
   $robot="/(ICC-Crawler|Teoma|Y!J-BSC|Pluggd\/Nutch|psbot|CazoodleBot|
    Googlebot|Antenna|BlogPeople|AppleWebKitOpenbot|NaverBot|PlantyNet|livedoor|
    msnbot|FlashGet|WebBooster|MIDown|moget|InternetLinkAgent|Wget|InterGet|WebFetch|
    WebCrawler|ArchitextSpider|Scooter|WebAuto|InfoNaviRobot|httpdown|Inetdown|Slurp|
    Spider|^Iron33|^fetch|^PageDown|^BMChecker|^Jerky|^Nutscrape|Baiduspider|TMCrawler)/m";
  if(preg_match($robot,$UserAgent) || ereg($robot,$UserAgent)) {
   return true;
  }else{
   return false;
  }
 }
 #-------------------------------------------------------------------------------------------------
 if(isRobot($UserAgent)) #検索エンジンロボット/Webクローラ向けの処理
 #-------------------------------------------------------------------------------------------------
 ?>

Download