Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Tera-WURFL is a PHP & MySQL based library that uses the Wireless Universal Resource File (WURFL) to identify specific mobile device capabilities and features.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
DatabaseConnectors
TeraWurflRemoteClient
TeraWurflUtils
TeraWurflXMLParsers
UserAgentMatchers
admin
data
test
.gitignore
README
TeraWurfl.php
TeraWurflConfig.php.example
TeraWurflLoader.php
TeraWurflWebservice.php
UserAgentFactory.php
UserAgentUtils.php
WurflConstants.php
WurflSupport.php
check_wurfl.php
test_usage.php
webservice.php

README

Tera-WURFL README
Version Stable 2.1.4
http://www.tera-wurfl.com/
https://github.com/kamermans/Tera-WURFL
http://www.linkedin.com/pub/steve-kamerman/8/761/89
-----------------------

JUST GET ME TO THE INSTALLATION!
Ok, it took me a lot longer to write this then it will take you to read it,
so please read EVERYTHING from INSTALLATION on.  Feel free to email me if
you need help with anything, or to request new features.

ABOUT TERA-WURFL
Tera-WURFL is a PHP based library with a database backend (MySQL, MSSQL, 
MongoDB) that uses the Wireless Universal Resource File (WURFL). The WURFL 
website  nicely defines the WURFL as follows: "The WURFL is an "ambitious" 
configuration file that contains info about all known Wireless devices on 
earth. Of course, new devices are created and released at all times. While 
this configuration file is bound to be out of date one day after each update,
chances are that the WURFL lists all of the WAP devices you can purchase in 
the nearest shops."

Tera-WURFL takes some functionality from the original PHP Tools Library by 
Andrea Trasatti and a prerelease version of the Java WURFL Evolution. It 
serves as a drop in replacement for the original PHP Tools with only minor 
changes to your existing code. Since Tera-WURFL uses a database backend, 
the real world performance increase over the existing PHP Tools implementation 
is extremely high - normally between 5x and 10x faster!

The author of Tera-WURFL is Steve Kamerman, a professional PHP Programmer,
MySQL DBA, Flash/Flex Actionscript Developer, Linux Administrator, 
IT Manager and part-time American Soldier. This project was originally 
sponsored by Tera Technologies and was developed as an internal project 
used for delivering content to customers of the mobile ringtone and image 
creation site Tera-Tones.com.

Read more about Tera-WURFL and download the latest release at:
http://www.tera-wurfl.com/

See what else Steve Kamerman has cookin' at his blog:
http://www.stevekamerman.com/

INSTALLATION
1. Copy the files into a directory on your webserver that can be accessed
   from the internet.  For the purposes of explaination I will refer to this
   location as http://yourserver.com/Tera-Wurfl/, with a local directory
   of /var/www/Tera-Wurfl/.
2. Open a web browser and go to:
   http://yourserver.com/Tera-Wurfl/admin/install.php
   you should see the "Tera-WURFL Installation" page with a bunch of errors
   on it.  The next steps will show you how to correct these errors.  You 
   can refresh this page to verify that your changes have taken effect.

CONFIGURATION FILE
3. Copy TeraWurflConfig.php.example to TeraWurflConfig.php, then edit it.
   Each setting is described in comments.  The only thing you NEED to modify
   is the database info (user, pass, db, etc).

FILE PERMISSIONS
4. By default, the DATADIR is set to "data/".  This directory holds the
   wurfl.xml file, your patch file(s) and the log file.  This directory
   and EVERYTHING in it needs to be accessible (read+write) by the user
   that runs your webserver. This is normally "apache", "www-data" or 
   "nobody" in Linux. (chown -R apache:apache ./data/)
5. Verify that the permissions errors on the installation page are fixed
   by refreshing the browser.
   
DATABASE OPTIONS
6. Create a new database for Tera-WURFL and a user that has a minimum of
   the following privileges on the new database:
      SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, CREATE TMP TABLE,
      CREATE ROUTINE, ALTER ROUTINE, EXECUTE
7. In the config file, set the DB_HOST, DB_USER, DB_PASS and DB_SCHEMA.
8. Verify that the database errors on the installation page are fixed
   by refreshing the browser.  If the database tables don't exist yet
   they will be created for you when you load the WURFL file.

LOADING THE Tera-WURFL DATABASE
9. If you are satisfied with the results on the installation page, you
   can load the database with the WURFL data.  There are three sources
   that the data can come from:
   a. Your local WURFL file
      This will load the DATADIR/wurfl.xml file into your database.
   b. The current released WURFL
      This will download the current wurfl.xml file from the official
      WURFL website and load it into your database.
   c. The current CVS WURFL
      This will download the current unreleased CVS wurfl.xml file from
      the official WURFL website and load it into your database.
10.There will be a delay while the server loads/downloads the WURFL, then
   you should see something like this:

Database Update OK

Total Time: 10.211848974228
Parse Time: 0.43991899490356
Validate Time: 2.7456870079041
Sort Time: 1.3005568981171
Patch Time: 0.44084501266479
Database Time: 3.9245390892029
Cache Rebuild Time: 1.3603019714355
Number of Queries: 294
PHP Memory Usage: 213.19 MB
--------------------------------
WURFL Version: www.wurflpro.com - 2009-08-25 08:15:48 (Tue Aug 25 08:19:41 -0500 2009)
WURFL Devices: 13714
PATCH New Devices: 3036
PATCH Merged Devices: 2

Update Complete!
   
   If there are errors, they are most likely problems connecting to the WURFL
   site or permission problems trying to write the temporary downloaded file
   to the DATADIR directory.  Also, many users have reported a "memory allocation"
   error - to fix this look for "OVERRIDE_MEMORY_LIMIT" in the config file. If 
   there are no errors, click on "Return to administration tool".

ADMINISTRATION PAGE
11.Verify that the WURFL is loaded by clicking on "Statistics, Settings,
   Log File".  You should see that there is data in your MERGE and INDEX
   tables. The CACHE table will fill up with cached data as devices access
   your site, and it will be cleared ONLY if you click on "Clear the device
   cache" from main administration page.
12.Click on "Tera-WURFL test script" to test the installation.  You can
   type in any user agent to search for it in the WURFL.  If you have caching
   enabled (default), the first time you search for a user agent you will see
   the total number of queries that Tera-WURFL performed to find a match
   (unless there was no match).  If there was a match, the device will be
   cached and the next time you search for it you will see "Total Queries: 1
   (Found in cache)".  Tera-WURFL only needed to perform 1 query since the
   devices full capabilities were cached.  If you go back to the admin page
   and look at the settings, you will see that the CACHE now has
   a couple rows in it.  You can verify the device was cached properly by going
   to "Cache Browser" from the main page and clicking on your user agent.
   
SECURITY
13.You should delete the admin/install.php file if everything is working ok.
14.Protect your 'admin' directory by using a method specific to your web
   server software.  For Apache, this means a .htaccess file would work:
   http://www.mobilefish.com/developer/apache/apache_quickguide_htaccess.html#protect

EXAMPLE
Here is a very simple example:
<?php
// Include the Tera-WURFL file
require_once('./TeraWurfl.php');

// instantiate the Tera-WURFL object
$wurflObj = new TeraWurfl();

// Get the capabilities of the current client.
$wurflObj->getDeviceCapabilitiesFromAgent();

// 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>";
}

// see what this device's preferred markup language is
echo "Markup: ".$wurflObj->getDeviceCapability("preferred_markup");

// see the display resolution
$width = $wurflObj->getDeviceCapability("resolution_width");
$height = $wurflObj->getDeviceCapability("resolution_height");
echo "<br/>Resolution: $width x $height<br/>";
?>

The complete list of capabilities is available here:
http://wurfl.sourceforge.net/help_doc.php#product_info
If you use $wurflObj->getDeviceCapability("cap_name") you can just use the capability name from
the WURFL site, otherwise you can access it directly from the wurfl object's
capabilities array like this: $wurflObj->capabilities['group_name']['cap_name']

Please see the test script (check_wurfl.php) for another example of usage.

SUPPORT

Please direct your questions to the Tera-WURFL Forum: http://www.tera-wurfl.com/forum
You can also contact Steve Kamerman by sending a GitHub message: https://github.com/kamermans/
Something went wrong with that request. Please try again.