Project

General

Profile

Bug #22511 ยป 14201.diff

Administrator Admin, 2010-04-26 11:00

View differences:

t3lib/utility/class.t3lib_utility_client.php (working copy)
'useragent' => $userAgent,
);
if ($userAgent) {
// browser
if (strstr($userAgent,'MSIE')) {
$browserInfo['browser']='msie';
} elseif(strstr($userAgent,'Konqueror')) {
$browserInfo['browser']='konqueror';
} elseif(strstr($userAgent,'Opera')) {
$browserInfo['browser']='opera';
} elseif(strstr($userAgent,'Lynx')) {
$browserInfo['browser']='lynx';
} elseif(strstr($userAgent,'PHP')) {
$browserInfo['browser']='php';
} elseif(strstr($userAgent,'AvantGo')) {
$browserInfo['browser']='avantgo';
} elseif(strstr($userAgent,'WebCapture')) {
$browserInfo['browser']='acrobat';
} elseif(strstr($userAgent,'IBrowse')) {
$browserInfo['browser']='ibrowse';
} elseif(strstr($userAgent,'Teleport')) {
$browserInfo['browser']='teleport';
} elseif(strstr($userAgent,'Mozilla')) {
$browserInfo['browser']='netscape';
} else {
$browserInfo['browser']='unknown';
// Analyze the userAgent string
// Declare known browsers to look for
$known = array('msie', 'firefox', 'webkit', 'opera', 'netscape', 'konqueror',
'gecko', 'chrome', 'safari', 'seamonkey', 'navigator', 'mosaic',
'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol');
$matches = array();
$pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9]+(?:\.[0-9]+)?)#';
// Find all phrases (or return empty array if none found)
if (!preg_match_all($pattern, strtolower($userAgent), $matches)) {
$browserInfo['browser'] = 'unknown';
} else {
// Since some UAs have more than one phrase (e.g Firefox has a Gecko phrase,
// Opera 7,8 have a MSIE phrase), use the last one found (the right-most one
// in the UA). That's usually the most correct.
$i = count($matches['browser']) - 1;
$browserInfo['browser'] = $matches['browser'][$i];
$browserInfo['version'] = $matches['version'][$i];
//But return all parsed browsers / version in an extra array
for ($i = 0; $i < count($matches['browser']); $i++) {
$browserInfo['all'][$matches['browser'][$i]] = $matches['version'][$i];
}
}
// version
switch($browserInfo['browser']) {
case 'netscape':
$browserInfo['version'] = self::getVersion(substr($userAgent, 8));
if (strstr($userAgent, 'Netscape6')) {
$browserInfo['version'] = 6;
}
break;
case 'msie':
$tmp = strstr($userAgent, 'MSIE');
$browserInfo['version'] = self::getVersion(substr($tmp, 4));
break;
case 'opera':
$tmp = strstr($userAgent, 'Opera');
$browserInfo['version'] = self::getVersion(substr($tmp, 5));
break;
case 'lynx':
$tmp = strstr($userAgent, 'Lynx/');
$browserInfo['version'] = self::getVersion(substr($tmp, 5));
break;
case 'php':
$tmp = strstr($userAgent, 'PHP/');
$browserInfo['version'] = self::getVersion(substr($tmp, 4));
break;
case 'avantgo':
$tmp = strstr($userAgent, 'AvantGo');
$browserInfo['version'] = self::getVersion(substr($tmp, 7));
break;
case 'acrobat':
$tmp = strstr($userAgent, 'WebCapture');
$browserInfo['version'] = self::getVersion(substr($tmp, 10));
break;
case 'ibrowse':
$tmp = strstr($userAgent, 'IBrowse/');
$browserInfo['version'] = self::getVersion(substr($tmp ,8));
break;
case 'konqueror':
$tmp = strstr($userAgent, 'Konqueror/');
$browserInfo['version'] = self::getVersion(substr($tmp, 10));
break;
// system
$browserInfo['system'] = '';
if (strstr($userAgent, 'Win')) {
// windows
if (strstr($userAgent, 'Win98') || strstr($userAgent, 'Windows 98')) {
$browserInfo['system'] = 'win98';
} elseif (strstr($userAgent, 'Win95') || strstr($userAgent, 'Windows 95')) {
$browserInfo['system'] = 'win95';
} elseif (strstr($userAgent, 'WinNT') || strstr($userAgent, 'Windows NT')) {
$browserInfo['system'] = 'winNT';
} elseif (strstr($userAgent, 'Win16') || strstr($userAgent, 'Windows 311')) {
$browserInfo['system'] = 'win311';
}
// system
$browserInfo['system'] = '';
if (strstr($userAgent, 'Win')) {
// windows
if (strstr($userAgent, 'Win98') || strstr($userAgent, 'Windows 98')) {
$browserInfo['system'] = 'win98';
} elseif (strstr($userAgent, 'Win95') || strstr($userAgent, 'Windows 95')) {
$browserInfo['system'] = 'win95';
} elseif (strstr($userAgent, 'WinNT') || strstr($userAgent, 'Windows NT')) {
$browserInfo['system'] = 'winNT';
} elseif (strstr($userAgent, 'Win16') || strstr($userAgent, 'Windows 311')) {
$browserInfo['system'] = 'win311';
}
} elseif (strstr($userAgent,'Mac')) {
$browserInfo['system'] = 'mac';
// unixes
} elseif (strstr($userAgent, 'Linux')) {
$browserInfo['system'] = 'linux';
} elseif (strstr($userAgent, 'SGI') && strstr($userAgent, ' IRIX ')) {
$browserInfo['system'] = 'unix_sgi';
} elseif (strstr($userAgent, ' SunOS ')) {
$browserInfo['system'] = 'unix_sun';
} elseif (strstr($userAgent, ' HP-UX ')) {
$browserInfo['system'] = 'unix_hp';
}
} elseif (strstr($userAgent,'Mac')) {
$browserInfo['system'] = 'mac';
// unixes
} elseif (strstr($userAgent, 'Linux')) {
$browserInfo['system'] = 'linux';
} elseif (strstr($userAgent, 'SGI') && strstr($userAgent, ' IRIX ')) {
$browserInfo['system'] = 'unix_sgi';
} elseif (strstr($userAgent, ' SunOS ')) {
$browserInfo['system'] = 'unix_sun';
} elseif (strstr($userAgent, ' HP-UX ')) {
$browserInfo['system'] = 'unix_hp';
}
return $browserInfo;
    (1-1/1)