function mobile_device_detect (
$iphone=true,
$android=true,
$opera=true,
$blackberry=true,
$palm=true,
$windows=true,
$mobileredirect=false,
$ipad=true) {
$mobile_browser = false;
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];
switch(true){
case (@eregi('ipod',$user_agent)||@eregi('iphone',$user_agent));
$mobile_browser = $iphone;
if(substr($iphone,0,4)=='http'){
$mobileredirect = $iphone;}
break;
case (@eregi('android',$user_agent));
$mobile_browser = $android;
if(substr($android,0,4)=='http'){
$mobileredirect = $android;}
break;
case (@eregi('ipad',$user_agent));
$mobile_browser = $ipad;if(substr($ipad,0,4)=='http'){
$mobileredirect = $ipad; } break;
case (@eregi('opera mini',$user_agent));
$mobile_browser = $opera;if(substr($opera,0,4)=='http'){
$mobileredirect = $opera;} break;
case (@eregi('blackberry',$user_agent));
$mobile_browser = $blackberry; if(substr($blackberry,0,4)=='http'){
$mobileredirect = $blackberry;} break;
case (preg_match('/(palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i',$user_agent));
$mobile_browser = $palm; if(substr($palm,0,4)=='http'){
$mobileredirect = $palm; } break;
case (preg_match('/(windows ce; ppc;|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent));
$mobile_browser = $windows; if(substr($windows,0,4)=='http'){
$mobileredirect = $windows; } break;
case (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobil e|pda|psp|treo)/i',$user_agent));
$mobile_browser = true; break;
case ((strpos($accept,'text/vnd.wap.wml')>0)||(strpos($accept,'application/vnd.wap.xhtml+xml')>0));
$mobile_browser = true; break;
case (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE']));
$mobile_browser = true; break;
case (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>
'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>
'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>
'770s','802s'=>'802s','a wa'=>'a wa', ... и так далее
_____________