diff --git a/lib/Browser.php b/lib/Browser.php
index ef052bb..3b4950e 100644
--- a/lib/Browser.php
+++ b/lib/Browser.php
@@ -75,10 +75,11 @@ class Browser
const BROWSER_CHROME = 'Chrome'; // http://www.google.com/chrome
const BROWSER_ANDROID = 'Android'; // http://www.android.com/
const BROWSER_GOOGLEBOT = 'GoogleBot'; // http://en.wikipedia.org/wiki/Googlebot
+ const BROWSER_TWITTER = 'Twitter';
+ const BROWSER_APACHE_CLIENT = 'Apache Client';
const BROWSER_CURL = 'cURL'; // https://en.wikipedia.org/wiki/CURL
const BROWSER_WGET = 'Wget'; // https://en.wikipedia.org/wiki/Wget
-
const BROWSER_YANDEXBOT = 'YandexBot'; // http://yandex.com/bots
const BROWSER_YANDEXIMAGERESIZER_BOT = 'YandexImageResizer'; // http://yandex.com/bots
const BROWSER_YANDEXIMAGES_BOT = 'YandexImages'; // http://yandex.com/bots
@@ -142,6 +143,10 @@ class Browser
const PLATFORM_JAVA_ANDROID = "Java/Android";
const PLATFORM_POSTMAN = "Postman";
const PLATFORM_I_FRAME = "Iframely";
+ const PLATFORM_FACEBOOK = 'Facebook Platform';
+ const PLATFORM_GOOGLE_API = 'Google API';
+ const PLATFORM_TWITTERBOOT = 'Twitter Boot';
+ const PLATFORM_APACHE = 'Apache';
const OPERATING_SYSTEM_UNKNOWN = 'unknown';
@@ -390,6 +395,20 @@ public function __toString()
"Browser User Agent String: {$this->getUserAgent()}
\n" .
"Platform: {$this->getPlatform()}
";
}
+
+ /**
+ * UPDATE: Ivijan-Stefan Stipic
+ * Returns a formatted array with a all informations of the browser.
+ * @return array with a all informations of the browser
+ */
+ public function __toArray() {
+ return array(
+ 'browser' => $this->getBrowser(),
+ 'version' => $this->getVersion(),
+ 'user_agent' => $this->getUserAgent(),
+ 'platform' => $this->getPlatform()
+ );
+ }
/**
* Protected routine to calculate and determine what the browser is in use (including platform)
@@ -977,6 +996,45 @@ protected function checkBrowserInternetExplorer()
return true;
}
}
+ /*
+ UPDATE: Ivijan-Stefan Stipic
+ -Test versions for IE8,9,10,11...
+ -Facebook, Google, Twitter platforms
+ */
+ else if( stripos($this->_agent,'trident') !== false && stripos($this->_agent,'windows') !== false && stripos($this->_agent,'rv') !== false ) {
+ $aversion = explode(' ',stristr($this->_agent,'rv:'));
+ $this->setVersion(str_replace('rv:','',$aversion[0]));
+ $this->setBrowser(self::BROWSER_IE);
+ return true;
+ }
+ else if( stripos($this->_agent,'facebook') !== false && stripos($this->_agent,'externalhit') !== false) {
+ $aversion = explode(' ',stristr($this->_agent,'facebookexternalhit/'));
+ $this->setPlatform(self::PLATFORM_FACEBOOK);
+ $this->setVersion(str_replace('facebookexternalhit/','',$aversion[0]));
+ $this->setBrowser(self::BROWSER_FACEBOOK);
+ return true;
+ }
+ else if( stripos($this->_agent,'Google-HTTP-Java-Client') !== false) {
+ $aversion = explode(' ',stristr($this->_agent,'Google-HTTP-Java-Client/'));
+ $this->setPlatform(self::PLATFORM_GOOGLE_API);
+ $this->setVersion(str_replace('Google-HTTP-Java-Client/','',$aversion[0]));
+ $this->setBrowser(self::BROWSER_GOOGLEBOT);
+ return true;
+ }
+ else if( stripos($this->_agent,'Twitterbot') !== false) {
+ $aversion = explode('/',$this->_agent);
+ $this->setPlatform(self::PLATFORM_TWITTERBOOT);
+ $this->setVersion($aversion[1]);
+ $this->setBrowser(self::BROWSER_TWITTER);
+ return true;
+ }
+ else if( stripos($this->_agent,'Jakarta') !== false && stripos($this->_agent,'HttpClient') !== false ) {
+ $aversion = explode('/',$this->_agent);
+ $this->setPlatform(self::PLATFORM_APACHE);
+ $this->setVersion($aversion[1]);
+ $this->setBrowser(self::BROWSER_APACHE_CLIENT);
+ return true;
+ }
return false;
}
@@ -1024,13 +1082,17 @@ protected function checkBrowserOpera()
return true;
} else if (stripos($this->_agent, 'OPR') !== false) {
$resultant = stristr($this->_agent, 'OPR');
- if (preg_match('/\//', $resultant)) {
+ if( preg_match('/Version\/(10.*)$/',$resultant,$matches) ) {
+ $this->setVersion($matches[1]);
+ }
+ else if (preg_match('/\//', $resultant)) {
$aresult = explode('/', str_replace("(", " ", $resultant));
if (isset($aresult[1])) {
$aversion = explode(' ', $aresult[1]);
$this->setVersion($aversion[0]);
}
- }
+ }
+
if (stripos($this->_agent, 'Mobile') !== false) {
$this->setMobile(true);
}
@@ -1805,6 +1867,8 @@ protected function checkPlatform()
$this->_platform = self::PLATFORM_POSTMAN;
} elseif (stripos($this->_agent, 'Iframely') !== false) {
$this->_platform = self::PLATFORM_I_FRAME;
+ } else {
+ $this->_platform = self::PLATFORM_UNKNOWN;
}
}
}