Smartphones and Pocket PCs redirection
#1
Posted 07 April 2009 - 06:33 PM
Please, would any of PHP experts help me to accomplish this script and verify if everything is correct in it, or not. I'm not a programmer, but I need to create a new snippet to redirect those who use pocket pcs and smartphones to a special page based on a template that fits common mobile browsers requirements. The script is to define user's OS.
<?
$redirect_uri = "_http://www.anysite.org/smartphones.php";
if (eregi("(windows ce)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}"))
elseif (eregi("(palmos) ([0-9]{1,2}.[0-9]{1,2}){0,1}"))
elseif (eregi("symbian"))
elseif (eregi("nitro"))
elseif (eregi("maemo"))
elseif (eregi("PLAYSTATION"))
elseif (eregi("j2me/midp"))
{
Header ("Location: $redirect_uri");
}
?>
#2
Posted 07 April 2009 - 08:22 PM
Also, for the redirect, use $etomite->sendRedirect($redirect_uri);
I'm not sure about the ereg, it's really not my cup of tea, but if it works go for it.
You might like to have a look at this example...
http://www.russellbe...etection-in-php
Edited by Cris D., 07 April 2009 - 08:30 PM.
#3
Posted 07 April 2009 - 08:55 PM
You will need to detect the browser by using $_REQUEST['HTTP_USER_AGENT'] or other methods for phone browsers.
Also, for the redirect, use $etomite->sendRedirect($redirect_uri);
I'm not sure about the ereg, it's really not my cup of tea, but if it works go for it.
You might like to have a look at this example...
http://www.russellbe...etection-in-php
Thank you, Cris, but before I click the link you suggested, there's another idea of the code:
how about it?
<?php
if (stripos($_SERVER['HTTP_USER_AGENT'], 'windows ce') !== FALSE) // or == TRUE
elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'palmos') !== FALSE) // or == TRUE
elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'symbian') !== FALSE) // or == TRUE
elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'nitro') !== FALSE) // or == TRUE
elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'maemo') !== FALSE) // or == TRUE
elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'PLAYSTATION') !== FALSE) // or == TRUE
else if (stripos($_SERVER['HTTP_USER_AGENT'], 'j2me/midp') !== FALSE) // or == TRUE
{
Header ("Location: _http://www.anysite.org/smartphones.php");
}
else
{
Header ("Location: _http://www.anysite.org/index.php");
}
?>
Thus we can chop off all possible mobile OSs and render user a proper page.
#4
Posted 08 April 2009 - 04:07 AM
$etomite->sendRedirect();
And why ask for more help on 1/2 baked code when you havn't checked out the resource I reccomended?
No-one is going to help you unless you have at least tried the code above and can explain the results. Did you want me to install this and test it for you and make the changes and post it back?... It's not going to happen.
I won't be replying to this thread again unless it looks like you are actually trying to integrate it within an etomite installation and can quote the parser error.
#5
Posted 08 April 2009 - 01:29 PM
We're here to give you the best advice we can without having to do all of the work ourselves as we have plenty of our own to do... If someone supplies you with links to code, whether proven or unproven, take advantage of the searching they have already done for you first... If that code can't be adapted, then we can go from there... Remember, you are venturing into what is virgin territory for many of us... I still use tree-knocking for communications...
As far as using $etomite->sendRedirect() instead of header(), the reasoning behind this is that sendRedirect() has features and error handling the header() doesn't have... Whevener Etomite has an alternative to a standard PHP function there is usually a reason and you should use the Etomite alternative...
#6
Posted 09 April 2009 - 08:17 AM
Edited by segri, 09 April 2009 - 08:20 AM.
#7
Posted 09 April 2009 - 08:53 AM
#9
Posted 28 June 2009 - 07:03 AM
I am trying to put redirection code into my website for mobile users as our pages will not shrink, i have created a basic infomation page to redirect mobile users to, i just need some code that works and yes i am thick, where in the HTML code do i place it. etc.
Thank you for your help
thebowes
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











