Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Digital Lifestyle
Web Design and Hosting
Safari and Flash Video
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Groovetube" data-source="post: 1386273" data-attributes="member: 223633"><p>mootools, interesting link.</p><p></p><p>I have generally this php function for mobile detection, because most things I do involve php.</p><p></p><p>I got it from somewhere I forget and modified it. This version just checks for phones specifically.</p><p></p><p>[PHP]function detect_mobile()</p><p>{</p><p> $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : '';</p><p> </p><p> $mobile_browser = '0';</p><p> </p><p> $agent = strtolower($_SERVER['HTTP_USER_AGENT']);</p><p> </p><p> if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipod|android|xoom)/i', $agent))</p><p> $mobile_browser++;</p><p> </p><p> if((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') !== false))</p><p> $mobile_browser++;</p><p> </p><p> if(isset($_SERVER['HTTP_X_WAP_PROFILE']))</p><p> $mobile_browser++;</p><p> </p><p> if(isset($_SERVER['HTTP_PROFILE']))</p><p> $mobile_browser++;</p><p> </p><p> $mobile_ua = substr($agent,0,4);</p><p> $mobile_agents = array(</p><p> 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',</p><p> 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',</p><p> 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',</p><p> 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',</p><p> 'newt','noki','oper','palm','pana','pant','phil','play','port','prox',</p><p> 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',</p><p> 'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',</p><p> 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',</p><p> 'wapr','webc','winw','xda','xda-'</p><p> );</p><p> </p><p> if(in_array($mobile_ua, $mobile_agents))</p><p> $mobile_browser++;</p><p> </p><p> if(strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false)</p><p> $mobile_browser++;</p><p> </p><p> // Pre-final check to reset everything if the user is on Windows</p><p> if(strpos($agent, 'windows') !== false)</p><p> $mobile_browser=0;</p><p> </p><p> // But WP7 is also Windows, with a slightly different characteristic</p><p> if(strpos($agent, 'windows phone') !== false)</p><p> $mobile_browser++;</p><p> </p><p> if($mobile_browser>0)</p><p> return true;</p><p> else</p><p> return false;</p><p>}[/PHP]</p></blockquote><p></p>
[QUOTE="Groovetube, post: 1386273, member: 223633"] mootools, interesting link. I have generally this php function for mobile detection, because most things I do involve php. I got it from somewhere I forget and modified it. This version just checks for phones specifically. [PHP]function detect_mobile() { $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : ''; $mobile_browser = '0'; $agent = strtolower($_SERVER['HTTP_USER_AGENT']); if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipod|android|xoom)/i', $agent)) $mobile_browser++; if((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') !== false)) $mobile_browser++; if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) $mobile_browser++; if(isset($_SERVER['HTTP_PROFILE'])) $mobile_browser++; $mobile_ua = substr($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','xda','xda-' ); if(in_array($mobile_ua, $mobile_agents)) $mobile_browser++; if(strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) $mobile_browser++; // Pre-final check to reset everything if the user is on Windows if(strpos($agent, 'windows') !== false) $mobile_browser=0; // But WP7 is also Windows, with a slightly different characteristic if(strpos($agent, 'windows phone') !== false) $mobile_browser++; if($mobile_browser>0) return true; else return false; }[/PHP] [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
Digital Lifestyle
Web Design and Hosting
Safari and Flash Video
Top