TeraWurfl
[ class tree: TeraWurfl ] [ index: TeraWurfl ] [ all elements ]

Source for file check_wurfl.php

Documentation is available at check_wurfl.php

  1. <?php
  2. /**
  3.  * Tera_WURFL - PHP MySQL driven WURFL
  4.  * 
  5.  * Tera-WURFL was written by Steve Kamerman, and is based on the
  6.  * Java WURFL Evolution package by Luca Passani and WURFL PHP Tools by Andrea Trassati.
  7.  * This version uses a MySQL database to store the entire WURFL file, multiple patch
  8.  * files, and a persistent caching mechanism to provide extreme performance increases.
  9.  * 
  10.  * @package TeraWurfl
  11.  * @author Steve Kamerman <stevekamerman AT gmail.com>
  12.  * @version Stable 2.1.3 $Date: 2010/09/18 15:43:21
  13.  * @license http://www.mozilla.org/MPL/ MPL Vesion 1.1
  14.  *
  15.  */
  16. if (!isset($_GET['force_ua'])) {
  17.     $_GET['force_ua''SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1';
  18. }
  19. ?>
  20. <form action="check_wurfl.php" method="GET">
  21. Mobile device user agent:<br />
  22. <input type="text" name="force_ua" size="100" value="<?php echo $_GET['force_ua']?>">
  23. <input type="submit" name="submit" value="Submit"/>
  24. </form>
  25. Try some of these:
  26. <ul>
  27.   <li><pre>SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1</pre></li>
  28.   <li><pre>MOT-T720/S_G_05.30.0CR MIB/2.0 Profile/MIDP-1.0 Configuration/CLDC-1.0</pre></li>
  29.   <li><pre>SAGEM-myX5-2/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.0 UP.Browser/6.2.2.6.d.2 (GUI) MMP/1.0</pre></li>
  30.   <li><pre>NokiaN90-1/3.0541.5.2 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1</pre></li>
  31. </ul>
  32. <hr size="1" />
  33. <?php
  34.  
  35. list($usec$secexplode(" "microtime());
  36. $start ((float)$usec + (float)$sec)
  37.  
  38. // Include the Tera-WURFL file
  39. require_once realpath(dirname(__FILE__).'/TeraWurfl.php');
  40.  
  41. list($usec$secexplode(" "microtime());
  42. $load_class ((float)$usec + (float)$sec)
  43.  
  44. // instantiate the Tera-WURFL object
  45. $wurflObj new TeraWurfl();
  46.  
  47. list($usec$secexplode(" "microtime());
  48. $init_class ((float)$usec + (float)$sec)
  49.  
  50. // Get the capabilities from the object
  51. $matched $wurflObj->GetDeviceCapabilitiesFromAgent($_GET['force_ua']);
  52.  
  53. list($usec$secexplode(" "microtime());
  54. $end ((float)$usec + (float)$sec)
  55.  
  56. echo "Time to load TeraWurfl.php:".($load_class-$start)."<br>\n";
  57. echo "Time to initialize class:".($init_class-$load_class)."<br>\n";
  58. echo "Time to find the user agent:".($end-$init_class)."<br>\n";
  59. echo "Total:".($end-$start)."<br>\n";
  60. $cached ($wurflObj->foundInCache)"<strong>(Found in cache)</strong>""";
  61. echo "<br>Total Queries: ".$wurflObj->db->numQueries." $cached<br>\n";
  62.  
  63. $text ($matched)?"a conlusive":"an <font color=\"#990000\">inconclusive</font>";
  64. echo "<h3>Test resulted in $text match</h3>";
  65. echo "<pre>";
  66. var_export($wurflObj->capabilities);
  67. echo "</pre>";
  68.  
  69. ?>
  70. <form action="check_wurfl.php" method="GET">
  71. Mobile device user agent:<br />
  72. <input type="text" name="force_ua" size="100" value="<?php echo $_GET['force_ua']?>">
  73. <input type="submit" name="submit" value="Submit"/>
  74. </form>

Documentation generated on Sun, 19 Sep 2010 00:15:48 +0000 by phpDocumentor 1.4.3