Created
July 11, 2013 14:32
-
-
Save openprojdev/5975977 to your computer and use it in GitHub Desktop.
Mobile Request Redirection using WURFL Lib, and Tera Wurfl PHP Lib http://wurfl.sourceforge.net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Set mobile check to true | |
| $mobile_check = true; | |
| if (preg_match('/bot|ipad|xoom|sch-i800|playbook|tablet|kindle/i',$_SERVER['HTTP_USER_AGENT'])) { | |
| $mobile_check = false; | |
| } | |
| if ( isset($_GET['desktop']) && !empty($_GET['desktop']) ) { | |
| $mobile_check = false; | |
| setcookie('desktop', 1); | |
| } | |
| if ( isset($_COOKIE['desktop']) && !empty($_COOKIE['desktop']) ) { | |
| $mobile_check = false; | |
| } | |
| if ($mobile_check == true ) { | |
| # Mobile redirection using WURFL Lib and database downloaded from http://wurfl.sourceforge.net | |
| require_once './Tera-Wurfl/TeraWurfl.php'; | |
| $wurflObj = new TeraWurfl(); | |
| $wurflObj->getDeviceCapabilitiesFromAgent(); | |
| if($wurflObj->getDeviceCapability("is_wireless_device")){ | |
| header("Location: http://mobilesite" . $_SERVER['REQUEST_URI']); | |
| exit(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment