| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Sinergi\BrowserDetector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | class Browser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     const UNKNOWN = 'unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     const VIVALDI = 'Vivaldi'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     const OPERA = 'Opera'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     const OPERA_MINI = 'Opera Mini'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     const WEBTV = 'WebTV'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     const IE = 'Internet Explorer'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     const POCKET_IE = 'Pocket Internet Explorer'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     const KONQUEROR = 'Konqueror'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     const ICAB = 'iCab'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     const OMNIWEB = 'OmniWeb'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     const FIREBIRD = 'Firebird'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     const FIREFOX = 'Firefox'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     const SEAMONKEY = 'SeaMonkey'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     const ICEWEASEL = 'Iceweasel'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     const SHIRETOKO = 'Shiretoko'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     const MOZILLA = 'Mozilla'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     const AMAYA = 'Amaya'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     const LYNX = 'Lynx'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     const SAFARI = 'Safari'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     const SAMSUNG_BROWSER = 'SamsungBrowser'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     const CHROME = 'Chrome'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     const NAVIGATOR = 'Android Navigator'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     const BLACKBERRY = 'BlackBerry'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     const ICECAT = 'IceCat'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     const NOKIA_S60 = 'Nokia S60 OSS Browser'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     const NOKIA = 'Nokia Browser'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     const MSN = 'MSN Browser'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     const NETSCAPE_NAVIGATOR = 'Netscape Navigator'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     const GALEON = 'Galeon'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     const NETPOSITIVE = 'NetPositive'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     const PHOENIX = 'Phoenix'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     const GSA = 'Google Search Appliance'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     const YANDEX = 'Yandex'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     const EDGE = 'Edge'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     const DRAGON = 'Dragon'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     const NSPLAYER = 'Windows Media Player'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     const UCBROWSER = 'UC Browser'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     const MICROSOFT_OFFICE = 'Microsoft Office'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     const APPLE_NEWS = 'Apple News'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     const DALVIK = 'Android'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     const VERSION_UNKNOWN = 'unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @var UserAgent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     private $userAgent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     private $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     private $version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     private $isChromeFrame = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     private $isWebkit = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     private $isFacebookWebView = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     private $isTwitterWebView = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     private $isCompatibilityMode = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @param null|string|UserAgent $userAgent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 8 |  |      * @throws \Sinergi\BrowserDetector\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 94 | 8 | View Code Duplication |     public function __construct($userAgent = null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 8 |  |         if ($userAgent instanceof UserAgent) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 8 |  |             $this->setUserAgent($userAgent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 8 |  |         } elseif (null === $userAgent || is_string($userAgent)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             $this->setUserAgent(new UserAgent($userAgent)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 8 |  |             throw new InvalidArgumentException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * Set the name of the Browser. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * @param string $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 8 |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 8 |  |     public function setName($name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 8 |  |         $this->name = (string)$name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * Return the name of the Browser. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 7 |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 7 |  |     public function getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 7 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 7 |  |         if (!isset($this->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             BrowserDetector::detect($this, $this->getUserAgent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 7 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         return $this->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * Check to see if the specific browser is valid. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * @param string $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     public function isBrowser($name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         return (0 == strcasecmp($this->getName(), trim($name))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * Set the version of the browser. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * @param string $version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 8 |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 8 |  |     public function setVersion($version) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 | 8 |  |         $this->version = (string)$version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * The version of the browser. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 7 |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 7 |  |     public function getVersion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         if (!isset($this->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             BrowserDetector::detect($this, $this->getUserAgent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 | 7 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         return (string) $this->version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * Detects scripted agents (robots / bots) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * Returns a resolved ScriptedAgent object if detected. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * Otherwise returns false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * @return ScriptedAgent|bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     public function detectScriptedAgent() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $ua = $this->getUserAgent()->getUserAgentString(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         if (stripos($ua, 'bot') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             stripos($ua, 'spider') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             stripos($ua, 'crawler') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             stripos($ua, 'preview') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             stripos($ua, 'slurp') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             stripos($ua, 'facebookexternalhit') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             stripos($ua, 'mediapartners') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             stripos($ua, 'google-adwords') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             stripos($ua, 'adxvastfetcher') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             stripos($ua, 'adbeat') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             stripos($ua, 'google favicon') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             stripos($ua, 'webdav client') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             stripos($ua, 'metauri api') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             stripos($ua, 'tlsprobe') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             stripos($ua, 'wpif') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             stripos($ua, 'imgsizer') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             stripos($ua, 'netcraft ssl server survey') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             stripos($ua, 'curl/') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             stripos($ua, 'go-http-client/') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             stripos($ua, 'python') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             stripos($ua, 'libwww') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |             stripos($ua, 'wget/') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |             stripos($ua, 'zgrab/') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             stripos($ua, 'Java/') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             stripos($ua, '() { :;}; /bin/bash -c') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             stripos($ua, 'browsershots') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             stripos($ua, 'magereport') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             stripos($ua, 'ubermetrics-technologies') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             stripos($ua, 'W3C') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             stripos($ua, 'Validator') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |             stripos($ua, 'Jigsaw/') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             stripos($ua, 'bing') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             stripos($ua, 'msn') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             stripos($ua, 'Google Web Preview') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |             stripos($ua, 'ips-agent') !== FALSE || | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             (stripos($ua, 'Chrome/51.0.2704.103') !== FALSE && !isset($_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS']) && stristr($_SERVER['HTTP_ACCEPT_LANGUAGE'], "ru-RU") !== FALSE) //ICQ Preview | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |             $scriptedAgent = new ScriptedAgent($ua); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             if ($scriptedAgent->getName()==ScriptedAgent::UNKNOWN) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             else | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                 return $scriptedAgent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         else | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      * @param bool $isChromeFrame | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |     public function setIsChromeFrame($isChromeFrame) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $this->isChromeFrame = (bool)$isChromeFrame; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 | 1 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 | 1 |  |      * Used to determine if the browser is actually "chromeframe". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     public function getIsChromeFrame() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         if (!isset($this->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             BrowserDetector::detect($this, $this->getUserAgent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 | 1 |  |         return $this->isChromeFrame; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 | 1 |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     public function isChromeFrame() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         return $this->getIsChromeFrame(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 | 1 |  |      * @param bool $isChromeFrame | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     public function setIsWebkit($isWebkit) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         $this->isWebkit = (bool)$isWebkit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 | 8 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 | 8 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 | 8 |  |      * Used to determine if the browser is actually "chromeframe". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |     public function getIsWebkit() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 | 8 |  |         if (!isset($this->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             BrowserDetector::detect($this, $this->getUserAgent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 | 8 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         return $this->isWebkit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 | 1 |  |     public function isWebkit() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 | 1 |  |         return $this->getIsWebkit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * @param bool $isFacebookWebView | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |     public function setIsFacebookWebView($isFacebookWebView) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         $this->isFacebookWebView = (bool) $isFacebookWebView; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * Used to determine if the browser is actually "facebook". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |     public function getIsFacebookWebView() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |         if (!isset($this->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |             BrowserDetector::detect($this, $this->getUserAgent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         return $this->isFacebookWebView; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |     public function isFacebookWebView() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |         return $this->getIsFacebookWebView(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |      * @param bool $isTwitterWebView | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     public function setIsTwitterWebView($isTwitterWebView) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         $this->isTwitterWebView = (bool) $isTwitterWebView; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |      * Used to determine if the browser is actually "Twitter". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     public function getIsTwitterWebView() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         if (!isset($this->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |             BrowserDetector::detect($this, $this->getUserAgent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         return $this->isTwitterWebView; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |      * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 367 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |     public function isTwitterWebView() | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |         return $this->getIsTwitterWebView(); | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |      * @param UserAgent $userAgent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |     public function setUserAgent(UserAgent $userAgent) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         $this->userAgent = $userAgent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |      * @return UserAgent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |     public function getUserAgent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |         return $this->userAgent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |      * @param bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     public function setIsCompatibilityMode($isCompatibilityMode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         $this->isCompatibilityMode = $isCompatibilityMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |     public function isCompatibilityMode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |         return $this->isCompatibilityMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      * Render pages outside of IE's compatibility mode. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     public function endCompatibilityMode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         header('X-UA-Compatible: IE=edge'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 420 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 421 |  |  |  | 
            
                        
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.