Back to vBulletin 3.7 Add-ons

Status of PHP 8.5 support: Possible. Open Contacts for details.

Add Google Chrome to the is_browser() function
Mod Version: 1.00, by Lea Verou

This modification is in the archives.
vB Version: 3.7.2 Rating: (3 votes - 5.00 average) Installs: 24
Released: 04 Sep 2008 Last Update: Never Downloads: 6
Not Supported Code Changes Re-usable Code Translations  

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:
PHP Code:
'safari'    => 0
add above:
PHP Code:
'chrome'    => 0//added for chrome detection 
2. Find:
PHP Code:
        // 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:
PHP Code:
        // 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:
PHP Code:
if (strpos($useragent'gecko') !== false AND !$is['safari'] AND !$is['konqueror']) 
Change to:
PHP Code:
if (strpos($useragent'gecko') !== false AND !$is['safari'] AND !$is['konqueror'] AND !$is['chrome']) 

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2025