Location: PHPKode > scripts > User Info > user-info/user_info.php
<?php
/*
 This class will grab all the possible information about the user/browser/OS
 Using as many info that the browser send to the user
 and Matching them against a list of possible values
 the function get() it will return the whole list of information

 a sample on how to use this class is at the bottom of this clas
 
 TO-DO:
  - add more possible OS and browser: look at this class:
    - http://www.phpclasses.org/browse/file/6481.html
  - allow plugins
*/
class user_info {
	private $info = array();
	
	public function __construct(){
	}
	
	public function get(){
		if($this->info == array()){
			
			$return['request_uri']		= $this->request_page();
			$return['request_method']	= $this->request_method();
			$return['url']				= $this->url();

			$return['user_agent']		= $this->user_agent();
			$return['browser']			= $this->broser('all');
			$return['os']				= $this->os();
			$return['language']			= $this->language();
			$return['accept']			= $this->accept();
			$return['encoding']			= $this->encoding();
			$return['charset']			= $this->charset();
			$return['IP']				= $this->IP();
			$return['security']			= $this->security();
			$return['is_crawler']		= $this->is_crawler();
			//return the Country
//			$return['country'] = phpAds_geoip_getGeo($IP, dirname(__FILE__).'/files_includes/geoip/GeoIP-106_20040501.dat');
			//check if it is crawler
			$this->info = $return;
		}
		return $this->info;
	}
	public function request_page(){
		//return the REQUEST_URI
		return $_SERVER['REQUEST_URI'];
	}
	public function request_method(){
		//return the request method (get,post ...)
		return $_SERVER['REQUEST_METHOD'];
	}
	public function url(){
		//return the actual url(SCRIPT_NAME,QUERY_STRING)
		if(isset($_SERVER['HTTPS'])){
			$return = 'ssl://';
		} else {
			switch($_SERVER['SERVER_PORT']){
				case 80:
				default:
					$return = 'http://';
			}
		}
		$return .= $_SERVER['HTTP_HOST'];
		$return .= $_SERVER['SCRIPT_NAME'];
		if($_SERVER['QUERY_STRING']!=''){
			$return .= '?'.$_SERVER['QUERY_STRING'];
		}
		return $return;
	}
	public function user_agent(){
		//return the user agent
		return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'';
	}
	public function security(){
		$return = 'unknown';
		$ua = $this->user_agent();
		if(($pos = strpos($ua,' N;')) !== false) {
			$return = 'no'
		}elseif(($pos = strpos($ua,' U;')) !== false) {
			$return = 'strong'
		}elseif(($pos = strpos($ua,' I;')) !== false) {
			$return = 'weak'
		}
		return $return;		
	}
	public function browser($what=''){
		//return the Browser
		$UserAgent = $this->user_agent();
		if(($pos = strpos($UserAgent,'MSIE')) !== false) {
			$Browser='Internet Explorer';
			$pos+=strlen('MSIE')+1;
			$endPos=strpos($UserAgent,';',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Firefox')) !== false) {
			$Browser='Mozilla Firefox';
			$pos+=strlen('Firefox')+1;
			$endPos=strpos($UserAgent,';',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Mozilla Firebird')) !== false) {
			$Browser='Mozilla Firebird';
			$pos+=strlen('Mozilla Firebird')+1;
			$endPos=strpos($UserAgent,';',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Netscape')) !== false) {
			$Browser='Netscape Navigator';
			$pos+=strlen('Netscape')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Konqueror')) !== false) {
			$Browser='Konqueror';
			$pos+=strlen('Konqueror')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Mozilla')) !== false) {
			$Browser='Mozilla';
			$pos+=strlen('Mozilla')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Opera')) !== false) {
			$Browser='Opera';
			$pos+=strlen('Opera')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'msnbot')) !== false) {
			$Browser='MSNBot';
			$pos+=strlen('msnbot')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'HTMLParser')) !== false) {
			$Browser='HTMLParser';
			$pos+=strlen('HTMLParser')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'SurveyBot')) !== false) {
			$Browser='SurveyBot - Whois Source';
			$pos+=strlen('SurveyBot')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Googlebot-Image')) !== false) {
			$Browser='Google Image';
			$pos+=strlen('Googlebot')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Googlebot')) !== false) {
			$Browser='Google';
			$pos+=strlen('Googlebot')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Feedfetcher')) !== false) {
			$Browser='Feedfetcher-Google';
			$pos+=strlen('Feedfetcher')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Gigabot')) !== false) {
			$Browser='Gigabot';
			$pos+=strlen('Gigabot')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Slurp')) !== false) {
			$Browser='Yahoo Slurp';
			$pos+=strlen('Slurp')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else if(($pos = strpos($UserAgent,'Alexa')) !== false) {
			$Browser='Alexa (IA Archive)';
			$pos+=strlen('Alexa')+1;
			$endPos=strpos($UserAgent,' ',$pos);
			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
			$BrowserVersion = substr($UserAgent,$pos,$endPos);
		} else {
			$Browser='Not Detected';
			$BrowserVersion='';
		}
		switch($what){
			case 'all':
				$return['browser'] = $Browser.' v.'.$BrowserVersion;
				$return['name'] = $Browser;
				$return['version'] = $BrowserVersion;
				break;
			case 'name':
				$return		= $Browser;
				break;
			case 'version':
				$return	= $BrowserVersion;
				break;
			default:
				$return	= $Browser.' v.'.$BrowserVersion;
				break;
		}
		return $return;
	}
	
	public function os($what=''){
		//return the OS
		$os = array();
		//amiga
		$os['amiga'] 		= array('name'=>'amiga','version'=>'');
		//dreamcast
		$os['dreamcast']	= array('name'=>'sega dreamcast','version'=>'');
		//googlebot
		$os['googlebot']	= array('name'=>'googlebot','version'=>'');
		//freebsd
		$os['freebsd']		= array('name'=>'freebsd','version'=>'');
		$os['freebsd amd64']= array('name'=>'freebsd','version'=>'amd64');
		$os['freebsd a64']	= array('name'=>'freebsd','version'=>'amd64');
		$os['freebsd i686']	= array('name'=>'freebsd','version'=>'i686');
		$os['freebsd i586']	= array('name'=>'freebsd','version'=>'i586');
		$os['freebsd i486']	= array('name'=>'freebsd','version'=>'i486');
		$os['freebsd i386']	= array('name'=>'freebsd','version'=>'i386');
		$os['freebsd 5']	= array('name'=>'freebsd','version'=>'5.x');
		$os['freebsd 6']	= array('name'=>'freebsd','version'=>'6.x');
		$os['freebsd 7']	= array('name'=>'freebsd','version'=>'7.x');
		//hp-ux
		$os['hp-ux']		= array('name'=>'hp-ux','version'=>'');
		$os['hpux']			= array('name'=>'hp-ux','version'=>'');
		//htmlparser
		$os['htmlparser']	= array('name'=>'htmlparser','version'=>'');
		//irix
		$os['irix'] 		= array('name'=>'irix','version'=>'');
		//liberate
		$os['liberate']		= array('name'=>'liberate','version'=>'');
		//lindows
		$os['lindows']		= array('name'=>'lindows os','version'=>'');
		//linux
		$os['linux']		= array('name'=>'linux','version'=>'');
		$os['linux i686']	= array('name'=>'linux','version'=>'i686');
		$os['linux i586']	= array('name'=>'linux','version'=>'i586');
		$os['linux i486']	= array('name'=>'linux','version'=>'i486');
		$os['linux i386']	= array('name'=>'linux','version'=>'i386');
		$os['linux ppc']	= array('name'=>'linux','version'=>'ppc');
		//mac
		$os['mac']			= array('name'=>'macintosh','version'=>'');
		$os['Mac OS X']		= array('name'=>'macintosh','version'=>'OS X');
		$os['Mac OS X 10_4']		= array('name'=>'macintosh','version'=>'OS X 10.4.x (Tiger)');
		$os['Mac OS X 10_5']		= array('name'=>'macintosh','version'=>'OS X 10.5.x (Leopard)');
		$os['Mac OS X 10_5_2']		= array('name'=>'macintosh','version'=>'OS X 10.5.2 (Leopard)');
		$os['Mac OS X 10_5_3']		= array('name'=>'macintosh','version'=>'OS X 10.5.3 (Leopard)');
		$os['Mac 10']		= array('name'=>'macintosh','version'=>'OS X');
		$os['PowerPC']		= array('name'=>'macintosh','version'=>'PPC');
		$os['PPC']			= array('name'=>'macintosh','version'=>'PPC');
		$os['68000']		= array('name'=>'macintosh','version'=>'68K');
		$os['68k']			= array('name'=>'macintosh','version'=>'68K');
		//netbsd
		$os['netbsd']		= array('name'=>'netbsd','version'=>'');
		$os['netbsd amd64']	= array('name'=>'netbsd','version'=>'amd64');
		$os['netbsd a64']	= array('name'=>'netbsd','version'=>'amd64');
		$os['netbsd i686']	= array('name'=>'netbsd','version'=>'i686');
		$os['netbsd i586']	= array('name'=>'netbsd','version'=>'i586');
		$os['netbsd i486']	= array('name'=>'netbsd','version'=>'i486');
		$os['netbsd i386']	= array('name'=>'netbsd','version'=>'i386');
		//netcraft
		$os['netcraft']		= array('name'=>'netcraft','version'=>'');
		//os/2
		$os['os/2']			= array('name'=>'os/2','version'=>'');
		$os['os2']			= array('name'=>'os/2','version'=>'');
		$os['Warp 4']		= array('name'=>'os/2','version'=>'Warp 4');
		$os['Warp 4.5']		= array('name'=>'os/2','version'=>'Warp 4.5');
		//osf1
		$os['osf1']			= array('name'=>'osf1','version'=>'');
		//openbsd
		$os['openbsd']		= array('name'=>'openbsd','version'=>'');
		$os['openbsd amd64']= array('name'=>'openbsd','version'=>'amd64');
		$os['openbsd a64']	= array('name'=>'openbsd','version'=>'amd64');
		$os['openbsd i686']	= array('name'=>'openbsd','version'=>'i686');
		$os['openbsd i586']	= array('name'=>'openbsd','version'=>'i586');
		$os['openbsd i486']	= array('name'=>'openbsd','version'=>'i486');
		$os['openbsd i386']	= array('name'=>'openbsd','version'=>'i386');
		//palm
		$os['palm']			= array('name'=>'palm','version'=>'');
		//power tv
		$os['powertv']		= array('name'=>'powertv','version'=>'');
		//prodigy
		$os['prodigy']		= array('name'=>'prodigy','version'=>'');
		//qnx
		$os['qnx']			= array('name'=>'qnx','version'=>'');
		$os['photon']		= array('name'=>'qnx','version'=>'photon');
		//siemens
		$os['sie-cx35']		= array('name'=>'Siemens CX35','version'=>'');
		//symbian
		$os['symbian']		= array('name'=>'symbian','version'=>'');
		$os['symbian/6.1']	= array('name'=>'symbian','version'=>'6.1');
		//sunos
		$os['sunos']		= array('name'=>'sunos','version'=>'');
		//Whois Source
		$os['surveybot']	= array('name'=>'Whois Source','version'=>'');
		//unix
		$os['unix']			= array('name'=>'unix','version'=>'');
		//Yahoo! Slurp
		$os['yahoo']		= array('name'=>'yahoo','version'=>'');
		$os['yahoo! slurp']	= array('name'=>'yahoo slurp','version'=>'');
		//web tv
		$os['web tv']		= array('name'=>'web tv','version'=>'');
		$os['webtv']		= array('name'=>'web tv','version'=>'');
		//windows
		$os['win'] 				= array('name'=>'windows','version'=>'');
		$os['windows nt']		= array('name'=>'windows','version'=>'nt');
		$os['winnt']			= array('name'=>'windows','version'=>'nt');
		$os['win3.11']			= array('name'=>'windows','version'=>'3.11');
		$os['win3.1']			= array('name'=>'windows','version'=>'3.1');
		$os['windows 95']		= array('name'=>'windows','version'=>'95');
		$os['win95']			= array('name'=>'windows','version'=>'95');
		$os['windows 98']		= array('name'=>'windows','version'=>'98');
		$os['win98']			= array('name'=>'windows','version'=>'98');
		$os['windows me']		= array('name'=>'windows','version'=>'me');
		$os['win 9x 4.90']		= array('name'=>'windows','version'=>'me');
		$os['windows nt 5.0']	= array('name'=>'windows','version'=>'2000');
		$os['winnt5.0'] 		= array('name'=>'windows','version'=>'2000');
		$os['windows 2000']		= array('name'=>'windows','version'=>'2000');
		$os['win2000']			= array('name'=>'windows','version'=>'2000');
		$os['windows nt 5.1']	= array('name'=>'windows','version'=>'xp');
		$os['winnt5.1']			= array('name'=>'windows','version'=>'xp');
		$os['windows xp']		= array('name'=>'windows','version'=>'xp');
		$os['winxp']			= array('name'=>'windows','version'=>'xp');
		$os['windows nt 5.2']	= array('name'=>'windows','version'=>'.net 2003');
		$os['winnt5.2']			= array('name'=>'windows','version'=>'.net 2003');
		$os['windows nt 6']		= array('name'=>'windows','version'=>'Codename: Longhorn');
		$os['winnt6']			= array('name'=>'windows','version'=>'Codename: Longhorn');
		$os['windows ce']		= array('name'=>'windows','version'=>'ce');


		$ua = $this->user_agent();
		$name = 'Not Detected';
		$version = '';
		if($ua!=''){
			foreach($os as $key=>$value){
				if(eregi($key, $ua)!==false){
					$name = $value['name'];
					$version = $value['version'];
				}
			}
		}
		switch($what){
			case 'all':
				$return['os'] = $name.' v.'.$version;
				$return['name'] = $name;
				$return['version'] = $version;
				break;
			case 'name':
				$return		= $name;
				break;
			case 'version':
				$return	= $version;
				break;
			default:
				$return	= $name.' '.$version;
				break;
		}
		return $return;
	}
	
	public function language(){
		//return the Accepted Languages
		if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			$lArr=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
			foreach($lArr as $k => $v) {
				$vArr=explode(';',$v);
				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : '1.0';
				$tmplCArr[$vArr[0]]=$vArr[1];
			}
			foreach($tmplCArr as $lC=>$qV) {
				$lC = strtolower(trim($lC));
				$langArr[]=array('code'=>$lC,'name'=>$this->_lang_details($lC),'QValue'=>$qV);
			}
		} else {
			$langArr[]=array('code'=>'*','name'=>'all languages are equally acceptable','QValue'=>'1.0');
		}
		return $langArr;
	}
	
	public function accept(){
		//return the Accepted Charset
		if(isset($_SERVER['HTTP_ACCEPT']) && !empty($_SERVER['HTTP_ACCEPT'])) {
			$cArr=explode(',',$_SERVER['HTTP_ACCEPT']);
			foreach($cArr as $k => $v) {
				$vArr=explode(';',$v);
				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
				$Arr[]=array('code'=>$vArr[0],'QValue'=>$vArr[1]);
			}
		} else {
			$Arr[]=array('code'=>'','QValue'=>1.0);
		}
		return $Arr;
	}
	public function encoding(){
		//return the Accepted Encoding
		if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
			$eArr=explode(',',$_SERVER['HTTP_ACCEPT_ENCODING']);
			foreach($eArr as $k => $v) {
				$vArr=explode(';',$v);
				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
				$Arr[]=array('code'=>$vArr[0],'QValue'=>$vArr[1]);
			}
		} else {
			$Arr[]=array('code'=>'','QValue'=>1.0);
		}
		return $Arr;
	}
	public function charset(){
		//return the Accepted Charset
		if(isset($_SERVER['HTTP_ACCEPT_CHARSET']) && !empty($_SERVER['HTTP_ACCEPT_CHARSET'])) {
			$cArr=explode(',',$_SERVER['HTTP_ACCEPT_CHARSET']);
			foreach($cArr as $k => $v) {
				$vArr=explode(';',$v);
				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
				$Arr[]=array('code'=>$vArr[0],'QValue'=>$vArr[1]);
			}
		} else {
			$Arr[]=array('code'=>'','QValue'=>1.0);
		}
		return $Arr;
	}
	public function IP(){
		$tmp = array();
		if  (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && strpos($_SERVER['HTTP_X_FORWARDED_FOR'],',')) {
		   $tmp += explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
		} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
		   $tmp[] = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
		}elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
		   $tmp[] = trim($_SERVER['HTTP_CLIENT_IP']);
		}
		$tmp[] = trim($_SERVER['REMOTE_ADDR']);
		return trim(str_replace('unknown','',strtolower(implode("\n",$tmp))));
	}
	private function _lang_details($lang){
		$langCode['af']		= 'Afrikaans';
		$langCode['sq']		= 'Albanian';
		$langCode['ar']		= 'Arabic';
		$langCode['ar-ar']	= 'Arabic (Standard)';
		$langCode['ar-dz']	= 'Arabic (Algeria)';
		$langCode['ar-bh']	= 'Arabic (Bahrain)';
		$langCode['ar-eg']	= 'Arabic (Egypt)';
		$langCode['ar-iq']	= 'Arabic (Iraq)';
		$langCode['ar-jo']	= 'Arabic (Jordan)';
		$langCode['ar-kw']	= 'Arabic (Kuwait)';
		$langCode['ar-lb']	= 'Arabic (Lebanon)';
		$langCode['ar-ly']	= 'Arabic (Libya)';
		$langCode['ar-ma']	= 'Arabic (Morocco)';
		$langCode['ar-om']	= 'Arabic (Oman)';
		$langCode['ar-qa']	= 'Arabic (Qatar)';
		$langCode['ar-sa']	= 'Arabic (Saudi Arabia)';
		$langCode['ar-sy']	= 'Arabic (Syria)';
		$langCode['ar-tn']	= 'Arabic (Tunisia)';
		$langCode['ar-ae']	= 'Arabic (U.A.E.)';
		$langCode['ar-ye']	= 'Arabic (Yemen)';
		$langCode['eu']		= 'Basque';
		$langCode['be']		= 'Belarusian';
		$langCode['bg']		= 'Bulgarian';
		$langCode['ca']		= 'Catalan';
		$langCode['zh-hk']	= 'Chinese (Hong Kong SAR)';
		$langCode['zh-cn']	= 'Chinese (PRC)';
		$langCode['zh-sg']	= 'Chinese (Singapore)';
		$langCode['zh-tw']	= 'Chinese (Taiwan)';
		$langCode['zh-mo']	= 'Chinese (Macao)';
		$langCode['hr']		= 'Croatian';
		$langCode['cs']		= 'Czech';
		$langCode['da']		= 'Danish';
		$langCode['da-dk']	= 'Danish';
		$langCode['nl']		= 'Dutch (Standard)';
		$langCode['nl-nl']	= 'Dutch';
		$langCode['nl-be']	= 'Dutch (Belgium)';
		$langCode['en']		= 'English';
		$langCode['en-au']	= 'English (Australia)';
		$langCode['en-bz']	= 'English (Belize)';
		$langCode['en-ca']	= 'English (Canada)';
		$langCode['en']		= 'English (Caribbean)';
		$langCode['en-ie']	= 'English (Ireland)';
		$langCode['en-jm']	= 'English (Jamaica)';
		$langCode['en-nz']	= 'English (New Zealand)';
		$langCode['en-za']	= 'English (South Africa)';
		$langCode['en-tt']	= 'English (Trinidad)';
		$langCode['en-gb']	= 'English (United Kingdom)';
		$langCode['en-us']	= 'English (United States)';
		$langCode['et']		= 'Estonian';
		$langCode['fo']		= 'Faeroese';
		$langCode['fa']		= 'Farsi';
		$langCode['fi']		= 'Finnish';
		$langCode['fi-fi']	= 'Finnish (Finland)';
		$langCode['fr-be']	= 'French (Belgium)';
		$langCode['fr-ca']	= 'French (Canada)';
		$langCode['fr-lu']	= 'French (Luxembourg)';
		$langCode['fr']		= 'French (Standard)';
		$langCode['fr-fr']	= 'French (France)';
		$langCode['fr-ch']	= 'French (Switzerland)';
		$langCode['mk']		= 'FYRO Macedonian';
		$langCode['gd-ie']	= 'Gaelic (Ireland)';
		$langCode['gd']		= 'Gaelic (Scotland)';
		$langCode['de']		= 'German (Standard)';
		$langCode['de-de']	= 'German (Standard)';
		$langCode['de-at']	= 'German (Austria)';
		$langCode['de-li']	= 'German (Liechtenstein)';
		$langCode['de-lu']	= 'German (Luxembourg)';
		$langCode['de-ch']	= 'German (Switzerland)';
		$langCode['el']		= 'Greek';
		$langCode['he']		= 'Hebrew';
		$langCode['hi']		= 'Hindi';
		$langCode['hu']		= 'Hungarian';
		$langCode['hu-hu']	= 'Hungarian (Standard)';
		$langCode['is']		= 'Icelandic';
		$langCode['id']		= 'Indonesian';
		$langCode['it']		= 'Italian';
		$langCode['it-it']	= 'Italian (Standard)';
		$langCode['it-ch']	= 'Italian (Switzerland)';
		$langCode['ja']		= 'Japanese';
		$langCode['ja-jp']	= 'Japanese (Japan)';
		$langCode['ko']		= 'Korean';
		$langCode['ko-kr']	= 'Korean (Korea)';
		$langCode['ko']		= 'Korean (Johab)';
		$langCode['lv']		= 'Latvian';
		$langCode['lt']		= 'Lithuanian';
		$langCode['ms']		= 'Malaysian';
		$langCode['mt']		= 'Maltese';
		$langCode['no']		= 'Norwegian (Bokmal)';
		$langCode['no-no']	= 'Norwegian (Bokmal)';
		$langCode['nb']		= 'Norwegian (Bokmal)';
		$langCode['nn']		= 'Norwegian (Nynorsk)';
		$langCode['pl']		= 'Polish';
		$langCode['pt-br']	= 'Portuguese (Brazil)';
		$langCode['pt-pt']	= 'Portuguese (Portugal)';
		$langCode['pt']		= 'Portuguese (Standard)';
		$langCode['rm']		= 'Rhaeto-Romanic';
		$langCode['ro']		= 'Romanian';
		$langCode['ro-mo']	= 'Romanian (Moldavia)';
		$langCode['ru']		= 'Russian';
		$langCode['ru-ru']	= 'Russian (Standard)';
		$langCode['ru-mo']	= 'Russian (Moldavia)';
		$langCode['sz']		= 'Sami (Lappish)';
		$langCode['sr']		= 'Serbian (Cyrillic)';
		$langCode['sr']		= 'Serbian (Latin)';
		$langCode['sk']		= 'Slovak';
		$langCode['sl']		= 'Slovenian';
		$langCode['sb']		= 'Sorbian';
		$langCode['es-ar']	= 'Spanish (Argentina)';
		$langCode['es-bo']	= 'Spanish (Bolivia)';
		$langCode['es-cl']	= 'Spanish (Chile)';
		$langCode['es-co']	= 'Spanish (Colombia)';
		$langCode['es-cr']	= 'Spanish (Costa Rica)';
		$langCode['es-do']	= 'Spanish (Dominican Republic)';
		$langCode['es-ec']	= 'Spanish (Ecuador)';
		$langCode['es-sv']	= 'Spanish (El Salvador)';
		$langCode['es-es']	= 'Spanish (Spain)';
		$langCode['es-gt']	= 'Spanish (Guatemala)';
		$langCode['es-hn']	= 'Spanish (Honduras)';
		$langCode['es-mx']	= 'Spanish (Mexico)';
		$langCode['es-ni']	= 'Spanish (Nicaragua)';
		$langCode['es-pa']	= 'Spanish (Panama)';
		$langCode['es-py']	= 'Spanish (Paraguay)';
		$langCode['es-pe']	= 'Spanish (Peru)';
		$langCode['es-pr']	= 'Spanish (Puerto Rico)';
		$langCode['es']		= 'Spanish (Spain Modern)';
		$langCode['es']		= 'Spanish (Spain Traditional)';
		$langCode['es-uy']	= 'Spanish (Uruguay)';
		$langCode['es-us']	= 'Spanish (United States)';
		$langCode['es-ve']	= 'Spanish (Venezuela)';
		$langCode['sx']		= 'Sutu';
		$langCode['sv']		= 'Swedish';
		$langCode['sv-se']	= 'Swedish';
		$langCode['sv-fi']	= 'Swedish (Finland)';
		$langCode['th']		= 'Thai';
		$langCode['ts']		= 'Tsonga';
		$langCode['tn']		= 'Tswana';
		$langCode['tr']		= 'Turkish';
		$langCode['uk']		= 'Ukrainian';
		$langCode['ur']		= 'Urdu';
		$langCode['us']		= 'English (United States)';
		$langCode['ve']		= 'Venda';
		$langCode['vi']		= 'Vietnamese';
		$langCode['xh']		= 'Xhosa';
		$langCode['ji']		= 'Yiddish';
		$langCode['zh']		= 'Chinese Simplified';
		$langCode['zh-Hans']= 'Chinese Simplified';
		$langCode['zh-Hant']= 'Chinese Simplified';
		$langCode['zh-tw']	= 'Chinese Traditional';
		$langCode['zu']		= 'Zulu';
		$langCode['*']		= 'all languages are equally acceptable';
		
		//EXTRAS
		$langCode['ie-ee']	= 'Internet Explorer - Easter Egg';
		$lang = strtolower($lang);
		if(isset($langCode[$lang])){
			return $langCode[$lang];
		}elseif(isset($langCode[str_replace('-','_',$lang)])){
			return $langCode[str_replace('_','-',$lang)];
		} else {
			return '';
		}
	}
	public function is_crawler(){
		$is_crawler = false;
		$_crawlers = array();

		$_crawlers[] = 'alexa';
		$_crawlers[] = 'archive';
		$_crawlers[] = 'askjeeves';
		$_crawlers[] = 'bot';
		$_crawlers[] = 'crawl';
		$_crawlers[] = 'echo!';
		$_crawlers[] = 'edintorni';
		$_crawlers[] = 'feedfetcher';
		$_crawlers[] = 'findlinks';
		//$_crawlers[] = 'funwebproducts';		//this is not a crawler, just junk installed in the browser
		$_crawlers[] = 'gigabot';
		$_crawlers[] = 'girafabot';
		$_crawlers[] = 'google';
		$_crawlers[] = 'holmes';
		$_crawlers[] = 'maxthon';
		$_crawlers[] = 'mediapartner';
		$_crawlers[] = 'mj12bot';
		$_crawlers[] = 'mirago';
		$_crawlers[] = 'moget';
		$_crawlers[] = 'msnbot';
		$_crawlers[] = 'netcraft';
		$_crawlers[] = 'newsgator';
		$_crawlers[] = 'nomad';
		$_crawlers[] = 'robot';
		$_crawlers[] = 'sbider';
		$_crawlers[] = 'spider';
		$_crawlers[] = 'scooter';
		$_crawlers[] = 'seekbot';
		$_crawlers[] = 'seeker';
		$_crawlers[] = 'spider';
		$_crawlers[] = 'survey';
		$_crawlers[] = 'T-H-U-N-D-E-R-S-T-O-N-E';
		$_crawlers[] = 'validator';
		$_crawlers[] = 'walhello';
		$_crawlers[] = 'yahoo';
		$_crawlers[] = 'zyborg';
		$ua = $this->user_agent();
		if($ua!=''){
			foreach($_crawlers as $value){
				if(strpos($ua, $value)!==false){
					$is_crawler = true;
					break;
				}
			}
		} else {
			$is_crawler = true;
		}
		return $is_crawler;
	}
}
/*
sample on how to use this class:
<?php
//sample on how o use user_info
require_once dirname(__FILE__).'/user_info.php';
$uinfo = new user_info();
?>Hello!<br />
Here a few info about you
<ul>
<li>IP: <?=$uinfo->IP();?></li>
<li>OS: <?=$uinfo->os();?>
	<ul>
		<li>name: <?=$uinfo->os('name');?></li>
		<li>version: <?=$uinfo->os('version');?></li>
	</ul>
</li>
<li>Are you a spider/robot: <?=$uinfo->is_crawler()?'Yes':'No'?></li>
<li>Browser: <?=$uinfo->browser();?>
	<ul>
		<li>name: <?=$uinfo->browser('name');?></li>
		<li>version: <?=$uinfo->browser('version');?></li>
	</ul>
</li>
<li>Security: <?=$uinfo->security();?></li>
<li>Languages:
	<ul><?php
	$tmps = $uinfo->language();
	foreach($tmps as $k=>$v){
		?><li>code: <?=$v['code']?></li>
		<li>name: <?=$v['name']?></li>
		<li>QValue: <?=$v['QValue']?></li><?php
	}
	?></ul>
</li>
<li>Accept:
	<ul><?php
	$tmps = $uinfo->accept();
	foreach($tmps as $k=>$v){
		?><li>code: <?=$v['code']?></li>
		<li>QValue: <?=$v['QValue']?></li><?php
	}
	?></ul>
</li>
<li>Encodings:
	<ul><?php
	$tmps = $uinfo->encoding();
	foreach($tmps as $k=>$v){
		?><li>code: <?=$v['code']?></li>
		<li>QValue: <?=$v['QValue']?></li><?php
	}
	?></ul>
</li>
<li>Charsets:
	<ul><?php
	$tmps = $uinfo->charset();
	foreach($tmps as $k=>$v){
		?><li>code: <?=$v['code']?></li>
		<li>QValue: <?=$v['QValue']?></li><?php
	}
	?></ul>
</li>
<li>Your User Agent: <?=$uinfo->user_agent()?></li>
<li>Requested Page: <?=$uinfo->request_page()?></li>
<li>Request Method: <?=$uinfo->request_method()?></li>
<li>This URL: <?=$uinfo->url()?></li>
</ul>


*/
?>
Return current item: User Info