index.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. require_once 'Zend/Loader/Autoloader.php';
  3. Zend_Loader_Autoloader::getInstance();
  4. $autoloader = Zend_Loader_Autoloader::getInstance();
  5. error_reporting(E_ALL);
  6. set_time_limit(0);
  7. $config['wurflapi']['wurfl_lib_dir'] = dirname(__FILE__) . '/_files/Wurfl/1.1/';
  8. $config['wurflapi']['wurfl_config_file'] = dirname(__FILE__) . '/_files/Wurfl/resources/wurfl-config.php';
  9. $config['terawurfl']['terawurfl_lib_dir'] = dirname(__FILE__) . '/_files/TeraWurfl_2.1.3/tera-WURFL/';
  10. $config['deviceatlas']['deviceatlas_lib_dir'] = dirname(__FILE__) . '/_files/DA_php_1.4.1/';
  11. $config['deviceatlas']['deviceatlas_data'] = dirname(__FILE__) . '/_files/DA_php_1.4.1/sample/json/20101014.json';
  12. $config['mobile']['features']['path'] = 'Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php';
  13. $config['mobile']['features']['classname'] = 'Zend_Http_UserAgent_Features_Adapter_TeraWurfl';
  14. $config['mobile']['features']['path'] = 'Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php';
  15. $config['mobile']['features']['classname'] = 'Zend_Http_UserAgent_Features_Adapter_DeviceAtlas';
  16. $config['server'] = $_SERVER;
  17. if (!empty($_GET['userAgent'])) {
  18. $config['server']['http_user_agent'] = $_GET['userAgent'];
  19. } else {
  20. $_GET['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
  21. }
  22. if (!empty($_GET['sequence'])) {
  23. $config['identification_sequence'] = $_GET['sequence'];
  24. }
  25. $oUserAgent = new Zend_Http_UserAgent($config);
  26. //$oUserAgent = Zend_Http_UserAgent::getInstance ();
  27. function printBrowserDetails($browser)
  28. {
  29. $device = $browser->getDevice();
  30. //Zend_Debug::dump($device->getAllFeatures());
  31. if (isset($device)) {
  32. print "<fieldset><legend><b>General informations</b></legend>";
  33. print "<ul>";
  34. print "<li>Browser Type: " . $browser->getBrowserType() . "</li>";
  35. print "<li>Browser Name: " . $device->getFeature('browser_name') . "</li>";
  36. print "<li>Browser Version: " . $device->getFeature('browser_version') . "</li>";
  37. print "<li>Browser Compatibility: " . $device->getFeature('browser_compatibility') . "</li>";
  38. print "<li>Browser Engine: " . $device->getFeature('browser_engine') . "</li>";
  39. print "<li>Device OS Name: " . $device->getFeature('device_os_name') . "</li>";
  40. print "<li>Device OS token: " . $device->getFeature('device_os_token') . "</li>";
  41. print "<li>Server OS: " . $device->getFeature('server_os') . "</li>";
  42. print "<li>Server Platform: " . $device->getFeature('server_platfom') . "</li>";
  43. print "<li>Server Platform Version: " . $device->getFeature('server_platfom_version') . "</li>";
  44. print "</ul>";
  45. print '</fieldset>';
  46. $wurfl = $device->getFeature("brand_name");
  47. if (!$wurfl) {
  48. print "<fieldset><legend><b>no WURFL identification</b></legend>";
  49. print '</fieldset>';
  50. } else {
  51. print "<fieldset><legend><b>WURFL capabilities</b></legend>";
  52. print "<ul>";
  53. print "<li>Mobile browser: " . $device->getFeature("mobile_browser") . "</li>";
  54. print "<li>Mobile browser version: " . $device->getFeature("mobile_browser_version") . "</li>";
  55. print "<li>Device Brand Name: " . $device->getFeature("brand_name") . "</li>";
  56. print "<li>Device Model Name: " . $device->getFeature('model_name') . "</li>";
  57. print "<li>Device OS: " . $device->getFeature('device_os') . "</li>";
  58. print "<li>Xhtml Preferred Markup:" . $device->getFeature('preferred_markup') . "</li>";
  59. print "<li>Resolution Width:" . $device->getFeature('resolution_width') . "</li>";
  60. print "<li>Resolution Height:" . $device->getFeature('resolution_height') . "</li>";
  61. print "<li>MP3:" . $device->getFeature('mp3') . "</li>";
  62. print "</ul>";
  63. print '</fieldset>';
  64. }
  65. print "<fieldset><legend><b>Full</b></legend>";
  66. Zend_Debug::dump($device->getAllFeatures());
  67. print '</fieldset>';
  68. }
  69. }
  70. $options = array(
  71. '',
  72. 'mobile, text, desktop',
  73. 'bot, mobile, validator, checker, console, offline, email, text',
  74. 'text, bot, validator, checker, console, offline, email'
  75. );
  76. ?>
  77. <div id="content">
  78. <p><b>Query by providing the user agent:</b></p>
  79. <p>look at <a target="_blank"
  80. href="http://www.useragentstring.com/pages/useragentstring.php"
  81. target="_blank">http://www.useragentstring.com/pages/useragentstring.php</a>
  82. or <a href="http://www.user-agents.org/" target="_blank">http://www.user-agents.org/</a></p>
  83. <p>For mobile, look at <a target="_blank"
  84. href="http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones">http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones</a></p>
  85. <fieldset>
  86. <form method="get">
  87. <div>Sequence : <select name="sequence" style="width: 500">
  88. <?php
  89. foreach ($options as $option) {
  90. $selected = ($option == $_GET['sequence'] ? ' selected ' : '');
  91. echo '<option value="' . $option . '"' . $selected . '>' . ($option ? $option : '(standard)') . '</option>';
  92. }
  93. ?>
  94. </select> (DON'T FORGET TO CLEAN SESSION COOKIE)<br />
  95. User Agent : <input type="text" name="userAgent" style="width: 700"
  96. value="<?=htmlentities($_GET['userAgent'])?>" /> <br />
  97. <input type="submit" /></div>
  98. </form>
  99. </fieldset>
  100. <?php
  101. if ($oUserAgent) {
  102. printBrowserDetails($oUserAgent);
  103. }
  104. ?>
  105. </div>