I've got customers using Parallels Web Presence Builder (WPB) which is a tool that helps you design web sites. They don't have direct access to the files. It's a front end for building the web site. They have a partnership with Unity Mobile. With Unity Mobile, you can build mobile friendly web sites.
So you build your main web site using WPB, then hit a button in the control panel that kicks you out to Unity Mobile where you build your mobile version. Unity Mobile provides some code to insert in the main site that is supposed to provide redirection for mobile devices. You browse from your phone or tablet to the main site, this code is supposed to execute, redirecting you to the mobile site.
Only, the code provided by Unity Mobile does not work given where WPB places the code in the page. So I'm looking for alternative methods of redirection.
So the code they provide should be inserted just under the opening HTML tag, before any other scripts execute. The Problem is that WPB places it much further down where the HTTP header that PHP tries adding does not work. Can anyone provide an alternative method that would work given where WPB places the code?
This is what the code should look like if placed correctly:
This is what WPB actually does, placing it much further down:
So you build your main web site using WPB, then hit a button in the control panel that kicks you out to Unity Mobile where you build your mobile version. Unity Mobile provides some code to insert in the main site that is supposed to provide redirection for mobile devices. You browse from your phone or tablet to the main site, this code is supposed to execute, redirecting you to the mobile site.
Only, the code provided by Unity Mobile does not work given where WPB places the code in the page. So I'm looking for alternative methods of redirection.
So the code they provide should be inserted just under the opening HTML tag, before any other scripts execute. The Problem is that WPB places it much further down where the HTTP header that PHP tries adding does not work. Can anyone provide an alternative method that would work given where WPB places the code?
This is what the code should look like if placed correctly:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<?PHP
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
$mobile_site_url = 'http://mobile.domain.com/';
$is_mobile = false;
$browser = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
$is_mobile = true;
} else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
$is_mobile = true;
} else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
$is_mobile = true;
};
if ($is_mobile)
header('Location: ' . $mobile_site_url);
}
?>
<head>
This is what WPB actually does, placing it much further down:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Home - Site Name</title>
<meta name="description" content="Some description here" /><meta name="keywords" content="some,keywords,here" /><meta name="generator" content="Parallels Web Presence Builder 11.0.10" />
<link rel="stylesheet" type="text/css" href="../css/style.css?template=generic" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="../css/ie7.css?template=generic" />
<![endif]-->
<script language="JavaScript" type="text/javascript" src="../js/style-fix.js"></script>
<script language="JavaScript" type="text/javascript" src="../js/css_browser_selector.js"></script>
<link type="text/css" href="../css/header-8b8528d2-66b4-12cd-ab1c-0aedf2d1d468.css?template=generic" rel="stylesheet" />
<link type="text/css" href="../css/navigation-a0049a57-79e8-aea6-d77b-1ab78d7146f2.css?template=generic" rel="stylesheet" />
<!--[if IE]><style type="text/css"></style><![endif]--><style type="text/css">#watermark {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.content {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.column1 {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.column2 {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
.header {-webkit-border-radius:0 0 10px 10px;-moz-border-radius:0 0 10px 10px;border-radius:0 0 10px 10px;}
.footer {-webkit-border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;border-radius:10px 10px 10px 10px;}
#content .container-content-inner {padding-bottom: 10px}
#content .container-content-inner {padding-top: 10px}
#column1 .container-content-inner {padding-bottom: 10px}
#column1 .container-content-inner {padding-top: 10px}
#column2 .container-content-inner {padding-bottom: 10px}
#column2 .container-content-inner {padding-top: 10px}
#header .widget-header:last-child .widget-content{-webkit-border-bottom-right-radius: 10px;-moz-border-radius-bottomright: 10px;border-bottom-right-radius: 10px;-webkit-border-bottom-left-radius: 10px;-moz-border-radius-bottomleft: 10px;border-bottom-left-radius: 10px;}
#header .widget-navigation .widget-content {padding-right: 10px}
#header .widget-navigation .widget-content {padding-left: 10px}
#footer .widget-navigation .widget-content {padding-right: 10px}
#footer .widget-navigation .widget-content {padding-left: 10px}
</style><script type="text/javascript" src="../components/jquery/jquery.min.js?ac=11.0.10_38713.12081600"></script>
<script type="text/javascript" src="../js/helpers.js?ac=11.0.10_38713.12081600"></script>
<link rel="shortcut icon" href="../favicon.ico?1394043840">
<script type="text/javascript">var siteBuilderJs = jQuery.noConflict(true);</script><script type="text/javascript">siteBuilderJs.startFixHeightColumns();</script><script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-48157946-1', 'domain.com');
ga('send', 'pageview');
</script>
</head>
<body id="template" class="">
<div class="site-frame">
<div id="wrapper" class="container-content external-border-none ">
<div class="external-top"><div><div><div><div></div></div></div></div></div>
<div class="external-side-left">
<div class="external-side-left-top">
<div class="external-side-left-bottom">
<div class="external-side-right">
<div class="external-side-right-top">
<div class="external-side-right-bottom">
<div id="watermark" class="pageContentText border-none">
<div id="watermark-content" class="container-content">
<div id="layout"><div id="header" class="header border-none">
<div id="header-top" class="top"><div><div></div></div></div>
<div id="header-side" class="side"><div id="header-side2" class="side2">
<div class="container-content">
<div id="header-content">
<div class="container-content-inner" id="header-content-inner">
<div class="widget widget-script" id="widget-facfbce9-46a4-bf01-1e63-39302f8f3dd8">
<div class="widget-content"><?PHP
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
$mobile_site_url = 'http://mobile.domain.com/';
$is_mobile = false;
$browser = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
$is_mobile = true;
} else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
$is_mobile = true;
} else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
$is_mobile = true;
};
if ($is_mobile)
header('Location: ' . $mobile_site_url);
}
?></div>
</div>
<div class="wi