Mobile website
<?php
if(isset($_GET['normal_site'])){
setcookie('mobile_site', 'off', time() + 604800);
header('Location: http://nerd.net');
}
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>Mobile Site | NERD.net</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta name='description' content=''>
<meta name='author' content='Fred Morlock'>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src='http://html5shim.googlecode.com/svn/tru ... '></script>
<![endif]-->
<script type='text/javascript'>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33874985-1']);
_gaq.push(['_setDomainName', 'nerd.net']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<h1>This is going to be the mobile site. </h1>
<footer><a href='index.php?normal_site=1'>Use Normal Site</a></footer>
</body>
</html>
init.inc.php (Lots of code. Only posting what is important)
$detect = new Mobile_Detect();
if(isset($_COOKIE['mobile_site'])){
if((($_COOKIE['mobile_site']) === 'off')){
// do nothing
}
}else{
if ($detect->isMobile()) {
header('Location: http://m.nerd.net');
}
}