phpbar.de logo

Mailinglisten-Archive

[php] Browsererkennung

[php] Browsererkennung

TomH php_(at)_phpcenter.de
Mon, 19 Mar 2001 23:01:04 +0100


Abend Stefan.

Ich hab hier was.  ist aber nicht so schoen und ich habs auch noch nicht
auf alle moeglichen browser getestet. Musst Du natuerlich noch
anpassen:)

if (substr_count($HTTP_USER_AGENT,"Win")>0){
	$OS="Win";
	if (substr_count($HTTP_USER_AGENT,"95")>0){
		$OS="Win95";
	}
	else if (substr_count($HTTP_USER_AGENT,"98")>0){
		$OS="W98";
	}
	else if (substr_count($HTTP_USER_AGENT,"NT")>0){
		$OS="WNT";
	}
	else if (substr_count($HTTP_USER_AGENT,"2000")>0){
		$OS="W2k";
	}
	else if (substr_count($HTTP_USER_AGENT,"ME")>0){
		$OS="WME";
	}
}
else if(substr_count($HTTP_USER_AGENT,"Mac")>0){
	$OS="M";
}
else if(substr_count($HTTP_USER_AGENT,"Linux")>0){
	$OS="L";
}
else if(substr_count($HTTP_USER_AGENT,"Sun")>0){
	$OS="S";
}
if (!$OS){
	$query="$query AND OS='0'";
}
else{
	$query="$query AND OS NOT LIKE '%$OS%'";
}
#Browser abfragen
if (substr_count($HTTP_USER_AGENT,"MSIE")>0){
	$BROWSER="IE";
	if (substr_count($HTTP_USER_AGENT,"MSIE2")>0){
		$BROWSER="I2";
	}
	else if (substr_count($HTTP_USER_AGENT,"MSIE3")>0){
		$BROWSER="I3";
	}
	else if (substr_count($HTTP_USER_AGENT,"MSIE4")>0 ||
substr_count($HTTP_USER_AGENT,"MSIE 4")>0){
		$BROWSER="I4";
	}
	else if (substr_count($HTTP_USER_AGENT,"MSIE5")>0 ||
substr_count($HTTP_USER_AGENT,"MSIE 5")>0){
		$BROWSER="I5";
	}
}
else if(substr_count($HTTP_USER_AGENT,"Opera")>0){
	$BROWSER="O";
}
else if(substr_count($HTTP_USER_AGENT,"Mozilla")>0){
	$BROWSER="N";
	$v=explode("/",$HTTP_USER_AGENT);
	$BROWSER=$BROWSER.substr($v[1],0,1);
}
if (!$BROWSER){
	$query="$query AND BROWSER='0'";
}
else{
	$query="$query AND BROWSER NOT LIKE '%$BROWSER%'";
}


Gruss,

TomH


php::bar PHP Wiki   -   Listenarchive