Wanted mobile detector code
Started on the old forum in December 2011 · view the original in the archive · old links redirect here
zong11 wrote: WapMasters i want mobile detector code so that site should run only on mobile not on pc. Plzzzzz help
Advertise your mobile site for FREE with AdTwirl
zong11 wrote: how to use this code?????
require_once('mobile_device_detect.php');
$mobile = mobile_device_detect();
if($mobile == true)
{
echo 'Mobile phone user.';
}
else
{
echo 'PC user.';
}
Advertise your mobile site for FREE with AdTwirl
<?php
//////GYSMS.com Browser Detection
$mobile_browser = '0';
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wa p|phone)/i',
strtolower($_SERVER['HTTP_USER_AGENT']))){
$mobile_browser++;
}
if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or
((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))){
$mobile_browser++;
}
$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(in_array($mobile_ua,$mobile_agents)){
$mobile_browser++;
}
if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')>0) {
$mobile_browser++;
}
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')>0) {
$mobile_browser=0;
}
if($mobile_browser>0){
header("Location: http://www.yourmobilesite.com");
}
else{
header("Location: http://www.yoursite.com/notphone.php");
}
?>
Added after 2 minutes:
i am using on all my sites and working very well.. check demo at adcell.mobi from ur mob and pc
Free Web Hosting @HostersPoint.com php Hosting with Web Builder
Buy - Sell ADs ADMOLA ADs Network Monetize Your Site Traffic
irfiii wrote: Added after 2 minutes:
i am using on all my sites and working very well.. check demo at adcell.mobi from ur mob and pc
the function by Andy Moore is more advanced, i would recommend you to use it instead of this code.
Advertise your mobile site for FREE with AdTwirl
ohhh Really? thanks for suggestion.. i will change it today8)
Free Web Hosting @HostersPoint.com php Hosting with Web Builder
Buy - Sell ADs ADMOLA ADs Network Monetize Your Site Traffic
<?php //////GYSMS.com Browser Detection $mobile_browser = '0'; if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wa p|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))){ $mobile_browser++; } if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))){ $mobile_browser++; } $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(in_array($mobile_ua,$mobile_agents)){ $mobile_browser++; } if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')>0) { $mobile_browser++; } if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')>0) { $mobile_browser=0; } if($mobile_browser>0){ header("Location: http://www.yourmobilesite.com"); } else{ header("Location: http://www.yoursite.com/notphone.php"); } ?>Added after 2 minutes:
i am using on all my sites and working very well.. check demo at adcell.mobi from ur mob and pc
Anyway if you using it or not, in this part needs to be a space between OperaMini:
if (strpos(strtolower($_SERVER['ALL_HTTP']),'Opera Mini')>0) {
$mobile_browser++;
}
And this i think is wrong because its alone in a string at position 0 in $_SERVER['HTTP_ACCEPT'].
//...
strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0)
//...
But i got an idea on mobile redirect. 🙂
may be wrong but it work fine on opera for me..
Free Web Hosting @HostersPoint.com php Hosting with Web Builder
Buy - Sell ADs ADMOLA ADs Network Monetize Your Site Traffic
brentg wrote: where do we apply this code?
anyone help please
Free Mobile Downloads: http://playwap.mobi
brentg wrote: anyone help please
In the script. 🤪
brentg wrote: anyone help please
Just change this habit of grabbing ready made things,Go thru some basic tutorials...That'd help you 🙂
I need some facebook likes, can you please help me 🤝 http://facebook.com/softwarefreakin I noticed social media is really powerful 🧙 Well DONE is better than well SAID