Lea Verou
09-03-2008, 10:00 PM
About the is_browser() function (http://members.vbulletin.com/api/vBulletin/_includes---functions.php.html#functionis_browser)
This modification will allow you to insert into templates code specific for Google Chrome (useful for correcting CSS issues that it has with box-shadow and opacity).
It obviously needs file edits, as there is no hook in there.
Should work for vB versions from 3.7.3 and below, although in very old versions, the code to find might slightly be different.
File: includes/functions.php
1. Find:
'safari' => 0,add above:
'chrome' => 0, //added for chrome detection2. Find:
// detect safari
# Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/74 (KHTML, like Gecko) Safari/74
# Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/51 (like Gecko) Safari/51
# Mozilla/5.0 (Windows; U; Windows NT 6.0; en) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3
# Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3
# Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3
if (strpos($useragent, 'applewebkit') !== false)
{
preg_match('#applewebkit/(\d+)#', $useragent, $regs);
$is['webkit'] = $regs[1];
if (strpos($useragent, 'safari') !== false)
{
preg_match('#safari/([0-9\.]+)#', $useragent, $regs);
$is['safari'] = $regs[1];
}
}
Add below:
// detect Google Chrome
# Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.14
if($is['webkit'] AND strpos($useragent, 'chrome') !== false)
{
preg_match('#chrome/([0-9\.]+)#', $useragent, $regs);
$is['chrome'] = $regs[1];
}
3. Find:
if (strpos($useragent, 'gecko') !== false AND !$is['safari'] AND !$is['konqueror'])Change to:
if (strpos($useragent, 'gecko') !== false AND !$is['safari'] AND !$is['konqueror'] AND !$is['chrome'])
This modification will allow you to insert into templates code specific for Google Chrome (useful for correcting CSS issues that it has with box-shadow and opacity).
It obviously needs file edits, as there is no hook in there.
Should work for vB versions from 3.7.3 and below, although in very old versions, the code to find might slightly be different.
File: includes/functions.php
1. Find:
'safari' => 0,add above:
'chrome' => 0, //added for chrome detection2. Find:
// detect safari
# Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/74 (KHTML, like Gecko) Safari/74
# Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/51 (like Gecko) Safari/51
# Mozilla/5.0 (Windows; U; Windows NT 6.0; en) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3
# Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3
# Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3
if (strpos($useragent, 'applewebkit') !== false)
{
preg_match('#applewebkit/(\d+)#', $useragent, $regs);
$is['webkit'] = $regs[1];
if (strpos($useragent, 'safari') !== false)
{
preg_match('#safari/([0-9\.]+)#', $useragent, $regs);
$is['safari'] = $regs[1];
}
}
Add below:
// detect Google Chrome
# Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.14
if($is['webkit'] AND strpos($useragent, 'chrome') !== false)
{
preg_match('#chrome/([0-9\.]+)#', $useragent, $regs);
$is['chrome'] = $regs[1];
}
3. Find:
if (strpos($useragent, 'gecko') !== false AND !$is['safari'] AND !$is['konqueror'])Change to:
if (strpos($useragent, 'gecko') !== false AND !$is['safari'] AND !$is['konqueror'] AND !$is['chrome'])