Location: PHPKode > scripts > Advanced User Agent > stnc_userAgent.php
<?php
/*
################################################################################
#                           Stnc Browser Detector                          #
################################################################################
# Class Name :Advanced Browser Detector
# Script-Version:     2.0                     #
# File-Release-Date:  17,07,2010              #
# Official web site and latest version:       #
#============================================================================== #
# Authors: selman tunç (<hide@address.com)   #
# Copyright © 2010 stncweb.net  -   selmantunc.com All Rights Reserved.      
#
# Thank you   
# Codeigniter framework (user.agent.php "class") -> http://codeigniter.com/    #
# PHP-Web-Stat  -> http://www.php-web-statistik.de
################################################################################
*/
/* Licence
 *################################################################################
 * | This program is free software; you can redistribute it and/or             |
 * | modify it under the terms of the GNU General var License              	   |
 * | as published by the Free Software Foundation; either version 2            |
 * | of the License, or (at your option) any later version.                    |
 * |                                                                           |
 * | This program is distributed in the hope that it will be useful,           |
 * | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
 * | GNU General var License for more details.                            	   |
 * |                                                                           |
 * +---------------------------------------------------------------------------+
 */
class detector {

  var $is_mobile = false;
  var $is_browser = false;
  var $is_vip_bot=false;
  var $is_robot=false;
  
   var $browser = NULL;
   var $mobile_browser=  NULL;
   var $vip_bot=  NULL; 
   var $robot=  NULL;
   var $operating_system=NULL;
   var $browser_lang=NULL;
  var $basic_browser=NULL;
    var $agent = NULL; 
//kurucu
function detector ($agent)
{
$this->agent=$agent ;
 $this->mobile_browser_detection() ; 
$this->browser_detection(); 
$this->vip_bot_detection ();
$this->browser_lang_detection(); 
$this->robot_detection ();
$this->operating_system_detection (); 
$this->basic_browser_detection();
}
   
function browser_detection (  )
{
 $browser_patterns = array
  (
    "(firefox).(([0-9]{1,2}\.[0-9]{1,3})?(\.[0-9]{1,3})?)"    => "Firefox",
   "(opera).([0-9]{1,2}\.[0-9]{1,3})"                         => "Opera",
   "(opera).([0-9]{1,2}\.[0-9x]{1,3})"                        => "Opera23",
   "(netscape).{1,2}([0-9]{1,2}\.[0-9]{1,4}(\.[0-9]{1,3})?)"  => "Netscape",
   "(OmniWeb).v([0-9]{1,3}(\.[0-9]{1,3})?)"                   => "OmniWeb",
   "(chrome).([0-9]{1,3}(\.[0-9]{1,3})?)"                     => "Google Chrome",
   "(safari).([0-9]{1,3}(\.[0-9]{1,3})?)"                     => "Safari",
//new codeigniter 
   	'Chimera'      		 									=> 'Chimera',
	'Phoenix'				    				    		=> 'Phoenix',
    'Firebird'   		              		 				=> 'Firebird',
	'icab'      										    => 'iCab',
	'hotjava'      										    => 'HotJava',
	'amaya'      			 								=> 'Amaya',

   
   
   "(seamonkey).([0-9]{1,3}(\.[0-9]{1,3})?)"                  => "Mozilla SeaMonkey",
   "(galeon).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"      => "Mozilla Galeon",
   "(camino).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"      => "Mozilla Camino",
   "(epiphany).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"    => "Mozilla Epiphany",
   "(Shiira).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"      => "Mozilla Shiira",
   "(k-meleon).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"    => "Mozilla K-Meleon",
   "(Mnenhy).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"      => "Mozilla Mnenhy",
   "(MultiZilla).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"  => "Mozilla MultiZilla",
   "(mozilla).+rv:([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)" => "Mozilla",
   
   "(msie).([0-9]{1,2}\.[0-9]{1,2}).+(crazy browser)"         => "IE CrazyBrowser",
   "(msie).([0-9]{1,2}\.[0-9]{1,2}).+slimBrowser"             => "IE SlimBrowser",
   "(msie).([0-9]{1,2}\.[0-9]{1,2}).+(deepnet explorer)"      => "IE DeepnetExplorer",
   "(msie).([0-9]{1,2}\.[0-9]{1,2}).+netcaptor"               => "IE NetCaptor",
   "(msie).([0-9]{1,2}\.[0-9]{1,2}).+(maxthon|myie2)"         => "IE Maxthon",
   "(msie) ([0-9]{1,2}\.[0-9]{1,2})"                          => "Internet Explorer",
   
   "(java)([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2})"               => "Java",
   "(NetPositive)\/([0-9]{1,2}\.[0-9]{0,3})"                  => "NetPositive",
   "(FrontPage)([0-9]{1,2}\.[0-9]{1,2})"                      => "MS FrontPage",
   "(PHP)\/([0-9]{1,2}\.[0-9]{1,2})"                          => "PHP",
   "(WebWasher)([0-9]{1,2}\.[0-9]{1,2})"                      => "WebWasher",
   "(konqueror).([0-9]{1,2}(\.[0-9])?)"                       => "Konqueror",
   "(lynx)"                 								  => "Lynx",
   "(mosaic)"               								  => "Mosaic",
   "(links).*([0-9]{1,2}\.[0-9]{1,2})"                        => "Links",
   "(OffByOne)"             								  => "OffByOne",
   "(ELinks)"               								  => "ELinks",
   "(teleport pro)\/([0-9\.]{1,9})"                           => "Teleport Pro",
   "(Amiga-AWeb)\/([0-9 ]{1}\.[0-9]{1,2}\.[0-9]{1,4})"        => "Amiga-AWeb",
   "(amigavoyager)\/([0-9]{1}\.[0-9]{1,2}\.[0-9]{1,4})"       => "AmigaVoyager",
   "(AvantGo)([0-9]{1}\.[0-9]{1,2})"                          => "AvantGo",
   "(AvantGo)([0-9]{1}\.[0-9]{1,2})"                          => "BrowserEmulator",
   "(cosmos)\/([0-9]{1,2}\.[0-9]{1,3})"                       => "Cosmos",
   "(da)([0-9]{1,2}\.[0-9]{1,3})"                             => "Download Accelerator",
   "(flashget)"             								  => "FlashGet",
   "(GetRight)\/([0-9]{1,2}\.[0-9b]{1,3})"                    => "GetRight",
   "(gigabaz)\/([0-9]{1,2}\.[0-9]{1,3})"                      => "GigaBaz",
   "(go!zilla)([0-9]{1,2}\.[0-9b]{1,3})"                      => "Go!zilla",
   "(gozilla)([0-9]{1,2}\.[0-9b]{1,3})"                       => "Go!zilla",
   "(ibrowse)\/([0-9]{1,2}\.[0-9]{1,3})"                      => "IBrowser",
   "(ICS) ([0-9]{1,2}\.[0-9]{1,3}\.[0-9]{1,3})"               => "ICS",
   "(lwp-trivial)\/([0-9]{1,2}\.[0-9]{1,3})"                  => "lpw-trivial",
   "(Lotus-Notes)\/([0-9]{1,2}\.[0-9]{1,3})"                  => "Lotus-Notes",
   "(msproxy)\/([0-9]{1,2}\.[0-9]{0,3})"                      => "MSProxy",
   "(NetAnts)\/([0-9]{1,2}\.[0-9]{0,3})"                      => "NetAnts",
   "(offline explorer)\/([0-9]{1,2}\.[0-9]{0,3})"             => "Offline Explorer",
   "(Penetrator)([0-9]{1,2}\.[0-9]{0,3})"                     => "Penetrator",
   "(planetweb)\/([0-9]{1,2}\.[0-9ab]{0,4})"                  => "Planetweb",
   "(PowerNet)\/([0-9]{1,2}\.[0-9]{0,4})"                     => "PowerNet",
   "(Rotondo)\/([0-9]{1,2}\.[0-9]{0,3})"                      => "Rotondo",
   "(UP\.Browser)\/([0-9]{1,2}\.[0-9]{0,3})"                  => "UP.Browser",
   "(w3m)"                  								  => "W3M",
   "(WebCapture)([0-9]{1,2}\.[0-9]{0,3})"                     => "WebCapture",
   "(WebCopier v)([0-9]{1,2}\.[0-9]{0,3})"                    => "WebCopier",
   "(webcollage)\/([0-9]{1,2}\.[0-9]{0,3})"                   => "Webcollage",
   "(WebScrape)\/([0-9]{1,2}\.[0-9]{0,3})"                    => "WebScrape",
   "(web downloader)(\/[0-9]{1,2}\.[0-9]{0,1})"               => "Web Downloader",
   "(mas downloader)(\/[0-9]{1,2}\.[0-9]{0,1})"               => "Web Downloader",
   "(webstripper)\/([0-9]{1,2}\.[0-9]{0,3})"                  => "WebStripper",
   "(WebZIP)\/([0-9]{1,2}\.[0-9]{0,3})"                       => "WebZIP",
   "(webtv)"               									  => "WebTv",
   "(Wget)\/([0-9]{1,2}\.[0-9]{0,3})"                         => "WGet",
   "(Dillo).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"       => "Dillo",
   
   //mobil browsers
      // legacy array, old values commented out
   'mobileexplorer'	    => 'Mobile Explorer',
   'openwave'			=> 'Open Wave',
   'opera mini'		    => 'Opera Mini',
   'operamini'			=> 'Opera Mini',
   'elaine'			    => 'Palm',
   'palmsource'		    => 'Palm',
   'digital paths'		=> 'Palm',
   'avantgo'			=> 'Avantgo',
   'xiino'				=> 'Xiino',
   'palmscape'			=> 'Palmscape',
//   'nokia'				=> 'Nokia',
//   'ericsson'			=> 'Ericsson',
//   'blackberry'		=> 'BlackBerry',
//   'motorola'			=> 'Motorola'

   // Phones and Manufacturers
				   
   'motorola'			=> "Motorola",
   'nokia'				=> "Nokia",
   'palm'				=> "Palm",
   'iphone'			    => "Apple iPhone",
   'ipod'				=> "Apple iPod Touch",
   'sony'				=> "Sony Ericsson",
   'ericsson'			=> "Sony Ericsson",
   'blackberry'		    => "BlackBerry",
   'cocoon'		     	=> "O2 Cocoon",
   'blazer'		    	=> "Treo",
   'lg'				    => "LG",
   'amoi'				=> "Amoi",
   'xda'				=> "XDA",
   'mda'				=> "MDA",
   'vario'				=> "Vario",
   'htc'				=> "HTC",
   'samsung'			=> "Samsung",
   'sharp'				=> "Sharp",
   'sie-'				=> "Siemens",
   'alcatel'			=> "Alcatel",
   'benq'				=> "BenQ",
   'ipaq'				=> "HP iPaq",
   'mot-'				=> "Motorola",
   'playstation portable' 	=> "PlayStation Portable",
   'hiptop'		    	=> "Danger Hiptop",
   'nec-'				=> "NEC",
   'panasonic'			=> "Panasonic",
   'philips'			=> "Philips",
   'sagem'				=> "Sagem",
   'sanyo'				=> "Sanyo",
   'spv'				=> "SPV",
   'zte'				=> "ZTE",
   'sendo'				=> "Sendo",

   // Operating Systems
   'symbian'				=> "Symbian",
   'SymbianOS'				=> "SymbianOS", 
   'elaine'				    => "Palm",
   'palm'   				=> "Palm",
   'series60'				=> "Symbian S60",
   'windows ce'		    	=> "Windows CE",

   // Browsers
   'obigo'  			    => "Obigo",
   'netfront'				=> "Netfront Browser",
   'openwave'				=> "Openwave Browser",
   'mobilexplorer'			=> "Mobile Explorer",
   'operamini'				=> "Opera Mini",
   'opera mini'	    		=> "Opera Mini",

   // Other
   'digital paths'			=> "Digital Paths",
   'avantgo'				=> "AvantGo",
   'xiino'   				=> "Xiino",
   'novarra'				=> "Novarra Transcoder",
   'vodafone'				=> "Vodafone",
   'docomo'					=> "NTT DoCoMo",
   'o2'  					 => "O2",

   // Fallback
   'mobile'					=> "Generic Mobile",
   'wireless' 				=> "Generic Mobile",
   'j2me'   				=> "Generic Mobile",
   'midp'   				=> "Generic Mobile",
   'cldc'   				=> "Generic Mobile",
   'up.link'				=> "Generic Mobile",
   'up.browser'				=> "Generic Mobile",
   'smartphone'				=> "Generic Mobile",
   'cellphone'				=> "Generic Mobile",
   
   
   
   'msnbot'                 => "MSN Bot",
   'googlebot'              => "Google Bot",
   'mediapartners-google'   => "Google Adsense",
   'inktomi'               => "Yahoo Inktomi Bot",
   'slurp'                  => "Yahoo Slurp Bot",
  //new code igniter
  'yahoo'			        => "Yahoo",
  'askjeeves'               => "AskJeeves",
  'fastcrawler'      		=> "FastCrawler",
  'infoseek'      		    => "InfoSeek bot 1.0",
  'lycos'			        => "Lycos",
   
   
   "baiduspider"            => "bot",
   "job crawler"            => "bot",
   "analyzer"               => "bot",
   "arachnofilia"           => "bot",
   "aspseek"                => "bot",
   "bot"                    => "bot",
   "check"                  => "bot",
   "crawl"                  => "bot",
   "infoseek"               => "bot",
   "netoskop"               => "bot",
   "NetSprint"              => "bot",
   "openfind"               => "bot",
   "roamer"                 => "bot",
   "bot"                    => "bot",
   "rover"                  => "bot",
   "scooter"                => "bot",
   "search"                 => "bot",
   "siphon"                 => "bot",
   "spider"                 => "bot",
   "sweep"                  => "bot",
   "walker"                 => "bot",
   "WebStripper"            => "bot",
   "wisenutbot"             => "bot",
   "gulliver"               => "bot",
   "validator"              => "bot",
   "yandex"                 => "bot",
   "ask jeeves"             => "bot",
   "moget@"                 => "bot",
   "teomaagent"             => "bot",
   "infoNavibot"            => "bot",
   "PPhpDig"                => "bot",
   "gigabaz"                => "bot",
   "Webclipping\.com"       => "bot",
   "RRC"                    => "bot",
   "netmechanic"            => "bot"
   
  );
  
  $browser = "";

  foreach ( $browser_patterns as $browser_pattern => $browser_name )
   {
  
  if ( preg_match ( "/".$browser_pattern."/i" , $this->agent  , $name ) )//orginal
     {
      
      $browser = @$browser_name." ".@$name [ 2 ];
      break;
      
     }
    
   }
    $this->is_browser = true;

  return trim ( $this->browser =$browser );
  
 }
   

  
//codeigniter array
function mobile_browser_detection (  )
{
 
 $mobiles= array
  (
   // legacy array, old values commented out
   'mobileexplorer'		=> "Mobile Explorer",
   'openwave'			=> "Open Wave",
   'opera mini'			=> "Opera Mini",
   'operamini'			=> "Opera Mini",
   'elaine'				=> "Palm",
   'palmsource'			=> "Palm",
   'digital paths'		=> "Palm",
   'avantgo'			=> "Avantgo",
   'xiino'				=> "Xiino",
   'palmscape'			=> "Palmscape",
//   'nokia'			=> 'Nokia',
//   'ericsson'			=> 'Ericsson',
//   'blackberry'		=> 'BlackBerry',
//   'motorola'			=> 'Motorola'

   // Phones and Manufacturers
   
   'motorola'			=> "Motorola",
   'nokia'				=> "Nokia",
   'palm'				=> "Palm",
   'iphone'				=> "Apple iPhone",
   'ipod'				=> "Apple iPod Touch",
   'sony'				=> "Sony Ericsson",
   'ericsson'			=> "Sony Ericsson",
   'blackberry'			=> "BlackBerry",
   'cocoon'				=> "O2 Cocoon",
   'blazer'				=> "Treo",
   'lg'					=> "LG",
   'amoi'				=> "Amoi",
   'xda'				=> "XDA",
   'mda'				=> "MDA",
   'vario'				=> "Vario",
   'htc'				=> "HTC",
   'samsung'			=> "Samsung",
   'sharp'				=> "Sharp",
   'sie-'				=> "Siemens",
   'alcatel'			=> "Alcatel",
   'benq'				=> "BenQ",
   'ipaq'				=> "HP iPaq",
   'mot-'				=> "Motorola",
   'playstation portable' 	=> "PlayStation Portable",
   'hiptop'				=> "Danger Hiptop",
   'nec-'				=> "NEC",
   'panasonic'			=> "Panasonic",
   'philips'			=> "Philips",
   'sagem'				=> "Sagem",
   'sanyo'				=> "Sanyo",
   'spv'				=> "SPV",
   'zte'				=> "ZTE",
   'sendo'				=> "Sendo",

   // Operating Systems
   'symbian'				=> "Symbian",
   'SymbianOS'				=> "SymbianOS", 
   'elaine'					=> "Palm",
   'palm'  					 => "Palm",
   'series60'				=> "Symbian S60",
   'windows ce'				=> "Windows CE",

   // Browsers
   'obigo'  				=> "Obigo",
   'netfront'				=> "Netfront Browser",
   'openwave'				=> "Openwave Browser",
   'mobilexplorer'			=> "Mobile Explorer",
   'operamini'				=> "Opera Mini",
   'opera mini'				=> "Opera Mini",

   
   // Other
   'digital paths'			=> "Digital Paths",
   'avantgo'				=> "AvantGo",
   'xiino' 				    => "Xiino",
   'novarra'				=> "Novarra Transcoder",
   'vodafone'				=> "Vodafone",
   'docomo'					=> "NTT DoCoMo",
   'o2'   					=> "O2",

   // Fallback
/*    'mobile'					=> "Generic Mobile",
   'wireless' 				=> "Generic Mobile",
   'j2me'   				=> "Generic Mobile",
   'midp'   				=> "Generic Mobile",
   'cldc'   				=> "Generic Mobile",
   'up.link'				=> "Generic Mobile",
   'up.browser'				=> "Generic Mobile",
   'smartphone'				=> "Generic Mobile",
   'cellphone'				=> "Generic Mobile" */
				);		
 
  
		if (is_array($mobiles) AND count($mobiles) > 0)
		{		
			foreach ($mobiles as $key => $val)
			{
				if (FALSE !== (strpos(strtolower($this->agent), $key)))
				{
   $this->is_mobile = TRUE;
   $this->mobile_browser= $val;
				
				}
			}
		}	
		return FALSE;
		
			}
  
   
 function vip_bot_detection ( )
{
  $bot_patterns = array
  (
  
   "msnbot"                 => "MSN Bot",
   "googlebot"              => "Google Bot",
   "mediapartners-google"   => "Google Adsense",
   "inktomi"                => "Yahoo Inktomi Bot",
   "slurp"                  => "Yahoo Slurp Bot",
  'yahoo'			        => 'Yahoo',
  'askjeeves'               => 'AskJeeves',
  'fastcrawler'      	    => 'FastCrawler',
  'infoseek'      		    => 'InfoSeek ; 1.0',
  'lycos'			        => 'Lycos',
  );
  
  $bot = "";
  
  foreach ( $bot_patterns as $bot_pattern => $bot_name )
   {
  if ( preg_match ( "/".$bot_pattern."/i" , $this->agent  , $name ) )
     {
      $bot = @$bot_name." ".@$name [ 2 ];
      break;
     }
   }
   $this->is_vip_bot=true;
  
  return trim ( $this->vip_bot= $bot );
  
 }


function browser_lang_detection() {
         $lang=split('[,;]',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
         $lang=strtolower($lang[0]);
         $lang=split('[-]',$lang);
        $this->browser_lang=$lang[0];
}


function robot_detection (  )
{
 $robot_patterns = array
  (

   "msnbot"                 => "MSN Bot",
   "googlebot"              => "Google Bot",
   "mediapartners-google"   => "Google Adsense",
   "inktomi"                => "Yahoo Inktomi Bot",
   "slurp"                  => "Yahoo Slurp Bot",
  "yahoo"			        => "Yahoo",
  "askjeeves"               => "AskJeeves",
  "fastcrawler"      	    => "FastCrawler",
  "infoseek"      		    => "InfoSeek ; 1.0",
  "lycos"			        => "Lycos",
  /////
   "baiduspider"            => "baiduspider bot",
   "job crawler"            => "baiduspiderbot",
   "analyzer"               => "job crawler bot",
   "arachnofilia"           => "arachnofilia bot",
   "aspseek"                => "aspseek bot",
   "bot"                    => "bot",
   "check"                  => "check bot",
   "crawl"                  => "crawl bot",
   "infoseek"               => "infoseek bot",
   "netoskop"               => "netoskop bot",
   "NetSprint"              => "NetSprint bot",
   "openfind"               => "openfind bot",
   "roamer"                 => "roamer bot",
   "rover"                  => "rover bot",
   "scooter"                => "scooter bot",
   "search"                 => "search bot",
   "siphon"                 => "siphon bot",
   "spider"                 => "spider bot",
   "sweep"                  => "sweep bot",
   "walker"                 => "walker bot",
   "WebStripper"            => "WebStripper bot",
   "wisenutbot"             => "wisenutbot bot",
   "gulliver"               => "gulliver bot",
   "validator"              => "validator bot",
   "yandex"                 => "yandex bot",
   "ask jeeves"             => "ask jeeves bot",
   "moget@"                 => "moget@ bot",
   "teomaagent"             => "teomaagent bot",
   "infoNavibot"            => "infoNavibot bot",
   "PPhpDig"                => "PPhpDig bot",
   "gigabaz"                => "gigabaz bot",
   "Webclipping\.com"       => "Webclipping\.com bot",
   "RRC"                    => "RRC bot",
   "netmechanic"            => "netmechanic bot" 
  );
  
  $robot = "";

  foreach ( $robot_patterns as $robot_pattern => $robot_name )
   {

  if ( preg_match ( "/".$robot_pattern."/i" , $this->agent , $name ) )

     {
      
      $robot = @$robot_name." ".@$name [ 2 ];
      break;
      
     }
    
   }
$this-> is_robot=true;
$this->robot=trim ( $robot );
  
 }


function basic_browser_detection()
	{
	    $browser_patterns = array(
					'Opera'				=> 'Opera',
					'MSIE'				=> 'Internet Explorer',
					'Internet Explorer'	=> 'Internet Explorer',
					'chrome'			=> 'Google Chrome',
					/*'webkit'			=> 'webkit',*/
				/* 	'Gecko'			    => 'Gecko', */
					'Firefox'			=> 'Firefox',
					'Shiira'			=> 'Shiira',
					'Chimera'			=> 'Chimera',
					'Phoenix'			=> 'Phoenix',
					'Firebird'			=> 'Firebird',
					'Camino'			=> 'Camino',
					'Netscape'			=> 'Netscape',
					'OmniWeb'			=> 'OmniWeb',
					'Safari'			=> 'Safari',
					'Mozilla'			=> 'Mozilla',
					'Konqueror'			=> 'Konqueror',
					'icab'				=> 'iCab',
					'Lynx'				=> 'Lynx',
					'Links'				=> 'Links',
					'hotjava'			=> 'HotJava',
					'amaya'				=> 'Amaya',
					'IBrowse'			=> 'IBrowse'
					
					
				);
	
	 $browser = "";
	    foreach ( $browser_patterns as $browser_pattern => $browser_name )
   {
  
  if ( preg_match("|".preg_quote($browser_pattern).".*?([0-9\.]+)|i" , $this->agent  , $name ) )//orginal
     {
     $basic_browser_version = $name[1];
   $basic_browser = $browser_name ;
      break;
      
     }
    
   }
    $this->is_browser = true;
$this->basic_browser_version=$basic_browser_version;
  return trim ( $this->basic_browser=$basic_browser);
 
    
 }	


 
	
function operating_system_detection (  )
 {
  
  $os_patterns = array
   (
    
    "(Windows XP)"        									=> "Windows XP",
    "(Windows NT 5.1|Windows NT5.1)"                        => "Windows XP",
    "(Windows 2000)"      									=> "Windows 2000",
    "(Windows NT 5.0)"    									=> "Windows 2000",
    "(Windows NT 4.0|WinNT4.0)"                             => "Windows NT",
    "(Windows NT 5.2)"   									=> "Windows Server 2003",
    "(Windows NT 6.0)"    									=> "Windows Vista",
	"(Windows NT 6.1)"    									=> "Windows 7", 
	"(Windows NT 7.0)"    									=> "Windows 7", 
    "(Windows CE)"        									=> "Windows CE",
    "(media center pc).([0-9]{1,2}\.[0-9]{1,2})"            => "Windows Media Center",
    "(win)([0-9]{1,2}\.[0-9x]{1,2})"                        => "Windows",
    "(win)([0-9]{2})"     									=> "Windows",
    "(windows)([0-9x]{2})"									=> "Windows",
    "(Windows ME)"       								    => "Windows ME",
    "(Win 9x 4.90)"       									=> "Windows ME",
    "(Windows 98|Win98)"  									=> "Windows 98",
    "(Windows 95)"        									=> "Windows 95",
    "(windows)([0-9]{1,2}\.[0-9]{1,2})"                     => "Windows",
    "(win32)"             									=> "Windows",
    "(GetRight)"          									=> "Windows",
    "(go!zilla)"          									=> "Windows",
    "(gozilla)"           									=> "Windows",
    "(gulliver)"          									=> "Windows",
    "(ia archiver)"       									=> "Windows",
    "(NetPositive)"       									=> "Windows",
    "(mass downloader)"   									=> "Windows",
    "(microsoft)"         									=> "Windows",
    "(offline explorer)"  									=> "Windows",
    "(teleport)"          									=> "Windows",
    "(web downloader)"    									=> "Windows",
    "(webcapture)"        									=> "Windows",
    "(webcollage)"        									=> "Windows",
    "(webcopier)"         									=> "Windows",
    "(webstripper)"       									=> "Windows",
    "(webzip)"            									=> "Windows",
    "(wget)"              									=> "Windows",
    "(flashget)"          									=> "Windows",
    "(MS FrontPage)"      									=> "Windows",
    "(msproxy)\/([0-9]{1,2}.[0-9]{1,2})"                    => "Windows",
    "(msie)([0-9]{1,2}.[0-9]{1,2})"                         => "Windows",
    "(UP.Browser)"        									=> "Windows CE",
    "(NetAnts)"           									=> "Windows",
    
    "(java)([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2})"            => "Java",
    "(Solaris)([0-9]{1,2}\.[0-9x]{1,2}){0,1}"               => "Solaris",
    "(dos x86)"           									=> "DOS",
    "(unix)"              									=> "Unix",
    
    "(Mac OS X)"          									=> "Mac OS X",
    "(Mac_PowerPC)"       									=> "Macintosh PowerPC",
    "(mac|Macintosh)"     									=> "Mac OS",
    "(sunos)([0-9]{1,2}\.[0-9]{1,2}){0,1}"                  => "SunOS",
    "(beos)([0-9]{1,2}\.[0-9]{1,2}){0,1}"                   => "BeOS",
    "(risc os)([0-9]{1,2}\.[0-9]{1,2})"                     => "RISC OS",
    "(os\/2)"             									=> "OS/2",
    "(freebsd)"          									=> "FreeBSD",
    "(openbsd)"           									=> "OpenBSD",
    "(netbsd)"            									=> "NetBSD",
    "(irix)"              									=> "IRIX",
    "(plan9)"             									=> "Plan9",
    "(osf)"               									=> "OSF",
    "(aix)"               									=> "AIX",
    "(GNU Hurd)"          									=> "GNU Hurd",
    
    "(fedora)"            									=> "Linux - Fedora",
    "(kubuntu)"           									=> "Linux - Kubuntu",
    "(ubuntu)"            									=> "Linux - Ubuntu",
    "(debian)"            									=> "Linux - Debian",
    "(CentOS)"            									=> "Linux - CentOS",
    "(Mandriva).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)" => "Linux - Mandriva",
    "(SUSE).([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?)"     => "Linux - SUSE",
    "(Dropline)"          									=> "Linux - Slackware",
    "(ASPLinux)"          									=> "Linux - ASPLinux",
    "(Red Hat)"           									=> "Linux - Red Hat",
    "(linux)"             									=> "Linux",
    "(libwww-perl)"       									=> "Unix",
    
    "(amigaos)([0-9]{1,2}\.[0-9]{1,2})"                     => "AmigaOS",
    "(amiga-aweb)"       									 => "AmigaOS",
    "(amiga)"             									=> "Amiga",
    "(AvantGo)"           									=> "PalmOS",
    "(webtv)\/([0-9]{1,2}\.[0-9]{1,2})"                     => "WebTV",
    "(Dreamcast)"        									=> "Dreamcast OS"
    
   );
  
  $operating_system = "";

  
  foreach ( $os_patterns as $os_pattern => $os_name )
   {
    
    if ( preg_match ( "/".$os_pattern."/i" , $this->agent  , $name ) )
     {
      $operating_system = @$os_name." ".@$name [ 2 ];
      break;
     }
    
   }
  
 $this->operating_system=trim ( $operating_system );
  
}}


?>
Return current item: Advanced User Agent