MDL-34446 Fix bugs in previous commit

This commit is contained in:
sam marshall 2012-08-15 13:32:19 +01:00 committed by Dan Poltawski
parent 1b2bd9768d
commit 007bf47f10

View file

@ -8394,7 +8394,14 @@ function check_php_version($version='5.2.4') {
if (empty($version)) { if (empty($version)) {
return true; // no version specified return true; // no version specified
} }
if (preg_match("/Opera\/([0-9\.]+)/i", $agent, $match)) { // Recent Opera useragents have Version/ with the actual version, e.g.:
// Opera/9.80 (Windows NT 6.1; WOW64; U; en) Presto/2.10.289 Version/12.01
// That's Opera 12.01, not 9.8.
if (preg_match("/Version\/([0-9\.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) {
return true;
}
} else if (preg_match("/Opera\/([0-9\.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) { if (version_compare($match[1], $version) >= 0) {
return true; return true;
} }
@ -8409,7 +8416,7 @@ function check_php_version($version='5.2.4') {
if (empty($version)) { if (empty($version)) {
return true; // no version specified return true; // no version specified
} }
if (preg_match("/AppleWebKit\/([0-9]+)/i", $agent, $match)) { if (preg_match("/AppleWebKit\/([0-9.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) { if (version_compare($match[1], $version) >= 0) {
return true; return true;
} }
@ -8445,7 +8452,7 @@ function check_php_version($version='5.2.4') {
if (empty($version)) { if (empty($version)) {
return true; // no version specified return true; // no version specified
} }
if (preg_match("/AppleWebKit\/([0-9]+)/i", $agent, $match)) { if (preg_match("/AppleWebKit\/([0-9.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) { if (version_compare($match[1], $version) >= 0) {
return true; return true;
} }
@ -8695,7 +8702,7 @@ function get_browser_version_classes() {
function can_use_rotated_text() { function can_use_rotated_text() {
global $USER; global $USER;
return (check_browser_version('MSIE', 9) || check_browser_version('Firefox', 2) || return (check_browser_version('MSIE', 9) || check_browser_version('Firefox', 2) ||
check_browser_version('Chrome', 21) || check_browser_version('Safari', 536.26) || check_browser_version('Chrome', 21) || check_browser_version('Safari', 536.25) ||
check_browser_version('Opera', 12) || check_browser_version('Safari iOS', 533)) && check_browser_version('Opera', 12) || check_browser_version('Safari iOS', 533)) &&
!$USER->screenreader; !$USER->screenreader;
} }