- ID: lg_un200_ver1_subuanovarravision
- is_mobile: true
- is_robot: true
- preferred_markup: html_wi_oma_xhtmlmp_1_0
- xhtml_support_level: 3
Query WURFL by providing the user agent:
http://fotistudio.ch/ redirects mobile clients according WURFL database to different sites. At the moment four sites are realized:
- http://fotistudio.ch/ - DokuWiki based desktop site
- http://m.fotistudio.ch/ - JQuery mobile site
- http://w.fotistudio.ch/ - WAP site
- http://s.fotistudio.ch/ - Compact HTML site
To fullfill AGPL I have to publish my glue code added to the DokuWiki template. The following lines are at the beginning of lib/tpl/*/main.php:
/* Switch to mobile site when using mobile device, but not when - user is navigating inside - user is switching from HTTPS - user is coming from mobile */ if (substr(getenv('HTTP_REFERER'), 0, 21) != 'http://fotistudio.ch/' && substr(getenv('HTTP_REFERER'), 0, 22) != 'https://fotistudio.ch/' && substr(getenv('HTTP_REFERER'), 0, 23) != 'http://m.fotistudio.ch/' && substr(getenv('HTTP_REFERER'), 0, 23) != 'http://s.fotistudio.ch/' && substr(getenv('HTTP_REFERER'), 0, 23) != 'http://w.fotistudio.ch/' && substr(getenv('HTTP_REFERER'), 0, 23) != 'gopher://fotistudio.ch/' && getenv('HTTPS') != 'on') { // Setup WURFL $wurflDir = $_SERVER['DOCUMENT_ROOT'] . '/wurfl/WURFL'; $resourcesDir = $_SERVER['DOCUMENT_ROOT'] . '/wurfl/resources'; $persistenceDir = $resourcesDir.'/storage/persistence'; $cacheDir = $resourcesDir.'/storage/cache'; require_once $wurflDir.'/Application.php'; $wurflConfig = new WURFL_Configuration_InMemoryConfig(); $wurflConfig->wurflFile($resourcesDir.'/wurfl.zip'); $wurflConfig->wurflPatch($resourcesDir.'/wurfl_patch.xml'); $wurflConfig->matchMode('performance'); $wurflConfig->allowReload(true); $wurflConfig->capabilityFilter(array( 'preferred_markup', 'is_wireless_device', 'xhtml_support_level' )); $wurflConfig->persistence('file', array('dir' => $persistenceDir)); $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000)); $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig); $wurflManager = $wurflManagerFactory->create(); $wurflInfo = $wurflManager->getWURFLInfo(); // Decide which page to show $requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER); if ($requestingDevice->getVirtualCapability('is_mobile') == 'true' && $requestingDevice->getVirtualCapability('is_robot') == 'false') { if ($requestingDevice->getCapability('xhtml_support_level') >= 4) { header('Location: http://m.fotistudio.ch' . getenv('REQUEST_URI')); exit; } else { if (substr($requestingDevice->getCapability('preferred_markup'), 0, 4) == 'wml_') { header('Location: http://w.fotistudio.ch' . getenv('REQUEST_URI')); exit; } else { header('Location: http://s.fotistudio.ch' . getenv('REQUEST_URI')); exit; } } } }
Feel free to copy & paste this code following the license rules of WURFL (AGPL v3) and DokuWiki (GPL v2).
Beat Rubischon <beat@0x1b.ch>