PHP cloaking script

Sometimes you need to show another text to crawlers :)
This script check serfer User-Agent and if this UA is listed in variable $bot_lst - so, it’s bot…

  1. // List of bots:
  2. $bot_lst=array(
  3.              'google',
  4.              'msn',
  5.              'yahoo'
  6.            );
  7.  
  8. $is_bot=0;
  9. for($i=0; $i<sizeof($bot_lst); $i++)
  10.   if(strstr(strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']), strtolower($bot_lst[$i])))
  11.     $is_bot=1;
  12.  
  13. if($is_bot) echo 'Hello bot :)';
  14. else echo 'Hi user :]';
  15.  
  16. echo '<p>Your UserAgent: '.$HTTP_SERVER_VARS['HTTP_USER_AGENT'].'</p>';

Tags: , , , , , ,