NAVIGATION
This shows you the differences between two versions of the page.
|
english:other-enhancements:tools:user-agent [2012/11/08 12:14] Knut Heermann (flip-flop) |
english:other-enhancements:tools:user-agent [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 305: | Line 305: | ||
| \\ | \\ | ||
| - | ===== Extracting the OS version from iOS ===== | + | \\ |
| + | |||
| + | ====== Extracting the OS version from iOS ====== | ||
| + | |||
| + | ==== Version 1.0 ==== | ||
| Use within the CMS e.g.: | Use within the CMS e.g.: | ||
| Line 362: | Line 366: | ||
| \\ | \\ | ||
| + | ==== Version 1.1 ==== | ||
| + | It is tested against iOS versions greater than 5. | ||
| + | |||
| + | Use within the CMS e.g.: | ||
| + | |||
| + | <!--if:platform:iOS-->iOS Version x - 5<!--/if--> | ||
| + | <!--if:platform:iOS_V6-->iOS Version6<!--/if--> | ||
| + | |||
| + | \\ | ||
| + | **Simple script:** derived from -> [[http://stackoverflow.com/questions/7768324/detect-ios-version-with-php|Detect iOS version with PHP]] | ||
| + | |||
| + | **File:** template/inc_script/**frontend_init**/rt_iOS_OS_user_agent.php | ||
| + | |||
| + | <code php |h rt_iOS_OS_user_agent.php |h> | ||
| + | <?php | ||
| + | /* | ||
| + | ******************************************************************* | ||
| + | * 08.11.2012 KH: Extract the OS from the User-Agent for iOS devices | ||
| + | * V1.1 | ||
| + | * This solution can be queried with the built in if statements. -> iOS, iOS_V6 | ||
| + | *Enhanced V1.1: Only if iOS V6 is used, the if statement is extended. | ||
| + | * | ||
| + | * | ||
| + | * In CMS e.g.: | ||
| + | * <!--if:platform:iOS-->iOS Version x - 5<!--/if--> | ||
| + | * <!--if:platform:iOS_V6-->iOS Version6<!--/if--> | ||
| + | * | ||
| + | * File: template/inc_script/frontend_init/rt_iOS_OS_user_agent.php | ||
| + | * | ||
| + | ********************************************************************/ | ||
| + | |||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | // obligate check for phpwcms constants | ||
| + | if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} | ||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | |||
| + | // Example USER-AGENT iOS | ||
| + | // -------------------------------------------------------- | ||
| + | // Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 | ||
| + | // Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 | ||
| + | // -------------------------------------------------------- | ||
| + | |||
| + | if ($GLOBALS['phpwcms']['USER_AGENT']['platform'] == 'iOS') { | ||
| + | |||
| + | $os_vers = preg_replace("/(.*) OS ([0-9]*)_(.*)/","$2", $_SERVER['HTTP_USER_AGENT']); | ||
| + | |||
| + | if (((int) $os_vers) == $os_vers) // Integer ? | ||
| + | if ($os_vers > 5) | ||
| + | $GLOBALS['phpwcms']['USER_AGENT']['platform'] .= '_V6'; | ||
| + | } | ||
| + | |||
| + | ?> | ||
| + | |||
| + | </code> | ||
| + | \\ | ||
| + | |||
| + | |||
| + | If iOS6 is in use we simply appended _V6. (**iOS** -> **iOS_V6**) to the output. All of the lower iOS versions have no control. | ||
| + | |||
| + | Please check with the iPod and older iOS versions. | ||
| + | |||
| + | \\ | ||