<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-GB link=blue vlink=purple>
<div class=WordSection1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Howdy<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Possibly a bit late (I’ve been on my holidays), but I wrote one
a couple of weeks ago. It uses PHP’s getbrowser() function (but as an object,
rather than the native one which is poorly supported) which, happily, one of
the object’s elements is isMobileDevice which I think you can guess what it
does.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>For details on how to use the Browscap object file, see <a
href="http://php.net/manual/en/function.get-browser.php">http://php.net/manual/en/function.get-browser.php</a>.
There’s a lot of things you can do with it. You instantiate it like this:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> $objBrowscap = new Browscap(/location/to/writable/cache/dir);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> $objBrowser = $objBrowscap->getBrowser();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>You need to specify a cache directory as it downloads the data
for all browsers which is about 400kb. The first time takes about 2 seconds to
download, but is instant once it’s cached.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>More info (and the original class file) can be found at <a
href="http://garetjax.info/projects/browscap/">http://garetjax.info/projects/browscap/</a><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The Mobile object file is my implementation of the class for my
framework. The key stuff is in line 54:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> If(isset($objBrowser->isMobileDevice)
&& $objBrowser->isMobileDevice == ‘true’) {<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> /* This is a mobile browser – do
what you have to do */<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> }<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I should point out that I’ve done an isset on the
isMobileDevice. Every browser I’ve tested it with (IE6 – 8, FF, Chrome,
Safari, Opera, iPhone and various other mobiles) declare this, but sod’s law
dictates there will be on that doesn’t.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Also, it returns a string of either true or false, not a Boolean.
This is a bit of a pain in the arse, but not the end of the world I guess.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hope that helps you guys.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>S<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> <a
href="mailto:phpwm-bounces@mailman.lug.org.uk">phpwm-bounces@mailman.lug.org.uk</a>
<a href="mailto:[mailto:phpwm-bounces@mailman.lug.org.uk]">[mailto:phpwm-bounces@mailman.lug.org.uk]</a>
<b>On Behalf Of </b>Mo Awkati<br>
<b>Sent:</b> 27 October 2010 20:22<br>
<b>To:</b> West Midlands PHP User Group<br>
<b>Subject:</b> Re: [Phpwm] mobile redirect<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'>Many thanks
Carl, much appreciated <br>
<br>
Mo<o:p></o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'><o:p> </o:p></span></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
<hr size=1 width="100%" align=center>
</span></div>
<p class=MsoNormal style='margin-bottom:12.0pt'><b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> Carl Sutton <<a
href="mailto:dogmatic69@gmail.com">dogmatic69@gmail.com</a>><br>
<b>To:</b> West Midlands PHP User Group <<a
href="mailto:phpwm@mailman.lug.org.uk">phpwm@mailman.lug.org.uk</a>><br>
<b>Sent:</b> Wed, 27 October, 2010 20:17:58<br>
<b>Subject:</b> Re: [Phpwm] mobile redirect<br>
</span><br>
mo<br>
<br>
when you use cake with that its quite nice as you can just use different html
layouts and views, leaving all the core php and models as is. makes maintenance
much easier.<br>
<br clear=all>
Carl Sutton<br>
<a href="http://dogmatic69.com" target="_blank">dogmatic69.com</a><br>
<br>
<o:p></o:p></p>
<div>
<p class=MsoNormal>On Wed, Oct 27, 2010 at 8:14 PM, Mo Awkati <<a
href="mailto:mawkati@yahoo.co.uk" target="_blank">mawkati@yahoo.co.uk</a>>
wrote:<o:p></o:p></p>
<div>
<div>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'><o:p> </o:p></span></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif"'><o:p> </o:p></span></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
<hr size=1 width="100%" align=center>
</span></div>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Carl Sutton <<a
href="mailto:dogmatic69@gmail.com" target="_blank">dogmatic69@gmail.com</a>><br>
<b>To:</b> West Midlands PHP User Group <<a
href="mailto:phpwm@mailman.lug.org.uk" target="_blank">phpwm@mailman.lug.org.uk</a>><br>
<b>Sent:</b> Wed, 27 October, 2010 19:42:21<br>
<b>Subject:</b> Re: [Phpwm] mobile redirect</span><o:p></o:p></p>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
for serious mobile stuff there is this <a href="http://wurfl.sourceforge.net/"
target="_blank">http://wurfl.sourceforge.net/</a><br>
<br>
if you want something more simple have a look at this <a
href="http://github.com/cakephp/cakephp/blob/master/cake/libs/controller/components/request_handler.php#L356"
target="_blank">http://github.com/cakephp/cakephp/blob/master/cake/libs/controller/components/request_handler.php#L356</a><br>
<br>
redirecting is simple <a
href="http://php.about.com/od/learnphp/ht/phpredirection.htm" target="_blank">http://php.about.com/od/learnphp/ht/phpredirection.htm</a><br>
<br clear=all>
Carl Sutton<br>
<a href="http://dogmatic69.com" target="_blank">dogmatic69.com</a><br>
<br>
<o:p></o:p></p>
<div>
<p class=MsoNormal>On Wed, Oct 27, 2010 at 7:05 PM, Mo Awkati <<a
href="mailto:mawkati@yahoo.co.uk" target="_blank">mawkati@yahoo.co.uk</a>>
wrote:<o:p></o:p></p>
<div>
<div>
<div>
<p class=MsoNormal><span style='font-family:"Arial","sans-serif";color:black'>Hi,<br>
<br>
Can anyone suggest a decent script for detecting mobile phone browsers and
redirecting<br>
visitor to the mobile phone version of the site?<br>
<br>
Many thanks<br>
<br>
Mo<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'>Cheers Carl, the Cake PHP is
more what I was looking for. I did google around but did not not come across
this one.<br>
<br>
many thanks<br>
<br>
Mo<br>
<br>
<o:p></o:p></p>
</div>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<p class=MsoNormal><br>
_______________________________________________<br>
Phpwm mailing list<br>
Website : <a href="http://www.phpwm.org" target="_blank">http://www.phpwm.org</a><br>
Twitter : <a href="http://www.twitter.com/phpwm" target="_blank">http://www.twitter.com/phpwm</a><br>
Facebook: <a href="http://www.facebook.com/group.php?gid=2361609907"
target="_blank">http://www.facebook.com/group.php?gid=2361609907</a><br>
<br>
Post to list: <a href="mailto:Phpwm@mailman.lug.org.uk" target="_blank">Phpwm@mailman.lug.org.uk</a><br>
Archive etc : <a href="https://mailman.lug.org.uk/mailman/listinfo/phpwm"
target="_blank">https://mailman.lug.org.uk/mailman/listinfo/phpwm</a><o:p></o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>