diff --git a/lib/moodlelib.php b/lib/moodlelib.php index fa8101229d8..3abb77d2621 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -8197,18 +8197,45 @@ function check_php_version($version='5.2.4') { case 'Gecko': /// Gecko based browsers - if (empty($version) and substr_count($agent, 'Camino')) { - // MacOS X Camino support - $version = 20041110; + // Do not look for dates any more, we expect real Firefox version here. + if (empty($version)) { + $version = 1; + } else if ($version > 20000000) { + // This is just a guess, it is not supposed to be 100% accurate! + if (preg_match('/^201/', $version)) { + $version = 3.6; + } else if (preg_match('/^200[7-9]/', $version)) { + $version = 3; + } else if (preg_match('/^2006/', $version)) { + $version = 2; + } else { + $version = 1.5; + } } - - // the proper string - Gecko/CCYYMMDD Vendor/Version - // Faster version and work-a-round No IDN problem. - if (preg_match("/Gecko\/([0-9]+)/i", $agent, $match)) { - if ($match[1] > $version) { - return true; + if (preg_match("/(Iceweasel|Firefox)\/([0-9\.]+)/i", $agent, $match)) { + // Use real Firefox version if specified in user agent string. + if (version_compare($match[2], $version) >= 0) { + return true; + } + } else if (preg_match("/Gecko\/([0-9\.]+)/i", $agent, $match)) { + // Gecko might contain date or Firefox revision, let's just guess the Firefox version from the date. + $browserver = $match[1]; + if ($browserver > 20000000) { + // This is just a guess, it is not supposed to be 100% accurate! + if (preg_match('/^201/', $browserver)) { + $browserver = 3.6; + } else if (preg_match('/^200[7-9]/', $browserver)) { + $browserver = 3; + } else if (preg_match('/^2006/', $version)) { + $browserver = 2; + } else { + $browserver = 1.5; } } + if (version_compare($browserver, $version) >= 0) { + return true; + } + } break;