web/lib/Zend/Http/UserAgent/Bot.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Http
       
    17  * @subpackage UserAgent
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  */
       
    21 require_once 'Zend/Http/UserAgent/AbstractDevice.php';
       
    22 
       
    23 /**
       
    24  * Bot browser type matcher
       
    25  *
       
    26  * @category   Zend
       
    27  * @package    Zend_Http
       
    28  * @subpackage UserAgent
       
    29  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    30  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    31  */
       
    32 
       
    33 class Zend_Http_UserAgent_Bot extends Zend_Http_UserAgent_AbstractDevice
       
    34 {
       
    35 
       
    36     /**
       
    37      * User Agent Signatures
       
    38      *
       
    39      * @var array
       
    40      */
       
    41     protected static $_uaSignatures = array(
       
    42         // The most common ones.
       
    43         'googlebot', 
       
    44         'msnbot', 
       
    45         'slurp', 
       
    46         'yahoo',
       
    47 
       
    48         // The rest, alphabetically.
       
    49         'alexa', 
       
    50         'appie', 
       
    51         'archiver', 
       
    52         'ask jeeves', 
       
    53         'baiduspider', 
       
    54         'bot', 
       
    55         'crawl', 
       
    56         'crawler', 
       
    57         'curl', 
       
    58         'eventbox', 
       
    59         'facebookexternal', 
       
    60         'fast', 
       
    61         'feedfetcher-google', 
       
    62         'firefly', 
       
    63         'froogle', 
       
    64         'gigabot', 
       
    65         'girafabot', 
       
    66         'google', 
       
    67         'infoseek', 
       
    68         'inktomi', 
       
    69         'java', 
       
    70         'larbin',
       
    71         'looksmart', 
       
    72         'mechanize', 
       
    73         'mediapartners-google', 
       
    74         'monitor', 
       
    75         'nambu', 
       
    76         'nationaldirectory', 
       
    77         'novarra', 
       
    78         'pear', 
       
    79         'perl', 
       
    80         'python', 
       
    81         'rabaz', 
       
    82         'radian', 
       
    83         'rankivabot', 
       
    84         'scooter', 
       
    85         'sogou web spider', 
       
    86         'spade', 
       
    87         'sphere', 
       
    88         'spider', 
       
    89         'technoratisnoop', 
       
    90         'tecnoseek', 
       
    91         'teoma', 
       
    92         'toolbar', 
       
    93         'transcoder', 
       
    94         'twitt', 
       
    95         'url_spider_sql', 
       
    96         'webalta crawler', 
       
    97         'webbug', 
       
    98         'webfindbot', 
       
    99         'wordpress', 
       
   100         'www.galaxy.com', 
       
   101         'yahoo! searchmonkey', 
       
   102         'yahoo! slurp', 
       
   103         'yandex', 
       
   104         'zyborg',
       
   105     );
       
   106 
       
   107     /**
       
   108      * Comparison of the UserAgent chain and browser signatures
       
   109      *
       
   110      * @param  string $userAgent User Agent chain
       
   111      * @param  array $server $_SERVER like param
       
   112      * @return bool
       
   113      */
       
   114     public static function match($userAgent, $server)
       
   115     {
       
   116         return self::_matchAgentAgainstSignatures($userAgent, self::$_uaSignatures);
       
   117     }
       
   118 
       
   119     /**
       
   120      * Gives the current browser type
       
   121      *
       
   122      * @return string
       
   123      */
       
   124     public function getType()
       
   125     {
       
   126         return 'bot';
       
   127     }
       
   128 }