/** * Get the key capabilities of the device * @return associative array of the capabilities */ public function getKeyCapabilities() { if (!$this->keyCapabilitiesAreSet) { if ($this->teraWurflObject->getDeviceCapabilitiesFromAgent()) { foreach ($this->keyCapabilities as $key => $value) { $this->keyCapabilities[$key] = $this->teraWurflObject->getDeviceCapability($key); } } $this->keyCapabilitiesAreSet = TRUE; } return $this->keyCapabilities; }
protected function actionRequest() { $this->wurfl->getDeviceCapabilitiesFromRequest($this->http_headers); $this->response['id'] = $this->wurfl->capabilities['id']; $this->response['user_agent'] = $this->wurfl->httpRequest->user_agent->original; if (!empty($this->capabilities)) { $this->response['capabilities'] = array(); foreach ($this->capabilities as $capability) { $this->response['capabilities'][$capability] = $this->wurfl->getDeviceCapability($capability); } } if ($this->matcher_history) { $this->response['matcher_history'] = $this->wurfl->getDeviceCapability('matcher_history'); } $this->response['success'] = true; $this->sendResponse(); }
<link rel="stylesheet" type="text/css" href="../../css/device/explorer.css" media="all" /> <![endif]--> </head> <body> <div id="container"> <h2><?php print $pageTitle; ?> </h2> <div id="content"> <h3>Raw Demo Results:</h3> <p class="centered"> <?php print 'wurflObj->getDeviceCapability("is_wireless_device") = ' . $wurflObj->getDeviceCapability("is_wireless_device"); ?> </p> <h3>Using the Results</h3> <?php if ($wurflObj->getDeviceCapability("is_wireless_device")) { ?> <p>This is content for phones only.</p> <p>You might want this content to link to <a href="https://en.wikipedia.org/wiki/Mobile_security">a page about mobile security</a>, for example.</p> <?php } else { ?> <p>This is content for browsers that are not on a phone.</p>
<?php require_once "TeraWurfl.php"; //include the Tera-WURFL file $wurflObj = new TeraWurfl(); //instantiate the Tera-WURFL object $wurflObj->getDeviceCapabilitiesFromAgent(); //get the capabilities of the current client //see if this client is on a wireless device (or if they can't be identified) if (!$wurflObj->getDeviceCapability("is_wireless_device")) { echo "<h2>You should not be here</h2>"; } echo "Markup: " . $wurflObj->getDeviceCapability("preferred_markup"); //see what this device's preferred markup language is $width = $wurflObj->getDeviceCapability("resolution_width"); //see the display resolution WIDTH $height = $wurflObj->getDeviceCapability("resolution_height"); //see the display resolution HEIGHT echo "<br/>Resolution: {$width} x {$height}<br/>";
/***BEGIN GEO TRACKING****/ if (bt_geo_enabled()) { require BT_ROOT . '/private/includes/traffic/geolookup.php'; $geo_block_id = runGeoLookup(); } /***END GEO TRACKING****/ /***BEGIN MOBILE TRACKING****/ if (bt_mobile_enabled()) { require BT_ROOT . '/private/includes/traffic/organization.php'; $organization_id = runOrganizationLookup(); //Track Devices: require_once BT_ROOT . '/private/libs/wurfl/TeraWurfl.php'; $wurflObj = new TeraWurfl(); $wurflObj->getDeviceCapabilitiesFromAgent(); //dont run for desktop OSes. $is_wireless = $wurflObj->getDeviceCapability('is_wireless_device'); $is_tablet = $wurflObj->getDeviceCapability('is_tablet'); $is_phone = $wurflObj->getDeviceCapability('can_assign_phone_number'); $is_desktop = true; if ($is_wireless == 'true') { $is_desktop = false; } else { if ($is_tablet == 'true') { $is_desktop = false; } else { if ($is_phone == 'true') { $is_desktop = false; } } } //dont run if its a desktop