spacepoet Posted March 5, 2011 Share Posted March 5, 2011 Hi Everyone: Can anyone show me or direct me to a PHP PHP Mobile Device Detection & Redirection Script. I use to use this when doing ASP: <% Dim user_agent, mobile_browser, Regex, match, mobile_agents, mobile_ua, i, size user_agent = Request.ServerVariables("HTTP_USER_AGENT") mobile_browser = 0 Set Regex = New RegExp With Regex .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm)" .IgnoreCase = True .Global = True End With match = Regex.Test(user_agent) If match Then mobile_browser = mobile_browser+1 If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/vnd.wap.xhtml+xml") Or Not IsEmpty(Request.ServerVariables("HTTP_X_PROFILE")) Or Not IsEmpty(Request.ServerVariables("HTTP_PROFILE")) Then mobile_browser = mobile_browser+1 end If 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-") size = Ubound(mobile_agents) mobile_ua = LCase(Left(user_agent, 4)) For i=0 To size If mobile_agents(i) = mobile_ua Then mobile_browser = mobile_browser+1 Exit For End If Next If mobile_browser>0 Then Response.Redirect("http://www.sp.com/SPMOBI/MOBI.asp") End If %> Is there a PHP equivalent of this? As always, I appreciate to wisdom of the board. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/229686-php-mobile-device-detection-redirection-script/ Share on other sites More sharing options...
jcbones Posted March 5, 2011 Share Posted March 5, 2011 This should help... Quote Link to comment https://forums.phpfreaks.com/topic/229686-php-mobile-device-detection-redirection-script/#findComment-1183357 Share on other sites More sharing options...
spacepoet Posted March 5, 2011 Author Share Posted March 5, 2011 Thank you! Seems pretty straightforward .. Quote Link to comment https://forums.phpfreaks.com/topic/229686-php-mobile-device-detection-redirection-script/#findComment-1183380 Share on other sites More sharing options...
anatak Posted March 5, 2011 Share Posted March 5, 2011 this site might also help you in case you did not come across it yet http://mobiforge.com/search/PHP+Mobile+Device+Detection+%2526+Redirection+Script Quote Link to comment https://forums.phpfreaks.com/topic/229686-php-mobile-device-detection-redirection-script/#findComment-1183389 Share on other sites More sharing options...
spacepoet Posted March 6, 2011 Author Share Posted March 6, 2011 Thanks as well! Yes, very helpful. Question: Does anyone know if there is an online Mobile Device simulator like this one: http://www.opera.com/mobile/demo/ Only for iPhones, Blackberry, Droid, etc.. I am sure I used on in an old job but can not remember what site it was! Quote Link to comment https://forums.phpfreaks.com/topic/229686-php-mobile-device-detection-redirection-script/#findComment-1183417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.