Location: PHPKode > projects > Simple Way to Usenet > swun/libs/core/pgen/client.class.php
<?php

class client {
		
	private static $browser;
	private static $version;
	
	public function __construct(){ }
	
	public static function lang(){ return langs::get_active(); }
	
	public static function charset(){ return langs::charset(); }
	
	public static function host(){ return $_SERVER['REMOTE_ADDR']; }
	
	public static function browser(){
		if ( isset(self::$browser) ){ return self::$browser; }
		$o = 'Unknow';
		//Opera		
		if ( eregi("opera",$this->agent) ){
			$val = stristr($this->agent, "opera");
			if ( eregi("/", $val) ){
				$val = explode("/",$val);
				$o = $val[0];
			} else {
				$val = explode(" ",stristr($val,"opera"));
				$o = $val[0];
			}
		
		//WEBTV	
		} elseif( eregi("webtv",$this->agent) ){
			$val = explode("/",stristr($this->agent,"webtv"));
			$o = $val[0];
			
		//MS Internet Explorer version 1
		} elseif( eregi("microsoft internet explorer", $this->agent) ){
			$o = "MSIE";
		
		//MS Internet Explorer
		} elseif( eregi("msie",$this->agent) && !eregi("opera",$this->agent) ){
			$val = explode(" ", stristr($this->agent,"msie"));
			$o = $val[0];
		
		//MS Pocket Internet Explorer
		} elseif(eregi("mspie",$this->agent) || eregi('pocket', $this->agent)){
			$val = explode(" ",stristr($this->agent,"mspie"));
			$o = "MSPIE";
			
		//NetPositive
		} elseif( eregi("NetPositive", $this->agent) ){
			$val = explode("/",stristr($this->agent,"NetPositive"));
			$o = $val[0];
			
		//Galeon
		} elseif( eregi("galeon",$this->agent) ){
			$val = explode(" ",stristr($this->agent,"galeon"));
			$val = explode("/",$val[0]);
			$o = $val[0];
			
		//Konqueror
		} elseif( eregi("Konqueror",$this->agent) ){
			$val = explode(" ",stristr($this->agent,"Konqueror"));
			$val = explode("/",$val[0]);
			$o = $val[0];
			
		//iCab
		} elseif( eregi("icab",$this->agent) ){
			$val = explode(" ",stristr($this->agent,"icab"));
			$o = $val[0];

		//OmniWeb
		} elseif( eregi("omniweb",$this->agent) ){
			$val = explode("/",stristr($this->agent,"omniweb") );
			$o = $val[0];
			
		//Phoenix
		} elseif( eregi("Phoenix", $this->agent) ){
			$o = "Phoenix";
		
		//Firebird
		} elseif( eregi("firebird", $this->agent) ){
			$o = "Firebird";
			
		//Firefox
		} elseif( eregi("Firefox", $this->agent) ){
			$o = "Firefox";
		
		//Mozilla Alpha/Beta Versions
		} elseif( eregi("mozilla",$this->agent) 
					&& eregi("rv:[0-9].[0-9][a-b]",$this->agent) 
					&& !eregi("netscape",$this->agent) ){
			$o = "Mozilla";
			
		//Mozilla Stable Versions
		} elseif( eregi("mozilla",$this->agent) 
					&& eregi("rv:[0-9]\.[0-9]" ,$this->agent) 
					&& !eregi("netscape",$this->agent) ){
			$o = "Mozilla";
		
		//Netscape
		} elseif( eregi("netscape",$this->agent)){
			$val = explode(" ",stristr($this->agent,"netscape"));
			$val = explode("/",$val[0]);
			$o = $val[0];

		} elseif( eregi("mozilla",$this->agent) 
					&& !eregi("rv:[0-9]\.[0-9]\.[0-9]",$this->agent) ){
			$o = "Netscape";
					
		//Lynx & Amaya
		} elseif( eregi("libwww", $this->agent) ){
			if (eregi("amaya", $this->agent)){
				$o = "Amaya";
			} else {
				$o = "Lynx";
			}
			
		//Safari
		} elseif( eregi("safari", $this->agent) ){
			$o = "Safari";
		
		//Links
		} elseif( eregi("Links", $this->agent) ){	
			$o = "Links";
		}
		// clean up extraneous garbage that may be in the name
		$o = ereg_replace("[^a-z,A-Z]", "", $o);
		self::$browser = $o;
		return $o;		
	}
	
	public static function version(){
		if ( isset(self::$version) ){ return self::$version; }
		$v = 'Unknow';
		//Opera		
		if ( eregi("opera",$this->agent) ){
			$val = stristr($this->agent, "opera");
			if ( eregi("/", $val) ){
				$val = explode("/",$val);
				$val = explode(" ",$val[1]);
				$v = $val[0];
			} else {
				$val = explode(" ",stristr($val,"opera"));
				$v = $val[1];
			}
		
		//WEBTV	
		} elseif( eregi("webtv",$this->agent) ){
			$val = explode("/",stristr($this->agent,"webtv"));
			$v = $val[1];
			
		//MS Internet Explorer version 1
		} elseif( eregi("microsoft internet explorer", $this->agent) ){
			$v = "1.0";
			$var = stristr($this->agent, "/");
			if (ereg("308|425|426|474|0b1", $var)){ $v = "1.5"; }
		
		//MS Internet Explorer
		} elseif( eregi("msie",$this->agent) && !eregi("opera",$this->agent) ){
			$val = explode(" ", stristr($this->agent,"msie"));
			$v = $val[1];
		
		//MS Pocket Internet Explorer
		} elseif(eregi("mspie",$this->agent) || eregi('pocket', $this->agent)){
			$val = explode(" ",stristr($this->agent,"mspie"));
			if ( eregi("mspie", $this->agent) ){
				$v = $val[1];
			} else {
				$val = explode("/",$this->agent);
				$v = $val[1];
			}	
			
		//NetPositive
		} elseif( eregi("NetPositive", $this->agent) ){
			$val = explode("/",stristr($this->agent,"NetPositive"));
			$v = $val[1];	
			
		//Galeon
		} elseif( eregi("galeon",$this->agent) ){
			$val = explode(" ",stristr($this->agent,"galeon"));
			$val = explode("/",$val[0]);
			$v = $val[1];	
			
		//Konqueror
		} elseif( eregi("Konqueror",$this->agent) ){
			$val = explode(" ",stristr($this->agent,"Konqueror"));
			$val = explode("/",$val[0]);
			$v = $val[1];	
			
		//iCab
		} elseif( eregi("icab",$this->agent) ){
			$val = explode(" ",stristr($this->agent,"icab"));
			$v = $val[1];

		//OmniWeb
		} elseif( eregi("omniweb",$this->agent) ){
			$val = explode("/",stristr($this->agent,"omniweb") );
			$v = $val[1];	
			
		//Phoenix
		} elseif( eregi("Phoenix", $this->agent) ){
			$val = explode("/", stristr($this->agent,"Phoenix/"));
			$v = $val[1];
		
		//Firebird
		} elseif( eregi("firebird", $this->agent) ){
			$val = stristr($this->agent, "Firebird");
			$val = explode("/",$val);
			$v = $val[1];
			
		//Firefox
		} elseif( eregi("Firefox", $this->agent) ){
			$val = stristr($this->agent, "Firefox");
			$val = explode("/",$val);
			$v = $val[1];	
		
		//Mozilla Alpha/Beta Versions
		} elseif( eregi("mozilla",$this->agent) 
					&& eregi("rv:[0-9].[0-9][a-b]",$this->agent) 
					&& !eregi("netscape",$this->agent) ){
			$val = explode(" ", stristr($this->agent, "rv:"));
			eregi("rv:[0-9].[0-9][a-b]", $this->agent, $val);
			$v = str_replace("rv:", "", $val[0]);
			
		//Mozilla Stable Versions
		} elseif( eregi("mozilla",$this->agent) 
					&& eregi("rv:[0-9]\.[0-9]" ,$this->agent) 
					&& !eregi("netscape",$this->agent) ){
			$val = explode(" ", stristr($this->agent, "rv:"));
			eregi("rv:[0-9]\.[0-9]\.[0-9]", $this->agent, $val);
			$v = str_replace("rv:", "", $val[0]);	
		
		//Netscape
		} elseif( eregi("netscape",$this->agent)){
			$val = explode(" ",stristr($this->agent,"netscape"));
			$val = explode("/",$val[0]);
			$v = $val[1];
			
		} elseif( eregi("mozilla",$this->agent) 
					&& !eregi("rv:[0-9]\.[0-9]\.[0-9]",$this->agent) ){
			$val = explode(" ",stristr($agent,"mozilla"));
			$val = explode("/",$val[0]);
			$v = $val[1];
					
		//Lynx & Amaya
		} elseif( eregi("libwww", $this->agent) ){
			if (eregi("amaya", $this->agent)){
				$val = explode("/",stristr($this->agent,"amaya"));
				$val = explode(" ", $val[1]);
				$v = $val[0];
			} else {
				$val = explode("/",$this->agent);
				$v = $val[1];
			}
			
		//Links
		} elseif( eregi("Links", $this->agent) ){	
			$val = split(";", $this->agent);
			$val = split("\(", $val[0]);
			$v = $val[1];	
			
		}
		// clean up extraneous garbage that may be in the version		
		$v = ereg_replace("[^0-9,.,a-z,A-Z]", "", $v);
		self::$version = $v;
		return $v;		
	}

	public static function mac(){
		return shell_exec('cat /proc/net/arp | grep '.self::host().' | cut -f 23 -d" " 2>&1');
	}
}
Return current item: Simple Way to Usenet