Example #1
0
 public static function init()
 {
     self::$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
     if (!empty($_SESSION['CLIENT']['name'])) {
         self::$name = $_SESSION['CLIENT']['name'];
         self::$version = (int) $_SESSION['CLIENT']['version'];
         return;
     }
     /*
      * maemo, epiphany, flock and galeon have "firefox" in their UA
      * chimera is an on old name of camino
      * cheshire, midori, omniweb, shiira and sunrise have "safari" in their UA
      * We don't detect MyIE2, AOL and America Online branded versions of MSIE
      * Sylera is a Japanese Gecko based browser
      */
     if (preg_match('#(crazy|maxthon|avant|webtv|ubvision|slimbrowser|slimbrowser)#', self::$ua, $match) || preg_match('#(elinks|opera|shiira|devontech|ibrowse|icab|conkeror|chimera|classilla|gnuzilla)#', self::$ua, $match) || preg_match('#(maemo|epiphany|flock|galeon|cheshire|midori|omniweb|swiftfox|iceweasel|swiftweasel)#', self::$ua, $match) || preg_match('#(konqueror|voyager|links|lynx|w3m|dillo|netscape|thunderbird|camino|seamonkey|linspire|multizilla|k\\-meleon|kazehakase|minimo)#', self::$ua, $match) || preg_match('#(chrome|safari|firefox)/([0-9]+(\\.[0-9]+)?)#', self::$ua, $match) || preg_match('#(msie) (1?[0-9](\\.[0-9])?)#', self::$ua, $match) || preg_match('#(webwasher)#', self::$ua, $match)) {
         if ('ubvision' === $match[1]) {
             $match[1] = 'ultrabrowser';
         }
         self::$name = $match[1];
         if (isset($match[2])) {
             self::$version = intval($match[2]);
         }
         if (('opera' === self::$name || 'safari' === self::$name) && preg_match('#version/([0-9]+(\\.[0-9]+)?)#', self::$ua, $match)) {
             self::$version = floatval($match[1]);
         }
     } else {
         if (preg_match('#(firebird|phoenix|bonecho|granparadiso|minefield|shiretoko)[\\/ ]([0-9]+(\\.[0-9]+)?)#', self::$ua)) {
             self::$name = 'firefox';
         } else {
             if (preg_match('#^mozilla/5.+gecko/200#', self::$ua)) {
                 self::$name = 'mozilla';
             }
         }
     }
     $_SESSION['CLIENT']['name'] = self::$name;
     $_SESSION['CLIENT']['version'] = self::$version;
 }