# include for mobile detection
##############
##############
function detectMobileDevice() {
#return true;
$debug = false;
#if ($debug)
#echo '
CHECKING:'.$_SERVER['HTTP_USER_AGENT'].'
';
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),' ppc;')>0) {
if ($debug)
echo 'c1';
return true;
}
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows ce')>0) {
if ($debug)
echo 'c2';
return true;
}
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'iemobile')>0) {
if ($debug)
echo 'c4';
return true;
}
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
if ($debug)
echo 'c5';
return true;
}
if ($debug)
echo 'mark1';
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');
if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
if ($debug)
echo 'cagent';
return true;
}
# ? no http_accept?
#else if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
else if (((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
if ($debug)
echo 'c6';
return true;
}
else if (in_array($mobile_ua,$mobile_agents)) {
if ($debug)
echo 'c7';
return true;
}
else if ((isset($_SERVER['ALL_HTTP'])) &&(strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0)) {
return true;
}
if ($debug)
echo 'returning false - not mobile';
return false;
}
## we're going to try to handle mobile processing detection
# first test is have we already discarded this option?
$show_mobile = 'NO';
if(isset($_COOKIE['RememberNOMOBILE'])) {
# no mobile detection has been set for this session -- ignore this processing
#echo '
found cookie no mobile';
} else {
# ok we may be doing something
if (detectMobileDevice()) {
# we HAVE detected a mobile device
# when we do this and don't have the cookie we immediately relocate to the mobile site
# but only for a few specific pages
$the_current_url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
# ingredient search
if ( $the_current_url == $this->{'System/BaseURL'}.'ingredient-search' ) {
$url = 'http://m.recipebridge.com/ingredient-search';
header("Location: ".$url);
exit;
}
# primary search page...
# like http://m.recipebridge.com/r/berry-recipes
if(strpos($the_current_url,$this->{'System/BaseURL'}.'r/') !== false) {
$url = 'http://m.recipebridge.com'.$_SERVER['REQUEST_URI'];
header("Location: ".$url);
exit;
}
# actual search page...
# like http://www.recipebridge.com/g/173/15948345/buddhas-mixed-berry-smoothie-recipe
if(strpos($the_current_url,$this->{'System/BaseURL'}.'g/') !== false) {
$url = 'http://m.recipebridge.com'.$_SERVER['REQUEST_URI'];
header("Location: ".$url);
exit;
}
}
} # end else maybe mobile
?>