<?
	
//判斷使用者終端載具
function get_user_device(){
	$windows = stripos($_SERVER['HTTP_USER_AGENT'],"Windows");
	$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
	$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
	$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
	if(stripos($_SERVER['HTTP_USER_AGENT'],"Android") && stripos($_SERVER['HTTP_USER_AGENT'],"mobile")){
		$Android = true;
	}else if(stripos($_SERVER['HTTP_USER_AGENT'],"Android")){
		$Android = false;
		$AndroidTablet = true;
	}else{
		$Android = false;
		$AndroidTablet = false;
	}
	$webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
	$BlackBerry = stripos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
	$RimTablet= stripos($_SERVER['HTTP_USER_AGENT'],"RIM Tablet");
	 
	//do something with this information
	if( $iPod || $iPhone ){
		//we're an iPhone/iPod touch -- do something here
		$usewhat = "iPhone" ;											
	}else if($iPad){
		//we're an iPad -- do something here
		$usewhat = "iPad" ;
	}else if($Android){
		//we're an Android Phone -- do something here
		$usewhat = "Android" ;
	}else if($AndroidTablet){
		//we're an Android Phone -- do something here
		$usewhat = "AndroidTablet" ;
	}else if($webOS){
		//we're a webOS device -- do something here	
		$usewhat = "webOS" ;
	}else if($BlackBerry){
		//we're a BlackBerry phone -- do something here
		$usewhat = "BlackBerry" ;
	}else if($RimTablet){
		//we're a RIM/BlackBerry Tablet -- do something here
		$usewhat = "RimTablet" ;
	}else if($windows){
		$usewhat = "Computer";
	}else{
		//we're not a mobile device.
		$usewhat = "未知" ;
	}
	return $usewhat;
}

?>