<?php
* Mobile Detect Library
* - export -
* =====================
*
* Use the resulting JSON export file in other languages
* other than PHP. Always check for 'version' key because
* new major versions can modify the structure of the JSON file.
*
* The result of running this script is the export.json file.
*
* @license Code and contributions have 'MIT License'
* More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
*
*/
if( file_exists(dirname(__FILE__).'/nicejson/nicejson.php') ) {
include_once dirname(__FILE__).'/nicejson/nicejson.php';
}
require_once dirname(__FILE__).'/../Mobile_Detect.php';
$detect = new Mobile_Detect;
$json = array(
'version' => $detect->getScriptVersion(),
'headerMatch' => $detect->getMobileHeaders(),
'uaHttpHeaders' => $detect->getUaHttpHeaders(),
'uaMatch' => array(
'phones' => $detect->getPhoneDevices(),
'tablets' => $detect->getTabletDevices(),
'browsers' => $detect->getBrowsers(),
'os' => $detect->getOperatingSystems(),
'utilities' => $detect->getUtilities()
)
);
$fileName = dirname(__FILE__).'/../Mobile_Detect.json';
if (file_put_contents(
$fileName,
function_exists('json_format') ? json_format($json) : json_encode($json)
)) {
echo 'Done. Check '.realpath($fileName).' file.';
}
else {
echo 'Failed to write '.realpath($fileName).' to disk.';
}