MDL-34446 Fix bugs in previous commit
authorsam marshall <s.marshall@open.ac.uk>
Wed, 15 Aug 2012 12:32:19 +0000 (13:32 +0100)
committerDan Poltawski <dan@moodle.com>
Thu, 16 Aug 2012 06:48:15 +0000 (14:48 +0800)
lib/moodlelib.php

index 16106b4..f229b6b 100644 (file)
@@ -8369,7 +8369,14 @@ function check_php_version($version='5.2.4') {
           if (empty($version)) {
               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) {
                   return true;
               }
@@ -8384,7 +8391,7 @@ function check_php_version($version='5.2.4') {
           if (empty($version)) {
               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) {
                   return true;
               }
@@ -8420,7 +8427,7 @@ function check_php_version($version='5.2.4') {
           if (empty($version)) {
               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) {
                   return true;
               }
@@ -8670,7 +8677,7 @@ function get_browser_version_classes() {
 function can_use_rotated_text() {
     global $USER;
     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)) &&
             !$USER->screenreader;
 }