Tera-WURFL

Tera-WURFL is a PHP class that can identify the capabilities of mobile devices using the standardized Wireless Universal Resource File (WURFL). This implementation uses the same methods as the stock PHP WURFL library, but significantly improves performance by storing the WURFL data in a MySQL database. You can also obtain a thumbnail image of the device and include your own device definitions in a patch file. It can figure out if the client visiting your site is a mobile device or a desktop Web browser. It can also identify a wide variety of capabilities.

Tags Software Development Libraries php classes Internet Web Dynamic Content
Operating Systems OS Independent
Implementation PHP

Tweet this project Short link

Rss Recent releases

  • Rrelease-mid
  •  24 Jul 2007 00:05
  • Rrelease-after

Changes: This release introduces an easy to use smart installation script that walks you through the installation to get you up and running in minutes. Also included is an XML Web service that allows you to query your database from any language that supports XML. The device matching system has also been re-written with performance and customization in mind.

  • Rrelease-mid
  •  16 May 2007 00:03
  • Rrelease-after

Changes: This version fixes a bug in version 1.5.0 that prevents the online WURFL DB updating system from working properly.

Changes: A MySQL caching system was introduced. A PHP5 typecasting error which occurred while loading data in tera_wurfl_parser.php was fixed. A PHP5 syntax error in the log_error() function was fixed. A lite version that does not include the 800+ device images or the wurfl.xml file was introduced. This is only a 32k download and once it's installed you can update the wurfl.xml from the admin page.

Changes: The error logging system was completely rewritten and its operation was verified after a bug was discovered. Many features were added to the Web administration console. The default DATADIR was changed to the included "data" directory. The README file was completely rewritten to include detailed installation instructions and other useful information. The clean installation process was optimized. Database statistics, log file monitoring, and global configuration were included in the Web interface. The default log level was changed to LOG_WARNING instead of LOG_ERR.

  • Rrelease-mid
  •  01 May 2007 23:59
  • Rrelease-after

Changes: The web administration interface was updated and some helpful links were added. A few relative path issues when including the class from a different directory were fixed. A couple problems with the naming convention and browser_is_wap detection were fixed.

Rss Recent comments

Rcomment-before 31 Oct 2006 18:31 Rcomment-trans kamermans Rcomment-after

PHP5 + MySQL5 Version
I've been playing around with MySQL 5's Stored Procedures a bit, and I completely implemented the searching section of $obj->getDeviceCapabilitesFromAgent method in 1 stored procedure. This one is a mouthfull but could speed things up significantly!

CREATE PROCEDURE `findUserAgent`(IN minlen INT, IN ua VARCHAR(128), IN preferroot TINYINT)

findua:BEGIN

DECLARE curlen INT;

DECLARE prematch VARCHAR(45) DEFAULT NULL;

DECLARE matches INT DEFAULT 0;

DECLARE maxmatch INT DEFAULT 0;

/* Look for an exact match first */

SELECT deviceID INTO prematch FROM tera_wurfl_hybrid WHERE user_agent=ua LIMIT 1;

IF prematch IS NOT NULL

THEN

/* Found an exact match - done. */

SELECT "Matched Exactly" AS match_type;

SELECT * FROM tera_wurfl_hybrid WHERE deviceID=prematch;

LEAVE findua;

END IF;

/* See if there is ever going to be a match */

SELECT COUNT(user_agent) INTO maxmatch FROM tera_wurfl_hybrid WHERE user_agent LIKE (CONCAT(LEFT(ua,minlen),'%'));

IF maxmatch = 0

THEN

/* No matches were found, even down to the smallest char length - we don't need to continue */

SELECT "Will Never Match" AS match_type;

LEAVE findua;

END IF;

/* We've already tested the full length and the smallest length, so don't test them again */

SELECT LEFT(ua, curlen - 1 ) INTO ua;

SET minlen = minlen + 1;

SELECT CHAR_LENGTH(ua) INTO curlen;

WHILE ( curlen > minlen AND matches = 0) DO

SELECT COUNT(user_agent) INTO matches FROM tera_wurfl_hybrid WHERE user_agent LIKE CONCAT(ua,'%');

IF matches > 0 AND curlen > minlen

THEN

SELECT "Matched After Trimming" AS match_type;

IF preferroot = 1

THEN

/* We would prefer a device root if there are multiple matching user agents */

SELECT * FROM tera_wurfl_hybrid WHERE user_agent LIKE CONCAT(ua,'%') ORDER BY actual_device_root DESC LIMIT 1;

LEAVE findua;

ELSE

/* We could really through a 'ORDER BY RAND() ' in there if we wanted to get creative */

SELECT * FROM tera_wurfl_hybrid WHERE user_agent LIKE CONCAT(ua,'%') ORDER BY actual_device_root ASC LIMIT 1;

LEAVE findua;

END IF;

END IF;

SELECT LEFT(ua, curlen - 1 ) INTO ua;

SELECT CHAR_LENGTH(ua) INTO curlen;

END WHILE;

/*SELECT "done" AS `status`;*/

SELECT "Did Not Match" AS match_type;

END

I may branch off the main PHP4+MySQL4 version and make a new version using this method since it's so fast.

This is auto formatted very poorly so if you want a copy of it in a different form let me know.

4b63207a73abece85e821c489dcd2f38_thumb

Project Spotlight

Templum

A lightweight, simple, and fast templating engine for PHP.

F3f97a3e2cd38ce2bc5d1c5afe6cf9e0_thumb

Project Spotlight

xarclock

An X clock widget.