index.php 5.3 KB

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