Changeset 1642
- Timestamp:
- 12/09/06 23:38:03 (3 years ago)
- Files:
-
- 1 modified
-
trunk/gregarius/extlib/browser.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/gregarius/extlib/browser.php
r1049 r1642 1 1 <?php 2 2 /***************************************************************** 3 * File name: browser.php Author: Gary White 4 * Last modified: November 10, 2003 3 * File name: browser.php 4 * Author: Gary White & Damien Raude-Morvan 5 * Last modified: December 10, 2006 5 6 * 6 7 ************************************************************** 7 8 * Copyright (C) 2003 Gary White 9 * Copyright (C) 2006 Damien Raude-Morvan <drazzib@drazzib.com> 8 10 * 9 11 This program is free software; you can redistribute it and/or … … 17 19 GNU General Public License for more details at: 18 20 http://www.gnu.org/copyleft/gpl.html 19 * 21 */ 22 23 /** 20 24 ************************************************************** 21 25 * … … 59 63 WebTV 60 64 *****************************************************************/ 61 62 65 class browser { 63 66 … … 70 73 var $isOpera = false; 71 74 var $isSafari = false; 75 var $isKonqueror = false; 72 76 var $isIE = false; 73 77 … … 174 178 $bd['version'] = $val[1]; 175 179 180 $this->isKonqueror = true; 181 176 182 // test for iCab 177 183 } … … 249 255 // test for Safari 250 256 } 251 elseif (eregi(" safari", $agent)) {257 elseif (eregi("AppleWebKit", $agent)) { 252 258 $bd['browser'] = "Safari"; 253 $bd['version'] = ""; 259 $val = explode("/", $agent); 260 $bd['version'] = $val[3]; 254 261 $this -> isSafari = true; 255 262 … … 306 313 } 307 314 315 /** Support of multipart/x-mixed-replace complete and stable : 316 * o in Safari 2.0.2 (http://webkit.org/blog/?p=32) 317 * (http://developer.apple.com/internet/safari/uamatrix.html) 318 * o in Konqueror at least 3.4.3 319 * (http://websvn.kde.org/trunk/KDE/kdelibs/khtml/kmultipart/kmultipart.cpp/) 320 */ 308 321 function supportsServerPush() { 309 return ($this->isMoz || $this->isOpera); 310 } 311 322 return ($this->isMoz 323 || $this->isOpera 324 || ($this->isSafari && $this->compareBrowserVersion("416", $this->Version)) 325 || ($this->isKonqueror && $this->compareBrowserVersion("3.4.3", $this->Version)) 326 ); 327 } 328 329 /** Support of XMLHTTPRequest complete and stable : 330 * o in Konqueror at least 3.4 (since 2004 - 331 * http://websvn.kde.org/trunk/KDE/kdelibs/khtml/ecma/xmlhttprequest.cpp/) 332 */ 312 333 function supportsAJAX() { 313 return ($this->isMoz || $this->isOpera || $this->isSafari || ($this -> isIE && $this -> Version > 5)); 334 return ($this->isMoz 335 || $this->isOpera 336 || $this->isSafari 337 || ($this->isIE && $this->compareBrowserVersion("5", $this->Version)) 338 || ($this->isKonqueror && $this->compareBrowserVersion("3.4", $this->Version)) 339 ); 340 } 341 342 /** 343 * Compare two version strings of browser. 344 * @param $requiredVersion minimal version number required for feature 345 * @param $browserVersion current detected browser version 346 * @return true if $browserVersion is greater than $requiredVersion 347 */ 348 function compareBrowserVersion($requiredVersion, $browserVersion) { 349 // Standardise versions 350 $requiredVersion = preg_replace('/([^0-9\.]+)/', '.$1.', $requiredVersion); 351 $requiredVersion = trim($requiredVersion); 352 $v1 = explode('.', $requiredVersion); 353 354 $browserVersion = preg_replace('/([^0-9\.]+)/', '.$1.', $browserVersion); 355 $browserVersion = trim($browserVersion); 356 $v2 = explode('.', $browserVersion); 357 358 $compare = 0; 359 for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++) { 360 if ($v1[$i] == $v2[$i]) { 361 continue; 362 } 363 364 $i1 = $v1[$i]; 365 $i2 = $v2[$i]; 366 367 if (is_numeric($i1) && is_numeric($i2)) { 368 $compare = ($i1 < $i2) ? -1 : 1; 369 } 370 } 371 372 return (bool) ($compare <= 0); 314 373 } 315 374 }
