[PC-BSD Commits] r2084 - websites/pbidir.com/bibivu/sbin

svn at pcbsd.org svn at pcbsd.org
Tue Jun 10 20:01:14 PDT 2008


Author: fabry
Date: 2008-06-10 20:01:13 -0700 (Tue, 10 Jun 2008)
New Revision: 2084

Modified:
   websites/pbidir.com/bibivu/sbin/user_info.php
Log:
extended the user_info class to better grab the OS

Modified: websites/pbidir.com/bibivu/sbin/user_info.php
===================================================================
--- websites/pbidir.com/bibivu/sbin/user_info.php	2008-06-10 21:06:05 UTC (rev 2083)
+++ websites/pbidir.com/bibivu/sbin/user_info.php	2008-06-11 03:01:13 UTC (rev 2084)
@@ -194,47 +194,158 @@
 		return $return;
 	}
 	
-	public function os(){
+	public function os($what=''){
 		//return the OS
-		$UserAgent = $this->user_agent();
-		if(eregi('Windows',$UserAgent)) {
-			$OS='Windows';
-		} else if(eregi('Linux',$UserAgent)) {
-			$OS='Linux';
-		} else if(eregi('Unix',$UserAgent)) {
-			$OS='Unix';
-		} else if(eregi('PC-BSD',$UserAgent)) {
-			$OS='PC-BSD';
-		} else if(eregi('FreeBSD',$UserAgent)) {
-			$OS='FreeBSD';
-		} else if(eregi('BSD',$UserAgent)) {
-			$OS='BSD';
-		} else if(eregi('Mac',$UserAgent)) {
-			$OS='Macintosh';
-		} else if(eregi('SunOS',$UserAgent)) {
-			$OS='SunOS';
-		} else if(eregi('HP-UX',$UserAgent)) {
-			$OS='Unix';
-		} else if(eregi('IRIX',$UserAgent)) {
-			$OS='Unix';
-		} else if(eregi('Netcraft',$UserAgent)) {
-			$OS='Netcraft';
-		} else if(eregi('Googlebot',$UserAgent)) {
-			$OS='Googlebot';
-		} else if(eregi('SurveyBot',$UserAgent)) {
-			$OS='Whois Source';
-		} else if(eregi('Yahoo! Slurp',$UserAgent)) {
-			$OS='Yahoo! Slurp';
-		} else if(eregi('Gigabot',$UserAgent)) {
-			$OS='Gigabot';
-		} else if(eregi('HTMLParser',$UserAgent)) {
-			$OS='HTMLParser';
-		} else if(eregi('robot',$UserAgent)) {
-			$OS='robot';
-		} else {
-			$OS='Not Detected';
+		$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 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'];
+				}
+			}
 		}
-		return $OS;
+		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(){
@@ -474,6 +585,7 @@
 		}
 	}
 	public function is_crawler(){
+		$is_crawler = false;
 		$_crawlers = array();
 
 		$_crawlers[] = 'alexa';
@@ -512,10 +624,10 @@
 		$_crawlers[] = 'walhello';
 		$_crawlers[] = 'yahoo';
 		$_crawlers[] = 'zyborg';
-		if(isset($_SERVER['HTTP_USER_AGENT']) && trim($_SERVER['HTTP_USER_AGENT'])!=''){
-			$_HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
+		$ua = $this->user_agent();
+		if($ua!=''){
 			foreach($_crawlers as $value){
-				if(strpos($_HTTP_USER_AGENT, $value)!==false){
+				if(strpos($ua, $value)!==false){
 					$is_crawler = true;
 					break;
 				}



More information about the Commits mailing list