Exemplo n.º 1
0
<?php

include "mdetect.php";
//Instantiate the object to do our testing with.
$uagent_obj = new uagent_info();
//Detect methods return 1 for true, 0 for false
$isIphoneIpod = $uagent_obj->DetectIphoneOrIpod();
//Check for both!
$isAndroid = $uagent_obj->DetectAndroid();
$isTierIphone = $uagent_obj->DetectTierIphone();
$isTierTablet = $uagent_obj->DetectTierTablet();
$isWebOS = $uagent_obj->DetectPalmWebOS();
$isTierRichCss = $uagent_obj->DetectTierRichCss();
$isTierGenericMobile = $uagent_obj->DetectTierOtherPhones();
if ($isIphoneIpod == 1) {
    header('Location: http://m.northfieldcabinetshop.com');
} else {
    if ($isAndroid == 1) {
        header('Location: http://m.northfieldcabinetshop.com');
    } else {
        if ($isTierIphone == 1) {
            header('Location: http://m.northfieldcabinetshop.com');
        } else {
            if ($isTierTablet == 1) {
                header('Location: http://m.northfieldcabinetshop.com');
            } else {
                if ($isWebOS == 1) {
                    header('Location: http://m.northfieldcabinetshop.com');
                } else {
                    if ($isTierRichCss == 1) {
                        header('Location: http://m.northfieldcabinetshop.com');
 /**
  * Device Detection
  *
  * Detect the user's device by using the MobileESP library written by Anthony Hand [http://blog.mobileesp.com/].
  * Return the string name of their device.
  *
  * @internal         Called during object instantiation
  * @uses             get_option, uagent_info
  * @param    void
  * @return   string  The current user's device in one of four options:
  *                      active, handheld, tablet, low_support
  */
 public function detect_users_device()
 {
     //Default is active (default computer theme set by the admin) until it's overridden
     $device = 'active';
     $low_support_device = 'handheld';
     $low_support_theme = get_option('dts_low_support_theme');
     // Give the handheld theme to any low_support device
     // UNLESS one has been set in the admin already
     if (!empty($low_support_theme) && is_array($low_support_theme)) {
         if (isset($low_support_theme['name'])) {
             if (!empty($low_support_theme['name'])) {
                 //Detect if the device is a low support device (poor css and javascript rendering / older devices)
                 $low_support_device = 'low_support';
             }
             // end if
         }
         // end if
     }
     // end if
     // Check for Varnish Device Detect: https://github.com/varnish/varnish-devicedetect/
     // Thanks to Tim Broder for this addition! https://github.com/broderboy | http://timbroder.com/
     $http_xua_handheld_devices = array('mobile-iphone', 'mobile-android', 'mobile-firefoxos', 'mobile-smartphone', 'mobile-generic');
     $http_xua_tablet_devices = array('tablet-ipad', 'tablet-android');
     // Determine if the HTTP X UA server variable is present
     if (isset($_SERVER['HTTP_X_UA_DEVICE'])) {
         // if it is, determine which device type is being used
         if (in_array($_SERVER['HTTP_X_UA_DEVICE'], $http_xua_handheld_devices)) {
             $device = 'handheld';
         } elseif (in_array($_SERVER['HTTP_X_UA_DEVICE'], $http_xua_tablet_devices)) {
             $device = 'tablet';
         }
     } else {
         // DEFAULT ACTION - Use MobileESP to sniff the UserAgent string
         // Include the MobileESP code library for acertaining device user agents
         include_once 'mobile-esp.php';
         // Setup the MobileESP Class
         $ua = new uagent_info();
         // Detect if the device is a handheld
         if ($ua->DetectSmartphone() || $ua->DetectTierRichCss()) {
             $device = 'handheld';
         }
         // Detect if the device is a tablet
         if ($ua->DetectTierTablet() || $ua->DetectKindle() || $ua->DetectAmazonSilk()) {
             $device = 'tablet';
         }
         // Detect if the device is a low_support device (poor javascript and css support / text-only)
         if ($ua->DetectBlackBerryLow() || $ua->DetectTierOtherPhones()) {
             $device = $low_support_device;
         }
     }
     // end if
     // Return the user's device
     return $device;
 }