About Tera-WURFL

Tera-WURFL is a PHP & MySQL based library 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 is loosely based on the original PHP Tools Library by Andrea Trasatti and serves as a drop in replacement with only minor changes to your existing code. Since Tera-WURFL uses a MySQL database backend, the real world performance increase over the existing PHP Tools (with multicache) 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/Actionscript Developer and Linux Administrator. This project is financially sponsored by Tera Technologies and was originally an internal project used for delivering content to customers of the mobile ringtone and image creation site Tera-Tones.com.

WALL4PHP Support

With the release of WALL4PHP 1.1 (the Wireless Abstraction Library), Kaspars Foigts has been nice enough to add support for Tera-WURFL! Thanks :D. To make your life easier, I have decided to combine the Tera-WURFL and WALL4PHP in one pre-configured package. To get it, just look for it in the 'Downloads' section.

Contents

Online Demo

Check out Tera-WURFL in action before you even install it! I've put a couple demos up for you, check 'em out:

Demo #1: Tera-WURFL identifying over 300 devices in real time.
This demo churns through my database of unique user agents / http headers and attempts to identify every device. As of version 1.5.0, Tera-WURFL now uses a caching system to increase performance and decrease server load. If you want to see the real world performance, you can go to the web administration below and update the WURFL file over the Internet. This will force the cache to be emptied, then when you visit this demo you will see real world performance.

Demo #2: Tera-WURFL Web Administration
This is the web administration page that comes with Tera-WURFL. It allows you to update the WURFL database over the Internet (or locally), update your database with your custom patch file and test your current configuration with manually entered user agents.

Demo #3: Tera-WURFL Manual Test Script
This script is very similar to the "check_wurfl.php" script used in the standard PHP Tools library, but it also includes an image of the identified device, if available.

Download

Please note that the wurfl.xml file and the device images are no longer included in the Tera-WURFL package. Since the WURFL data changes regularly, the default now is to download the WURFL data from the Internet via the admin page. The device images are available at the WURFL Device Images page and should be extracted into the "device_pix" folder.

Current version:
tera_wurfl-stable_v1.5.2.zip (44kb) New Release - 22 July 2007!

Version 1.5.2 + WALL4PHP:
Here is version 1.5.2 pre-configured with WALL4PHP 1.1:
tera_wurfl1.5.2_wall4php1.1.zip (150kb - includes WALL4PHP 1.1)

Older versions:
tera_wurfl-stable_v1.5.1.zip (2.7mb)
tera_wurfl-stable_v1.5.1_lite.zip (31kb) Lite version.
tera-wurfl1.5.1_wall4php1.1.zip (2.9mb - includes WALL4PHP 1.1)
tera_wurfl-stable_v1.5.0.zip (2.7mb)
tera_wurfl-stable_v1.5.0_lite.zip (31kb) Lite version.
tera-wurfl1.5.0_wall4php1.1.zip (2.9mb - includes WALL4PHP 1.1)
tera_wurfl-beta-v1.4.4.zip (2.7mb)
tera_wurfl1.4.4_wall4php1.1.zip (2.8mb - includes WALL4PHP 1.1)
tera_wurfl-beta-v1.4.3.zip (2.4mb)
tera_wurfl1.4.3_wall4php1.1.zip
(2.6mb - includes WALL4PHP 1.1)
tera_wurfl-beta-v1.4.2.zip (2.4mb)
tera_wurfl-beta-v1.4.1.zip
(2.4mb)
tera_wurfl-beta-v1.4.0.zip
(2.4mb)
tera_wurfl-beta-v1.3.0.zip (18kb)
tera_wurfl-beta-v1.2.zip (18kb)
tera_wurfl-alpha2-v1-1-4-4.zip (16kb)

Version History

Stable 1.5.2
Introduced a smart installation script to help you get Tera-WURFL up and running fast!
getDeviceCapabilitiesFromAgent() function now returns boolean true (match) or false (no match).
Introduced "MATCH_TO_UA_PREFIX" if true, matching will stop if the user agent prefix cannot be matched. The user
    agent prefix is everything from the beginning of the UA to the first '/', like "SonyEricssonK700i". If this is not matched in
    the WURFL, there searching will stop.
Introduced "RETURN_GENERIC" if true, the user agent and accept headers will be used to determine if this device is
    wireless or not and the capabilities array will be populated with appropriate generic data. This IS considered a match.
    Set this to false to stop getting generic matches.
Introduced webservice.php which can be used to query the Tera-WURFL database via an HTTP request. The results are
   returned in XML. This is a BETA feature, but it is very safe. There are details and example in the head of the file.
Re-wrote the README file - now it has very clear instructions on usage and installation.
Now Tera-WURFL includes the web browsers patch by default so you can tell Mobile and Non-Mobile devices apart.
Cleaned up some minor logging issues.
Completely re-wrote the UA matching system, scrapping a lot of unnecessary code that was wasting time!

Stable 1.5.1
Fixed a bug that prevented the updating system from working correctly over the web.
If you have version 1.5.0 you can delete line 266 from the file tera_wurfl_parser.php and it will function the same as 1.5.1.

Stable 1.5.0
Introduced a MySQL caching system - many thanks to Andrea Trasatti for his help!
Fixed a PHP5 typecasting error while loading data in tera_wurfl_parser.php (thanks Mait Vilbiks and everyone else!)
Fixed a PHP5 syntax error in the log_error() function (thanks Michal Albrecht!)
Introduced a lite version that does not include the 800+ device images or the wurfl.xml file. This is only a 32k download
    and one it's installed you can update the wurfl.xml from the admin page.
After much testing and some decent market penetration I have deemed this class "Stable".

Beta 1.4.4
Completely rewrote the error logging system and verified it's operation after a bug was discovered (thanks Neil!)
Added many features to the web administration console - seriously - check out the online demo!
Changed default DATADIR to the included 'data' directory
Completely rewrote the README file to include detailed installation instructions and other useful info
Optimized the clean installation process - now Tera-WURFL has a brain!
Included the current stable release of the wurfl.xml file so you don't need to download it
Included database statistics, log file monitoring and global configuration in web interface
Changed default log level to LOG_WARNING instead of LOG_ERR
Described in great detail the purpose of the different database tables

Beta 1.4.3
Updated the web administration interface and added some helpful links.
Fixed a few relative path issues when including the class from a different directory.
Fixed a couple problems with my naming convention and browser_is_wap detection (thanks MOLABIB!)

Beta 1.4.2
Changed the web update URL for the wurfl.xml file.
Made the file locations absolute instead of relative so you can run the class from a different directory
Fixed an issue with the searching algorithm - thanks Christian Aune Thomassen! (WapTheWeb)

Beta 1.4.1
Fixed issues with incorrectly identified device root resulting in the wrong device image being used.

Beta 1.4.0
Added support for the Device Thumbnails by André van den Heever and Luca Passani.

Beta 1.3.0
Added patching support to allow users to make changes to their WURFL database without editing the main WURFL.
Added the ability to enable/disable the patch without rebuilding the database.
Added a simple web administration utility to manage the WURFL and patch file.
Added the ability to update the WURFL database directly from wurfl.sourceforge.net

Beta 1.2
Initial public release. Basic implementation of the library - very limited documentation included in comments.

Alpha2
Internal release. This is left on the site for historical reasons only. Use of this version is not recommended!

News

April 27, 2007 - Tera-WURFL goes stable!

Thanks to everyone who helped me test Beta 1.4.5RC1 - this pre-release was the stepping stone to version Stable 1.5.0.
I was lucky to get some help testing 1.4.5RC1 from a client that gets very high traffic. After upgrading from 1.4.4 to 1.4.5RC1, his server's mysqld process went from 20-40% down to 6%!

"The system gets over 2 million WAP hits per day ... The impact on the server is definitely significant. Before this, mysqld was using between 20% and 40% of the CPU, and now it's down to 6% or less. Load average on the box was averaging 3.84 before, and now it's averaging 2.72."

November 16, 2006 - WURFL and Tera-WURFL Updated!

The WURFL has been updated and now contains over 2000 real devices! Unfortunately somewhere along the line the people over at the WURFL project moved the wurfl.xml file! The file used to be located at http://www.nusho.it/wurfl/dl.php?t=d&f=wurfl.xml, but now that page returns an HTTP Error 302 (Moved Temporarily) and would normally redirect you to the actual file, but file_get_contents() and the fopen wrappers in PHP don't follow header redirections like a browser does - this results in an error when you try to update it. To fix the problem, you can change the WURFL_DL_URL constant in the configuration file to "http://wurfl.sourceforge.net/wurfl.xml".

I have been thinking about a caching system per Christian Aune Thomassen's request - this seems like a good idea but I need to look into some other issues first - like putting a system together so you can easily add devices to your patch file from the web interface.

Online Documentation

You should start out by reading the README file. This file contains lots of important information, like installation.

Here are some important documentation links:

README
Class Documentation
Configuration File Documentation

You can also see the highlighted source code for all the files in the documentation area.

Links

Contact Us

You can email me - Steve Kamerman at kamermans(at)teratechnologies.net