@@ -12,26 +12,26 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Validation_Email', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Validation_Email |
|
| 17 | - */ |
|
| 18 | - class Redux_Validation_Email extends Redux_Validate { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Validation_Email |
|
| 17 | + */ |
|
| 18 | + class Redux_Validation_Email extends Redux_Validate { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Field Render Function. |
|
| 22 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 23 | - * |
|
| 24 | - * @since ReduxFramework 1.0.0 |
|
| 25 | - */ |
|
| 26 | - public function validate() { |
|
| 27 | - $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a valid email for this option.', 'redux-framework' ); |
|
| 20 | + /** |
|
| 21 | + * Field Render Function. |
|
| 22 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 23 | + * |
|
| 24 | + * @since ReduxFramework 1.0.0 |
|
| 25 | + */ |
|
| 26 | + public function validate() { |
|
| 27 | + $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a valid email for this option.', 'redux-framework' ); |
|
| 28 | 28 | |
| 29 | - if ( ! is_email( $this->value ) ) { |
|
| 30 | - $this->value = ( isset( $this->current ) ) ? $this->current : ''; |
|
| 31 | - $this->field['current'] = $this->value; |
|
| 29 | + if ( ! is_email( $this->value ) ) { |
|
| 30 | + $this->value = ( isset( $this->current ) ) ? $this->current : ''; |
|
| 31 | + $this->field['current'] = $this->value; |
|
| 32 | 32 | |
| 33 | - $this->error = $this->field; |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - } |
|
| 33 | + $this->error = $this->field; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -12,30 +12,30 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Validation_Html_Custom', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Validation_Html_Custom |
|
| 17 | - */ |
|
| 18 | - class Redux_Validation_Html_Custom extends Redux_Validate { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Validation_Html_Custom |
|
| 17 | + */ |
|
| 18 | + class Redux_Validation_Html_Custom extends Redux_Validate { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Field Render Function. |
|
| 22 | - * Takes the vars and validates them |
|
| 23 | - * |
|
| 24 | - * @since ReduxFramework 1.0.0 |
|
| 25 | - */ |
|
| 26 | - public function validate() { |
|
| 27 | - $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'Invalid HTML was found in this field and has been removed.', 'redux-framework' ); |
|
| 20 | + /** |
|
| 21 | + * Field Render Function. |
|
| 22 | + * Takes the vars and validates them |
|
| 23 | + * |
|
| 24 | + * @since ReduxFramework 1.0.0 |
|
| 25 | + */ |
|
| 26 | + public function validate() { |
|
| 27 | + $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'Invalid HTML was found in this field and has been removed.', 'redux-framework' ); |
|
| 28 | 28 | |
| 29 | - if ( isset( $this->field['allowed_html'] ) ) { |
|
| 30 | - $html = wp_kses( $this->value, $this->field['allowed_html'] ); |
|
| 29 | + if ( isset( $this->field['allowed_html'] ) ) { |
|
| 30 | + $html = wp_kses( $this->value, $this->field['allowed_html'] ); |
|
| 31 | 31 | |
| 32 | - if ( $html !== $this->value ) { |
|
| 33 | - $this->field['current'] = $html; |
|
| 34 | - $this->warning = $this->field; |
|
| 35 | - } |
|
| 32 | + if ( $html !== $this->value ) { |
|
| 33 | + $this->field['current'] = $html; |
|
| 34 | + $this->warning = $this->field; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $this->value = $html; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - } |
|
| 37 | + $this->value = $html; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -12,28 +12,28 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Validation_Url', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Validation_Url |
|
| 17 | - */ |
|
| 18 | - class Redux_Validation_Url extends Redux_Validate { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Validation_Url |
|
| 17 | + */ |
|
| 18 | + class Redux_Validation_Url extends Redux_Validate { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Field Render Function. |
|
| 22 | - * Takes the vars and validates them |
|
| 23 | - * |
|
| 24 | - * @since ReduxFramework 1.0.0 |
|
| 25 | - */ |
|
| 26 | - public function validate() { |
|
| 27 | - $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a valid URL for this option.', 'redux-framework' ); |
|
| 20 | + /** |
|
| 21 | + * Field Render Function. |
|
| 22 | + * Takes the vars and validates them |
|
| 23 | + * |
|
| 24 | + * @since ReduxFramework 1.0.0 |
|
| 25 | + */ |
|
| 26 | + public function validate() { |
|
| 27 | + $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a valid URL for this option.', 'redux-framework' ); |
|
| 28 | 28 | |
| 29 | - if ( false === filter_var( $this->value, FILTER_VALIDATE_URL ) ) { |
|
| 30 | - $this->value = ( isset( $this->current ) ) ? $this->current : ''; |
|
| 31 | - $this->field['current'] = $this->value; |
|
| 29 | + if ( false === filter_var( $this->value, FILTER_VALIDATE_URL ) ) { |
|
| 30 | + $this->value = ( isset( $this->current ) ) ? $this->current : ''; |
|
| 31 | + $this->field['current'] = $this->value; |
|
| 32 | 32 | |
| 33 | - $this->error = $this->field; |
|
| 34 | - } else { |
|
| 35 | - $this->value = esc_url_raw( $this->value ); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - } |
|
| 33 | + $this->error = $this->field; |
|
| 34 | + } else { |
|
| 35 | + $this->value = esc_url_raw( $this->value ); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -12,23 +12,23 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Validation_Not_Empty', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Validation_Not_Empty |
|
| 17 | - */ |
|
| 18 | - class Redux_Validation_Not_Empty extends Redux_Validate { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Validation_Not_Empty |
|
| 17 | + */ |
|
| 18 | + class Redux_Validation_Not_Empty extends Redux_Validate { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Field Validation Function. |
|
| 22 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 23 | - * |
|
| 24 | - * @since ReduxFramework 1.0.0 |
|
| 25 | - */ |
|
| 26 | - public function validate() { |
|
| 27 | - $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'This field cannot be empty. Please provide a value.', 'redux-framework' ); |
|
| 20 | + /** |
|
| 21 | + * Field Validation Function. |
|
| 22 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 23 | + * |
|
| 24 | + * @since ReduxFramework 1.0.0 |
|
| 25 | + */ |
|
| 26 | + public function validate() { |
|
| 27 | + $this->field['msg'] = $this->field['msg'] ?? esc_html__( 'This field cannot be empty. Please provide a value.', 'redux-framework' ); |
|
| 28 | 28 | |
| 29 | - if ( ! isset( $this->value ) || '' === $this->value || 0 === strlen( $this->value ) ) { |
|
| 30 | - $this->error = $this->field; |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - } |
|
| 29 | + if ( ! isset( $this->value ) || '' === $this->value || 0 === strlen( $this->value ) ) { |
|
| 30 | + $this->error = $this->field; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -42,1933 +42,1933 @@ |
||
| 42 | 42 | * |
| 43 | 43 | */ |
| 44 | 44 | class ReduxBrowser { |
| 45 | - private $_agent = ''; |
|
| 46 | - private $_browser_name = ''; |
|
| 47 | - private $_version = ''; |
|
| 48 | - private $_platform = ''; |
|
| 49 | - private $_os = ''; |
|
| 50 | - private $_is_aol = false; |
|
| 51 | - private $_is_mobile = false; |
|
| 52 | - private $_is_tablet = false; |
|
| 53 | - private $_is_robot = false; |
|
| 54 | - private $_is_facebook = false; |
|
| 55 | - private $_aol_version = ''; |
|
| 56 | - |
|
| 57 | - const BROWSER_UNKNOWN = 'unknown'; |
|
| 58 | - const VERSION_UNKNOWN = 'unknown'; |
|
| 59 | - |
|
| 60 | - const BROWSER_OPERA = 'Opera'; // http://www.opera.com/ |
|
| 61 | - const BROWSER_OPERA_MINI = 'Opera Mini'; // http://www.opera.com/mini/ |
|
| 62 | - const BROWSER_WEBTV = 'WebTV'; // http://www.webtv.net/pc/ |
|
| 63 | - const BROWSER_EDGE = 'Edge'; // https://www.microsoft.com/edge |
|
| 64 | - const BROWSER_IE = 'Internet Explorer'; // http://www.microsoft.com/ie/ |
|
| 65 | - const BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // http://en.wikipedia.org/wiki/Internet_Explorer_Mobile |
|
| 66 | - const BROWSER_KONQUEROR = 'Konqueror'; // http://www.konqueror.org/ |
|
| 67 | - const BROWSER_ICAB = 'iCab'; // http://www.icab.de/ |
|
| 68 | - const BROWSER_OMNIWEB = 'OmniWeb'; // http://www.omnigroup.com/applications/omniweb/ |
|
| 69 | - const BROWSER_FIREBIRD = 'Firebird'; // http://www.ibphoenix.com/ |
|
| 70 | - const BROWSER_FIREFOX = 'Firefox'; // https://www.mozilla.org/en-US/firefox/ |
|
| 71 | - const BROWSER_BRAVE = 'Brave'; // https://brave.com/ |
|
| 72 | - const BROWSER_PALEMOON = 'Palemoon'; // https://www.palemoon.org/ |
|
| 73 | - const BROWSER_ICEWEASEL = 'Iceweasel'; // http://www.geticeweasel.org/ |
|
| 74 | - const BROWSER_SHIRETOKO = 'Shiretoko'; // http://wiki.mozilla.org/Projects/shiretoko |
|
| 75 | - const BROWSER_MOZILLA = 'Mozilla'; // http://www.mozilla.com/en-US/ |
|
| 76 | - const BROWSER_AMAYA = 'Amaya'; // http://www.w3.org/Amaya/ |
|
| 77 | - const BROWSER_LYNX = 'Lynx'; // http://en.wikipedia.org/wiki/Lynx |
|
| 78 | - const BROWSER_SAFARI = 'Safari'; // http://apple.com |
|
| 79 | - const BROWSER_IPHONE = 'iPhone'; // http://apple.com |
|
| 80 | - const BROWSER_IPOD = 'iPod'; // http://apple.com |
|
| 81 | - const BROWSER_IPAD = 'iPad'; // http://apple.com |
|
| 82 | - const BROWSER_CHROME = 'Chrome'; // http://www.google.com/chrome |
|
| 83 | - const BROWSER_ANDROID = 'Android'; // http://www.android.com/ |
|
| 84 | - const BROWSER_GOOGLEBOT = 'GoogleBot'; // http://en.wikipedia.org/wiki/Googlebot |
|
| 85 | - const BROWSER_CURL = 'cURL'; // https://en.wikipedia.org/wiki/CURL |
|
| 86 | - const BROWSER_WGET = 'Wget'; // https://en.wikipedia.org/wiki/Wget |
|
| 87 | - const BROWSER_UCBROWSER = 'UCBrowser'; // https://www.ucweb.com/ |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - const BROWSER_YANDEXBOT = 'YandexBot'; // http://yandex.com/bots |
|
| 91 | - const BROWSER_YANDEXIMAGERESIZER_BOT = 'YandexImageResizer'; // http://yandex.com/bots |
|
| 92 | - const BROWSER_YANDEXIMAGES_BOT = 'YandexImages'; // http://yandex.com/bots |
|
| 93 | - const BROWSER_YANDEXVIDEO_BOT = 'YandexVideo'; // http://yandex.com/bots |
|
| 94 | - const BROWSER_YANDEXMEDIA_BOT = 'YandexMedia'; // http://yandex.com/bots |
|
| 95 | - const BROWSER_YANDEXBLOGS_BOT = 'YandexBlogs'; // http://yandex.com/bots |
|
| 96 | - const BROWSER_YANDEXFAVICONS_BOT = 'YandexFavicons'; // http://yandex.com/bots |
|
| 97 | - const BROWSER_YANDEXWEBMASTER_BOT = 'YandexWebmaster'; // http://yandex.com/bots |
|
| 98 | - const BROWSER_YANDEXDIRECT_BOT = 'YandexDirect'; // http://yandex.com/bots |
|
| 99 | - const BROWSER_YANDEXMETRIKA_BOT = 'YandexMetrika'; // http://yandex.com/bots |
|
| 100 | - const BROWSER_YANDEXNEWS_BOT = 'YandexNews'; // http://yandex.com/bots |
|
| 101 | - const BROWSER_YANDEXCATALOG_BOT = 'YandexCatalog'; // http://yandex.com/bots |
|
| 102 | - |
|
| 103 | - const BROWSER_SLURP = 'Yahoo! Slurp'; // http://en.wikipedia.org/wiki/Yahoo!_Slurp |
|
| 104 | - const BROWSER_W3CVALIDATOR = 'W3C Validator'; // http://validator.w3.org/ |
|
| 105 | - const BROWSER_BLACKBERRY = 'BlackBerry'; // http://www.blackberry.com/ |
|
| 106 | - const BROWSER_ICECAT = 'IceCat'; // http://en.wikipedia.org/wiki/GNU_IceCat |
|
| 107 | - const BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // http://en.wikipedia.org/wiki/Web_Browser_for_S60 |
|
| 108 | - const BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform |
|
| 109 | - const BROWSER_MSN = 'MSN Browser'; // http://explorer.msn.com/ |
|
| 110 | - const BROWSER_MSNBOT = 'MSN Bot'; // http://search.msn.com/msnbot.htm |
|
| 111 | - const BROWSER_BINGBOT = 'Bing Bot'; // http://en.wikipedia.org/wiki/Bingbot |
|
| 112 | - const BROWSER_VIVALDI = 'Vivaldi'; // https://vivaldi.com/ |
|
| 113 | - const BROWSER_YANDEX = 'Yandex'; // https://browser.yandex.ua/ |
|
| 114 | - |
|
| 115 | - const BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // http://browser.netscape.com/ (DEPRECATED) |
|
| 116 | - const BROWSER_GALEON = 'Galeon'; // http://galeon.sourceforge.net/ (DEPRECATED) |
|
| 117 | - const BROWSER_NETPOSITIVE = 'NetPositive'; // http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) |
|
| 118 | - const BROWSER_PHOENIX = 'Phoenix'; // http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) |
|
| 119 | - const BROWSER_PLAYSTATION = "PlayStation"; |
|
| 120 | - const BROWSER_SAMSUNG = "SamsungBrowser"; |
|
| 121 | - const BROWSER_SILK = "Silk"; |
|
| 122 | - const BROWSER_I_FRAME = "Iframely"; |
|
| 123 | - const BROWSER_COCOA = "CocoaRestClient"; |
|
| 124 | - |
|
| 125 | - const PLATFORM_UNKNOWN = 'unknown'; |
|
| 126 | - const PLATFORM_WINDOWS = 'Windows'; |
|
| 127 | - const PLATFORM_WINDOWS_CE = 'Windows CE'; |
|
| 128 | - const PLATFORM_APPLE = 'Apple'; |
|
| 129 | - const PLATFORM_LINUX = 'Linux'; |
|
| 130 | - const PLATFORM_OS2 = 'OS/2'; |
|
| 131 | - const PLATFORM_BEOS = 'BeOS'; |
|
| 132 | - const PLATFORM_IPHONE = 'iPhone'; |
|
| 133 | - const PLATFORM_IPOD = 'iPod'; |
|
| 134 | - const PLATFORM_IPAD = 'iPad'; |
|
| 135 | - const PLATFORM_BLACKBERRY = 'BlackBerry'; |
|
| 136 | - const PLATFORM_NOKIA = 'Nokia'; |
|
| 137 | - const PLATFORM_FREEBSD = 'FreeBSD'; |
|
| 138 | - const PLATFORM_OPENBSD = 'OpenBSD'; |
|
| 139 | - const PLATFORM_NETBSD = 'NetBSD'; |
|
| 140 | - const PLATFORM_SUNOS = 'SunOS'; |
|
| 141 | - const PLATFORM_OPENSOLARIS = 'OpenSolaris'; |
|
| 142 | - const PLATFORM_ANDROID = 'Android'; |
|
| 143 | - const PLATFORM_PLAYSTATION = "Sony PlayStation"; |
|
| 144 | - const PLATFORM_ROKU = "Roku"; |
|
| 145 | - const PLATFORM_APPLE_TV = "Apple TV"; |
|
| 146 | - const PLATFORM_TERMINAL = "Terminal"; |
|
| 147 | - const PLATFORM_FIRE_OS = "Fire OS"; |
|
| 148 | - const PLATFORM_SMART_TV = "SMART-TV"; |
|
| 149 | - const PLATFORM_CHROME_OS = "Chrome OS"; |
|
| 150 | - const PLATFORM_JAVA_ANDROID = "Java/Android"; |
|
| 151 | - const PLATFORM_POSTMAN = "Postman"; |
|
| 152 | - const PLATFORM_I_FRAME = "Iframely"; |
|
| 153 | - |
|
| 154 | - const OPERATING_SYSTEM_UNKNOWN = 'unknown'; |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Class constructor |
|
| 158 | - * |
|
| 159 | - * @param string $userAgent |
|
| 160 | - */ |
|
| 161 | - public function __construct( $userAgent = '' ) { |
|
| 162 | - if ( $userAgent != '' ) { |
|
| 163 | - $this->setUserAgent( $userAgent ); |
|
| 164 | - } else { |
|
| 165 | - $this->reset(); |
|
| 166 | - $this->determine(); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Reset all properties |
|
| 172 | - */ |
|
| 173 | - public function reset() { |
|
| 174 | - $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 175 | - $this->_browser_name = self::BROWSER_UNKNOWN; |
|
| 176 | - $this->_version = self::VERSION_UNKNOWN; |
|
| 177 | - $this->_platform = self::PLATFORM_UNKNOWN; |
|
| 178 | - $this->_os = self::OPERATING_SYSTEM_UNKNOWN; |
|
| 179 | - $this->_is_aol = false; |
|
| 180 | - $this->_is_mobile = false; |
|
| 181 | - $this->_is_tablet = false; |
|
| 182 | - $this->_is_robot = false; |
|
| 183 | - $this->_is_facebook = false; |
|
| 184 | - $this->_aol_version = self::VERSION_UNKNOWN; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Check to see if the specific browser is valid |
|
| 189 | - * |
|
| 190 | - * @param string $browserName |
|
| 191 | - * |
|
| 192 | - * @return bool True if the browser is the specified browser |
|
| 193 | - */ |
|
| 194 | - function isBrowser( $browserName ) { |
|
| 195 | - return ( 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ) ); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * The name of the browser. All return types are from the class contants |
|
| 200 | - * |
|
| 201 | - * @return string Name of the browser |
|
| 202 | - */ |
|
| 203 | - public function getBrowser() { |
|
| 204 | - return $this->_browser_name; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Set the name of the browser |
|
| 209 | - * |
|
| 210 | - * @param $browser string The name of the Browser |
|
| 211 | - */ |
|
| 212 | - public function setBrowser( $browser ) { |
|
| 213 | - $this->_browser_name = $browser; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * The name of the platform. All return types are from the class contants |
|
| 218 | - * |
|
| 219 | - * @return string Name of the browser |
|
| 220 | - */ |
|
| 221 | - public function getPlatform() { |
|
| 222 | - return $this->_platform; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Set the name of the platform |
|
| 227 | - * |
|
| 228 | - * @param string $platform The name of the Platform |
|
| 229 | - */ |
|
| 230 | - public function setPlatform( $platform ) { |
|
| 231 | - $this->_platform = $platform; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * The version of the browser. |
|
| 236 | - * |
|
| 237 | - * @return string Version of the browser (will only contain alpha-numeric characters and a period) |
|
| 238 | - */ |
|
| 239 | - public function getVersion() { |
|
| 240 | - return $this->_version; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Set the version of the browser |
|
| 245 | - * |
|
| 246 | - * @param string $version The version of the Browser |
|
| 247 | - */ |
|
| 248 | - public function setVersion( $version ) { |
|
| 249 | - $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * The version of AOL. |
|
| 254 | - * |
|
| 255 | - * @return string Version of AOL (will only contain alpha-numeric characters and a period) |
|
| 256 | - */ |
|
| 257 | - public function getAolVersion() { |
|
| 258 | - return $this->_aol_version; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Set the version of AOL |
|
| 263 | - * |
|
| 264 | - * @param string $version The version of AOL |
|
| 265 | - */ |
|
| 266 | - public function setAolVersion( $version ) { |
|
| 267 | - $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * Is the browser from AOL? |
|
| 272 | - * |
|
| 273 | - * @return boolean True if the browser is from AOL otherwise false |
|
| 274 | - */ |
|
| 275 | - public function isAol() { |
|
| 276 | - return $this->_is_aol; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Is the browser from a mobile device? |
|
| 281 | - * |
|
| 282 | - * @return boolean True if the browser is from a mobile device otherwise false |
|
| 283 | - */ |
|
| 284 | - public function isMobile() { |
|
| 285 | - return $this->_is_mobile; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Is the browser from a tablet device? |
|
| 290 | - * |
|
| 291 | - * @return boolean True if the browser is from a tablet device otherwise false |
|
| 292 | - */ |
|
| 293 | - public function isTablet() { |
|
| 294 | - return $this->_is_tablet; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Is the browser from a robot (ex Slurp,GoogleBot)? |
|
| 299 | - * |
|
| 300 | - * @return boolean True if the browser is from a robot otherwise false |
|
| 301 | - */ |
|
| 302 | - public function isRobot() { |
|
| 303 | - return $this->_is_robot; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Is the browser from facebook? |
|
| 308 | - * |
|
| 309 | - * @return boolean True if the browser is from facebook otherwise false |
|
| 310 | - */ |
|
| 311 | - public function isFacebook() { |
|
| 312 | - return $this->_is_facebook; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Set the browser to be from AOL |
|
| 317 | - * |
|
| 318 | - * @param $isAol |
|
| 319 | - */ |
|
| 320 | - public function setAol( $isAol ) { |
|
| 321 | - $this->_is_aol = $isAol; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Set the Browser to be mobile |
|
| 326 | - * |
|
| 327 | - * @param boolean $value is the browser a mobile browser or not |
|
| 328 | - */ |
|
| 329 | - protected function setMobile( $value = true ) { |
|
| 330 | - $this->_is_mobile = $value; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * Set the Browser to be tablet |
|
| 335 | - * |
|
| 336 | - * @param boolean $value is the browser a tablet browser or not |
|
| 337 | - */ |
|
| 338 | - protected function setTablet( $value = true ) { |
|
| 339 | - $this->_is_tablet = $value; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * Set the Browser to be a robot |
|
| 344 | - * |
|
| 345 | - * @param boolean $value is the browser a robot or not |
|
| 346 | - */ |
|
| 347 | - protected function setRobot( $value = true ) { |
|
| 348 | - $this->_is_robot = $value; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * Set the Browser to be a Facebook request |
|
| 353 | - * |
|
| 354 | - * @param boolean $value is the browser a robot or not |
|
| 355 | - */ |
|
| 356 | - protected function setFacebook( $value = true ) { |
|
| 357 | - $this->_is_facebook = $value; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Get the user agent value in use to determine the browser |
|
| 362 | - * |
|
| 363 | - * @return string The user agent from the HTTP header |
|
| 364 | - */ |
|
| 365 | - public function getUserAgent() { |
|
| 366 | - return $this->_agent; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) |
|
| 371 | - * |
|
| 372 | - * @param string $agent_string The value for the User Agent |
|
| 373 | - */ |
|
| 374 | - public function setUserAgent( $agent_string ) { |
|
| 375 | - $this->reset(); |
|
| 376 | - $this->_agent = $agent_string; |
|
| 377 | - $this->determine(); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Used to determine if the browser is actually "chromeframe" |
|
| 382 | - * |
|
| 383 | - * @return boolean True if the browser is using chromeframe |
|
| 384 | - * @since 1.7 |
|
| 385 | - */ |
|
| 386 | - public function isChromeFrame() { |
|
| 387 | - return ( strpos( $this->_agent, "chromeframe" ) !== false ); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Returns a formatted string with a summary of the details of the browser. |
|
| 392 | - * |
|
| 393 | - * @return string formatted string with a summary of the browser |
|
| 394 | - */ |
|
| 395 | - public function __toString() { |
|
| 396 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
| 397 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
| 398 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
| 399 | - "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * Protected routine to calculate and determine what the browser is in use (including platform) |
|
| 404 | - */ |
|
| 405 | - protected function determine() { |
|
| 406 | - $this->checkPlatform(); |
|
| 407 | - $this->checkBrowsers(); |
|
| 408 | - $this->checkForAol(); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Protected routine to determine the browser type |
|
| 413 | - * |
|
| 414 | - * @return boolean True if the browser was detected otherwise false |
|
| 415 | - */ |
|
| 416 | - protected function checkBrowsers() { |
|
| 417 | - return ( |
|
| 418 | - // well-known, well-used |
|
| 419 | - // Special Notes: |
|
| 420 | - // (1) Opera must be checked before FireFox due to the odd |
|
| 421 | - // user agents used in some older versions of Opera |
|
| 422 | - // (2) WebTV is strapped onto Internet Explorer so we must |
|
| 423 | - // check for WebTV before IE |
|
| 424 | - // (3) (deprecated) Galeon is based on Firefox and needs to be |
|
| 425 | - // tested before Firefox is tested |
|
| 426 | - // (4) OmniWeb is based on Safari so OmniWeb check must occur |
|
| 427 | - // before Safari |
|
| 428 | - // (5) Netscape 9+ is based on Firefox so Netscape checks |
|
| 429 | - // before FireFox are necessary |
|
| 430 | - // (6) Vivaldi is UA contains both Firefox and Chrome so Vivaldi checks |
|
| 431 | - // before Firefox and Chrome |
|
| 432 | - $this->checkBrowserWebTv() || |
|
| 433 | - $this->checkBrowserBrave() || |
|
| 434 | - $this->checkBrowserUCBrowser() || |
|
| 435 | - $this->checkBrowserEdge() || |
|
| 436 | - $this->checkBrowserInternetExplorer() || |
|
| 437 | - $this->checkBrowserOpera() || |
|
| 438 | - $this->checkBrowserGaleon() || |
|
| 439 | - $this->checkBrowserNetscapeNavigator9Plus() || |
|
| 440 | - $this->checkBrowserVivaldi() || |
|
| 441 | - $this->checkBrowserYandex() || |
|
| 442 | - $this->checkBrowserPalemoon() || |
|
| 443 | - $this->checkBrowserFirefox() || |
|
| 444 | - $this->checkBrowserChrome() || |
|
| 445 | - $this->checkBrowserOmniWeb() || |
|
| 446 | - |
|
| 447 | - // common mobile |
|
| 448 | - $this->checkBrowserAndroid() || |
|
| 449 | - $this->checkBrowseriPad() || |
|
| 450 | - $this->checkBrowseriPod() || |
|
| 451 | - $this->checkBrowseriPhone() || |
|
| 452 | - $this->checkBrowserBlackBerry() || |
|
| 453 | - $this->checkBrowserNokia() || |
|
| 454 | - |
|
| 455 | - // common bots |
|
| 456 | - $this->checkBrowserGoogleBot() || |
|
| 457 | - $this->checkBrowserMSNBot() || |
|
| 458 | - $this->checkBrowserBingBot() || |
|
| 459 | - $this->checkBrowserSlurp() || |
|
| 460 | - |
|
| 461 | - // Yandex bots |
|
| 462 | - $this->checkBrowserYandexBot() || |
|
| 463 | - $this->checkBrowserYandexImageResizerBot() || |
|
| 464 | - $this->checkBrowserYandexBlogsBot() || |
|
| 465 | - $this->checkBrowserYandexCatalogBot() || |
|
| 466 | - $this->checkBrowserYandexDirectBot() || |
|
| 467 | - $this->checkBrowserYandexFaviconsBot() || |
|
| 468 | - $this->checkBrowserYandexImagesBot() || |
|
| 469 | - $this->checkBrowserYandexMediaBot() || |
|
| 470 | - $this->checkBrowserYandexMetrikaBot() || |
|
| 471 | - $this->checkBrowserYandexNewsBot() || |
|
| 472 | - $this->checkBrowserYandexVideoBot() || |
|
| 473 | - $this->checkBrowserYandexWebmasterBot() || |
|
| 474 | - |
|
| 475 | - // check for facebook external hit when loading URL |
|
| 476 | - $this->checkFacebookExternalHit() || |
|
| 477 | - |
|
| 478 | - // WebKit base check (post mobile and others) |
|
| 479 | - $this->checkBrowserSamsung() || |
|
| 480 | - $this->checkBrowserSilk() || |
|
| 481 | - $this->checkBrowserSafari() || |
|
| 482 | - |
|
| 483 | - // everyone else |
|
| 484 | - $this->checkBrowserNetPositive() || |
|
| 485 | - $this->checkBrowserFirebird() || |
|
| 486 | - $this->checkBrowserKonqueror() || |
|
| 487 | - $this->checkBrowserIcab() || |
|
| 488 | - $this->checkBrowserPhoenix() || |
|
| 489 | - $this->checkBrowserAmaya() || |
|
| 490 | - $this->checkBrowserLynx() || |
|
| 491 | - $this->checkBrowserShiretoko() || |
|
| 492 | - $this->checkBrowserIceCat() || |
|
| 493 | - $this->checkBrowserIceweasel() || |
|
| 494 | - $this->checkBrowserW3CValidator() || |
|
| 495 | - $this->checkBrowserCurl() || |
|
| 496 | - $this->checkBrowserWget() || |
|
| 497 | - $this->checkBrowserPlayStation() || |
|
| 498 | - $this->checkBrowserIframely() || |
|
| 499 | - $this->checkBrowserCocoa() || |
|
| 500 | - $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */ ); |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Determine if the user is using a BlackBerry (last updated 1.7) |
|
| 505 | - * |
|
| 506 | - * @return boolean True if the browser is the BlackBerry browser otherwise false |
|
| 507 | - */ |
|
| 508 | - protected function checkBrowserBlackBerry() { |
|
| 509 | - if ( stripos( $this->_agent, 'blackberry' ) !== false ) { |
|
| 510 | - $aresult = explode( '/', stristr( $this->_agent, "BlackBerry" ) ); |
|
| 511 | - if ( isset( $aresult[1] ) ) { |
|
| 512 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 513 | - $this->setVersion( $aversion[0] ); |
|
| 514 | - $this->_browser_name = self::BROWSER_BLACKBERRY; |
|
| 515 | - $this->setMobile( true ); |
|
| 516 | - |
|
| 517 | - return true; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - return false; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - /** |
|
| 525 | - * Determine if the user is using an AOL User Agent (last updated 1.7) |
|
| 526 | - * |
|
| 527 | - * @return boolean True if the browser is from AOL otherwise false |
|
| 528 | - */ |
|
| 529 | - protected function checkForAol() { |
|
| 530 | - $this->setAol( false ); |
|
| 531 | - $this->setAolVersion( self::VERSION_UNKNOWN ); |
|
| 532 | - |
|
| 533 | - if ( stripos( $this->_agent, 'aol' ) !== false ) { |
|
| 534 | - $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) ); |
|
| 535 | - if ( isset( $aversion[1] ) ) { |
|
| 536 | - $this->setAol( true ); |
|
| 537 | - $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) ); |
|
| 538 | - |
|
| 539 | - return true; |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - return false; |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * Determine if the browser is the GoogleBot or not (last updated 1.7) |
|
| 548 | - * |
|
| 549 | - * @return boolean True if the browser is the GoogletBot otherwise false |
|
| 550 | - */ |
|
| 551 | - protected function checkBrowserGoogleBot() { |
|
| 552 | - if ( stripos( $this->_agent, 'googlebot' ) !== false ) { |
|
| 553 | - $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) ); |
|
| 554 | - if ( isset( $aresult[1] ) ) { |
|
| 555 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 556 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 557 | - $this->_browser_name = self::BROWSER_GOOGLEBOT; |
|
| 558 | - $this->setRobot( true ); |
|
| 559 | - |
|
| 560 | - return true; |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - return false; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Determine if the browser is the YandexBot or not |
|
| 569 | - * |
|
| 570 | - * @return boolean True if the browser is the YandexBot otherwise false |
|
| 571 | - */ |
|
| 572 | - protected function checkBrowserYandexBot() { |
|
| 573 | - if ( stripos( $this->_agent, 'YandexBot' ) !== false ) { |
|
| 574 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexBot' ) ); |
|
| 575 | - if ( isset( $aresult[1] ) ) { |
|
| 576 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 577 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 578 | - $this->_browser_name = self::BROWSER_YANDEXBOT; |
|
| 579 | - $this->setRobot( true ); |
|
| 580 | - |
|
| 581 | - return true; |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - return false; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Determine if the browser is the YandexImageResizer or not |
|
| 590 | - * |
|
| 591 | - * @return boolean True if the browser is the YandexImageResizer otherwise false |
|
| 592 | - */ |
|
| 593 | - protected function checkBrowserYandexImageResizerBot() { |
|
| 594 | - if ( stripos( $this->_agent, 'YandexImageResizer' ) !== false ) { |
|
| 595 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexImageResizer' ) ); |
|
| 596 | - if ( isset( $aresult[1] ) ) { |
|
| 597 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 598 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 599 | - $this->_browser_name = self::BROWSER_YANDEXIMAGERESIZER_BOT; |
|
| 600 | - $this->setRobot( true ); |
|
| 601 | - |
|
| 602 | - return true; |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - return false; |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * Determine if the browser is the YandexCatalog or not |
|
| 611 | - * |
|
| 612 | - * @return boolean True if the browser is the YandexCatalog otherwise false |
|
| 613 | - */ |
|
| 614 | - protected function checkBrowserYandexCatalogBot() { |
|
| 615 | - if ( stripos( $this->_agent, 'YandexCatalog' ) !== false ) { |
|
| 616 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexCatalog' ) ); |
|
| 617 | - if ( isset( $aresult[1] ) ) { |
|
| 618 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 619 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 620 | - $this->_browser_name = self::BROWSER_YANDEXCATALOG_BOT; |
|
| 621 | - $this->setRobot( true ); |
|
| 622 | - |
|
| 623 | - return true; |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - return false; |
|
| 628 | - } |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * Determine if the browser is the YandexNews or not |
|
| 632 | - * |
|
| 633 | - * @return boolean True if the browser is the YandexNews otherwise false |
|
| 634 | - */ |
|
| 635 | - protected function checkBrowserYandexNewsBot() { |
|
| 636 | - if ( stripos( $this->_agent, 'YandexNews' ) !== false ) { |
|
| 637 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexNews' ) ); |
|
| 638 | - if ( isset( $aresult[1] ) ) { |
|
| 639 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 640 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 641 | - $this->_browser_name = self::BROWSER_YANDEXNEWS_BOT; |
|
| 642 | - $this->setRobot( true ); |
|
| 643 | - |
|
| 644 | - return true; |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - return false; |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - /** |
|
| 652 | - * Determine if the browser is the YandexMetrika or not |
|
| 653 | - * |
|
| 654 | - * @return boolean True if the browser is the YandexMetrika otherwise false |
|
| 655 | - */ |
|
| 656 | - protected function checkBrowserYandexMetrikaBot() { |
|
| 657 | - if ( stripos( $this->_agent, 'YandexMetrika' ) !== false ) { |
|
| 658 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexMetrika' ) ); |
|
| 659 | - if ( isset( $aresult[1] ) ) { |
|
| 660 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 661 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 662 | - $this->_browser_name = self::BROWSER_YANDEXMETRIKA_BOT; |
|
| 663 | - $this->setRobot( true ); |
|
| 664 | - |
|
| 665 | - return true; |
|
| 666 | - } |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - return false; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * Determine if the browser is the YandexDirect or not |
|
| 674 | - * |
|
| 675 | - * @return boolean True if the browser is the YandexDirect otherwise false |
|
| 676 | - */ |
|
| 677 | - protected function checkBrowserYandexDirectBot() { |
|
| 678 | - if ( stripos( $this->_agent, 'YandexDirect' ) !== false ) { |
|
| 679 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexDirect' ) ); |
|
| 680 | - if ( isset( $aresult[1] ) ) { |
|
| 681 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 682 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 683 | - $this->_browser_name = self::BROWSER_YANDEXDIRECT_BOT; |
|
| 684 | - $this->setRobot( true ); |
|
| 685 | - |
|
| 686 | - return true; |
|
| 687 | - } |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - return false; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * Determine if the browser is the YandexWebmaster or not |
|
| 695 | - * |
|
| 696 | - * @return boolean True if the browser is the YandexWebmaster otherwise false |
|
| 697 | - */ |
|
| 698 | - protected function checkBrowserYandexWebmasterBot() { |
|
| 699 | - if ( stripos( $this->_agent, 'YandexWebmaster' ) !== false ) { |
|
| 700 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexWebmaster' ) ); |
|
| 701 | - if ( isset( $aresult[1] ) ) { |
|
| 702 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 703 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 704 | - $this->_browser_name = self::BROWSER_YANDEXWEBMASTER_BOT; |
|
| 705 | - $this->setRobot( true ); |
|
| 706 | - |
|
| 707 | - return true; |
|
| 708 | - } |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - return false; |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * Determine if the browser is the YandexFavicons or not |
|
| 716 | - * |
|
| 717 | - * @return boolean True if the browser is the YandexFavicons otherwise false |
|
| 718 | - */ |
|
| 719 | - protected function checkBrowserYandexFaviconsBot() { |
|
| 720 | - if ( stripos( $this->_agent, 'YandexFavicons' ) !== false ) { |
|
| 721 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexFavicons' ) ); |
|
| 722 | - if ( isset( $aresult[1] ) ) { |
|
| 723 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 724 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 725 | - $this->_browser_name = self::BROWSER_YANDEXFAVICONS_BOT; |
|
| 726 | - $this->setRobot( true ); |
|
| 727 | - |
|
| 728 | - return true; |
|
| 729 | - } |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - return false; |
|
| 733 | - } |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * Determine if the browser is the YandexBlogs or not |
|
| 737 | - * |
|
| 738 | - * @return boolean True if the browser is the YandexBlogs otherwise false |
|
| 739 | - */ |
|
| 740 | - protected function checkBrowserYandexBlogsBot() { |
|
| 741 | - if ( stripos( $this->_agent, 'YandexBlogs' ) !== false ) { |
|
| 742 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexBlogs' ) ); |
|
| 743 | - if ( isset( $aresult[1] ) ) { |
|
| 744 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 745 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 746 | - $this->_browser_name = self::BROWSER_YANDEXBLOGS_BOT; |
|
| 747 | - $this->setRobot( true ); |
|
| 748 | - |
|
| 749 | - return true; |
|
| 750 | - } |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - return false; |
|
| 754 | - } |
|
| 755 | - |
|
| 756 | - /** |
|
| 757 | - * Determine if the browser is the YandexMedia or not |
|
| 758 | - * |
|
| 759 | - * @return boolean True if the browser is the YandexMedia otherwise false |
|
| 760 | - */ |
|
| 761 | - protected function checkBrowserYandexMediaBot() { |
|
| 762 | - if ( stripos( $this->_agent, 'YandexMedia' ) !== false ) { |
|
| 763 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexMedia' ) ); |
|
| 764 | - if ( isset( $aresult[1] ) ) { |
|
| 765 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 766 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 767 | - $this->_browser_name = self::BROWSER_YANDEXMEDIA_BOT; |
|
| 768 | - $this->setRobot( true ); |
|
| 769 | - |
|
| 770 | - return true; |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - return false; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - /** |
|
| 778 | - * Determine if the browser is the YandexVideo or not |
|
| 779 | - * |
|
| 780 | - * @return boolean True if the browser is the YandexVideo otherwise false |
|
| 781 | - */ |
|
| 782 | - protected function checkBrowserYandexVideoBot() { |
|
| 783 | - if ( stripos( $this->_agent, 'YandexVideo' ) !== false ) { |
|
| 784 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexVideo' ) ); |
|
| 785 | - if ( isset( $aresult[1] ) ) { |
|
| 786 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 787 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 788 | - $this->_browser_name = self::BROWSER_YANDEXVIDEO_BOT; |
|
| 789 | - $this->setRobot( true ); |
|
| 790 | - |
|
| 791 | - return true; |
|
| 792 | - } |
|
| 793 | - } |
|
| 794 | - |
|
| 795 | - return false; |
|
| 796 | - } |
|
| 797 | - |
|
| 798 | - /** |
|
| 799 | - * Determine if the browser is the YandexImages or not |
|
| 800 | - * |
|
| 801 | - * @return boolean True if the browser is the YandexImages otherwise false |
|
| 802 | - */ |
|
| 803 | - protected function checkBrowserYandexImagesBot() { |
|
| 804 | - if ( stripos( $this->_agent, 'YandexImages' ) !== false ) { |
|
| 805 | - $aresult = explode( '/', stristr( $this->_agent, 'YandexImages' ) ); |
|
| 806 | - if ( isset( $aresult[1] ) ) { |
|
| 807 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 808 | - $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 809 | - $this->_browser_name = self::BROWSER_YANDEXIMAGES_BOT; |
|
| 810 | - $this->setRobot( true ); |
|
| 811 | - |
|
| 812 | - return true; |
|
| 813 | - } |
|
| 814 | - } |
|
| 815 | - |
|
| 816 | - return false; |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - /** |
|
| 820 | - * Determine if the browser is the MSNBot or not (last updated 1.9) |
|
| 821 | - * |
|
| 822 | - * @return boolean True if the browser is the MSNBot otherwise false |
|
| 823 | - */ |
|
| 824 | - protected function checkBrowserMSNBot() { |
|
| 825 | - if ( stripos( $this->_agent, "msnbot" ) !== false ) { |
|
| 826 | - $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) ); |
|
| 827 | - if ( isset( $aresult[1] ) ) { |
|
| 828 | - $aversion = explode( " ", $aresult[1] ); |
|
| 829 | - $this->setVersion( str_replace( ";", '', $aversion[0] ) ); |
|
| 830 | - $this->_browser_name = self::BROWSER_MSNBOT; |
|
| 831 | - $this->setRobot( true ); |
|
| 832 | - |
|
| 833 | - return true; |
|
| 834 | - } |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - return false; |
|
| 838 | - } |
|
| 839 | - |
|
| 840 | - /** |
|
| 841 | - * Determine if the browser is the BingBot or not (last updated 1.9) |
|
| 842 | - * |
|
| 843 | - * @return boolean True if the browser is the BingBot otherwise false |
|
| 844 | - */ |
|
| 845 | - protected function checkBrowserBingBot() { |
|
| 846 | - if ( stripos( $this->_agent, "bingbot" ) !== false ) { |
|
| 847 | - $aresult = explode( "/", stristr( $this->_agent, "bingbot" ) ); |
|
| 848 | - if ( isset( $aresult[1] ) ) { |
|
| 849 | - $aversion = explode( " ", $aresult[1] ); |
|
| 850 | - $this->setVersion( str_replace( ";", '', $aversion[0] ) ); |
|
| 851 | - $this->_browser_name = self::BROWSER_BINGBOT; |
|
| 852 | - $this->setRobot( true ); |
|
| 853 | - |
|
| 854 | - return true; |
|
| 855 | - } |
|
| 856 | - } |
|
| 857 | - |
|
| 858 | - return false; |
|
| 859 | - } |
|
| 860 | - |
|
| 861 | - /** |
|
| 862 | - * Determine if the browser is the W3C Validator or not (last updated 1.7) |
|
| 863 | - * |
|
| 864 | - * @return boolean True if the browser is the W3C Validator otherwise false |
|
| 865 | - */ |
|
| 866 | - protected function checkBrowserW3CValidator() { |
|
| 867 | - if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) { |
|
| 868 | - $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) ); |
|
| 869 | - if ( isset( $aresult[1] ) ) { |
|
| 870 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 871 | - $this->setVersion( $aversion[0] ); |
|
| 872 | - $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 873 | - |
|
| 874 | - return true; |
|
| 875 | - } |
|
| 876 | - } elseif ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) { |
|
| 877 | - // Some of the Validator versions do not delineate w/ a slash - add it back in |
|
| 878 | - $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent ); |
|
| 879 | - $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) ); |
|
| 880 | - if ( isset( $aresult[1] ) ) { |
|
| 881 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 882 | - $this->setVersion( $aversion[0] ); |
|
| 883 | - $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 884 | - |
|
| 885 | - return true; |
|
| 886 | - } |
|
| 887 | - } elseif ( stripos( $this->_agent, 'W3C-mobileOK' ) !== false ) { |
|
| 888 | - $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 889 | - $this->setMobile( true ); |
|
| 890 | - |
|
| 891 | - return true; |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - return false; |
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - /** |
|
| 898 | - * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7) |
|
| 899 | - * |
|
| 900 | - * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false |
|
| 901 | - */ |
|
| 902 | - protected function checkBrowserSlurp() { |
|
| 903 | - if ( stripos( $this->_agent, 'slurp' ) !== false ) { |
|
| 904 | - $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) ); |
|
| 905 | - if ( isset( $aresult[1] ) ) { |
|
| 906 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 907 | - $this->setVersion( $aversion[0] ); |
|
| 908 | - $this->_browser_name = self::BROWSER_SLURP; |
|
| 909 | - $this->setRobot( true ); |
|
| 910 | - $this->setMobile( false ); |
|
| 911 | - |
|
| 912 | - return true; |
|
| 913 | - } |
|
| 914 | - } |
|
| 915 | - |
|
| 916 | - return false; |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - /** |
|
| 920 | - * Determine if the browser is Brave or not |
|
| 921 | - * |
|
| 922 | - * @return boolean True if the browser is Brave otherwise false |
|
| 923 | - */ |
|
| 924 | - protected function checkBrowserBrave() { |
|
| 925 | - if ( stripos( $this->_agent, 'Brave/' ) !== false ) { |
|
| 926 | - $aResult = explode( '/', stristr( $this->_agent, 'Brave' ) ); |
|
| 927 | - if ( isset( $aResult[1] ) ) { |
|
| 928 | - $aversion = explode( ' ', $aResult[1] ); |
|
| 929 | - $this->setVersion( $aversion[0] ); |
|
| 930 | - $this->setBrowser( self::BROWSER_BRAVE ); |
|
| 931 | - |
|
| 932 | - return true; |
|
| 933 | - } |
|
| 934 | - } elseif ( stripos( $this->_agent, ' Brave ' ) !== false ) { |
|
| 935 | - $this->setBrowser( self::BROWSER_BRAVE ); |
|
| 936 | - // this version of the UA did not ship with a version marker |
|
| 937 | - // e.g. Mozilla/5.0 (Linux; Android 7.0; SM-G955F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/68.0.3440.91 Mobile Safari/537.36 |
|
| 938 | - $this->setVersion( '' ); |
|
| 939 | - |
|
| 940 | - return true; |
|
| 941 | - } |
|
| 942 | - |
|
| 943 | - return false; |
|
| 944 | - } |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * Determine if the browser is Edge or not |
|
| 948 | - * |
|
| 949 | - * @return boolean True if the browser is Edge otherwise false |
|
| 950 | - */ |
|
| 951 | - protected function checkBrowserEdge() { |
|
| 952 | - if ( $name = ( stripos( $this->_agent, 'Edge/' ) !== false ? 'Edge' : ( ( stripos( $this->_agent, 'Edg/' ) !== false || stripos( $this->_agent, 'EdgA/' ) !== false ) ? 'Edg' : false ) ) ) { |
|
| 953 | - $aresult = explode( '/', stristr( $this->_agent, $name ) ); |
|
| 954 | - if ( isset( $aresult[1] ) ) { |
|
| 955 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 956 | - $this->setVersion( $aversion[0] ); |
|
| 957 | - $this->setBrowser( self::BROWSER_EDGE ); |
|
| 958 | - if ( stripos( $this->_agent, 'Windows Phone' ) !== false || stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 959 | - $this->setMobile( true ); |
|
| 960 | - } |
|
| 961 | - |
|
| 962 | - return true; |
|
| 963 | - } |
|
| 964 | - } |
|
| 965 | - |
|
| 966 | - return false; |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - /** |
|
| 970 | - * Determine if the browser is Internet Explorer or not (last updated 1.7) |
|
| 971 | - * |
|
| 972 | - * @return boolean True if the browser is Internet Explorer otherwise false |
|
| 973 | - */ |
|
| 974 | - protected function checkBrowserInternetExplorer() { |
|
| 975 | - // Test for IE11 |
|
| 976 | - if ( stripos( $this->_agent, 'Trident/7.0; rv:11.0' ) !== false ) { |
|
| 977 | - $this->setBrowser( self::BROWSER_IE ); |
|
| 978 | - $this->setVersion( '11.0' ); |
|
| 979 | - |
|
| 980 | - return true; |
|
| 981 | - } // Test for v1 - v1.5 IE |
|
| 982 | - elseif ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) { |
|
| 983 | - $this->setBrowser( self::BROWSER_IE ); |
|
| 984 | - $this->setVersion( '1.0' ); |
|
| 985 | - $aresult = stristr( $this->_agent, '/' ); |
|
| 986 | - if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) { |
|
| 987 | - $this->setVersion( '1.5' ); |
|
| 988 | - } |
|
| 989 | - |
|
| 990 | - return true; |
|
| 991 | - } // Test for versions > 1.5 |
|
| 992 | - elseif ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) { |
|
| 993 | - // See if the browser is the odd MSN Explorer |
|
| 994 | - if ( stripos( $this->_agent, 'msnb' ) !== false ) { |
|
| 995 | - $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) ); |
|
| 996 | - if ( isset( $aresult[1] ) ) { |
|
| 997 | - $this->setBrowser( self::BROWSER_MSN ); |
|
| 998 | - $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); |
|
| 999 | - |
|
| 1000 | - return true; |
|
| 1001 | - } |
|
| 1002 | - } |
|
| 1003 | - $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) ); |
|
| 1004 | - if ( isset( $aresult[1] ) ) { |
|
| 1005 | - $this->setBrowser( self::BROWSER_IE ); |
|
| 1006 | - $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); |
|
| 1007 | - if ( stripos( $this->_agent, 'IEMobile' ) !== false ) { |
|
| 1008 | - $this->setBrowser( self::BROWSER_POCKET_IE ); |
|
| 1009 | - $this->setMobile( true ); |
|
| 1010 | - } |
|
| 1011 | - |
|
| 1012 | - return true; |
|
| 1013 | - } |
|
| 1014 | - } // Test for versions > IE 10 |
|
| 1015 | - elseif ( stripos( $this->_agent, 'trident' ) !== false ) { |
|
| 1016 | - $this->setBrowser( self::BROWSER_IE ); |
|
| 1017 | - $result = explode( 'rv:', $this->_agent ); |
|
| 1018 | - if ( isset( $result[1] ) ) { |
|
| 1019 | - $this->setVersion( preg_replace( '/[^0-9.]+/', '', $result[1] ) ); |
|
| 1020 | - $this->_agent = str_replace( array( "Mozilla", "Gecko" ), "MSIE", $this->_agent ); |
|
| 1021 | - } |
|
| 1022 | - } // Test for Pocket IE |
|
| 1023 | - elseif ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) { |
|
| 1024 | - $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) ); |
|
| 1025 | - if ( isset( $aresult[1] ) ) { |
|
| 1026 | - $this->setPlatform( self::PLATFORM_WINDOWS_CE ); |
|
| 1027 | - $this->setBrowser( self::BROWSER_POCKET_IE ); |
|
| 1028 | - $this->setMobile( true ); |
|
| 1029 | - |
|
| 1030 | - if ( stripos( $this->_agent, 'mspie' ) !== false ) { |
|
| 1031 | - $this->setVersion( $aresult[1] ); |
|
| 1032 | - } else { |
|
| 1033 | - $aversion = explode( '/', $this->_agent ); |
|
| 1034 | - if ( isset( $aversion[1] ) ) { |
|
| 1035 | - $this->setVersion( $aversion[1] ); |
|
| 1036 | - } |
|
| 1037 | - } |
|
| 1038 | - |
|
| 1039 | - return true; |
|
| 1040 | - } |
|
| 1041 | - } |
|
| 1042 | - |
|
| 1043 | - return false; |
|
| 1044 | - } |
|
| 1045 | - |
|
| 1046 | - /** |
|
| 1047 | - * Determine if the browser is Opera or not (last updated 1.7) |
|
| 1048 | - * |
|
| 1049 | - * @return boolean True if the browser is Opera otherwise false |
|
| 1050 | - */ |
|
| 1051 | - protected function checkBrowserOpera() { |
|
| 1052 | - if ( stripos( $this->_agent, 'opera mini' ) !== false ) { |
|
| 1053 | - $resultant = stristr( $this->_agent, 'opera mini' ); |
|
| 1054 | - if ( preg_match( '/\//', $resultant ) ) { |
|
| 1055 | - $aresult = explode( '/', $resultant ); |
|
| 1056 | - if ( isset( $aresult[1] ) ) { |
|
| 1057 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1058 | - $this->setVersion( $aversion[0] ); |
|
| 1059 | - } |
|
| 1060 | - } else { |
|
| 1061 | - $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) ); |
|
| 1062 | - if ( isset( $aversion[1] ) ) { |
|
| 1063 | - $this->setVersion( $aversion[1] ); |
|
| 1064 | - } |
|
| 1065 | - } |
|
| 1066 | - $this->_browser_name = self::BROWSER_OPERA_MINI; |
|
| 1067 | - $this->setMobile( true ); |
|
| 1068 | - |
|
| 1069 | - return true; |
|
| 1070 | - } elseif ( stripos( $this->_agent, 'opera' ) !== false ) { |
|
| 1071 | - $resultant = stristr( $this->_agent, 'opera' ); |
|
| 1072 | - if ( preg_match( '/Version\/(1*.*)$/', $resultant, $matches ) ) { |
|
| 1073 | - $this->setVersion( $matches[1] ); |
|
| 1074 | - } elseif ( preg_match( '/\//', $resultant ) ) { |
|
| 1075 | - $aresult = explode( '/', str_replace( "(", " ", $resultant ) ); |
|
| 1076 | - if ( isset( $aresult[1] ) ) { |
|
| 1077 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1078 | - $this->setVersion( $aversion[0] ); |
|
| 1079 | - } |
|
| 1080 | - } else { |
|
| 1081 | - $aversion = explode( ' ', stristr( $resultant, 'opera' ) ); |
|
| 1082 | - $this->setVersion( isset( $aversion[1] ) ? $aversion[1] : '' ); |
|
| 1083 | - } |
|
| 1084 | - if ( stripos( $this->_agent, 'Opera Mobi' ) !== false ) { |
|
| 1085 | - $this->setMobile( true ); |
|
| 1086 | - } |
|
| 1087 | - $this->_browser_name = self::BROWSER_OPERA; |
|
| 1088 | - |
|
| 1089 | - return true; |
|
| 1090 | - } elseif ( stripos( $this->_agent, 'OPR' ) !== false ) { |
|
| 1091 | - $resultant = stristr( $this->_agent, 'OPR' ); |
|
| 1092 | - if ( preg_match( '/\//', $resultant ) ) { |
|
| 1093 | - $aresult = explode( '/', str_replace( "(", " ", $resultant ) ); |
|
| 1094 | - if ( isset( $aresult[1] ) ) { |
|
| 1095 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1096 | - $this->setVersion( $aversion[0] ); |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1100 | - $this->setMobile( true ); |
|
| 1101 | - } |
|
| 1102 | - $this->_browser_name = self::BROWSER_OPERA; |
|
| 1103 | - |
|
| 1104 | - return true; |
|
| 1105 | - } |
|
| 1106 | - |
|
| 1107 | - return false; |
|
| 1108 | - } |
|
| 1109 | - |
|
| 1110 | - /** |
|
| 1111 | - * Determine if the browser is Chrome or not (last updated 1.7) |
|
| 1112 | - * |
|
| 1113 | - * @return boolean True if the browser is Chrome otherwise false |
|
| 1114 | - */ |
|
| 1115 | - protected function checkBrowserChrome() { |
|
| 1116 | - if ( stripos( $this->_agent, 'Chrome' ) !== false ) { |
|
| 1117 | - $aresult = preg_split( '/[\/;]+/', stristr( $this->_agent, 'Chrome' ) ); |
|
| 1118 | - if ( isset( $aresult[1] ) ) { |
|
| 1119 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1120 | - $this->setVersion( $aversion[0] ); |
|
| 1121 | - $this->setBrowser( self::BROWSER_CHROME ); |
|
| 1122 | - //Chrome on Android |
|
| 1123 | - if ( stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 1124 | - if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1125 | - $this->setMobile( true ); |
|
| 1126 | - } else { |
|
| 1127 | - $this->setTablet( true ); |
|
| 1128 | - } |
|
| 1129 | - } |
|
| 1130 | - |
|
| 1131 | - return true; |
|
| 1132 | - } |
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - return false; |
|
| 1136 | - } |
|
| 1137 | - |
|
| 1138 | - |
|
| 1139 | - /** |
|
| 1140 | - * Determine if the browser is WebTv or not (last updated 1.7) |
|
| 1141 | - * |
|
| 1142 | - * @return boolean True if the browser is WebTv otherwise false |
|
| 1143 | - */ |
|
| 1144 | - protected function checkBrowserWebTv() { |
|
| 1145 | - if ( stripos( $this->_agent, 'webtv' ) !== false ) { |
|
| 1146 | - $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) ); |
|
| 1147 | - if ( isset( $aresult[1] ) ) { |
|
| 1148 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1149 | - $this->setVersion( $aversion[0] ); |
|
| 1150 | - $this->setBrowser( self::BROWSER_WEBTV ); |
|
| 1151 | - |
|
| 1152 | - return true; |
|
| 1153 | - } |
|
| 1154 | - } |
|
| 1155 | - |
|
| 1156 | - return false; |
|
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - /** |
|
| 1160 | - * Determine if the browser is NetPositive or not (last updated 1.7) |
|
| 1161 | - * |
|
| 1162 | - * @return boolean True if the browser is NetPositive otherwise false |
|
| 1163 | - */ |
|
| 1164 | - protected function checkBrowserNetPositive() { |
|
| 1165 | - if ( stripos( $this->_agent, 'NetPositive' ) !== false ) { |
|
| 1166 | - $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) ); |
|
| 1167 | - if ( isset( $aresult[1] ) ) { |
|
| 1168 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1169 | - $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) ); |
|
| 1170 | - $this->setBrowser( self::BROWSER_NETPOSITIVE ); |
|
| 1171 | - |
|
| 1172 | - return true; |
|
| 1173 | - } |
|
| 1174 | - } |
|
| 1175 | - |
|
| 1176 | - return false; |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - /** |
|
| 1180 | - * Determine if the browser is Galeon or not (last updated 1.7) |
|
| 1181 | - * |
|
| 1182 | - * @return boolean True if the browser is Galeon otherwise false |
|
| 1183 | - */ |
|
| 1184 | - protected function checkBrowserGaleon() { |
|
| 1185 | - if ( stripos( $this->_agent, 'galeon' ) !== false ) { |
|
| 1186 | - $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) ); |
|
| 1187 | - $aversion = explode( '/', $aresult[0] ); |
|
| 1188 | - if ( isset( $aversion[1] ) ) { |
|
| 1189 | - $this->setVersion( $aversion[1] ); |
|
| 1190 | - $this->setBrowser( self::BROWSER_GALEON ); |
|
| 1191 | - |
|
| 1192 | - return true; |
|
| 1193 | - } |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - return false; |
|
| 1197 | - } |
|
| 1198 | - |
|
| 1199 | - /** |
|
| 1200 | - * Determine if the browser is Konqueror or not (last updated 1.7) |
|
| 1201 | - * |
|
| 1202 | - * @return boolean True if the browser is Konqueror otherwise false |
|
| 1203 | - */ |
|
| 1204 | - protected function checkBrowserKonqueror() { |
|
| 1205 | - if ( stripos( $this->_agent, 'Konqueror' ) !== false ) { |
|
| 1206 | - $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) ); |
|
| 1207 | - $aversion = explode( '/', $aresult[0] ); |
|
| 1208 | - if ( isset( $aversion[1] ) ) { |
|
| 1209 | - $this->setVersion( $aversion[1] ); |
|
| 1210 | - $this->setBrowser( self::BROWSER_KONQUEROR ); |
|
| 1211 | - |
|
| 1212 | - return true; |
|
| 1213 | - } |
|
| 1214 | - } |
|
| 1215 | - |
|
| 1216 | - return false; |
|
| 1217 | - } |
|
| 1218 | - |
|
| 1219 | - /** |
|
| 1220 | - * Determine if the browser is iCab or not (last updated 1.7) |
|
| 1221 | - * |
|
| 1222 | - * @return boolean True if the browser is iCab otherwise false |
|
| 1223 | - */ |
|
| 1224 | - protected function checkBrowserIcab() { |
|
| 1225 | - if ( stripos( $this->_agent, 'icab' ) !== false ) { |
|
| 1226 | - $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) ); |
|
| 1227 | - if ( isset( $aversion[1] ) ) { |
|
| 1228 | - $this->setVersion( $aversion[1] ); |
|
| 1229 | - $this->setBrowser( self::BROWSER_ICAB ); |
|
| 1230 | - |
|
| 1231 | - return true; |
|
| 1232 | - } |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - return false; |
|
| 1236 | - } |
|
| 1237 | - |
|
| 1238 | - /** |
|
| 1239 | - * Determine if the browser is OmniWeb or not (last updated 1.7) |
|
| 1240 | - * |
|
| 1241 | - * @return boolean True if the browser is OmniWeb otherwise false |
|
| 1242 | - */ |
|
| 1243 | - protected function checkBrowserOmniWeb() { |
|
| 1244 | - if ( stripos( $this->_agent, 'omniweb' ) !== false ) { |
|
| 1245 | - $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) ); |
|
| 1246 | - $aversion = explode( ' ', isset( $aresult[1] ) ? $aresult[1] : '' ); |
|
| 1247 | - $this->setVersion( $aversion[0] ); |
|
| 1248 | - $this->setBrowser( self::BROWSER_OMNIWEB ); |
|
| 1249 | - |
|
| 1250 | - return true; |
|
| 1251 | - } |
|
| 1252 | - |
|
| 1253 | - return false; |
|
| 1254 | - } |
|
| 1255 | - |
|
| 1256 | - /** |
|
| 1257 | - * Determine if the browser is Phoenix or not (last updated 1.7) |
|
| 1258 | - * |
|
| 1259 | - * @return boolean True if the browser is Phoenix otherwise false |
|
| 1260 | - */ |
|
| 1261 | - protected function checkBrowserPhoenix() { |
|
| 1262 | - if ( stripos( $this->_agent, 'Phoenix' ) !== false ) { |
|
| 1263 | - $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) ); |
|
| 1264 | - if ( isset( $aversion[1] ) ) { |
|
| 1265 | - $this->setVersion( $aversion[1] ); |
|
| 1266 | - $this->setBrowser( self::BROWSER_PHOENIX ); |
|
| 1267 | - |
|
| 1268 | - return true; |
|
| 1269 | - } |
|
| 1270 | - } |
|
| 1271 | - |
|
| 1272 | - return false; |
|
| 1273 | - } |
|
| 1274 | - |
|
| 1275 | - /** |
|
| 1276 | - * Determine if the browser is Firebird or not (last updated 1.7) |
|
| 1277 | - * |
|
| 1278 | - * @return boolean True if the browser is Firebird otherwise false |
|
| 1279 | - */ |
|
| 1280 | - protected function checkBrowserFirebird() { |
|
| 1281 | - if ( stripos( $this->_agent, 'Firebird' ) !== false ) { |
|
| 1282 | - $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) ); |
|
| 1283 | - if ( isset( $aversion[1] ) ) { |
|
| 1284 | - $this->setVersion( $aversion[1] ); |
|
| 1285 | - $this->setBrowser( self::BROWSER_FIREBIRD ); |
|
| 1286 | - |
|
| 1287 | - return true; |
|
| 1288 | - } |
|
| 1289 | - } |
|
| 1290 | - |
|
| 1291 | - return false; |
|
| 1292 | - } |
|
| 1293 | - |
|
| 1294 | - /** |
|
| 1295 | - * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7) |
|
| 1296 | - * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008) |
|
| 1297 | - * |
|
| 1298 | - * @return boolean True if the browser is Netscape Navigator 9+ otherwise false |
|
| 1299 | - */ |
|
| 1300 | - protected function checkBrowserNetscapeNavigator9Plus() { |
|
| 1301 | - if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1302 | - $this->setVersion( $matches[1] ); |
|
| 1303 | - $this->setBrowser( self::BROWSER_NETSCAPE_NAVIGATOR ); |
|
| 1304 | - |
|
| 1305 | - return true; |
|
| 1306 | - } elseif ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1307 | - $this->setVersion( $matches[1] ); |
|
| 1308 | - $this->setBrowser( self::BROWSER_NETSCAPE_NAVIGATOR ); |
|
| 1309 | - |
|
| 1310 | - return true; |
|
| 1311 | - } |
|
| 1312 | - |
|
| 1313 | - return false; |
|
| 1314 | - } |
|
| 1315 | - |
|
| 1316 | - /** |
|
| 1317 | - * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7) |
|
| 1318 | - * |
|
| 1319 | - * @return boolean True if the browser is Shiretoko otherwise false |
|
| 1320 | - */ |
|
| 1321 | - protected function checkBrowserShiretoko() { |
|
| 1322 | - if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1323 | - $this->setVersion( $matches[1] ); |
|
| 1324 | - $this->setBrowser( self::BROWSER_SHIRETOKO ); |
|
| 1325 | - |
|
| 1326 | - return true; |
|
| 1327 | - } |
|
| 1328 | - |
|
| 1329 | - return false; |
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - /** |
|
| 1333 | - * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7) |
|
| 1334 | - * |
|
| 1335 | - * @return boolean True if the browser is Ice Cat otherwise false |
|
| 1336 | - */ |
|
| 1337 | - protected function checkBrowserIceCat() { |
|
| 1338 | - if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1339 | - $this->setVersion( $matches[1] ); |
|
| 1340 | - $this->setBrowser( self::BROWSER_ICECAT ); |
|
| 1341 | - |
|
| 1342 | - return true; |
|
| 1343 | - } |
|
| 1344 | - |
|
| 1345 | - return false; |
|
| 1346 | - } |
|
| 1347 | - |
|
| 1348 | - /** |
|
| 1349 | - * Determine if the browser is Nokia or not (last updated 1.7) |
|
| 1350 | - * |
|
| 1351 | - * @return boolean True if the browser is Nokia otherwise false |
|
| 1352 | - */ |
|
| 1353 | - protected function checkBrowserNokia() { |
|
| 1354 | - if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) { |
|
| 1355 | - $this->setVersion( $matches[2] ); |
|
| 1356 | - if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) { |
|
| 1357 | - $this->setBrowser( self::BROWSER_NOKIA_S60 ); |
|
| 1358 | - } else { |
|
| 1359 | - $this->setBrowser( self::BROWSER_NOKIA ); |
|
| 1360 | - } |
|
| 1361 | - $this->setMobile( true ); |
|
| 1362 | - |
|
| 1363 | - return true; |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - return false; |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - /** |
|
| 1370 | - * Determine if the browser is Palemoon or not |
|
| 1371 | - * |
|
| 1372 | - * @return boolean True if the browser is Palemoon otherwise false |
|
| 1373 | - */ |
|
| 1374 | - protected function checkBrowserPalemoon() { |
|
| 1375 | - if ( stripos( $this->_agent, 'safari' ) === false ) { |
|
| 1376 | - if ( preg_match( "/Palemoon[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { |
|
| 1377 | - $this->setVersion( $matches[1] ); |
|
| 1378 | - $this->setBrowser( self::BROWSER_PALEMOON ); |
|
| 1379 | - |
|
| 1380 | - return true; |
|
| 1381 | - } elseif ( preg_match( "/Palemoon([0-9a-zA-Z\.]+)/i", $this->_agent, $matches ) ) { |
|
| 1382 | - $this->setVersion( $matches[1] ); |
|
| 1383 | - $this->setBrowser( self::BROWSER_PALEMOON ); |
|
| 1384 | - |
|
| 1385 | - return true; |
|
| 1386 | - } elseif ( preg_match( "/Palemoon/i", $this->_agent, $matches ) ) { |
|
| 1387 | - $this->setVersion( '' ); |
|
| 1388 | - $this->setBrowser( self::BROWSER_PALEMOON ); |
|
| 1389 | - |
|
| 1390 | - return true; |
|
| 1391 | - } |
|
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - return false; |
|
| 1395 | - } |
|
| 1396 | - |
|
| 1397 | - /** |
|
| 1398 | - * Determine if the browser is UCBrowser or not |
|
| 1399 | - * |
|
| 1400 | - * @return boolean True if the browser is UCBrowser otherwise false |
|
| 1401 | - */ |
|
| 1402 | - protected function checkBrowserUCBrowser() { |
|
| 1403 | - if ( preg_match( '/UC ?Browser\/?([\d\.]+)/', $this->_agent, $matches ) ) { |
|
| 1404 | - if ( isset( $matches[1] ) ) { |
|
| 1405 | - $this->setVersion( $matches[1] ); |
|
| 1406 | - } |
|
| 1407 | - if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1408 | - $this->setMobile( true ); |
|
| 1409 | - } else { |
|
| 1410 | - $this->setTablet( true ); |
|
| 1411 | - } |
|
| 1412 | - $this->setBrowser( self::BROWSER_UCBROWSER ); |
|
| 1413 | - |
|
| 1414 | - return true; |
|
| 1415 | - } |
|
| 1416 | - |
|
| 1417 | - return false; |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - /** |
|
| 1421 | - * Determine if the browser is Firefox or not |
|
| 1422 | - * |
|
| 1423 | - * @return boolean True if the browser is Firefox otherwise false |
|
| 1424 | - */ |
|
| 1425 | - protected function checkBrowserFirefox() { |
|
| 1426 | - if ( stripos( $this->_agent, 'safari' ) === false ) { |
|
| 1427 | - if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { |
|
| 1428 | - $this->setVersion( $matches[1] ); |
|
| 1429 | - $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1430 | - //Firefox on Android |
|
| 1431 | - if ( stripos( $this->_agent, 'Android' ) !== false || stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1432 | - if ( stripos( $this->_agent, 'Mobile' ) !== false || stripos( $this->_agent, 'Tablet' ) !== false ) { |
|
| 1433 | - $this->setMobile( true ); |
|
| 1434 | - } else { |
|
| 1435 | - $this->setTablet( true ); |
|
| 1436 | - } |
|
| 1437 | - } |
|
| 1438 | - |
|
| 1439 | - return true; |
|
| 1440 | - } elseif ( preg_match( "/Firefox([0-9a-zA-Z\.]+)/i", $this->_agent, $matches ) ) { |
|
| 1441 | - $this->setVersion( $matches[1] ); |
|
| 1442 | - $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1443 | - |
|
| 1444 | - return true; |
|
| 1445 | - } elseif ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) { |
|
| 1446 | - $this->setVersion( '' ); |
|
| 1447 | - $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1448 | - |
|
| 1449 | - return true; |
|
| 1450 | - } |
|
| 1451 | - } elseif ( preg_match( "/FxiOS[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { |
|
| 1452 | - $this->setVersion( $matches[1] ); |
|
| 1453 | - $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1454 | - //Firefox on Android |
|
| 1455 | - if ( stripos( $this->_agent, 'Android' ) !== false || stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1456 | - if ( stripos( $this->_agent, 'Mobile' ) !== false || stripos( $this->_agent, 'Tablet' ) !== false ) { |
|
| 1457 | - $this->setMobile( true ); |
|
| 1458 | - } else { |
|
| 1459 | - $this->setTablet( true ); |
|
| 1460 | - } |
|
| 1461 | - } |
|
| 1462 | - |
|
| 1463 | - return true; |
|
| 1464 | - } |
|
| 1465 | - |
|
| 1466 | - return false; |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - /** |
|
| 1470 | - * Determine if the browser is Firefox or not (last updated 1.7) |
|
| 1471 | - * |
|
| 1472 | - * @return boolean True if the browser is Firefox otherwise false |
|
| 1473 | - */ |
|
| 1474 | - protected function checkBrowserIceweasel() { |
|
| 1475 | - if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) { |
|
| 1476 | - $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) ); |
|
| 1477 | - if ( isset( $aresult[1] ) ) { |
|
| 1478 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1479 | - $this->setVersion( $aversion[0] ); |
|
| 1480 | - $this->setBrowser( self::BROWSER_ICEWEASEL ); |
|
| 1481 | - |
|
| 1482 | - return true; |
|
| 1483 | - } |
|
| 1484 | - } |
|
| 1485 | - |
|
| 1486 | - return false; |
|
| 1487 | - } |
|
| 1488 | - |
|
| 1489 | - /** |
|
| 1490 | - * Determine if the browser is Mozilla or not (last updated 1.7) |
|
| 1491 | - * |
|
| 1492 | - * @return boolean True if the browser is Mozilla otherwise false |
|
| 1493 | - */ |
|
| 1494 | - protected function checkBrowserMozilla() { |
|
| 1495 | - if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { |
|
| 1496 | - $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) ); |
|
| 1497 | - preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion ); |
|
| 1498 | - $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); |
|
| 1499 | - $this->setBrowser( self::BROWSER_MOZILLA ); |
|
| 1500 | - |
|
| 1501 | - return true; |
|
| 1502 | - } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { |
|
| 1503 | - $aversion = explode( '', stristr( $this->_agent, 'rv:' ) ); |
|
| 1504 | - $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); |
|
| 1505 | - $this->setBrowser( self::BROWSER_MOZILLA ); |
|
| 1506 | - |
|
| 1507 | - return true; |
|
| 1508 | - } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) { |
|
| 1509 | - $this->setVersion( $matches[1] ); |
|
| 1510 | - $this->setBrowser( self::BROWSER_MOZILLA ); |
|
| 1511 | - |
|
| 1512 | - return true; |
|
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - return false; |
|
| 1516 | - } |
|
| 1517 | - |
|
| 1518 | - /** |
|
| 1519 | - * Determine if the browser is Lynx or not (last updated 1.7) |
|
| 1520 | - * |
|
| 1521 | - * @return boolean True if the browser is Lynx otherwise false |
|
| 1522 | - */ |
|
| 1523 | - protected function checkBrowserLynx() { |
|
| 1524 | - if ( stripos( $this->_agent, 'lynx' ) !== false ) { |
|
| 1525 | - $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) ); |
|
| 1526 | - $aversion = explode( ' ', ( isset( $aresult[1] ) ? $aresult[1] : '' ) ); |
|
| 1527 | - $this->setVersion( $aversion[0] ); |
|
| 1528 | - $this->setBrowser( self::BROWSER_LYNX ); |
|
| 1529 | - |
|
| 1530 | - return true; |
|
| 1531 | - } |
|
| 1532 | - |
|
| 1533 | - return false; |
|
| 1534 | - } |
|
| 1535 | - |
|
| 1536 | - /** |
|
| 1537 | - * Determine if the browser is Amaya or not (last updated 1.7) |
|
| 1538 | - * |
|
| 1539 | - * @return boolean True if the browser is Amaya otherwise false |
|
| 1540 | - */ |
|
| 1541 | - protected function checkBrowserAmaya() { |
|
| 1542 | - if ( stripos( $this->_agent, 'amaya' ) !== false ) { |
|
| 1543 | - $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) ); |
|
| 1544 | - if ( isset( $aresult[1] ) ) { |
|
| 1545 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1546 | - $this->setVersion( $aversion[0] ); |
|
| 1547 | - $this->setBrowser( self::BROWSER_AMAYA ); |
|
| 1548 | - |
|
| 1549 | - return true; |
|
| 1550 | - } |
|
| 1551 | - } |
|
| 1552 | - |
|
| 1553 | - return false; |
|
| 1554 | - } |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * Determine if the browser is Safari or not (last updated 1.7) |
|
| 1558 | - * |
|
| 1559 | - * @return boolean True if the browser is Safari otherwise false |
|
| 1560 | - */ |
|
| 1561 | - protected function checkBrowserSafari() { |
|
| 1562 | - if ( |
|
| 1563 | - stripos( $this->_agent, 'Safari' ) !== false |
|
| 1564 | - && stripos( $this->_agent, 'iPhone' ) === false |
|
| 1565 | - && stripos( $this->_agent, 'iPod' ) === false |
|
| 1566 | - ) { |
|
| 1567 | - |
|
| 1568 | - $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); |
|
| 1569 | - if ( isset( $aresult[1] ) ) { |
|
| 1570 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1571 | - $this->setVersion( $aversion[0] ); |
|
| 1572 | - } else { |
|
| 1573 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1574 | - } |
|
| 1575 | - $this->setBrowser( self::BROWSER_SAFARI ); |
|
| 1576 | - |
|
| 1577 | - return true; |
|
| 1578 | - } |
|
| 1579 | - |
|
| 1580 | - return false; |
|
| 1581 | - } |
|
| 1582 | - |
|
| 1583 | - protected function checkBrowserSamsung() { |
|
| 1584 | - if ( stripos( $this->_agent, 'SamsungBrowser' ) !== false ) { |
|
| 1585 | - |
|
| 1586 | - $aresult = explode( '/', stristr( $this->_agent, 'SamsungBrowser' ) ); |
|
| 1587 | - if ( isset( $aresult[1] ) ) { |
|
| 1588 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1589 | - $this->setVersion( $aversion[0] ); |
|
| 1590 | - } else { |
|
| 1591 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1592 | - } |
|
| 1593 | - $this->setBrowser( self::BROWSER_SAMSUNG ); |
|
| 1594 | - |
|
| 1595 | - return true; |
|
| 1596 | - } |
|
| 1597 | - |
|
| 1598 | - return false; |
|
| 1599 | - } |
|
| 1600 | - |
|
| 1601 | - protected function checkBrowserSilk() { |
|
| 1602 | - if ( stripos( $this->_agent, 'Silk' ) !== false ) { |
|
| 1603 | - $aresult = explode( '/', stristr( $this->_agent, 'Silk' ) ); |
|
| 1604 | - if ( isset( $aresult[1] ) ) { |
|
| 1605 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1606 | - $this->setVersion( $aversion[0] ); |
|
| 1607 | - } else { |
|
| 1608 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1609 | - } |
|
| 1610 | - $this->setBrowser( self::BROWSER_SILK ); |
|
| 1611 | - |
|
| 1612 | - return true; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - return false; |
|
| 1616 | - } |
|
| 1617 | - |
|
| 1618 | - protected function checkBrowserIframely() { |
|
| 1619 | - if ( stripos( $this->_agent, 'Iframely' ) !== false ) { |
|
| 1620 | - $aresult = explode( '/', stristr( $this->_agent, 'Iframely' ) ); |
|
| 1621 | - if ( isset( $aresult[1] ) ) { |
|
| 1622 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1623 | - $this->setVersion( $aversion[0] ); |
|
| 1624 | - } else { |
|
| 1625 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1626 | - } |
|
| 1627 | - $this->setBrowser( self::BROWSER_I_FRAME ); |
|
| 1628 | - |
|
| 1629 | - return true; |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - return false; |
|
| 1633 | - } |
|
| 1634 | - |
|
| 1635 | - protected function checkBrowserCocoa() { |
|
| 1636 | - if ( stripos( $this->_agent, 'CocoaRestClient' ) !== false ) { |
|
| 1637 | - $aresult = explode( '/', stristr( $this->_agent, 'CocoaRestClient' ) ); |
|
| 1638 | - if ( isset( $aresult[1] ) ) { |
|
| 1639 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1640 | - $this->setVersion( $aversion[0] ); |
|
| 1641 | - } else { |
|
| 1642 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1643 | - } |
|
| 1644 | - $this->setBrowser( self::BROWSER_COCOA ); |
|
| 1645 | - |
|
| 1646 | - return true; |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - return false; |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - /** |
|
| 1653 | - * Detect if URL is loaded from FacebookExternalHit |
|
| 1654 | - * |
|
| 1655 | - * @return boolean True if it detects FacebookExternalHit otherwise false |
|
| 1656 | - */ |
|
| 1657 | - protected function checkFacebookExternalHit() { |
|
| 1658 | - if ( stristr( $this->_agent, 'FacebookExternalHit' ) ) { |
|
| 1659 | - $this->setRobot( true ); |
|
| 1660 | - $this->setFacebook( true ); |
|
| 1661 | - |
|
| 1662 | - return true; |
|
| 1663 | - } |
|
| 1664 | - |
|
| 1665 | - return false; |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - /** |
|
| 1669 | - * Detect if URL is being loaded from internal Facebook browser |
|
| 1670 | - * |
|
| 1671 | - * @return boolean True if it detects internal Facebook browser otherwise false |
|
| 1672 | - */ |
|
| 1673 | - protected function checkForFacebookIos() { |
|
| 1674 | - if ( stristr( $this->_agent, 'FBIOS' ) ) { |
|
| 1675 | - $this->setFacebook( true ); |
|
| 1676 | - |
|
| 1677 | - return true; |
|
| 1678 | - } |
|
| 1679 | - |
|
| 1680 | - return false; |
|
| 1681 | - } |
|
| 1682 | - |
|
| 1683 | - /** |
|
| 1684 | - * Detect Version for the Safari browser on iOS devices |
|
| 1685 | - * |
|
| 1686 | - * @return boolean True if it detects the version correctly otherwise false |
|
| 1687 | - */ |
|
| 1688 | - protected function getSafariVersionOnIos() { |
|
| 1689 | - $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); |
|
| 1690 | - if ( isset( $aresult[1] ) ) { |
|
| 1691 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1692 | - $this->setVersion( $aversion[0] ); |
|
| 1693 | - |
|
| 1694 | - return true; |
|
| 1695 | - } |
|
| 1696 | - |
|
| 1697 | - return false; |
|
| 1698 | - } |
|
| 1699 | - |
|
| 1700 | - /** |
|
| 1701 | - * Detect Version for the Chrome browser on iOS devices |
|
| 1702 | - * |
|
| 1703 | - * @return boolean True if it detects the version correctly otherwise false |
|
| 1704 | - */ |
|
| 1705 | - protected function getChromeVersionOnIos() { |
|
| 1706 | - $aresult = explode( '/', stristr( $this->_agent, 'CriOS' ) ); |
|
| 1707 | - if ( isset( $aresult[1] ) ) { |
|
| 1708 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1709 | - $this->setVersion( $aversion[0] ); |
|
| 1710 | - $this->setBrowser( self::BROWSER_CHROME ); |
|
| 1711 | - |
|
| 1712 | - return true; |
|
| 1713 | - } |
|
| 1714 | - |
|
| 1715 | - return false; |
|
| 1716 | - } |
|
| 1717 | - |
|
| 1718 | - /** |
|
| 1719 | - * Determine if the browser is iPhone or not (last updated 1.7) |
|
| 1720 | - * |
|
| 1721 | - * @return boolean True if the browser is iPhone otherwise false |
|
| 1722 | - */ |
|
| 1723 | - protected function checkBrowseriPhone() { |
|
| 1724 | - if ( stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1725 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1726 | - $this->setBrowser( self::BROWSER_IPHONE ); |
|
| 1727 | - $this->getSafariVersionOnIos(); |
|
| 1728 | - $this->getChromeVersionOnIos(); |
|
| 1729 | - $this->checkForFacebookIos(); |
|
| 1730 | - $this->setMobile( true ); |
|
| 1731 | - |
|
| 1732 | - return true; |
|
| 1733 | - } |
|
| 1734 | - |
|
| 1735 | - return false; |
|
| 1736 | - } |
|
| 1737 | - |
|
| 1738 | - /** |
|
| 1739 | - * Determine if the browser is iPad or not (last updated 1.7) |
|
| 1740 | - * |
|
| 1741 | - * @return boolean True if the browser is iPad otherwise false |
|
| 1742 | - */ |
|
| 1743 | - protected function checkBrowseriPad() { |
|
| 1744 | - if ( stripos( $this->_agent, 'iPad' ) !== false ) { |
|
| 1745 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1746 | - $this->setBrowser( self::BROWSER_IPAD ); |
|
| 1747 | - $this->getSafariVersionOnIos(); |
|
| 1748 | - $this->getChromeVersionOnIos(); |
|
| 1749 | - $this->checkForFacebookIos(); |
|
| 1750 | - $this->setTablet( true ); |
|
| 1751 | - |
|
| 1752 | - return true; |
|
| 1753 | - } |
|
| 1754 | - |
|
| 1755 | - return false; |
|
| 1756 | - } |
|
| 1757 | - |
|
| 1758 | - /** |
|
| 1759 | - * Determine if the browser is iPod or not (last updated 1.7) |
|
| 1760 | - * |
|
| 1761 | - * @return boolean True if the browser is iPod otherwise false |
|
| 1762 | - */ |
|
| 1763 | - protected function checkBrowseriPod() { |
|
| 1764 | - if ( stripos( $this->_agent, 'iPod' ) !== false ) { |
|
| 1765 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1766 | - $this->setBrowser( self::BROWSER_IPOD ); |
|
| 1767 | - $this->getSafariVersionOnIos(); |
|
| 1768 | - $this->getChromeVersionOnIos(); |
|
| 1769 | - $this->checkForFacebookIos(); |
|
| 1770 | - $this->setMobile( true ); |
|
| 1771 | - |
|
| 1772 | - return true; |
|
| 1773 | - } |
|
| 1774 | - |
|
| 1775 | - return false; |
|
| 1776 | - } |
|
| 1777 | - |
|
| 1778 | - /** |
|
| 1779 | - * Determine if the browser is Android or not (last updated 1.7) |
|
| 1780 | - * |
|
| 1781 | - * @return boolean True if the browser is Android otherwise false |
|
| 1782 | - */ |
|
| 1783 | - protected function checkBrowserAndroid() { |
|
| 1784 | - if ( stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 1785 | - $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) ); |
|
| 1786 | - if ( isset( $aresult[1] ) ) { |
|
| 1787 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1788 | - $this->setVersion( $aversion[0] ); |
|
| 1789 | - } else { |
|
| 1790 | - $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1791 | - } |
|
| 1792 | - if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1793 | - $this->setMobile( true ); |
|
| 1794 | - } else { |
|
| 1795 | - $this->setTablet( true ); |
|
| 1796 | - } |
|
| 1797 | - $this->setBrowser( self::BROWSER_ANDROID ); |
|
| 1798 | - |
|
| 1799 | - return true; |
|
| 1800 | - } |
|
| 1801 | - |
|
| 1802 | - return false; |
|
| 1803 | - } |
|
| 1804 | - |
|
| 1805 | - /** |
|
| 1806 | - * Determine if the browser is Vivaldi |
|
| 1807 | - * |
|
| 1808 | - * @return boolean True if the browser is Vivaldi otherwise false |
|
| 1809 | - */ |
|
| 1810 | - protected function checkBrowserVivaldi() { |
|
| 1811 | - if ( stripos( $this->_agent, 'Vivaldi' ) !== false ) { |
|
| 1812 | - $aresult = explode( '/', stristr( $this->_agent, 'Vivaldi' ) ); |
|
| 1813 | - if ( isset( $aresult[1] ) ) { |
|
| 1814 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1815 | - $this->setVersion( $aversion[0] ); |
|
| 1816 | - $this->setBrowser( self::BROWSER_VIVALDI ); |
|
| 1817 | - |
|
| 1818 | - return true; |
|
| 1819 | - } |
|
| 1820 | - } |
|
| 1821 | - |
|
| 1822 | - return false; |
|
| 1823 | - } |
|
| 1824 | - |
|
| 1825 | - /** |
|
| 1826 | - * Determine if the browser is Yandex |
|
| 1827 | - * |
|
| 1828 | - * @return boolean True if the browser is Yandex otherwise false |
|
| 1829 | - */ |
|
| 1830 | - protected function checkBrowserYandex() { |
|
| 1831 | - if ( stripos( $this->_agent, 'YaBrowser' ) !== false ) { |
|
| 1832 | - $aresult = explode( '/', stristr( $this->_agent, 'YaBrowser' ) ); |
|
| 1833 | - if ( isset( $aresult[1] ) ) { |
|
| 1834 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1835 | - $this->setVersion( $aversion[0] ); |
|
| 1836 | - $this->setBrowser( self::BROWSER_YANDEX ); |
|
| 1837 | - |
|
| 1838 | - if ( stripos( $this->_agent, 'iPad' ) !== false ) { |
|
| 1839 | - $this->setTablet( true ); |
|
| 1840 | - } elseif ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1841 | - $this->setMobile( true ); |
|
| 1842 | - } elseif ( stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 1843 | - $this->setTablet( true ); |
|
| 1844 | - } |
|
| 1845 | - |
|
| 1846 | - return true; |
|
| 1847 | - } |
|
| 1848 | - } |
|
| 1849 | - |
|
| 1850 | - return false; |
|
| 1851 | - } |
|
| 1852 | - |
|
| 1853 | - /** |
|
| 1854 | - * Determine if the browser is a PlayStation |
|
| 1855 | - * |
|
| 1856 | - * @return boolean True if the browser is PlayStation otherwise false |
|
| 1857 | - */ |
|
| 1858 | - protected function checkBrowserPlayStation() { |
|
| 1859 | - if ( stripos( $this->_agent, 'PlayStation ' ) !== false ) { |
|
| 1860 | - $aresult = explode( ' ', stristr( $this->_agent, 'PlayStation ' ) ); |
|
| 1861 | - $this->setBrowser( self::BROWSER_PLAYSTATION ); |
|
| 1862 | - if ( isset( $aresult[0] ) ) { |
|
| 1863 | - $aversion = explode( ')', $aresult[2] ); |
|
| 1864 | - $this->setVersion( $aversion[0] ); |
|
| 1865 | - if ( stripos( $this->_agent, 'Portable)' ) !== false || stripos( $this->_agent, 'Vita' ) !== false ) { |
|
| 1866 | - $this->setMobile( true ); |
|
| 1867 | - } |
|
| 1868 | - |
|
| 1869 | - return true; |
|
| 1870 | - } |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - return false; |
|
| 1874 | - } |
|
| 1875 | - |
|
| 1876 | - /** |
|
| 1877 | - * Determine if the browser is Wget or not (last updated 1.7) |
|
| 1878 | - * |
|
| 1879 | - * @return boolean True if the browser is Wget otherwise false |
|
| 1880 | - */ |
|
| 1881 | - protected function checkBrowserWget() { |
|
| 1882 | - if ( preg_match( "!^Wget/([^ ]+)!i", $this->_agent, $aresult ) ) { |
|
| 1883 | - $this->setVersion( $aresult[1] ); |
|
| 1884 | - $this->setBrowser( self::BROWSER_WGET ); |
|
| 1885 | - |
|
| 1886 | - return true; |
|
| 1887 | - } |
|
| 1888 | - |
|
| 1889 | - return false; |
|
| 1890 | - } |
|
| 1891 | - |
|
| 1892 | - /** |
|
| 1893 | - * Determine if the browser is cURL or not (last updated 1.7) |
|
| 1894 | - * |
|
| 1895 | - * @return boolean True if the browser is cURL otherwise false |
|
| 1896 | - */ |
|
| 1897 | - protected function checkBrowserCurl() { |
|
| 1898 | - if ( strpos( $this->_agent, 'curl' ) === 0 ) { |
|
| 1899 | - $aresult = explode( '/', stristr( $this->_agent, 'curl' ) ); |
|
| 1900 | - if ( isset( $aresult[1] ) ) { |
|
| 1901 | - $aversion = explode( ' ', $aresult[1] ); |
|
| 1902 | - $this->setVersion( $aversion[0] ); |
|
| 1903 | - $this->setBrowser( self::BROWSER_CURL ); |
|
| 1904 | - |
|
| 1905 | - return true; |
|
| 1906 | - } |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - return false; |
|
| 1910 | - } |
|
| 1911 | - |
|
| 1912 | - /** |
|
| 1913 | - * Determine the user's platform (last updated 2.0) |
|
| 1914 | - */ |
|
| 1915 | - protected function checkPlatform() { |
|
| 1916 | - if ( stripos( $this->_agent, 'windows' ) !== false ) { |
|
| 1917 | - $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1918 | - } elseif ( stripos( $this->_agent, 'iPad' ) !== false ) { |
|
| 1919 | - $this->_platform = self::PLATFORM_IPAD; |
|
| 1920 | - } elseif ( stripos( $this->_agent, 'iPod' ) !== false ) { |
|
| 1921 | - $this->_platform = self::PLATFORM_IPOD; |
|
| 1922 | - } elseif ( stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1923 | - $this->_platform = self::PLATFORM_IPHONE; |
|
| 1924 | - } elseif ( stripos( $this->_agent, 'mac' ) !== false ) { |
|
| 1925 | - $this->_platform = self::PLATFORM_APPLE; |
|
| 1926 | - } elseif ( stripos( $this->_agent, 'android' ) !== false ) { |
|
| 1927 | - $this->_platform = self::PLATFORM_ANDROID; |
|
| 1928 | - } elseif ( stripos( $this->_agent, 'Silk' ) !== false ) { |
|
| 1929 | - $this->_platform = self::PLATFORM_FIRE_OS; |
|
| 1930 | - } elseif ( stripos( $this->_agent, 'linux' ) !== false && stripos( $this->_agent, 'SMART-TV' ) !== false ) { |
|
| 1931 | - $this->_platform = self::PLATFORM_LINUX . '/' . self::PLATFORM_SMART_TV; |
|
| 1932 | - } elseif ( stripos( $this->_agent, 'linux' ) !== false ) { |
|
| 1933 | - $this->_platform = self::PLATFORM_LINUX; |
|
| 1934 | - } elseif ( stripos( $this->_agent, 'Nokia' ) !== false ) { |
|
| 1935 | - $this->_platform = self::PLATFORM_NOKIA; |
|
| 1936 | - } elseif ( stripos( $this->_agent, 'BlackBerry' ) !== false ) { |
|
| 1937 | - $this->_platform = self::PLATFORM_BLACKBERRY; |
|
| 1938 | - } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) { |
|
| 1939 | - $this->_platform = self::PLATFORM_FREEBSD; |
|
| 1940 | - } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) { |
|
| 1941 | - $this->_platform = self::PLATFORM_OPENBSD; |
|
| 1942 | - } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) { |
|
| 1943 | - $this->_platform = self::PLATFORM_NETBSD; |
|
| 1944 | - } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) { |
|
| 1945 | - $this->_platform = self::PLATFORM_OPENSOLARIS; |
|
| 1946 | - } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) { |
|
| 1947 | - $this->_platform = self::PLATFORM_SUNOS; |
|
| 1948 | - } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) { |
|
| 1949 | - $this->_platform = self::PLATFORM_OS2; |
|
| 1950 | - } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) { |
|
| 1951 | - $this->_platform = self::PLATFORM_BEOS; |
|
| 1952 | - } elseif ( stripos( $this->_agent, 'win' ) !== false ) { |
|
| 1953 | - $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1954 | - } elseif ( stripos( $this->_agent, 'Playstation' ) !== false ) { |
|
| 1955 | - $this->_platform = self::PLATFORM_PLAYSTATION; |
|
| 1956 | - } elseif ( stripos( $this->_agent, 'Roku' ) !== false ) { |
|
| 1957 | - $this->_platform = self::PLATFORM_ROKU; |
|
| 1958 | - } elseif ( stripos( $this->_agent, 'iOS' ) !== false ) { |
|
| 1959 | - $this->_platform = self::PLATFORM_IPHONE . '/' . self::PLATFORM_IPAD; |
|
| 1960 | - } elseif ( stripos( $this->_agent, 'tvOS' ) !== false ) { |
|
| 1961 | - $this->_platform = self::PLATFORM_APPLE_TV; |
|
| 1962 | - } elseif ( stripos( $this->_agent, 'curl' ) !== false ) { |
|
| 1963 | - $this->_platform = self::PLATFORM_TERMINAL; |
|
| 1964 | - } elseif ( stripos( $this->_agent, 'CrOS' ) !== false ) { |
|
| 1965 | - $this->_platform = self::PLATFORM_CHROME_OS; |
|
| 1966 | - } elseif ( stripos( $this->_agent, 'okhttp' ) !== false ) { |
|
| 1967 | - $this->_platform = self::PLATFORM_JAVA_ANDROID; |
|
| 1968 | - } elseif ( stripos( $this->_agent, 'PostmanRuntime' ) !== false ) { |
|
| 1969 | - $this->_platform = self::PLATFORM_POSTMAN; |
|
| 1970 | - } elseif ( stripos( $this->_agent, 'Iframely' ) !== false ) { |
|
| 1971 | - $this->_platform = self::PLATFORM_I_FRAME; |
|
| 1972 | - } |
|
| 1973 | - } |
|
| 45 | + private $_agent = ''; |
|
| 46 | + private $_browser_name = ''; |
|
| 47 | + private $_version = ''; |
|
| 48 | + private $_platform = ''; |
|
| 49 | + private $_os = ''; |
|
| 50 | + private $_is_aol = false; |
|
| 51 | + private $_is_mobile = false; |
|
| 52 | + private $_is_tablet = false; |
|
| 53 | + private $_is_robot = false; |
|
| 54 | + private $_is_facebook = false; |
|
| 55 | + private $_aol_version = ''; |
|
| 56 | + |
|
| 57 | + const BROWSER_UNKNOWN = 'unknown'; |
|
| 58 | + const VERSION_UNKNOWN = 'unknown'; |
|
| 59 | + |
|
| 60 | + const BROWSER_OPERA = 'Opera'; // http://www.opera.com/ |
|
| 61 | + const BROWSER_OPERA_MINI = 'Opera Mini'; // http://www.opera.com/mini/ |
|
| 62 | + const BROWSER_WEBTV = 'WebTV'; // http://www.webtv.net/pc/ |
|
| 63 | + const BROWSER_EDGE = 'Edge'; // https://www.microsoft.com/edge |
|
| 64 | + const BROWSER_IE = 'Internet Explorer'; // http://www.microsoft.com/ie/ |
|
| 65 | + const BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // http://en.wikipedia.org/wiki/Internet_Explorer_Mobile |
|
| 66 | + const BROWSER_KONQUEROR = 'Konqueror'; // http://www.konqueror.org/ |
|
| 67 | + const BROWSER_ICAB = 'iCab'; // http://www.icab.de/ |
|
| 68 | + const BROWSER_OMNIWEB = 'OmniWeb'; // http://www.omnigroup.com/applications/omniweb/ |
|
| 69 | + const BROWSER_FIREBIRD = 'Firebird'; // http://www.ibphoenix.com/ |
|
| 70 | + const BROWSER_FIREFOX = 'Firefox'; // https://www.mozilla.org/en-US/firefox/ |
|
| 71 | + const BROWSER_BRAVE = 'Brave'; // https://brave.com/ |
|
| 72 | + const BROWSER_PALEMOON = 'Palemoon'; // https://www.palemoon.org/ |
|
| 73 | + const BROWSER_ICEWEASEL = 'Iceweasel'; // http://www.geticeweasel.org/ |
|
| 74 | + const BROWSER_SHIRETOKO = 'Shiretoko'; // http://wiki.mozilla.org/Projects/shiretoko |
|
| 75 | + const BROWSER_MOZILLA = 'Mozilla'; // http://www.mozilla.com/en-US/ |
|
| 76 | + const BROWSER_AMAYA = 'Amaya'; // http://www.w3.org/Amaya/ |
|
| 77 | + const BROWSER_LYNX = 'Lynx'; // http://en.wikipedia.org/wiki/Lynx |
|
| 78 | + const BROWSER_SAFARI = 'Safari'; // http://apple.com |
|
| 79 | + const BROWSER_IPHONE = 'iPhone'; // http://apple.com |
|
| 80 | + const BROWSER_IPOD = 'iPod'; // http://apple.com |
|
| 81 | + const BROWSER_IPAD = 'iPad'; // http://apple.com |
|
| 82 | + const BROWSER_CHROME = 'Chrome'; // http://www.google.com/chrome |
|
| 83 | + const BROWSER_ANDROID = 'Android'; // http://www.android.com/ |
|
| 84 | + const BROWSER_GOOGLEBOT = 'GoogleBot'; // http://en.wikipedia.org/wiki/Googlebot |
|
| 85 | + const BROWSER_CURL = 'cURL'; // https://en.wikipedia.org/wiki/CURL |
|
| 86 | + const BROWSER_WGET = 'Wget'; // https://en.wikipedia.org/wiki/Wget |
|
| 87 | + const BROWSER_UCBROWSER = 'UCBrowser'; // https://www.ucweb.com/ |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + const BROWSER_YANDEXBOT = 'YandexBot'; // http://yandex.com/bots |
|
| 91 | + const BROWSER_YANDEXIMAGERESIZER_BOT = 'YandexImageResizer'; // http://yandex.com/bots |
|
| 92 | + const BROWSER_YANDEXIMAGES_BOT = 'YandexImages'; // http://yandex.com/bots |
|
| 93 | + const BROWSER_YANDEXVIDEO_BOT = 'YandexVideo'; // http://yandex.com/bots |
|
| 94 | + const BROWSER_YANDEXMEDIA_BOT = 'YandexMedia'; // http://yandex.com/bots |
|
| 95 | + const BROWSER_YANDEXBLOGS_BOT = 'YandexBlogs'; // http://yandex.com/bots |
|
| 96 | + const BROWSER_YANDEXFAVICONS_BOT = 'YandexFavicons'; // http://yandex.com/bots |
|
| 97 | + const BROWSER_YANDEXWEBMASTER_BOT = 'YandexWebmaster'; // http://yandex.com/bots |
|
| 98 | + const BROWSER_YANDEXDIRECT_BOT = 'YandexDirect'; // http://yandex.com/bots |
|
| 99 | + const BROWSER_YANDEXMETRIKA_BOT = 'YandexMetrika'; // http://yandex.com/bots |
|
| 100 | + const BROWSER_YANDEXNEWS_BOT = 'YandexNews'; // http://yandex.com/bots |
|
| 101 | + const BROWSER_YANDEXCATALOG_BOT = 'YandexCatalog'; // http://yandex.com/bots |
|
| 102 | + |
|
| 103 | + const BROWSER_SLURP = 'Yahoo! Slurp'; // http://en.wikipedia.org/wiki/Yahoo!_Slurp |
|
| 104 | + const BROWSER_W3CVALIDATOR = 'W3C Validator'; // http://validator.w3.org/ |
|
| 105 | + const BROWSER_BLACKBERRY = 'BlackBerry'; // http://www.blackberry.com/ |
|
| 106 | + const BROWSER_ICECAT = 'IceCat'; // http://en.wikipedia.org/wiki/GNU_IceCat |
|
| 107 | + const BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // http://en.wikipedia.org/wiki/Web_Browser_for_S60 |
|
| 108 | + const BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform |
|
| 109 | + const BROWSER_MSN = 'MSN Browser'; // http://explorer.msn.com/ |
|
| 110 | + const BROWSER_MSNBOT = 'MSN Bot'; // http://search.msn.com/msnbot.htm |
|
| 111 | + const BROWSER_BINGBOT = 'Bing Bot'; // http://en.wikipedia.org/wiki/Bingbot |
|
| 112 | + const BROWSER_VIVALDI = 'Vivaldi'; // https://vivaldi.com/ |
|
| 113 | + const BROWSER_YANDEX = 'Yandex'; // https://browser.yandex.ua/ |
|
| 114 | + |
|
| 115 | + const BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // http://browser.netscape.com/ (DEPRECATED) |
|
| 116 | + const BROWSER_GALEON = 'Galeon'; // http://galeon.sourceforge.net/ (DEPRECATED) |
|
| 117 | + const BROWSER_NETPOSITIVE = 'NetPositive'; // http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) |
|
| 118 | + const BROWSER_PHOENIX = 'Phoenix'; // http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) |
|
| 119 | + const BROWSER_PLAYSTATION = "PlayStation"; |
|
| 120 | + const BROWSER_SAMSUNG = "SamsungBrowser"; |
|
| 121 | + const BROWSER_SILK = "Silk"; |
|
| 122 | + const BROWSER_I_FRAME = "Iframely"; |
|
| 123 | + const BROWSER_COCOA = "CocoaRestClient"; |
|
| 124 | + |
|
| 125 | + const PLATFORM_UNKNOWN = 'unknown'; |
|
| 126 | + const PLATFORM_WINDOWS = 'Windows'; |
|
| 127 | + const PLATFORM_WINDOWS_CE = 'Windows CE'; |
|
| 128 | + const PLATFORM_APPLE = 'Apple'; |
|
| 129 | + const PLATFORM_LINUX = 'Linux'; |
|
| 130 | + const PLATFORM_OS2 = 'OS/2'; |
|
| 131 | + const PLATFORM_BEOS = 'BeOS'; |
|
| 132 | + const PLATFORM_IPHONE = 'iPhone'; |
|
| 133 | + const PLATFORM_IPOD = 'iPod'; |
|
| 134 | + const PLATFORM_IPAD = 'iPad'; |
|
| 135 | + const PLATFORM_BLACKBERRY = 'BlackBerry'; |
|
| 136 | + const PLATFORM_NOKIA = 'Nokia'; |
|
| 137 | + const PLATFORM_FREEBSD = 'FreeBSD'; |
|
| 138 | + const PLATFORM_OPENBSD = 'OpenBSD'; |
|
| 139 | + const PLATFORM_NETBSD = 'NetBSD'; |
|
| 140 | + const PLATFORM_SUNOS = 'SunOS'; |
|
| 141 | + const PLATFORM_OPENSOLARIS = 'OpenSolaris'; |
|
| 142 | + const PLATFORM_ANDROID = 'Android'; |
|
| 143 | + const PLATFORM_PLAYSTATION = "Sony PlayStation"; |
|
| 144 | + const PLATFORM_ROKU = "Roku"; |
|
| 145 | + const PLATFORM_APPLE_TV = "Apple TV"; |
|
| 146 | + const PLATFORM_TERMINAL = "Terminal"; |
|
| 147 | + const PLATFORM_FIRE_OS = "Fire OS"; |
|
| 148 | + const PLATFORM_SMART_TV = "SMART-TV"; |
|
| 149 | + const PLATFORM_CHROME_OS = "Chrome OS"; |
|
| 150 | + const PLATFORM_JAVA_ANDROID = "Java/Android"; |
|
| 151 | + const PLATFORM_POSTMAN = "Postman"; |
|
| 152 | + const PLATFORM_I_FRAME = "Iframely"; |
|
| 153 | + |
|
| 154 | + const OPERATING_SYSTEM_UNKNOWN = 'unknown'; |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Class constructor |
|
| 158 | + * |
|
| 159 | + * @param string $userAgent |
|
| 160 | + */ |
|
| 161 | + public function __construct( $userAgent = '' ) { |
|
| 162 | + if ( $userAgent != '' ) { |
|
| 163 | + $this->setUserAgent( $userAgent ); |
|
| 164 | + } else { |
|
| 165 | + $this->reset(); |
|
| 166 | + $this->determine(); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Reset all properties |
|
| 172 | + */ |
|
| 173 | + public function reset() { |
|
| 174 | + $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 175 | + $this->_browser_name = self::BROWSER_UNKNOWN; |
|
| 176 | + $this->_version = self::VERSION_UNKNOWN; |
|
| 177 | + $this->_platform = self::PLATFORM_UNKNOWN; |
|
| 178 | + $this->_os = self::OPERATING_SYSTEM_UNKNOWN; |
|
| 179 | + $this->_is_aol = false; |
|
| 180 | + $this->_is_mobile = false; |
|
| 181 | + $this->_is_tablet = false; |
|
| 182 | + $this->_is_robot = false; |
|
| 183 | + $this->_is_facebook = false; |
|
| 184 | + $this->_aol_version = self::VERSION_UNKNOWN; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Check to see if the specific browser is valid |
|
| 189 | + * |
|
| 190 | + * @param string $browserName |
|
| 191 | + * |
|
| 192 | + * @return bool True if the browser is the specified browser |
|
| 193 | + */ |
|
| 194 | + function isBrowser( $browserName ) { |
|
| 195 | + return ( 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ) ); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * The name of the browser. All return types are from the class contants |
|
| 200 | + * |
|
| 201 | + * @return string Name of the browser |
|
| 202 | + */ |
|
| 203 | + public function getBrowser() { |
|
| 204 | + return $this->_browser_name; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Set the name of the browser |
|
| 209 | + * |
|
| 210 | + * @param $browser string The name of the Browser |
|
| 211 | + */ |
|
| 212 | + public function setBrowser( $browser ) { |
|
| 213 | + $this->_browser_name = $browser; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * The name of the platform. All return types are from the class contants |
|
| 218 | + * |
|
| 219 | + * @return string Name of the browser |
|
| 220 | + */ |
|
| 221 | + public function getPlatform() { |
|
| 222 | + return $this->_platform; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Set the name of the platform |
|
| 227 | + * |
|
| 228 | + * @param string $platform The name of the Platform |
|
| 229 | + */ |
|
| 230 | + public function setPlatform( $platform ) { |
|
| 231 | + $this->_platform = $platform; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * The version of the browser. |
|
| 236 | + * |
|
| 237 | + * @return string Version of the browser (will only contain alpha-numeric characters and a period) |
|
| 238 | + */ |
|
| 239 | + public function getVersion() { |
|
| 240 | + return $this->_version; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Set the version of the browser |
|
| 245 | + * |
|
| 246 | + * @param string $version The version of the Browser |
|
| 247 | + */ |
|
| 248 | + public function setVersion( $version ) { |
|
| 249 | + $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * The version of AOL. |
|
| 254 | + * |
|
| 255 | + * @return string Version of AOL (will only contain alpha-numeric characters and a period) |
|
| 256 | + */ |
|
| 257 | + public function getAolVersion() { |
|
| 258 | + return $this->_aol_version; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Set the version of AOL |
|
| 263 | + * |
|
| 264 | + * @param string $version The version of AOL |
|
| 265 | + */ |
|
| 266 | + public function setAolVersion( $version ) { |
|
| 267 | + $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * Is the browser from AOL? |
|
| 272 | + * |
|
| 273 | + * @return boolean True if the browser is from AOL otherwise false |
|
| 274 | + */ |
|
| 275 | + public function isAol() { |
|
| 276 | + return $this->_is_aol; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Is the browser from a mobile device? |
|
| 281 | + * |
|
| 282 | + * @return boolean True if the browser is from a mobile device otherwise false |
|
| 283 | + */ |
|
| 284 | + public function isMobile() { |
|
| 285 | + return $this->_is_mobile; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Is the browser from a tablet device? |
|
| 290 | + * |
|
| 291 | + * @return boolean True if the browser is from a tablet device otherwise false |
|
| 292 | + */ |
|
| 293 | + public function isTablet() { |
|
| 294 | + return $this->_is_tablet; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Is the browser from a robot (ex Slurp,GoogleBot)? |
|
| 299 | + * |
|
| 300 | + * @return boolean True if the browser is from a robot otherwise false |
|
| 301 | + */ |
|
| 302 | + public function isRobot() { |
|
| 303 | + return $this->_is_robot; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Is the browser from facebook? |
|
| 308 | + * |
|
| 309 | + * @return boolean True if the browser is from facebook otherwise false |
|
| 310 | + */ |
|
| 311 | + public function isFacebook() { |
|
| 312 | + return $this->_is_facebook; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Set the browser to be from AOL |
|
| 317 | + * |
|
| 318 | + * @param $isAol |
|
| 319 | + */ |
|
| 320 | + public function setAol( $isAol ) { |
|
| 321 | + $this->_is_aol = $isAol; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Set the Browser to be mobile |
|
| 326 | + * |
|
| 327 | + * @param boolean $value is the browser a mobile browser or not |
|
| 328 | + */ |
|
| 329 | + protected function setMobile( $value = true ) { |
|
| 330 | + $this->_is_mobile = $value; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * Set the Browser to be tablet |
|
| 335 | + * |
|
| 336 | + * @param boolean $value is the browser a tablet browser or not |
|
| 337 | + */ |
|
| 338 | + protected function setTablet( $value = true ) { |
|
| 339 | + $this->_is_tablet = $value; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * Set the Browser to be a robot |
|
| 344 | + * |
|
| 345 | + * @param boolean $value is the browser a robot or not |
|
| 346 | + */ |
|
| 347 | + protected function setRobot( $value = true ) { |
|
| 348 | + $this->_is_robot = $value; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * Set the Browser to be a Facebook request |
|
| 353 | + * |
|
| 354 | + * @param boolean $value is the browser a robot or not |
|
| 355 | + */ |
|
| 356 | + protected function setFacebook( $value = true ) { |
|
| 357 | + $this->_is_facebook = $value; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Get the user agent value in use to determine the browser |
|
| 362 | + * |
|
| 363 | + * @return string The user agent from the HTTP header |
|
| 364 | + */ |
|
| 365 | + public function getUserAgent() { |
|
| 366 | + return $this->_agent; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) |
|
| 371 | + * |
|
| 372 | + * @param string $agent_string The value for the User Agent |
|
| 373 | + */ |
|
| 374 | + public function setUserAgent( $agent_string ) { |
|
| 375 | + $this->reset(); |
|
| 376 | + $this->_agent = $agent_string; |
|
| 377 | + $this->determine(); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Used to determine if the browser is actually "chromeframe" |
|
| 382 | + * |
|
| 383 | + * @return boolean True if the browser is using chromeframe |
|
| 384 | + * @since 1.7 |
|
| 385 | + */ |
|
| 386 | + public function isChromeFrame() { |
|
| 387 | + return ( strpos( $this->_agent, "chromeframe" ) !== false ); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Returns a formatted string with a summary of the details of the browser. |
|
| 392 | + * |
|
| 393 | + * @return string formatted string with a summary of the browser |
|
| 394 | + */ |
|
| 395 | + public function __toString() { |
|
| 396 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
| 397 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
| 398 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
| 399 | + "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * Protected routine to calculate and determine what the browser is in use (including platform) |
|
| 404 | + */ |
|
| 405 | + protected function determine() { |
|
| 406 | + $this->checkPlatform(); |
|
| 407 | + $this->checkBrowsers(); |
|
| 408 | + $this->checkForAol(); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Protected routine to determine the browser type |
|
| 413 | + * |
|
| 414 | + * @return boolean True if the browser was detected otherwise false |
|
| 415 | + */ |
|
| 416 | + protected function checkBrowsers() { |
|
| 417 | + return ( |
|
| 418 | + // well-known, well-used |
|
| 419 | + // Special Notes: |
|
| 420 | + // (1) Opera must be checked before FireFox due to the odd |
|
| 421 | + // user agents used in some older versions of Opera |
|
| 422 | + // (2) WebTV is strapped onto Internet Explorer so we must |
|
| 423 | + // check for WebTV before IE |
|
| 424 | + // (3) (deprecated) Galeon is based on Firefox and needs to be |
|
| 425 | + // tested before Firefox is tested |
|
| 426 | + // (4) OmniWeb is based on Safari so OmniWeb check must occur |
|
| 427 | + // before Safari |
|
| 428 | + // (5) Netscape 9+ is based on Firefox so Netscape checks |
|
| 429 | + // before FireFox are necessary |
|
| 430 | + // (6) Vivaldi is UA contains both Firefox and Chrome so Vivaldi checks |
|
| 431 | + // before Firefox and Chrome |
|
| 432 | + $this->checkBrowserWebTv() || |
|
| 433 | + $this->checkBrowserBrave() || |
|
| 434 | + $this->checkBrowserUCBrowser() || |
|
| 435 | + $this->checkBrowserEdge() || |
|
| 436 | + $this->checkBrowserInternetExplorer() || |
|
| 437 | + $this->checkBrowserOpera() || |
|
| 438 | + $this->checkBrowserGaleon() || |
|
| 439 | + $this->checkBrowserNetscapeNavigator9Plus() || |
|
| 440 | + $this->checkBrowserVivaldi() || |
|
| 441 | + $this->checkBrowserYandex() || |
|
| 442 | + $this->checkBrowserPalemoon() || |
|
| 443 | + $this->checkBrowserFirefox() || |
|
| 444 | + $this->checkBrowserChrome() || |
|
| 445 | + $this->checkBrowserOmniWeb() || |
|
| 446 | + |
|
| 447 | + // common mobile |
|
| 448 | + $this->checkBrowserAndroid() || |
|
| 449 | + $this->checkBrowseriPad() || |
|
| 450 | + $this->checkBrowseriPod() || |
|
| 451 | + $this->checkBrowseriPhone() || |
|
| 452 | + $this->checkBrowserBlackBerry() || |
|
| 453 | + $this->checkBrowserNokia() || |
|
| 454 | + |
|
| 455 | + // common bots |
|
| 456 | + $this->checkBrowserGoogleBot() || |
|
| 457 | + $this->checkBrowserMSNBot() || |
|
| 458 | + $this->checkBrowserBingBot() || |
|
| 459 | + $this->checkBrowserSlurp() || |
|
| 460 | + |
|
| 461 | + // Yandex bots |
|
| 462 | + $this->checkBrowserYandexBot() || |
|
| 463 | + $this->checkBrowserYandexImageResizerBot() || |
|
| 464 | + $this->checkBrowserYandexBlogsBot() || |
|
| 465 | + $this->checkBrowserYandexCatalogBot() || |
|
| 466 | + $this->checkBrowserYandexDirectBot() || |
|
| 467 | + $this->checkBrowserYandexFaviconsBot() || |
|
| 468 | + $this->checkBrowserYandexImagesBot() || |
|
| 469 | + $this->checkBrowserYandexMediaBot() || |
|
| 470 | + $this->checkBrowserYandexMetrikaBot() || |
|
| 471 | + $this->checkBrowserYandexNewsBot() || |
|
| 472 | + $this->checkBrowserYandexVideoBot() || |
|
| 473 | + $this->checkBrowserYandexWebmasterBot() || |
|
| 474 | + |
|
| 475 | + // check for facebook external hit when loading URL |
|
| 476 | + $this->checkFacebookExternalHit() || |
|
| 477 | + |
|
| 478 | + // WebKit base check (post mobile and others) |
|
| 479 | + $this->checkBrowserSamsung() || |
|
| 480 | + $this->checkBrowserSilk() || |
|
| 481 | + $this->checkBrowserSafari() || |
|
| 482 | + |
|
| 483 | + // everyone else |
|
| 484 | + $this->checkBrowserNetPositive() || |
|
| 485 | + $this->checkBrowserFirebird() || |
|
| 486 | + $this->checkBrowserKonqueror() || |
|
| 487 | + $this->checkBrowserIcab() || |
|
| 488 | + $this->checkBrowserPhoenix() || |
|
| 489 | + $this->checkBrowserAmaya() || |
|
| 490 | + $this->checkBrowserLynx() || |
|
| 491 | + $this->checkBrowserShiretoko() || |
|
| 492 | + $this->checkBrowserIceCat() || |
|
| 493 | + $this->checkBrowserIceweasel() || |
|
| 494 | + $this->checkBrowserW3CValidator() || |
|
| 495 | + $this->checkBrowserCurl() || |
|
| 496 | + $this->checkBrowserWget() || |
|
| 497 | + $this->checkBrowserPlayStation() || |
|
| 498 | + $this->checkBrowserIframely() || |
|
| 499 | + $this->checkBrowserCocoa() || |
|
| 500 | + $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */ ); |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Determine if the user is using a BlackBerry (last updated 1.7) |
|
| 505 | + * |
|
| 506 | + * @return boolean True if the browser is the BlackBerry browser otherwise false |
|
| 507 | + */ |
|
| 508 | + protected function checkBrowserBlackBerry() { |
|
| 509 | + if ( stripos( $this->_agent, 'blackberry' ) !== false ) { |
|
| 510 | + $aresult = explode( '/', stristr( $this->_agent, "BlackBerry" ) ); |
|
| 511 | + if ( isset( $aresult[1] ) ) { |
|
| 512 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 513 | + $this->setVersion( $aversion[0] ); |
|
| 514 | + $this->_browser_name = self::BROWSER_BLACKBERRY; |
|
| 515 | + $this->setMobile( true ); |
|
| 516 | + |
|
| 517 | + return true; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + return false; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + /** |
|
| 525 | + * Determine if the user is using an AOL User Agent (last updated 1.7) |
|
| 526 | + * |
|
| 527 | + * @return boolean True if the browser is from AOL otherwise false |
|
| 528 | + */ |
|
| 529 | + protected function checkForAol() { |
|
| 530 | + $this->setAol( false ); |
|
| 531 | + $this->setAolVersion( self::VERSION_UNKNOWN ); |
|
| 532 | + |
|
| 533 | + if ( stripos( $this->_agent, 'aol' ) !== false ) { |
|
| 534 | + $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) ); |
|
| 535 | + if ( isset( $aversion[1] ) ) { |
|
| 536 | + $this->setAol( true ); |
|
| 537 | + $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) ); |
|
| 538 | + |
|
| 539 | + return true; |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + return false; |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * Determine if the browser is the GoogleBot or not (last updated 1.7) |
|
| 548 | + * |
|
| 549 | + * @return boolean True if the browser is the GoogletBot otherwise false |
|
| 550 | + */ |
|
| 551 | + protected function checkBrowserGoogleBot() { |
|
| 552 | + if ( stripos( $this->_agent, 'googlebot' ) !== false ) { |
|
| 553 | + $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) ); |
|
| 554 | + if ( isset( $aresult[1] ) ) { |
|
| 555 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 556 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 557 | + $this->_browser_name = self::BROWSER_GOOGLEBOT; |
|
| 558 | + $this->setRobot( true ); |
|
| 559 | + |
|
| 560 | + return true; |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + return false; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Determine if the browser is the YandexBot or not |
|
| 569 | + * |
|
| 570 | + * @return boolean True if the browser is the YandexBot otherwise false |
|
| 571 | + */ |
|
| 572 | + protected function checkBrowserYandexBot() { |
|
| 573 | + if ( stripos( $this->_agent, 'YandexBot' ) !== false ) { |
|
| 574 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexBot' ) ); |
|
| 575 | + if ( isset( $aresult[1] ) ) { |
|
| 576 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 577 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 578 | + $this->_browser_name = self::BROWSER_YANDEXBOT; |
|
| 579 | + $this->setRobot( true ); |
|
| 580 | + |
|
| 581 | + return true; |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + return false; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Determine if the browser is the YandexImageResizer or not |
|
| 590 | + * |
|
| 591 | + * @return boolean True if the browser is the YandexImageResizer otherwise false |
|
| 592 | + */ |
|
| 593 | + protected function checkBrowserYandexImageResizerBot() { |
|
| 594 | + if ( stripos( $this->_agent, 'YandexImageResizer' ) !== false ) { |
|
| 595 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexImageResizer' ) ); |
|
| 596 | + if ( isset( $aresult[1] ) ) { |
|
| 597 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 598 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 599 | + $this->_browser_name = self::BROWSER_YANDEXIMAGERESIZER_BOT; |
|
| 600 | + $this->setRobot( true ); |
|
| 601 | + |
|
| 602 | + return true; |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + return false; |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * Determine if the browser is the YandexCatalog or not |
|
| 611 | + * |
|
| 612 | + * @return boolean True if the browser is the YandexCatalog otherwise false |
|
| 613 | + */ |
|
| 614 | + protected function checkBrowserYandexCatalogBot() { |
|
| 615 | + if ( stripos( $this->_agent, 'YandexCatalog' ) !== false ) { |
|
| 616 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexCatalog' ) ); |
|
| 617 | + if ( isset( $aresult[1] ) ) { |
|
| 618 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 619 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 620 | + $this->_browser_name = self::BROWSER_YANDEXCATALOG_BOT; |
|
| 621 | + $this->setRobot( true ); |
|
| 622 | + |
|
| 623 | + return true; |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + return false; |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * Determine if the browser is the YandexNews or not |
|
| 632 | + * |
|
| 633 | + * @return boolean True if the browser is the YandexNews otherwise false |
|
| 634 | + */ |
|
| 635 | + protected function checkBrowserYandexNewsBot() { |
|
| 636 | + if ( stripos( $this->_agent, 'YandexNews' ) !== false ) { |
|
| 637 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexNews' ) ); |
|
| 638 | + if ( isset( $aresult[1] ) ) { |
|
| 639 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 640 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 641 | + $this->_browser_name = self::BROWSER_YANDEXNEWS_BOT; |
|
| 642 | + $this->setRobot( true ); |
|
| 643 | + |
|
| 644 | + return true; |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + /** |
|
| 652 | + * Determine if the browser is the YandexMetrika or not |
|
| 653 | + * |
|
| 654 | + * @return boolean True if the browser is the YandexMetrika otherwise false |
|
| 655 | + */ |
|
| 656 | + protected function checkBrowserYandexMetrikaBot() { |
|
| 657 | + if ( stripos( $this->_agent, 'YandexMetrika' ) !== false ) { |
|
| 658 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexMetrika' ) ); |
|
| 659 | + if ( isset( $aresult[1] ) ) { |
|
| 660 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 661 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 662 | + $this->_browser_name = self::BROWSER_YANDEXMETRIKA_BOT; |
|
| 663 | + $this->setRobot( true ); |
|
| 664 | + |
|
| 665 | + return true; |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + return false; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * Determine if the browser is the YandexDirect or not |
|
| 674 | + * |
|
| 675 | + * @return boolean True if the browser is the YandexDirect otherwise false |
|
| 676 | + */ |
|
| 677 | + protected function checkBrowserYandexDirectBot() { |
|
| 678 | + if ( stripos( $this->_agent, 'YandexDirect' ) !== false ) { |
|
| 679 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexDirect' ) ); |
|
| 680 | + if ( isset( $aresult[1] ) ) { |
|
| 681 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 682 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 683 | + $this->_browser_name = self::BROWSER_YANDEXDIRECT_BOT; |
|
| 684 | + $this->setRobot( true ); |
|
| 685 | + |
|
| 686 | + return true; |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * Determine if the browser is the YandexWebmaster or not |
|
| 695 | + * |
|
| 696 | + * @return boolean True if the browser is the YandexWebmaster otherwise false |
|
| 697 | + */ |
|
| 698 | + protected function checkBrowserYandexWebmasterBot() { |
|
| 699 | + if ( stripos( $this->_agent, 'YandexWebmaster' ) !== false ) { |
|
| 700 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexWebmaster' ) ); |
|
| 701 | + if ( isset( $aresult[1] ) ) { |
|
| 702 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 703 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 704 | + $this->_browser_name = self::BROWSER_YANDEXWEBMASTER_BOT; |
|
| 705 | + $this->setRobot( true ); |
|
| 706 | + |
|
| 707 | + return true; |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + /** |
|
| 715 | + * Determine if the browser is the YandexFavicons or not |
|
| 716 | + * |
|
| 717 | + * @return boolean True if the browser is the YandexFavicons otherwise false |
|
| 718 | + */ |
|
| 719 | + protected function checkBrowserYandexFaviconsBot() { |
|
| 720 | + if ( stripos( $this->_agent, 'YandexFavicons' ) !== false ) { |
|
| 721 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexFavicons' ) ); |
|
| 722 | + if ( isset( $aresult[1] ) ) { |
|
| 723 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 724 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 725 | + $this->_browser_name = self::BROWSER_YANDEXFAVICONS_BOT; |
|
| 726 | + $this->setRobot( true ); |
|
| 727 | + |
|
| 728 | + return true; |
|
| 729 | + } |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + return false; |
|
| 733 | + } |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * Determine if the browser is the YandexBlogs or not |
|
| 737 | + * |
|
| 738 | + * @return boolean True if the browser is the YandexBlogs otherwise false |
|
| 739 | + */ |
|
| 740 | + protected function checkBrowserYandexBlogsBot() { |
|
| 741 | + if ( stripos( $this->_agent, 'YandexBlogs' ) !== false ) { |
|
| 742 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexBlogs' ) ); |
|
| 743 | + if ( isset( $aresult[1] ) ) { |
|
| 744 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 745 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 746 | + $this->_browser_name = self::BROWSER_YANDEXBLOGS_BOT; |
|
| 747 | + $this->setRobot( true ); |
|
| 748 | + |
|
| 749 | + return true; |
|
| 750 | + } |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + return false; |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * Determine if the browser is the YandexMedia or not |
|
| 758 | + * |
|
| 759 | + * @return boolean True if the browser is the YandexMedia otherwise false |
|
| 760 | + */ |
|
| 761 | + protected function checkBrowserYandexMediaBot() { |
|
| 762 | + if ( stripos( $this->_agent, 'YandexMedia' ) !== false ) { |
|
| 763 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexMedia' ) ); |
|
| 764 | + if ( isset( $aresult[1] ) ) { |
|
| 765 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 766 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 767 | + $this->_browser_name = self::BROWSER_YANDEXMEDIA_BOT; |
|
| 768 | + $this->setRobot( true ); |
|
| 769 | + |
|
| 770 | + return true; |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + return false; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + /** |
|
| 778 | + * Determine if the browser is the YandexVideo or not |
|
| 779 | + * |
|
| 780 | + * @return boolean True if the browser is the YandexVideo otherwise false |
|
| 781 | + */ |
|
| 782 | + protected function checkBrowserYandexVideoBot() { |
|
| 783 | + if ( stripos( $this->_agent, 'YandexVideo' ) !== false ) { |
|
| 784 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexVideo' ) ); |
|
| 785 | + if ( isset( $aresult[1] ) ) { |
|
| 786 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 787 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 788 | + $this->_browser_name = self::BROWSER_YANDEXVIDEO_BOT; |
|
| 789 | + $this->setRobot( true ); |
|
| 790 | + |
|
| 791 | + return true; |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + |
|
| 795 | + return false; |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + /** |
|
| 799 | + * Determine if the browser is the YandexImages or not |
|
| 800 | + * |
|
| 801 | + * @return boolean True if the browser is the YandexImages otherwise false |
|
| 802 | + */ |
|
| 803 | + protected function checkBrowserYandexImagesBot() { |
|
| 804 | + if ( stripos( $this->_agent, 'YandexImages' ) !== false ) { |
|
| 805 | + $aresult = explode( '/', stristr( $this->_agent, 'YandexImages' ) ); |
|
| 806 | + if ( isset( $aresult[1] ) ) { |
|
| 807 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 808 | + $this->setVersion( str_replace( ';', '', $aversion[0] ) ); |
|
| 809 | + $this->_browser_name = self::BROWSER_YANDEXIMAGES_BOT; |
|
| 810 | + $this->setRobot( true ); |
|
| 811 | + |
|
| 812 | + return true; |
|
| 813 | + } |
|
| 814 | + } |
|
| 815 | + |
|
| 816 | + return false; |
|
| 817 | + } |
|
| 818 | + |
|
| 819 | + /** |
|
| 820 | + * Determine if the browser is the MSNBot or not (last updated 1.9) |
|
| 821 | + * |
|
| 822 | + * @return boolean True if the browser is the MSNBot otherwise false |
|
| 823 | + */ |
|
| 824 | + protected function checkBrowserMSNBot() { |
|
| 825 | + if ( stripos( $this->_agent, "msnbot" ) !== false ) { |
|
| 826 | + $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) ); |
|
| 827 | + if ( isset( $aresult[1] ) ) { |
|
| 828 | + $aversion = explode( " ", $aresult[1] ); |
|
| 829 | + $this->setVersion( str_replace( ";", '', $aversion[0] ) ); |
|
| 830 | + $this->_browser_name = self::BROWSER_MSNBOT; |
|
| 831 | + $this->setRobot( true ); |
|
| 832 | + |
|
| 833 | + return true; |
|
| 834 | + } |
|
| 835 | + } |
|
| 836 | + |
|
| 837 | + return false; |
|
| 838 | + } |
|
| 839 | + |
|
| 840 | + /** |
|
| 841 | + * Determine if the browser is the BingBot or not (last updated 1.9) |
|
| 842 | + * |
|
| 843 | + * @return boolean True if the browser is the BingBot otherwise false |
|
| 844 | + */ |
|
| 845 | + protected function checkBrowserBingBot() { |
|
| 846 | + if ( stripos( $this->_agent, "bingbot" ) !== false ) { |
|
| 847 | + $aresult = explode( "/", stristr( $this->_agent, "bingbot" ) ); |
|
| 848 | + if ( isset( $aresult[1] ) ) { |
|
| 849 | + $aversion = explode( " ", $aresult[1] ); |
|
| 850 | + $this->setVersion( str_replace( ";", '', $aversion[0] ) ); |
|
| 851 | + $this->_browser_name = self::BROWSER_BINGBOT; |
|
| 852 | + $this->setRobot( true ); |
|
| 853 | + |
|
| 854 | + return true; |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | + |
|
| 858 | + return false; |
|
| 859 | + } |
|
| 860 | + |
|
| 861 | + /** |
|
| 862 | + * Determine if the browser is the W3C Validator or not (last updated 1.7) |
|
| 863 | + * |
|
| 864 | + * @return boolean True if the browser is the W3C Validator otherwise false |
|
| 865 | + */ |
|
| 866 | + protected function checkBrowserW3CValidator() { |
|
| 867 | + if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) { |
|
| 868 | + $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) ); |
|
| 869 | + if ( isset( $aresult[1] ) ) { |
|
| 870 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 871 | + $this->setVersion( $aversion[0] ); |
|
| 872 | + $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 873 | + |
|
| 874 | + return true; |
|
| 875 | + } |
|
| 876 | + } elseif ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) { |
|
| 877 | + // Some of the Validator versions do not delineate w/ a slash - add it back in |
|
| 878 | + $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent ); |
|
| 879 | + $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) ); |
|
| 880 | + if ( isset( $aresult[1] ) ) { |
|
| 881 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 882 | + $this->setVersion( $aversion[0] ); |
|
| 883 | + $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 884 | + |
|
| 885 | + return true; |
|
| 886 | + } |
|
| 887 | + } elseif ( stripos( $this->_agent, 'W3C-mobileOK' ) !== false ) { |
|
| 888 | + $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 889 | + $this->setMobile( true ); |
|
| 890 | + |
|
| 891 | + return true; |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + return false; |
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + /** |
|
| 898 | + * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7) |
|
| 899 | + * |
|
| 900 | + * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false |
|
| 901 | + */ |
|
| 902 | + protected function checkBrowserSlurp() { |
|
| 903 | + if ( stripos( $this->_agent, 'slurp' ) !== false ) { |
|
| 904 | + $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) ); |
|
| 905 | + if ( isset( $aresult[1] ) ) { |
|
| 906 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 907 | + $this->setVersion( $aversion[0] ); |
|
| 908 | + $this->_browser_name = self::BROWSER_SLURP; |
|
| 909 | + $this->setRobot( true ); |
|
| 910 | + $this->setMobile( false ); |
|
| 911 | + |
|
| 912 | + return true; |
|
| 913 | + } |
|
| 914 | + } |
|
| 915 | + |
|
| 916 | + return false; |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + /** |
|
| 920 | + * Determine if the browser is Brave or not |
|
| 921 | + * |
|
| 922 | + * @return boolean True if the browser is Brave otherwise false |
|
| 923 | + */ |
|
| 924 | + protected function checkBrowserBrave() { |
|
| 925 | + if ( stripos( $this->_agent, 'Brave/' ) !== false ) { |
|
| 926 | + $aResult = explode( '/', stristr( $this->_agent, 'Brave' ) ); |
|
| 927 | + if ( isset( $aResult[1] ) ) { |
|
| 928 | + $aversion = explode( ' ', $aResult[1] ); |
|
| 929 | + $this->setVersion( $aversion[0] ); |
|
| 930 | + $this->setBrowser( self::BROWSER_BRAVE ); |
|
| 931 | + |
|
| 932 | + return true; |
|
| 933 | + } |
|
| 934 | + } elseif ( stripos( $this->_agent, ' Brave ' ) !== false ) { |
|
| 935 | + $this->setBrowser( self::BROWSER_BRAVE ); |
|
| 936 | + // this version of the UA did not ship with a version marker |
|
| 937 | + // e.g. Mozilla/5.0 (Linux; Android 7.0; SM-G955F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/68.0.3440.91 Mobile Safari/537.36 |
|
| 938 | + $this->setVersion( '' ); |
|
| 939 | + |
|
| 940 | + return true; |
|
| 941 | + } |
|
| 942 | + |
|
| 943 | + return false; |
|
| 944 | + } |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * Determine if the browser is Edge or not |
|
| 948 | + * |
|
| 949 | + * @return boolean True if the browser is Edge otherwise false |
|
| 950 | + */ |
|
| 951 | + protected function checkBrowserEdge() { |
|
| 952 | + if ( $name = ( stripos( $this->_agent, 'Edge/' ) !== false ? 'Edge' : ( ( stripos( $this->_agent, 'Edg/' ) !== false || stripos( $this->_agent, 'EdgA/' ) !== false ) ? 'Edg' : false ) ) ) { |
|
| 953 | + $aresult = explode( '/', stristr( $this->_agent, $name ) ); |
|
| 954 | + if ( isset( $aresult[1] ) ) { |
|
| 955 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 956 | + $this->setVersion( $aversion[0] ); |
|
| 957 | + $this->setBrowser( self::BROWSER_EDGE ); |
|
| 958 | + if ( stripos( $this->_agent, 'Windows Phone' ) !== false || stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 959 | + $this->setMobile( true ); |
|
| 960 | + } |
|
| 961 | + |
|
| 962 | + return true; |
|
| 963 | + } |
|
| 964 | + } |
|
| 965 | + |
|
| 966 | + return false; |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + /** |
|
| 970 | + * Determine if the browser is Internet Explorer or not (last updated 1.7) |
|
| 971 | + * |
|
| 972 | + * @return boolean True if the browser is Internet Explorer otherwise false |
|
| 973 | + */ |
|
| 974 | + protected function checkBrowserInternetExplorer() { |
|
| 975 | + // Test for IE11 |
|
| 976 | + if ( stripos( $this->_agent, 'Trident/7.0; rv:11.0' ) !== false ) { |
|
| 977 | + $this->setBrowser( self::BROWSER_IE ); |
|
| 978 | + $this->setVersion( '11.0' ); |
|
| 979 | + |
|
| 980 | + return true; |
|
| 981 | + } // Test for v1 - v1.5 IE |
|
| 982 | + elseif ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) { |
|
| 983 | + $this->setBrowser( self::BROWSER_IE ); |
|
| 984 | + $this->setVersion( '1.0' ); |
|
| 985 | + $aresult = stristr( $this->_agent, '/' ); |
|
| 986 | + if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) { |
|
| 987 | + $this->setVersion( '1.5' ); |
|
| 988 | + } |
|
| 989 | + |
|
| 990 | + return true; |
|
| 991 | + } // Test for versions > 1.5 |
|
| 992 | + elseif ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) { |
|
| 993 | + // See if the browser is the odd MSN Explorer |
|
| 994 | + if ( stripos( $this->_agent, 'msnb' ) !== false ) { |
|
| 995 | + $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) ); |
|
| 996 | + if ( isset( $aresult[1] ) ) { |
|
| 997 | + $this->setBrowser( self::BROWSER_MSN ); |
|
| 998 | + $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); |
|
| 999 | + |
|
| 1000 | + return true; |
|
| 1001 | + } |
|
| 1002 | + } |
|
| 1003 | + $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) ); |
|
| 1004 | + if ( isset( $aresult[1] ) ) { |
|
| 1005 | + $this->setBrowser( self::BROWSER_IE ); |
|
| 1006 | + $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); |
|
| 1007 | + if ( stripos( $this->_agent, 'IEMobile' ) !== false ) { |
|
| 1008 | + $this->setBrowser( self::BROWSER_POCKET_IE ); |
|
| 1009 | + $this->setMobile( true ); |
|
| 1010 | + } |
|
| 1011 | + |
|
| 1012 | + return true; |
|
| 1013 | + } |
|
| 1014 | + } // Test for versions > IE 10 |
|
| 1015 | + elseif ( stripos( $this->_agent, 'trident' ) !== false ) { |
|
| 1016 | + $this->setBrowser( self::BROWSER_IE ); |
|
| 1017 | + $result = explode( 'rv:', $this->_agent ); |
|
| 1018 | + if ( isset( $result[1] ) ) { |
|
| 1019 | + $this->setVersion( preg_replace( '/[^0-9.]+/', '', $result[1] ) ); |
|
| 1020 | + $this->_agent = str_replace( array( "Mozilla", "Gecko" ), "MSIE", $this->_agent ); |
|
| 1021 | + } |
|
| 1022 | + } // Test for Pocket IE |
|
| 1023 | + elseif ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) { |
|
| 1024 | + $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) ); |
|
| 1025 | + if ( isset( $aresult[1] ) ) { |
|
| 1026 | + $this->setPlatform( self::PLATFORM_WINDOWS_CE ); |
|
| 1027 | + $this->setBrowser( self::BROWSER_POCKET_IE ); |
|
| 1028 | + $this->setMobile( true ); |
|
| 1029 | + |
|
| 1030 | + if ( stripos( $this->_agent, 'mspie' ) !== false ) { |
|
| 1031 | + $this->setVersion( $aresult[1] ); |
|
| 1032 | + } else { |
|
| 1033 | + $aversion = explode( '/', $this->_agent ); |
|
| 1034 | + if ( isset( $aversion[1] ) ) { |
|
| 1035 | + $this->setVersion( $aversion[1] ); |
|
| 1036 | + } |
|
| 1037 | + } |
|
| 1038 | + |
|
| 1039 | + return true; |
|
| 1040 | + } |
|
| 1041 | + } |
|
| 1042 | + |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + /** |
|
| 1047 | + * Determine if the browser is Opera or not (last updated 1.7) |
|
| 1048 | + * |
|
| 1049 | + * @return boolean True if the browser is Opera otherwise false |
|
| 1050 | + */ |
|
| 1051 | + protected function checkBrowserOpera() { |
|
| 1052 | + if ( stripos( $this->_agent, 'opera mini' ) !== false ) { |
|
| 1053 | + $resultant = stristr( $this->_agent, 'opera mini' ); |
|
| 1054 | + if ( preg_match( '/\//', $resultant ) ) { |
|
| 1055 | + $aresult = explode( '/', $resultant ); |
|
| 1056 | + if ( isset( $aresult[1] ) ) { |
|
| 1057 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1058 | + $this->setVersion( $aversion[0] ); |
|
| 1059 | + } |
|
| 1060 | + } else { |
|
| 1061 | + $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) ); |
|
| 1062 | + if ( isset( $aversion[1] ) ) { |
|
| 1063 | + $this->setVersion( $aversion[1] ); |
|
| 1064 | + } |
|
| 1065 | + } |
|
| 1066 | + $this->_browser_name = self::BROWSER_OPERA_MINI; |
|
| 1067 | + $this->setMobile( true ); |
|
| 1068 | + |
|
| 1069 | + return true; |
|
| 1070 | + } elseif ( stripos( $this->_agent, 'opera' ) !== false ) { |
|
| 1071 | + $resultant = stristr( $this->_agent, 'opera' ); |
|
| 1072 | + if ( preg_match( '/Version\/(1*.*)$/', $resultant, $matches ) ) { |
|
| 1073 | + $this->setVersion( $matches[1] ); |
|
| 1074 | + } elseif ( preg_match( '/\//', $resultant ) ) { |
|
| 1075 | + $aresult = explode( '/', str_replace( "(", " ", $resultant ) ); |
|
| 1076 | + if ( isset( $aresult[1] ) ) { |
|
| 1077 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1078 | + $this->setVersion( $aversion[0] ); |
|
| 1079 | + } |
|
| 1080 | + } else { |
|
| 1081 | + $aversion = explode( ' ', stristr( $resultant, 'opera' ) ); |
|
| 1082 | + $this->setVersion( isset( $aversion[1] ) ? $aversion[1] : '' ); |
|
| 1083 | + } |
|
| 1084 | + if ( stripos( $this->_agent, 'Opera Mobi' ) !== false ) { |
|
| 1085 | + $this->setMobile( true ); |
|
| 1086 | + } |
|
| 1087 | + $this->_browser_name = self::BROWSER_OPERA; |
|
| 1088 | + |
|
| 1089 | + return true; |
|
| 1090 | + } elseif ( stripos( $this->_agent, 'OPR' ) !== false ) { |
|
| 1091 | + $resultant = stristr( $this->_agent, 'OPR' ); |
|
| 1092 | + if ( preg_match( '/\//', $resultant ) ) { |
|
| 1093 | + $aresult = explode( '/', str_replace( "(", " ", $resultant ) ); |
|
| 1094 | + if ( isset( $aresult[1] ) ) { |
|
| 1095 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1096 | + $this->setVersion( $aversion[0] ); |
|
| 1097 | + } |
|
| 1098 | + } |
|
| 1099 | + if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1100 | + $this->setMobile( true ); |
|
| 1101 | + } |
|
| 1102 | + $this->_browser_name = self::BROWSER_OPERA; |
|
| 1103 | + |
|
| 1104 | + return true; |
|
| 1105 | + } |
|
| 1106 | + |
|
| 1107 | + return false; |
|
| 1108 | + } |
|
| 1109 | + |
|
| 1110 | + /** |
|
| 1111 | + * Determine if the browser is Chrome or not (last updated 1.7) |
|
| 1112 | + * |
|
| 1113 | + * @return boolean True if the browser is Chrome otherwise false |
|
| 1114 | + */ |
|
| 1115 | + protected function checkBrowserChrome() { |
|
| 1116 | + if ( stripos( $this->_agent, 'Chrome' ) !== false ) { |
|
| 1117 | + $aresult = preg_split( '/[\/;]+/', stristr( $this->_agent, 'Chrome' ) ); |
|
| 1118 | + if ( isset( $aresult[1] ) ) { |
|
| 1119 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1120 | + $this->setVersion( $aversion[0] ); |
|
| 1121 | + $this->setBrowser( self::BROWSER_CHROME ); |
|
| 1122 | + //Chrome on Android |
|
| 1123 | + if ( stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 1124 | + if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1125 | + $this->setMobile( true ); |
|
| 1126 | + } else { |
|
| 1127 | + $this->setTablet( true ); |
|
| 1128 | + } |
|
| 1129 | + } |
|
| 1130 | + |
|
| 1131 | + return true; |
|
| 1132 | + } |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + return false; |
|
| 1136 | + } |
|
| 1137 | + |
|
| 1138 | + |
|
| 1139 | + /** |
|
| 1140 | + * Determine if the browser is WebTv or not (last updated 1.7) |
|
| 1141 | + * |
|
| 1142 | + * @return boolean True if the browser is WebTv otherwise false |
|
| 1143 | + */ |
|
| 1144 | + protected function checkBrowserWebTv() { |
|
| 1145 | + if ( stripos( $this->_agent, 'webtv' ) !== false ) { |
|
| 1146 | + $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) ); |
|
| 1147 | + if ( isset( $aresult[1] ) ) { |
|
| 1148 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1149 | + $this->setVersion( $aversion[0] ); |
|
| 1150 | + $this->setBrowser( self::BROWSER_WEBTV ); |
|
| 1151 | + |
|
| 1152 | + return true; |
|
| 1153 | + } |
|
| 1154 | + } |
|
| 1155 | + |
|
| 1156 | + return false; |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + /** |
|
| 1160 | + * Determine if the browser is NetPositive or not (last updated 1.7) |
|
| 1161 | + * |
|
| 1162 | + * @return boolean True if the browser is NetPositive otherwise false |
|
| 1163 | + */ |
|
| 1164 | + protected function checkBrowserNetPositive() { |
|
| 1165 | + if ( stripos( $this->_agent, 'NetPositive' ) !== false ) { |
|
| 1166 | + $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) ); |
|
| 1167 | + if ( isset( $aresult[1] ) ) { |
|
| 1168 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1169 | + $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) ); |
|
| 1170 | + $this->setBrowser( self::BROWSER_NETPOSITIVE ); |
|
| 1171 | + |
|
| 1172 | + return true; |
|
| 1173 | + } |
|
| 1174 | + } |
|
| 1175 | + |
|
| 1176 | + return false; |
|
| 1177 | + } |
|
| 1178 | + |
|
| 1179 | + /** |
|
| 1180 | + * Determine if the browser is Galeon or not (last updated 1.7) |
|
| 1181 | + * |
|
| 1182 | + * @return boolean True if the browser is Galeon otherwise false |
|
| 1183 | + */ |
|
| 1184 | + protected function checkBrowserGaleon() { |
|
| 1185 | + if ( stripos( $this->_agent, 'galeon' ) !== false ) { |
|
| 1186 | + $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) ); |
|
| 1187 | + $aversion = explode( '/', $aresult[0] ); |
|
| 1188 | + if ( isset( $aversion[1] ) ) { |
|
| 1189 | + $this->setVersion( $aversion[1] ); |
|
| 1190 | + $this->setBrowser( self::BROWSER_GALEON ); |
|
| 1191 | + |
|
| 1192 | + return true; |
|
| 1193 | + } |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + return false; |
|
| 1197 | + } |
|
| 1198 | + |
|
| 1199 | + /** |
|
| 1200 | + * Determine if the browser is Konqueror or not (last updated 1.7) |
|
| 1201 | + * |
|
| 1202 | + * @return boolean True if the browser is Konqueror otherwise false |
|
| 1203 | + */ |
|
| 1204 | + protected function checkBrowserKonqueror() { |
|
| 1205 | + if ( stripos( $this->_agent, 'Konqueror' ) !== false ) { |
|
| 1206 | + $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) ); |
|
| 1207 | + $aversion = explode( '/', $aresult[0] ); |
|
| 1208 | + if ( isset( $aversion[1] ) ) { |
|
| 1209 | + $this->setVersion( $aversion[1] ); |
|
| 1210 | + $this->setBrowser( self::BROWSER_KONQUEROR ); |
|
| 1211 | + |
|
| 1212 | + return true; |
|
| 1213 | + } |
|
| 1214 | + } |
|
| 1215 | + |
|
| 1216 | + return false; |
|
| 1217 | + } |
|
| 1218 | + |
|
| 1219 | + /** |
|
| 1220 | + * Determine if the browser is iCab or not (last updated 1.7) |
|
| 1221 | + * |
|
| 1222 | + * @return boolean True if the browser is iCab otherwise false |
|
| 1223 | + */ |
|
| 1224 | + protected function checkBrowserIcab() { |
|
| 1225 | + if ( stripos( $this->_agent, 'icab' ) !== false ) { |
|
| 1226 | + $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) ); |
|
| 1227 | + if ( isset( $aversion[1] ) ) { |
|
| 1228 | + $this->setVersion( $aversion[1] ); |
|
| 1229 | + $this->setBrowser( self::BROWSER_ICAB ); |
|
| 1230 | + |
|
| 1231 | + return true; |
|
| 1232 | + } |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + return false; |
|
| 1236 | + } |
|
| 1237 | + |
|
| 1238 | + /** |
|
| 1239 | + * Determine if the browser is OmniWeb or not (last updated 1.7) |
|
| 1240 | + * |
|
| 1241 | + * @return boolean True if the browser is OmniWeb otherwise false |
|
| 1242 | + */ |
|
| 1243 | + protected function checkBrowserOmniWeb() { |
|
| 1244 | + if ( stripos( $this->_agent, 'omniweb' ) !== false ) { |
|
| 1245 | + $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) ); |
|
| 1246 | + $aversion = explode( ' ', isset( $aresult[1] ) ? $aresult[1] : '' ); |
|
| 1247 | + $this->setVersion( $aversion[0] ); |
|
| 1248 | + $this->setBrowser( self::BROWSER_OMNIWEB ); |
|
| 1249 | + |
|
| 1250 | + return true; |
|
| 1251 | + } |
|
| 1252 | + |
|
| 1253 | + return false; |
|
| 1254 | + } |
|
| 1255 | + |
|
| 1256 | + /** |
|
| 1257 | + * Determine if the browser is Phoenix or not (last updated 1.7) |
|
| 1258 | + * |
|
| 1259 | + * @return boolean True if the browser is Phoenix otherwise false |
|
| 1260 | + */ |
|
| 1261 | + protected function checkBrowserPhoenix() { |
|
| 1262 | + if ( stripos( $this->_agent, 'Phoenix' ) !== false ) { |
|
| 1263 | + $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) ); |
|
| 1264 | + if ( isset( $aversion[1] ) ) { |
|
| 1265 | + $this->setVersion( $aversion[1] ); |
|
| 1266 | + $this->setBrowser( self::BROWSER_PHOENIX ); |
|
| 1267 | + |
|
| 1268 | + return true; |
|
| 1269 | + } |
|
| 1270 | + } |
|
| 1271 | + |
|
| 1272 | + return false; |
|
| 1273 | + } |
|
| 1274 | + |
|
| 1275 | + /** |
|
| 1276 | + * Determine if the browser is Firebird or not (last updated 1.7) |
|
| 1277 | + * |
|
| 1278 | + * @return boolean True if the browser is Firebird otherwise false |
|
| 1279 | + */ |
|
| 1280 | + protected function checkBrowserFirebird() { |
|
| 1281 | + if ( stripos( $this->_agent, 'Firebird' ) !== false ) { |
|
| 1282 | + $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) ); |
|
| 1283 | + if ( isset( $aversion[1] ) ) { |
|
| 1284 | + $this->setVersion( $aversion[1] ); |
|
| 1285 | + $this->setBrowser( self::BROWSER_FIREBIRD ); |
|
| 1286 | + |
|
| 1287 | + return true; |
|
| 1288 | + } |
|
| 1289 | + } |
|
| 1290 | + |
|
| 1291 | + return false; |
|
| 1292 | + } |
|
| 1293 | + |
|
| 1294 | + /** |
|
| 1295 | + * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7) |
|
| 1296 | + * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008) |
|
| 1297 | + * |
|
| 1298 | + * @return boolean True if the browser is Netscape Navigator 9+ otherwise false |
|
| 1299 | + */ |
|
| 1300 | + protected function checkBrowserNetscapeNavigator9Plus() { |
|
| 1301 | + if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1302 | + $this->setVersion( $matches[1] ); |
|
| 1303 | + $this->setBrowser( self::BROWSER_NETSCAPE_NAVIGATOR ); |
|
| 1304 | + |
|
| 1305 | + return true; |
|
| 1306 | + } elseif ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1307 | + $this->setVersion( $matches[1] ); |
|
| 1308 | + $this->setBrowser( self::BROWSER_NETSCAPE_NAVIGATOR ); |
|
| 1309 | + |
|
| 1310 | + return true; |
|
| 1311 | + } |
|
| 1312 | + |
|
| 1313 | + return false; |
|
| 1314 | + } |
|
| 1315 | + |
|
| 1316 | + /** |
|
| 1317 | + * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7) |
|
| 1318 | + * |
|
| 1319 | + * @return boolean True if the browser is Shiretoko otherwise false |
|
| 1320 | + */ |
|
| 1321 | + protected function checkBrowserShiretoko() { |
|
| 1322 | + if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1323 | + $this->setVersion( $matches[1] ); |
|
| 1324 | + $this->setBrowser( self::BROWSER_SHIRETOKO ); |
|
| 1325 | + |
|
| 1326 | + return true; |
|
| 1327 | + } |
|
| 1328 | + |
|
| 1329 | + return false; |
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + /** |
|
| 1333 | + * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7) |
|
| 1334 | + * |
|
| 1335 | + * @return boolean True if the browser is Ice Cat otherwise false |
|
| 1336 | + */ |
|
| 1337 | + protected function checkBrowserIceCat() { |
|
| 1338 | + if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) { |
|
| 1339 | + $this->setVersion( $matches[1] ); |
|
| 1340 | + $this->setBrowser( self::BROWSER_ICECAT ); |
|
| 1341 | + |
|
| 1342 | + return true; |
|
| 1343 | + } |
|
| 1344 | + |
|
| 1345 | + return false; |
|
| 1346 | + } |
|
| 1347 | + |
|
| 1348 | + /** |
|
| 1349 | + * Determine if the browser is Nokia or not (last updated 1.7) |
|
| 1350 | + * |
|
| 1351 | + * @return boolean True if the browser is Nokia otherwise false |
|
| 1352 | + */ |
|
| 1353 | + protected function checkBrowserNokia() { |
|
| 1354 | + if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) { |
|
| 1355 | + $this->setVersion( $matches[2] ); |
|
| 1356 | + if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) { |
|
| 1357 | + $this->setBrowser( self::BROWSER_NOKIA_S60 ); |
|
| 1358 | + } else { |
|
| 1359 | + $this->setBrowser( self::BROWSER_NOKIA ); |
|
| 1360 | + } |
|
| 1361 | + $this->setMobile( true ); |
|
| 1362 | + |
|
| 1363 | + return true; |
|
| 1364 | + } |
|
| 1365 | + |
|
| 1366 | + return false; |
|
| 1367 | + } |
|
| 1368 | + |
|
| 1369 | + /** |
|
| 1370 | + * Determine if the browser is Palemoon or not |
|
| 1371 | + * |
|
| 1372 | + * @return boolean True if the browser is Palemoon otherwise false |
|
| 1373 | + */ |
|
| 1374 | + protected function checkBrowserPalemoon() { |
|
| 1375 | + if ( stripos( $this->_agent, 'safari' ) === false ) { |
|
| 1376 | + if ( preg_match( "/Palemoon[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { |
|
| 1377 | + $this->setVersion( $matches[1] ); |
|
| 1378 | + $this->setBrowser( self::BROWSER_PALEMOON ); |
|
| 1379 | + |
|
| 1380 | + return true; |
|
| 1381 | + } elseif ( preg_match( "/Palemoon([0-9a-zA-Z\.]+)/i", $this->_agent, $matches ) ) { |
|
| 1382 | + $this->setVersion( $matches[1] ); |
|
| 1383 | + $this->setBrowser( self::BROWSER_PALEMOON ); |
|
| 1384 | + |
|
| 1385 | + return true; |
|
| 1386 | + } elseif ( preg_match( "/Palemoon/i", $this->_agent, $matches ) ) { |
|
| 1387 | + $this->setVersion( '' ); |
|
| 1388 | + $this->setBrowser( self::BROWSER_PALEMOON ); |
|
| 1389 | + |
|
| 1390 | + return true; |
|
| 1391 | + } |
|
| 1392 | + } |
|
| 1393 | + |
|
| 1394 | + return false; |
|
| 1395 | + } |
|
| 1396 | + |
|
| 1397 | + /** |
|
| 1398 | + * Determine if the browser is UCBrowser or not |
|
| 1399 | + * |
|
| 1400 | + * @return boolean True if the browser is UCBrowser otherwise false |
|
| 1401 | + */ |
|
| 1402 | + protected function checkBrowserUCBrowser() { |
|
| 1403 | + if ( preg_match( '/UC ?Browser\/?([\d\.]+)/', $this->_agent, $matches ) ) { |
|
| 1404 | + if ( isset( $matches[1] ) ) { |
|
| 1405 | + $this->setVersion( $matches[1] ); |
|
| 1406 | + } |
|
| 1407 | + if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1408 | + $this->setMobile( true ); |
|
| 1409 | + } else { |
|
| 1410 | + $this->setTablet( true ); |
|
| 1411 | + } |
|
| 1412 | + $this->setBrowser( self::BROWSER_UCBROWSER ); |
|
| 1413 | + |
|
| 1414 | + return true; |
|
| 1415 | + } |
|
| 1416 | + |
|
| 1417 | + return false; |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + /** |
|
| 1421 | + * Determine if the browser is Firefox or not |
|
| 1422 | + * |
|
| 1423 | + * @return boolean True if the browser is Firefox otherwise false |
|
| 1424 | + */ |
|
| 1425 | + protected function checkBrowserFirefox() { |
|
| 1426 | + if ( stripos( $this->_agent, 'safari' ) === false ) { |
|
| 1427 | + if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { |
|
| 1428 | + $this->setVersion( $matches[1] ); |
|
| 1429 | + $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1430 | + //Firefox on Android |
|
| 1431 | + if ( stripos( $this->_agent, 'Android' ) !== false || stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1432 | + if ( stripos( $this->_agent, 'Mobile' ) !== false || stripos( $this->_agent, 'Tablet' ) !== false ) { |
|
| 1433 | + $this->setMobile( true ); |
|
| 1434 | + } else { |
|
| 1435 | + $this->setTablet( true ); |
|
| 1436 | + } |
|
| 1437 | + } |
|
| 1438 | + |
|
| 1439 | + return true; |
|
| 1440 | + } elseif ( preg_match( "/Firefox([0-9a-zA-Z\.]+)/i", $this->_agent, $matches ) ) { |
|
| 1441 | + $this->setVersion( $matches[1] ); |
|
| 1442 | + $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1443 | + |
|
| 1444 | + return true; |
|
| 1445 | + } elseif ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) { |
|
| 1446 | + $this->setVersion( '' ); |
|
| 1447 | + $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1448 | + |
|
| 1449 | + return true; |
|
| 1450 | + } |
|
| 1451 | + } elseif ( preg_match( "/FxiOS[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { |
|
| 1452 | + $this->setVersion( $matches[1] ); |
|
| 1453 | + $this->setBrowser( self::BROWSER_FIREFOX ); |
|
| 1454 | + //Firefox on Android |
|
| 1455 | + if ( stripos( $this->_agent, 'Android' ) !== false || stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1456 | + if ( stripos( $this->_agent, 'Mobile' ) !== false || stripos( $this->_agent, 'Tablet' ) !== false ) { |
|
| 1457 | + $this->setMobile( true ); |
|
| 1458 | + } else { |
|
| 1459 | + $this->setTablet( true ); |
|
| 1460 | + } |
|
| 1461 | + } |
|
| 1462 | + |
|
| 1463 | + return true; |
|
| 1464 | + } |
|
| 1465 | + |
|
| 1466 | + return false; |
|
| 1467 | + } |
|
| 1468 | + |
|
| 1469 | + /** |
|
| 1470 | + * Determine if the browser is Firefox or not (last updated 1.7) |
|
| 1471 | + * |
|
| 1472 | + * @return boolean True if the browser is Firefox otherwise false |
|
| 1473 | + */ |
|
| 1474 | + protected function checkBrowserIceweasel() { |
|
| 1475 | + if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) { |
|
| 1476 | + $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) ); |
|
| 1477 | + if ( isset( $aresult[1] ) ) { |
|
| 1478 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1479 | + $this->setVersion( $aversion[0] ); |
|
| 1480 | + $this->setBrowser( self::BROWSER_ICEWEASEL ); |
|
| 1481 | + |
|
| 1482 | + return true; |
|
| 1483 | + } |
|
| 1484 | + } |
|
| 1485 | + |
|
| 1486 | + return false; |
|
| 1487 | + } |
|
| 1488 | + |
|
| 1489 | + /** |
|
| 1490 | + * Determine if the browser is Mozilla or not (last updated 1.7) |
|
| 1491 | + * |
|
| 1492 | + * @return boolean True if the browser is Mozilla otherwise false |
|
| 1493 | + */ |
|
| 1494 | + protected function checkBrowserMozilla() { |
|
| 1495 | + if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { |
|
| 1496 | + $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) ); |
|
| 1497 | + preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion ); |
|
| 1498 | + $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); |
|
| 1499 | + $this->setBrowser( self::BROWSER_MOZILLA ); |
|
| 1500 | + |
|
| 1501 | + return true; |
|
| 1502 | + } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { |
|
| 1503 | + $aversion = explode( '', stristr( $this->_agent, 'rv:' ) ); |
|
| 1504 | + $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); |
|
| 1505 | + $this->setBrowser( self::BROWSER_MOZILLA ); |
|
| 1506 | + |
|
| 1507 | + return true; |
|
| 1508 | + } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) { |
|
| 1509 | + $this->setVersion( $matches[1] ); |
|
| 1510 | + $this->setBrowser( self::BROWSER_MOZILLA ); |
|
| 1511 | + |
|
| 1512 | + return true; |
|
| 1513 | + } |
|
| 1514 | + |
|
| 1515 | + return false; |
|
| 1516 | + } |
|
| 1517 | + |
|
| 1518 | + /** |
|
| 1519 | + * Determine if the browser is Lynx or not (last updated 1.7) |
|
| 1520 | + * |
|
| 1521 | + * @return boolean True if the browser is Lynx otherwise false |
|
| 1522 | + */ |
|
| 1523 | + protected function checkBrowserLynx() { |
|
| 1524 | + if ( stripos( $this->_agent, 'lynx' ) !== false ) { |
|
| 1525 | + $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) ); |
|
| 1526 | + $aversion = explode( ' ', ( isset( $aresult[1] ) ? $aresult[1] : '' ) ); |
|
| 1527 | + $this->setVersion( $aversion[0] ); |
|
| 1528 | + $this->setBrowser( self::BROWSER_LYNX ); |
|
| 1529 | + |
|
| 1530 | + return true; |
|
| 1531 | + } |
|
| 1532 | + |
|
| 1533 | + return false; |
|
| 1534 | + } |
|
| 1535 | + |
|
| 1536 | + /** |
|
| 1537 | + * Determine if the browser is Amaya or not (last updated 1.7) |
|
| 1538 | + * |
|
| 1539 | + * @return boolean True if the browser is Amaya otherwise false |
|
| 1540 | + */ |
|
| 1541 | + protected function checkBrowserAmaya() { |
|
| 1542 | + if ( stripos( $this->_agent, 'amaya' ) !== false ) { |
|
| 1543 | + $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) ); |
|
| 1544 | + if ( isset( $aresult[1] ) ) { |
|
| 1545 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1546 | + $this->setVersion( $aversion[0] ); |
|
| 1547 | + $this->setBrowser( self::BROWSER_AMAYA ); |
|
| 1548 | + |
|
| 1549 | + return true; |
|
| 1550 | + } |
|
| 1551 | + } |
|
| 1552 | + |
|
| 1553 | + return false; |
|
| 1554 | + } |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * Determine if the browser is Safari or not (last updated 1.7) |
|
| 1558 | + * |
|
| 1559 | + * @return boolean True if the browser is Safari otherwise false |
|
| 1560 | + */ |
|
| 1561 | + protected function checkBrowserSafari() { |
|
| 1562 | + if ( |
|
| 1563 | + stripos( $this->_agent, 'Safari' ) !== false |
|
| 1564 | + && stripos( $this->_agent, 'iPhone' ) === false |
|
| 1565 | + && stripos( $this->_agent, 'iPod' ) === false |
|
| 1566 | + ) { |
|
| 1567 | + |
|
| 1568 | + $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); |
|
| 1569 | + if ( isset( $aresult[1] ) ) { |
|
| 1570 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1571 | + $this->setVersion( $aversion[0] ); |
|
| 1572 | + } else { |
|
| 1573 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1574 | + } |
|
| 1575 | + $this->setBrowser( self::BROWSER_SAFARI ); |
|
| 1576 | + |
|
| 1577 | + return true; |
|
| 1578 | + } |
|
| 1579 | + |
|
| 1580 | + return false; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + protected function checkBrowserSamsung() { |
|
| 1584 | + if ( stripos( $this->_agent, 'SamsungBrowser' ) !== false ) { |
|
| 1585 | + |
|
| 1586 | + $aresult = explode( '/', stristr( $this->_agent, 'SamsungBrowser' ) ); |
|
| 1587 | + if ( isset( $aresult[1] ) ) { |
|
| 1588 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1589 | + $this->setVersion( $aversion[0] ); |
|
| 1590 | + } else { |
|
| 1591 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1592 | + } |
|
| 1593 | + $this->setBrowser( self::BROWSER_SAMSUNG ); |
|
| 1594 | + |
|
| 1595 | + return true; |
|
| 1596 | + } |
|
| 1597 | + |
|
| 1598 | + return false; |
|
| 1599 | + } |
|
| 1600 | + |
|
| 1601 | + protected function checkBrowserSilk() { |
|
| 1602 | + if ( stripos( $this->_agent, 'Silk' ) !== false ) { |
|
| 1603 | + $aresult = explode( '/', stristr( $this->_agent, 'Silk' ) ); |
|
| 1604 | + if ( isset( $aresult[1] ) ) { |
|
| 1605 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1606 | + $this->setVersion( $aversion[0] ); |
|
| 1607 | + } else { |
|
| 1608 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1609 | + } |
|
| 1610 | + $this->setBrowser( self::BROWSER_SILK ); |
|
| 1611 | + |
|
| 1612 | + return true; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + return false; |
|
| 1616 | + } |
|
| 1617 | + |
|
| 1618 | + protected function checkBrowserIframely() { |
|
| 1619 | + if ( stripos( $this->_agent, 'Iframely' ) !== false ) { |
|
| 1620 | + $aresult = explode( '/', stristr( $this->_agent, 'Iframely' ) ); |
|
| 1621 | + if ( isset( $aresult[1] ) ) { |
|
| 1622 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1623 | + $this->setVersion( $aversion[0] ); |
|
| 1624 | + } else { |
|
| 1625 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1626 | + } |
|
| 1627 | + $this->setBrowser( self::BROWSER_I_FRAME ); |
|
| 1628 | + |
|
| 1629 | + return true; |
|
| 1630 | + } |
|
| 1631 | + |
|
| 1632 | + return false; |
|
| 1633 | + } |
|
| 1634 | + |
|
| 1635 | + protected function checkBrowserCocoa() { |
|
| 1636 | + if ( stripos( $this->_agent, 'CocoaRestClient' ) !== false ) { |
|
| 1637 | + $aresult = explode( '/', stristr( $this->_agent, 'CocoaRestClient' ) ); |
|
| 1638 | + if ( isset( $aresult[1] ) ) { |
|
| 1639 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1640 | + $this->setVersion( $aversion[0] ); |
|
| 1641 | + } else { |
|
| 1642 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1643 | + } |
|
| 1644 | + $this->setBrowser( self::BROWSER_COCOA ); |
|
| 1645 | + |
|
| 1646 | + return true; |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + return false; |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + /** |
|
| 1653 | + * Detect if URL is loaded from FacebookExternalHit |
|
| 1654 | + * |
|
| 1655 | + * @return boolean True if it detects FacebookExternalHit otherwise false |
|
| 1656 | + */ |
|
| 1657 | + protected function checkFacebookExternalHit() { |
|
| 1658 | + if ( stristr( $this->_agent, 'FacebookExternalHit' ) ) { |
|
| 1659 | + $this->setRobot( true ); |
|
| 1660 | + $this->setFacebook( true ); |
|
| 1661 | + |
|
| 1662 | + return true; |
|
| 1663 | + } |
|
| 1664 | + |
|
| 1665 | + return false; |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + /** |
|
| 1669 | + * Detect if URL is being loaded from internal Facebook browser |
|
| 1670 | + * |
|
| 1671 | + * @return boolean True if it detects internal Facebook browser otherwise false |
|
| 1672 | + */ |
|
| 1673 | + protected function checkForFacebookIos() { |
|
| 1674 | + if ( stristr( $this->_agent, 'FBIOS' ) ) { |
|
| 1675 | + $this->setFacebook( true ); |
|
| 1676 | + |
|
| 1677 | + return true; |
|
| 1678 | + } |
|
| 1679 | + |
|
| 1680 | + return false; |
|
| 1681 | + } |
|
| 1682 | + |
|
| 1683 | + /** |
|
| 1684 | + * Detect Version for the Safari browser on iOS devices |
|
| 1685 | + * |
|
| 1686 | + * @return boolean True if it detects the version correctly otherwise false |
|
| 1687 | + */ |
|
| 1688 | + protected function getSafariVersionOnIos() { |
|
| 1689 | + $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); |
|
| 1690 | + if ( isset( $aresult[1] ) ) { |
|
| 1691 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1692 | + $this->setVersion( $aversion[0] ); |
|
| 1693 | + |
|
| 1694 | + return true; |
|
| 1695 | + } |
|
| 1696 | + |
|
| 1697 | + return false; |
|
| 1698 | + } |
|
| 1699 | + |
|
| 1700 | + /** |
|
| 1701 | + * Detect Version for the Chrome browser on iOS devices |
|
| 1702 | + * |
|
| 1703 | + * @return boolean True if it detects the version correctly otherwise false |
|
| 1704 | + */ |
|
| 1705 | + protected function getChromeVersionOnIos() { |
|
| 1706 | + $aresult = explode( '/', stristr( $this->_agent, 'CriOS' ) ); |
|
| 1707 | + if ( isset( $aresult[1] ) ) { |
|
| 1708 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1709 | + $this->setVersion( $aversion[0] ); |
|
| 1710 | + $this->setBrowser( self::BROWSER_CHROME ); |
|
| 1711 | + |
|
| 1712 | + return true; |
|
| 1713 | + } |
|
| 1714 | + |
|
| 1715 | + return false; |
|
| 1716 | + } |
|
| 1717 | + |
|
| 1718 | + /** |
|
| 1719 | + * Determine if the browser is iPhone or not (last updated 1.7) |
|
| 1720 | + * |
|
| 1721 | + * @return boolean True if the browser is iPhone otherwise false |
|
| 1722 | + */ |
|
| 1723 | + protected function checkBrowseriPhone() { |
|
| 1724 | + if ( stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1725 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1726 | + $this->setBrowser( self::BROWSER_IPHONE ); |
|
| 1727 | + $this->getSafariVersionOnIos(); |
|
| 1728 | + $this->getChromeVersionOnIos(); |
|
| 1729 | + $this->checkForFacebookIos(); |
|
| 1730 | + $this->setMobile( true ); |
|
| 1731 | + |
|
| 1732 | + return true; |
|
| 1733 | + } |
|
| 1734 | + |
|
| 1735 | + return false; |
|
| 1736 | + } |
|
| 1737 | + |
|
| 1738 | + /** |
|
| 1739 | + * Determine if the browser is iPad or not (last updated 1.7) |
|
| 1740 | + * |
|
| 1741 | + * @return boolean True if the browser is iPad otherwise false |
|
| 1742 | + */ |
|
| 1743 | + protected function checkBrowseriPad() { |
|
| 1744 | + if ( stripos( $this->_agent, 'iPad' ) !== false ) { |
|
| 1745 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1746 | + $this->setBrowser( self::BROWSER_IPAD ); |
|
| 1747 | + $this->getSafariVersionOnIos(); |
|
| 1748 | + $this->getChromeVersionOnIos(); |
|
| 1749 | + $this->checkForFacebookIos(); |
|
| 1750 | + $this->setTablet( true ); |
|
| 1751 | + |
|
| 1752 | + return true; |
|
| 1753 | + } |
|
| 1754 | + |
|
| 1755 | + return false; |
|
| 1756 | + } |
|
| 1757 | + |
|
| 1758 | + /** |
|
| 1759 | + * Determine if the browser is iPod or not (last updated 1.7) |
|
| 1760 | + * |
|
| 1761 | + * @return boolean True if the browser is iPod otherwise false |
|
| 1762 | + */ |
|
| 1763 | + protected function checkBrowseriPod() { |
|
| 1764 | + if ( stripos( $this->_agent, 'iPod' ) !== false ) { |
|
| 1765 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1766 | + $this->setBrowser( self::BROWSER_IPOD ); |
|
| 1767 | + $this->getSafariVersionOnIos(); |
|
| 1768 | + $this->getChromeVersionOnIos(); |
|
| 1769 | + $this->checkForFacebookIos(); |
|
| 1770 | + $this->setMobile( true ); |
|
| 1771 | + |
|
| 1772 | + return true; |
|
| 1773 | + } |
|
| 1774 | + |
|
| 1775 | + return false; |
|
| 1776 | + } |
|
| 1777 | + |
|
| 1778 | + /** |
|
| 1779 | + * Determine if the browser is Android or not (last updated 1.7) |
|
| 1780 | + * |
|
| 1781 | + * @return boolean True if the browser is Android otherwise false |
|
| 1782 | + */ |
|
| 1783 | + protected function checkBrowserAndroid() { |
|
| 1784 | + if ( stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 1785 | + $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) ); |
|
| 1786 | + if ( isset( $aresult[1] ) ) { |
|
| 1787 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1788 | + $this->setVersion( $aversion[0] ); |
|
| 1789 | + } else { |
|
| 1790 | + $this->setVersion( self::VERSION_UNKNOWN ); |
|
| 1791 | + } |
|
| 1792 | + if ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1793 | + $this->setMobile( true ); |
|
| 1794 | + } else { |
|
| 1795 | + $this->setTablet( true ); |
|
| 1796 | + } |
|
| 1797 | + $this->setBrowser( self::BROWSER_ANDROID ); |
|
| 1798 | + |
|
| 1799 | + return true; |
|
| 1800 | + } |
|
| 1801 | + |
|
| 1802 | + return false; |
|
| 1803 | + } |
|
| 1804 | + |
|
| 1805 | + /** |
|
| 1806 | + * Determine if the browser is Vivaldi |
|
| 1807 | + * |
|
| 1808 | + * @return boolean True if the browser is Vivaldi otherwise false |
|
| 1809 | + */ |
|
| 1810 | + protected function checkBrowserVivaldi() { |
|
| 1811 | + if ( stripos( $this->_agent, 'Vivaldi' ) !== false ) { |
|
| 1812 | + $aresult = explode( '/', stristr( $this->_agent, 'Vivaldi' ) ); |
|
| 1813 | + if ( isset( $aresult[1] ) ) { |
|
| 1814 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1815 | + $this->setVersion( $aversion[0] ); |
|
| 1816 | + $this->setBrowser( self::BROWSER_VIVALDI ); |
|
| 1817 | + |
|
| 1818 | + return true; |
|
| 1819 | + } |
|
| 1820 | + } |
|
| 1821 | + |
|
| 1822 | + return false; |
|
| 1823 | + } |
|
| 1824 | + |
|
| 1825 | + /** |
|
| 1826 | + * Determine if the browser is Yandex |
|
| 1827 | + * |
|
| 1828 | + * @return boolean True if the browser is Yandex otherwise false |
|
| 1829 | + */ |
|
| 1830 | + protected function checkBrowserYandex() { |
|
| 1831 | + if ( stripos( $this->_agent, 'YaBrowser' ) !== false ) { |
|
| 1832 | + $aresult = explode( '/', stristr( $this->_agent, 'YaBrowser' ) ); |
|
| 1833 | + if ( isset( $aresult[1] ) ) { |
|
| 1834 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1835 | + $this->setVersion( $aversion[0] ); |
|
| 1836 | + $this->setBrowser( self::BROWSER_YANDEX ); |
|
| 1837 | + |
|
| 1838 | + if ( stripos( $this->_agent, 'iPad' ) !== false ) { |
|
| 1839 | + $this->setTablet( true ); |
|
| 1840 | + } elseif ( stripos( $this->_agent, 'Mobile' ) !== false ) { |
|
| 1841 | + $this->setMobile( true ); |
|
| 1842 | + } elseif ( stripos( $this->_agent, 'Android' ) !== false ) { |
|
| 1843 | + $this->setTablet( true ); |
|
| 1844 | + } |
|
| 1845 | + |
|
| 1846 | + return true; |
|
| 1847 | + } |
|
| 1848 | + } |
|
| 1849 | + |
|
| 1850 | + return false; |
|
| 1851 | + } |
|
| 1852 | + |
|
| 1853 | + /** |
|
| 1854 | + * Determine if the browser is a PlayStation |
|
| 1855 | + * |
|
| 1856 | + * @return boolean True if the browser is PlayStation otherwise false |
|
| 1857 | + */ |
|
| 1858 | + protected function checkBrowserPlayStation() { |
|
| 1859 | + if ( stripos( $this->_agent, 'PlayStation ' ) !== false ) { |
|
| 1860 | + $aresult = explode( ' ', stristr( $this->_agent, 'PlayStation ' ) ); |
|
| 1861 | + $this->setBrowser( self::BROWSER_PLAYSTATION ); |
|
| 1862 | + if ( isset( $aresult[0] ) ) { |
|
| 1863 | + $aversion = explode( ')', $aresult[2] ); |
|
| 1864 | + $this->setVersion( $aversion[0] ); |
|
| 1865 | + if ( stripos( $this->_agent, 'Portable)' ) !== false || stripos( $this->_agent, 'Vita' ) !== false ) { |
|
| 1866 | + $this->setMobile( true ); |
|
| 1867 | + } |
|
| 1868 | + |
|
| 1869 | + return true; |
|
| 1870 | + } |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + return false; |
|
| 1874 | + } |
|
| 1875 | + |
|
| 1876 | + /** |
|
| 1877 | + * Determine if the browser is Wget or not (last updated 1.7) |
|
| 1878 | + * |
|
| 1879 | + * @return boolean True if the browser is Wget otherwise false |
|
| 1880 | + */ |
|
| 1881 | + protected function checkBrowserWget() { |
|
| 1882 | + if ( preg_match( "!^Wget/([^ ]+)!i", $this->_agent, $aresult ) ) { |
|
| 1883 | + $this->setVersion( $aresult[1] ); |
|
| 1884 | + $this->setBrowser( self::BROWSER_WGET ); |
|
| 1885 | + |
|
| 1886 | + return true; |
|
| 1887 | + } |
|
| 1888 | + |
|
| 1889 | + return false; |
|
| 1890 | + } |
|
| 1891 | + |
|
| 1892 | + /** |
|
| 1893 | + * Determine if the browser is cURL or not (last updated 1.7) |
|
| 1894 | + * |
|
| 1895 | + * @return boolean True if the browser is cURL otherwise false |
|
| 1896 | + */ |
|
| 1897 | + protected function checkBrowserCurl() { |
|
| 1898 | + if ( strpos( $this->_agent, 'curl' ) === 0 ) { |
|
| 1899 | + $aresult = explode( '/', stristr( $this->_agent, 'curl' ) ); |
|
| 1900 | + if ( isset( $aresult[1] ) ) { |
|
| 1901 | + $aversion = explode( ' ', $aresult[1] ); |
|
| 1902 | + $this->setVersion( $aversion[0] ); |
|
| 1903 | + $this->setBrowser( self::BROWSER_CURL ); |
|
| 1904 | + |
|
| 1905 | + return true; |
|
| 1906 | + } |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + return false; |
|
| 1910 | + } |
|
| 1911 | + |
|
| 1912 | + /** |
|
| 1913 | + * Determine the user's platform (last updated 2.0) |
|
| 1914 | + */ |
|
| 1915 | + protected function checkPlatform() { |
|
| 1916 | + if ( stripos( $this->_agent, 'windows' ) !== false ) { |
|
| 1917 | + $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1918 | + } elseif ( stripos( $this->_agent, 'iPad' ) !== false ) { |
|
| 1919 | + $this->_platform = self::PLATFORM_IPAD; |
|
| 1920 | + } elseif ( stripos( $this->_agent, 'iPod' ) !== false ) { |
|
| 1921 | + $this->_platform = self::PLATFORM_IPOD; |
|
| 1922 | + } elseif ( stripos( $this->_agent, 'iPhone' ) !== false ) { |
|
| 1923 | + $this->_platform = self::PLATFORM_IPHONE; |
|
| 1924 | + } elseif ( stripos( $this->_agent, 'mac' ) !== false ) { |
|
| 1925 | + $this->_platform = self::PLATFORM_APPLE; |
|
| 1926 | + } elseif ( stripos( $this->_agent, 'android' ) !== false ) { |
|
| 1927 | + $this->_platform = self::PLATFORM_ANDROID; |
|
| 1928 | + } elseif ( stripos( $this->_agent, 'Silk' ) !== false ) { |
|
| 1929 | + $this->_platform = self::PLATFORM_FIRE_OS; |
|
| 1930 | + } elseif ( stripos( $this->_agent, 'linux' ) !== false && stripos( $this->_agent, 'SMART-TV' ) !== false ) { |
|
| 1931 | + $this->_platform = self::PLATFORM_LINUX . '/' . self::PLATFORM_SMART_TV; |
|
| 1932 | + } elseif ( stripos( $this->_agent, 'linux' ) !== false ) { |
|
| 1933 | + $this->_platform = self::PLATFORM_LINUX; |
|
| 1934 | + } elseif ( stripos( $this->_agent, 'Nokia' ) !== false ) { |
|
| 1935 | + $this->_platform = self::PLATFORM_NOKIA; |
|
| 1936 | + } elseif ( stripos( $this->_agent, 'BlackBerry' ) !== false ) { |
|
| 1937 | + $this->_platform = self::PLATFORM_BLACKBERRY; |
|
| 1938 | + } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) { |
|
| 1939 | + $this->_platform = self::PLATFORM_FREEBSD; |
|
| 1940 | + } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) { |
|
| 1941 | + $this->_platform = self::PLATFORM_OPENBSD; |
|
| 1942 | + } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) { |
|
| 1943 | + $this->_platform = self::PLATFORM_NETBSD; |
|
| 1944 | + } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) { |
|
| 1945 | + $this->_platform = self::PLATFORM_OPENSOLARIS; |
|
| 1946 | + } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) { |
|
| 1947 | + $this->_platform = self::PLATFORM_SUNOS; |
|
| 1948 | + } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) { |
|
| 1949 | + $this->_platform = self::PLATFORM_OS2; |
|
| 1950 | + } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) { |
|
| 1951 | + $this->_platform = self::PLATFORM_BEOS; |
|
| 1952 | + } elseif ( stripos( $this->_agent, 'win' ) !== false ) { |
|
| 1953 | + $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1954 | + } elseif ( stripos( $this->_agent, 'Playstation' ) !== false ) { |
|
| 1955 | + $this->_platform = self::PLATFORM_PLAYSTATION; |
|
| 1956 | + } elseif ( stripos( $this->_agent, 'Roku' ) !== false ) { |
|
| 1957 | + $this->_platform = self::PLATFORM_ROKU; |
|
| 1958 | + } elseif ( stripos( $this->_agent, 'iOS' ) !== false ) { |
|
| 1959 | + $this->_platform = self::PLATFORM_IPHONE . '/' . self::PLATFORM_IPAD; |
|
| 1960 | + } elseif ( stripos( $this->_agent, 'tvOS' ) !== false ) { |
|
| 1961 | + $this->_platform = self::PLATFORM_APPLE_TV; |
|
| 1962 | + } elseif ( stripos( $this->_agent, 'curl' ) !== false ) { |
|
| 1963 | + $this->_platform = self::PLATFORM_TERMINAL; |
|
| 1964 | + } elseif ( stripos( $this->_agent, 'CrOS' ) !== false ) { |
|
| 1965 | + $this->_platform = self::PLATFORM_CHROME_OS; |
|
| 1966 | + } elseif ( stripos( $this->_agent, 'okhttp' ) !== false ) { |
|
| 1967 | + $this->_platform = self::PLATFORM_JAVA_ANDROID; |
|
| 1968 | + } elseif ( stripos( $this->_agent, 'PostmanRuntime' ) !== false ) { |
|
| 1969 | + $this->_platform = self::PLATFORM_POSTMAN; |
|
| 1970 | + } elseif ( stripos( $this->_agent, 'Iframely' ) !== false ) { |
|
| 1971 | + $this->_platform = self::PLATFORM_I_FRAME; |
|
| 1972 | + } |
|
| 1973 | + } |
|
| 1974 | 1974 | } |
@@ -12,73 +12,73 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Editor', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_editor class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Editor extends Redux_Field { |
|
| 15 | + /** |
|
| 16 | + * Main Redux_editor class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Editor extends Redux_Field { |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Field Render Function. |
|
| 24 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 25 | - * |
|
| 26 | - * @since 1.0.0 |
|
| 27 | - * @access public |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function render() { |
|
| 31 | - if ( ! isset( $this->field['args'] ) ) { |
|
| 32 | - $this->field['args'] = array(); |
|
| 33 | - } |
|
| 22 | + /** |
|
| 23 | + * Field Render Function. |
|
| 24 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 25 | + * |
|
| 26 | + * @since 1.0.0 |
|
| 27 | + * @access public |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function render() { |
|
| 31 | + if ( ! isset( $this->field['args'] ) ) { |
|
| 32 | + $this->field['args'] = array(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $this->field['args']['onchange_callback'] = "alert('here')"; |
|
| 35 | + $this->field['args']['onchange_callback'] = "alert('here')"; |
|
| 36 | 36 | |
| 37 | - // Setup up default args. |
|
| 38 | - $defaults = array( |
|
| 39 | - 'textarea_name' => esc_attr( $this->field['name'] . $this->field['name_suffix'] ), |
|
| 40 | - 'editor_class' => esc_attr( $this->field['class'] ), |
|
| 41 | - 'textarea_rows' => 10, // Wordpress default. |
|
| 42 | - 'teeny' => true, |
|
| 43 | - ); |
|
| 37 | + // Setup up default args. |
|
| 38 | + $defaults = array( |
|
| 39 | + 'textarea_name' => esc_attr( $this->field['name'] . $this->field['name_suffix'] ), |
|
| 40 | + 'editor_class' => esc_attr( $this->field['class'] ), |
|
| 41 | + 'textarea_rows' => 10, // Wordpress default. |
|
| 42 | + 'teeny' => true, |
|
| 43 | + ); |
|
| 44 | 44 | |
| 45 | - if ( isset( $this->field['editor_options'] ) && empty( $this->field['args'] ) ) { |
|
| 46 | - $this->field['args'] = $this->field['editor_options']; |
|
| 47 | - unset( $this->field['editor_options'] ); |
|
| 48 | - } |
|
| 45 | + if ( isset( $this->field['editor_options'] ) && empty( $this->field['args'] ) ) { |
|
| 46 | + $this->field['args'] = $this->field['editor_options']; |
|
| 47 | + unset( $this->field['editor_options'] ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $this->field['args'] = wp_parse_args( $this->field['args'], $defaults ); |
|
| 50 | + $this->field['args'] = wp_parse_args( $this->field['args'], $defaults ); |
|
| 51 | 51 | |
| 52 | - wp_editor( $this->value, $this->field['id'], $this->field['args'] ); |
|
| 53 | - } |
|
| 52 | + wp_editor( $this->value, $this->field['id'], $this->field['args'] ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Enqueue Function. |
|
| 57 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * @access public |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function enqueue() { |
|
| 64 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 65 | - wp_enqueue_style( |
|
| 66 | - 'redux-field-editor', |
|
| 67 | - Redux_Core::$url . 'inc/fields/editor/redux-editor.css', |
|
| 68 | - array(), |
|
| 69 | - $this->timestamp |
|
| 70 | - ); |
|
| 71 | - } |
|
| 55 | + /** |
|
| 56 | + * Enqueue Function. |
|
| 57 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * @access public |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function enqueue() { |
|
| 64 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 65 | + wp_enqueue_style( |
|
| 66 | + 'redux-field-editor', |
|
| 67 | + Redux_Core::$url . 'inc/fields/editor/redux-editor.css', |
|
| 68 | + array(), |
|
| 69 | + $this->timestamp |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - wp_enqueue_script( |
|
| 74 | - 'redux-field-editor', |
|
| 75 | - Redux_Core::$url . 'inc/fields/editor/redux-editor' . Redux_Functions::is_min() . '.js', |
|
| 76 | - array( 'jquery', 'redux-js' ), |
|
| 77 | - $this->timestamp, |
|
| 78 | - true |
|
| 79 | - ); |
|
| 80 | - } |
|
| 81 | - } |
|
| 73 | + wp_enqueue_script( |
|
| 74 | + 'redux-field-editor', |
|
| 75 | + Redux_Core::$url . 'inc/fields/editor/redux-editor' . Redux_Functions::is_min() . '.js', |
|
| 76 | + array( 'jquery', 'redux-js' ), |
|
| 77 | + $this->timestamp, |
|
| 78 | + true |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | class_alias( 'Redux_Editor', 'ReduxFramework_Editor' ); |
@@ -11,90 +11,90 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Palette', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Palette |
|
| 16 | - */ |
|
| 17 | - class Redux_Palette extends Redux_Field { |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Field Render Function. |
|
| 21 | - * Takes the vars and outputs the HTML for the field in the settings. |
|
| 22 | - * |
|
| 23 | - * @since 1.0.0 |
|
| 24 | - * @access public |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function render() { |
|
| 28 | - if ( ! isset( $this->field['palettes'] ) && empty( $this->field['palettes'] ) ) { |
|
| 29 | - echo 'No palettes have been set.'; |
|
| 30 | - |
|
| 31 | - return; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - echo '<div id="' . esc_attr( $this->field['id'] ) . '" class="buttonset">'; |
|
| 35 | - |
|
| 36 | - foreach ( $this->field['palettes'] as $value => $color_set ) { |
|
| 37 | - $checked = checked( $this->value, $value, false ); |
|
| 38 | - |
|
| 39 | - echo '<input |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Palette |
|
| 16 | + */ |
|
| 17 | + class Redux_Palette extends Redux_Field { |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Field Render Function. |
|
| 21 | + * Takes the vars and outputs the HTML for the field in the settings. |
|
| 22 | + * |
|
| 23 | + * @since 1.0.0 |
|
| 24 | + * @access public |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function render() { |
|
| 28 | + if ( ! isset( $this->field['palettes'] ) && empty( $this->field['palettes'] ) ) { |
|
| 29 | + echo 'No palettes have been set.'; |
|
| 30 | + |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + echo '<div id="' . esc_attr( $this->field['id'] ) . '" class="buttonset">'; |
|
| 35 | + |
|
| 36 | + foreach ( $this->field['palettes'] as $value => $color_set ) { |
|
| 37 | + $checked = checked( $this->value, $value, false ); |
|
| 38 | + |
|
| 39 | + echo '<input |
|
| 40 | 40 | type="radio" |
| 41 | 41 | value="' . esc_attr( $value ) . '" |
| 42 | 42 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" |
| 43 | 43 | class="redux-palette-set ' . esc_attr( $this->field['class'] ) . '" |
| 44 | 44 | id="' . esc_attr( $this->field['id'] . '-' . $value ) . '"' . esc_html( $checked ) . '>'; |
| 45 | 45 | |
| 46 | - echo '<label for="' . esc_attr( $this->field['id'] . '-' . $value ) . '">'; |
|
| 47 | - |
|
| 48 | - foreach ( $color_set as $color ) { |
|
| 49 | - echo '<span style=background:' . esc_attr( $color ) . '>' . esc_attr( $color ) . '</span>'; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - echo '</label>'; |
|
| 53 | - echo '</input>'; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - echo '</div>'; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Enqueue Function. |
|
| 61 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * @access public |
|
| 65 | - * @return void |
|
| 66 | - */ |
|
| 67 | - public function enqueue() { |
|
| 68 | - $min = Redux_Functions::is_min(); |
|
| 69 | - |
|
| 70 | - wp_enqueue_script( |
|
| 71 | - 'redux-field-palette', |
|
| 72 | - Redux_Core::$url . 'inc/fields/palette/redux-palette' . $min . '.js', |
|
| 73 | - array( 'jquery', 'redux-js', 'jquery-ui-button', 'jquery-ui-core' ), |
|
| 74 | - $this->timestamp, |
|
| 75 | - true |
|
| 76 | - ); |
|
| 77 | - |
|
| 78 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 79 | - wp_enqueue_style( |
|
| 80 | - 'redux-field-palette', |
|
| 81 | - Redux_Core::$url . 'inc/fields/palette/redux-palette.css', |
|
| 82 | - array(), |
|
| 83 | - $this->timestamp |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Enable output_variables to be generated. |
|
| 90 | - * |
|
| 91 | - * @since 4.0.3 |
|
| 92 | - * @return void |
|
| 93 | - */ |
|
| 94 | - public function output_variables() { |
|
| 95 | - // No code needed, just defining the method is enough. |
|
| 96 | - } |
|
| 97 | - } |
|
| 46 | + echo '<label for="' . esc_attr( $this->field['id'] . '-' . $value ) . '">'; |
|
| 47 | + |
|
| 48 | + foreach ( $color_set as $color ) { |
|
| 49 | + echo '<span style=background:' . esc_attr( $color ) . '>' . esc_attr( $color ) . '</span>'; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + echo '</label>'; |
|
| 53 | + echo '</input>'; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + echo '</div>'; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Enqueue Function. |
|
| 61 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * @access public |
|
| 65 | + * @return void |
|
| 66 | + */ |
|
| 67 | + public function enqueue() { |
|
| 68 | + $min = Redux_Functions::is_min(); |
|
| 69 | + |
|
| 70 | + wp_enqueue_script( |
|
| 71 | + 'redux-field-palette', |
|
| 72 | + Redux_Core::$url . 'inc/fields/palette/redux-palette' . $min . '.js', |
|
| 73 | + array( 'jquery', 'redux-js', 'jquery-ui-button', 'jquery-ui-core' ), |
|
| 74 | + $this->timestamp, |
|
| 75 | + true |
|
| 76 | + ); |
|
| 77 | + |
|
| 78 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 79 | + wp_enqueue_style( |
|
| 80 | + 'redux-field-palette', |
|
| 81 | + Redux_Core::$url . 'inc/fields/palette/redux-palette.css', |
|
| 82 | + array(), |
|
| 83 | + $this->timestamp |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Enable output_variables to be generated. |
|
| 90 | + * |
|
| 91 | + * @since 4.0.3 |
|
| 92 | + * @return void |
|
| 93 | + */ |
|
| 94 | + public function output_variables() { |
|
| 95 | + // No code needed, just defining the method is enough. |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | class_alias( 'Redux_Palette', 'ReduxFramework_Palette' ); |
@@ -12,127 +12,127 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Multi_Text', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_multi_text class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Multi_Text extends Redux_Field { |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Set field defaults. |
|
| 24 | - */ |
|
| 25 | - public function set_defaults() { |
|
| 26 | - $defaults = array( |
|
| 27 | - 'show_empty' => true, |
|
| 28 | - 'add_text' => esc_html__( 'Add More', 'redux-framework' ), |
|
| 29 | - ); |
|
| 30 | - |
|
| 31 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Field Render Function. |
|
| 36 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * @access public |
|
| 40 | - * @return void |
|
| 41 | - */ |
|
| 42 | - public function render() { |
|
| 43 | - echo '<ul id="' . esc_attr( $this->field['id'] ) . '-ul" class="redux-multi-text ' . esc_attr( $this->field['class'] ) . '">'; |
|
| 44 | - |
|
| 45 | - if ( isset( $this->value ) && is_array( $this->value ) ) { |
|
| 46 | - foreach ( $this->value as $k => $value ) { |
|
| 47 | - if ( '' !== $value || ( true === $this->field['show_empty'] ) ) { |
|
| 48 | - echo '<li>'; |
|
| 49 | - echo '<input |
|
| 15 | + /** |
|
| 16 | + * Main Redux_multi_text class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Multi_Text extends Redux_Field { |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Set field defaults. |
|
| 24 | + */ |
|
| 25 | + public function set_defaults() { |
|
| 26 | + $defaults = array( |
|
| 27 | + 'show_empty' => true, |
|
| 28 | + 'add_text' => esc_html__( 'Add More', 'redux-framework' ), |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Field Render Function. |
|
| 36 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * @access public |
|
| 40 | + * @return void |
|
| 41 | + */ |
|
| 42 | + public function render() { |
|
| 43 | + echo '<ul id="' . esc_attr( $this->field['id'] ) . '-ul" class="redux-multi-text ' . esc_attr( $this->field['class'] ) . '">'; |
|
| 44 | + |
|
| 45 | + if ( isset( $this->value ) && is_array( $this->value ) ) { |
|
| 46 | + foreach ( $this->value as $k => $value ) { |
|
| 47 | + if ( '' !== $value || ( true === $this->field['show_empty'] ) ) { |
|
| 48 | + echo '<li>'; |
|
| 49 | + echo '<input |
|
| 50 | 50 | type="text" |
| 51 | 51 | id="' . esc_attr( $this->field['id'] . '-' . $k ) . '" |
| 52 | 52 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[]" |
| 53 | 53 | value="' . esc_attr( $value ) . '" |
| 54 | 54 | class="regular-text" /> '; |
| 55 | 55 | |
| 56 | - echo '<a |
|
| 56 | + echo '<a |
|
| 57 | 57 | data-id="' . esc_attr( $this->field['id'] ) . '-ul" |
| 58 | 58 | href="javascript:void(0);" |
| 59 | 59 | class="deletion redux-multi-text-remove">' . |
| 60 | - esc_html__( 'Remove', 'redux-framework' ) . '</a>'; |
|
| 61 | - echo '</li>'; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } elseif ( true === $this->field['show_empty'] ) { |
|
| 65 | - echo '<li>'; |
|
| 66 | - echo '<input |
|
| 60 | + esc_html__( 'Remove', 'redux-framework' ) . '</a>'; |
|
| 61 | + echo '</li>'; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } elseif ( true === $this->field['show_empty'] ) { |
|
| 65 | + echo '<li>'; |
|
| 66 | + echo '<input |
|
| 67 | 67 | type="text" |
| 68 | 68 | id="' . esc_attr( $this->field['id'] . '-0' ) . '" |
| 69 | 69 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[]" |
| 70 | 70 | value="" |
| 71 | 71 | class="regular-text" /> '; |
| 72 | 72 | |
| 73 | - echo '<a |
|
| 73 | + echo '<a |
|
| 74 | 74 | data-id="' . esc_attr( $this->field['id'] ) . '-ul" |
| 75 | 75 | href="javascript:void(0);" |
| 76 | 76 | class="deletion redux-multi-text-remove">' . |
| 77 | - esc_html__( 'Remove', 'redux-framework' ) . '</a>'; |
|
| 77 | + esc_html__( 'Remove', 'redux-framework' ) . '</a>'; |
|
| 78 | 78 | |
| 79 | - echo '</li>'; |
|
| 80 | - } |
|
| 79 | + echo '</li>'; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - $the_name = ''; |
|
| 83 | - if ( isset( $this->value ) && empty( $this->value ) && false === $this->field['show_empty'] ) { |
|
| 84 | - $the_name = $this->field['name'] . $this->field['name_suffix']; |
|
| 85 | - } |
|
| 82 | + $the_name = ''; |
|
| 83 | + if ( isset( $this->value ) && empty( $this->value ) && false === $this->field['show_empty'] ) { |
|
| 84 | + $the_name = $this->field['name'] . $this->field['name_suffix']; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - echo '<li style="display:none;">'; |
|
| 88 | - echo '<input |
|
| 87 | + echo '<li style="display:none;">'; |
|
| 88 | + echo '<input |
|
| 89 | 89 | type="text" |
| 90 | 90 | id="' . esc_attr( $this->field['id'] ) . '" |
| 91 | 91 | name="' . esc_attr( $the_name ) . '" |
| 92 | 92 | value="" |
| 93 | 93 | class="regular-text" /> '; |
| 94 | 94 | |
| 95 | - echo '<a |
|
| 95 | + echo '<a |
|
| 96 | 96 | data-id="' . esc_attr( $this->field['id'] ) . '-ul" |
| 97 | 97 | href="javascript:void(0);" |
| 98 | 98 | class="deletion redux-multi-text-remove">' . |
| 99 | - esc_html__( 'Remove', 'redux-framework' ) . '</a>'; |
|
| 100 | - |
|
| 101 | - echo '</li>'; |
|
| 102 | - echo '</ul>'; |
|
| 103 | - |
|
| 104 | - echo '<span style="clear:both;display:block;height:0;"></span>'; |
|
| 105 | - $this->field['add_number'] = ( isset( $this->field['add_number'] ) && is_numeric( $this->field['add_number'] ) ) ? $this->field['add_number'] : 1; |
|
| 106 | - echo '<a href="javascript:void(0);" class="button button-primary redux-multi-text-add" data-add_number="' . esc_attr( $this->field['add_number'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '-ul" data-name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '">' . esc_html( $this->field['add_text'] ) . '</a><br/>'; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Enqueue Function. |
|
| 111 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 112 | - * |
|
| 113 | - * @since 1.0.0 |
|
| 114 | - * @access public |
|
| 115 | - * @return void |
|
| 116 | - */ |
|
| 117 | - public function enqueue() { |
|
| 118 | - wp_enqueue_script( |
|
| 119 | - 'redux-field-multi-text', |
|
| 120 | - Redux_Core::$url . 'inc/fields/multi_text/redux-multi-text' . Redux_Functions::is_min() . '.js', |
|
| 121 | - array( 'jquery', 'redux-js' ), |
|
| 122 | - $this->timestamp, |
|
| 123 | - true |
|
| 124 | - ); |
|
| 125 | - |
|
| 126 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 127 | - wp_enqueue_style( |
|
| 128 | - 'redux-field-multi-text', |
|
| 129 | - Redux_Core::$url . 'inc/fields/multi_text/redux-multi-text.css', |
|
| 130 | - array(), |
|
| 131 | - $this->timestamp |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 99 | + esc_html__( 'Remove', 'redux-framework' ) . '</a>'; |
|
| 100 | + |
|
| 101 | + echo '</li>'; |
|
| 102 | + echo '</ul>'; |
|
| 103 | + |
|
| 104 | + echo '<span style="clear:both;display:block;height:0;"></span>'; |
|
| 105 | + $this->field['add_number'] = ( isset( $this->field['add_number'] ) && is_numeric( $this->field['add_number'] ) ) ? $this->field['add_number'] : 1; |
|
| 106 | + echo '<a href="javascript:void(0);" class="button button-primary redux-multi-text-add" data-add_number="' . esc_attr( $this->field['add_number'] ) . '" data-id="' . esc_attr( $this->field['id'] ) . '-ul" data-name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '">' . esc_html( $this->field['add_text'] ) . '</a><br/>'; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Enqueue Function. |
|
| 111 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 112 | + * |
|
| 113 | + * @since 1.0.0 |
|
| 114 | + * @access public |
|
| 115 | + * @return void |
|
| 116 | + */ |
|
| 117 | + public function enqueue() { |
|
| 118 | + wp_enqueue_script( |
|
| 119 | + 'redux-field-multi-text', |
|
| 120 | + Redux_Core::$url . 'inc/fields/multi_text/redux-multi-text' . Redux_Functions::is_min() . '.js', |
|
| 121 | + array( 'jquery', 'redux-js' ), |
|
| 122 | + $this->timestamp, |
|
| 123 | + true |
|
| 124 | + ); |
|
| 125 | + |
|
| 126 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 127 | + wp_enqueue_style( |
|
| 128 | + 'redux-field-multi-text', |
|
| 129 | + Redux_Core::$url . 'inc/fields/multi_text/redux-multi-text.css', |
|
| 130 | + array(), |
|
| 131 | + $this->timestamp |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | class_alias( 'Redux_Multi_Text', 'ReduxFramework_Multi_Text' ); |
@@ -14,86 +14,86 @@ discard block |
||
| 14 | 14 | // Don't duplicate me! |
| 15 | 15 | if ( ! class_exists( 'Redux_Options_Object', false ) ) { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Main Redux_options_object class |
|
| 19 | - * |
|
| 20 | - * @since 1.0.0 |
|
| 21 | - */ |
|
| 22 | - class Redux_Options_Object extends Redux_Field { |
|
| 23 | - |
|
| 24 | - public $is_field; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Redux_Options_Object constructor. |
|
| 28 | - * |
|
| 29 | - * @param array $field Field array. |
|
| 30 | - * @param mixed $value Value array. |
|
| 31 | - * @param object $parent ReduxFramework object. |
|
| 32 | - * |
|
| 33 | - * @throws ReflectionException . |
|
| 34 | - */ |
|
| 35 | - public function __construct( array $field, $value, $parent ) { |
|
| 36 | - parent::__construct( $field, $value, $parent ); |
|
| 37 | - |
|
| 38 | - $this->is_field = $this->parent->extensions['options_object']->is_field; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Set field defaults. |
|
| 43 | - */ |
|
| 44 | - public function set_defaults() { |
|
| 45 | - $defaults = array( |
|
| 46 | - 'options' => array(), |
|
| 47 | - 'stylesheet' => '', |
|
| 48 | - 'output' => true, |
|
| 49 | - 'enqueue' => true, |
|
| 50 | - 'enqueue_frontend' => true, |
|
| 51 | - ); |
|
| 52 | - |
|
| 53 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Field Render Function. |
|
| 58 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 59 | - * |
|
| 60 | - * @since 1.0.0 |
|
| 61 | - * @access public |
|
| 62 | - * @return void |
|
| 63 | - */ |
|
| 64 | - public function render() { |
|
| 65 | - if ( version_compare( phpversion(), '5.3.0', '>=' ) ) { |
|
| 66 | - $json = wp_json_encode( $this->parent->options, true ); |
|
| 67 | - } else { |
|
| 68 | - $json = wp_json_encode( $this->parent->options ); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $defaults = array( |
|
| 72 | - 'full_width' => true, |
|
| 73 | - 'overflow' => 'inherit', |
|
| 74 | - ); |
|
| 75 | - |
|
| 76 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 77 | - |
|
| 78 | - if ( $this->is_field ) { |
|
| 79 | - $full_width = $this->field['full_width']; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - $do_close = false; |
|
| 83 | - |
|
| 84 | - $id = $this->parent->args['opt_name'] . '-' . $this->field['id']; |
|
| 85 | - |
|
| 86 | - if ( ! $this->is_field || ( $this->is_field && false === $full_width ) ) { |
|
| 87 | - ?> |
|
| 17 | + /** |
|
| 18 | + * Main Redux_options_object class |
|
| 19 | + * |
|
| 20 | + * @since 1.0.0 |
|
| 21 | + */ |
|
| 22 | + class Redux_Options_Object extends Redux_Field { |
|
| 23 | + |
|
| 24 | + public $is_field; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Redux_Options_Object constructor. |
|
| 28 | + * |
|
| 29 | + * @param array $field Field array. |
|
| 30 | + * @param mixed $value Value array. |
|
| 31 | + * @param object $parent ReduxFramework object. |
|
| 32 | + * |
|
| 33 | + * @throws ReflectionException . |
|
| 34 | + */ |
|
| 35 | + public function __construct( array $field, $value, $parent ) { |
|
| 36 | + parent::__construct( $field, $value, $parent ); |
|
| 37 | + |
|
| 38 | + $this->is_field = $this->parent->extensions['options_object']->is_field; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Set field defaults. |
|
| 43 | + */ |
|
| 44 | + public function set_defaults() { |
|
| 45 | + $defaults = array( |
|
| 46 | + 'options' => array(), |
|
| 47 | + 'stylesheet' => '', |
|
| 48 | + 'output' => true, |
|
| 49 | + 'enqueue' => true, |
|
| 50 | + 'enqueue_frontend' => true, |
|
| 51 | + ); |
|
| 52 | + |
|
| 53 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Field Render Function. |
|
| 58 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 59 | + * |
|
| 60 | + * @since 1.0.0 |
|
| 61 | + * @access public |
|
| 62 | + * @return void |
|
| 63 | + */ |
|
| 64 | + public function render() { |
|
| 65 | + if ( version_compare( phpversion(), '5.3.0', '>=' ) ) { |
|
| 66 | + $json = wp_json_encode( $this->parent->options, true ); |
|
| 67 | + } else { |
|
| 68 | + $json = wp_json_encode( $this->parent->options ); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $defaults = array( |
|
| 72 | + 'full_width' => true, |
|
| 73 | + 'overflow' => 'inherit', |
|
| 74 | + ); |
|
| 75 | + |
|
| 76 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 77 | + |
|
| 78 | + if ( $this->is_field ) { |
|
| 79 | + $full_width = $this->field['full_width']; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + $do_close = false; |
|
| 83 | + |
|
| 84 | + $id = $this->parent->args['opt_name'] . '-' . $this->field['id']; |
|
| 85 | + |
|
| 86 | + if ( ! $this->is_field || ( $this->is_field && false === $full_width ) ) { |
|
| 87 | + ?> |
|
| 88 | 88 | <style>#<?php echo esc_html( $id ); ?>{padding: 0;}</style> |
| 89 | 89 | <?php // phpcs:ignore WordPress.CodeAnalysis.EmptyStatement ?> |
| 90 | 90 | <?php echo '</td></tr></table>'; ?> |
| 91 | 91 | <table id="<?php echo esc_attr( $id ); ?>" class="form-table no-border redux-group-table redux-raw-table" style=" overflow: <?php esc_attr( $this->field['overflow'] ); ?>;"> |
| 92 | 92 | <tbody><tr><td> |
| 93 | 93 | <?php |
| 94 | - $do_close = true; |
|
| 95 | - } |
|
| 96 | - ?> |
|
| 94 | + $do_close = true; |
|
| 95 | + } |
|
| 96 | + ?> |
|
| 97 | 97 | <fieldset |
| 98 | 98 | id="<?php echo esc_attr( $id ); ?>-fieldset" |
| 99 | 99 | class="redux-field redux-container-<?php echo esc_attr( $this->field['type'] ) . ' ' . esc_attr( $this->field['class'] ); ?>" |
@@ -117,34 +117,34 @@ discard block |
||
| 117 | 117 | <td> |
| 118 | 118 | <?php } ?> |
| 119 | 119 | <?php |
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Enqueue Function. |
|
| 124 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 125 | - * |
|
| 126 | - * @since 1.0.0 |
|
| 127 | - * @access public |
|
| 128 | - * @return void |
|
| 129 | - */ |
|
| 130 | - public function enqueue() { |
|
| 131 | - wp_enqueue_script( |
|
| 132 | - 'redux-extension-options-object', |
|
| 133 | - $this->url . 'redux-options-object' . Redux_Functions::is_min() . '.js', |
|
| 134 | - array( 'jquery', 'redux-js' ), |
|
| 135 | - Redux_Extension_Options_Object::$version, |
|
| 136 | - true |
|
| 137 | - ); |
|
| 138 | - |
|
| 139 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 140 | - wp_enqueue_style( |
|
| 141 | - 'redux-options-object', |
|
| 142 | - $this->url . 'redux-options-object.css', |
|
| 143 | - array(), |
|
| 144 | - Redux_Extension_Options_Object::$version, |
|
| 145 | - 'all' |
|
| 146 | - ); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Enqueue Function. |
|
| 124 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 125 | + * |
|
| 126 | + * @since 1.0.0 |
|
| 127 | + * @access public |
|
| 128 | + * @return void |
|
| 129 | + */ |
|
| 130 | + public function enqueue() { |
|
| 131 | + wp_enqueue_script( |
|
| 132 | + 'redux-extension-options-object', |
|
| 133 | + $this->url . 'redux-options-object' . Redux_Functions::is_min() . '.js', |
|
| 134 | + array( 'jquery', 'redux-js' ), |
|
| 135 | + Redux_Extension_Options_Object::$version, |
|
| 136 | + true |
|
| 137 | + ); |
|
| 138 | + |
|
| 139 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 140 | + wp_enqueue_style( |
|
| 141 | + 'redux-options-object', |
|
| 142 | + $this->url . 'redux-options-object.css', |
|
| 143 | + array(), |
|
| 144 | + Redux_Extension_Options_Object::$version, |
|
| 145 | + 'all' |
|
| 146 | + ); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | } |