PDA

View Full Version : Administrative and Maintenance Tools - Add Google Chrome to the is_browser() function


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'])

Floris
09-04-2008, 03:09 AM
I think this will eventually be put into an official release, (hopes), but until then thank you for the tweak ;) I will try to update my sites soon so chrome users can enjoy it to the fullest.

Merjawy
09-04-2008, 03:12 AM
Thanks.. my site looked wierd.. things at the top were listed at the buttom :)

Michael Biddle
09-04-2008, 05:00 AM
Tagged for later. Thank you!

nerofix
09-04-2008, 12:33 PM
How to block chrome-browser users completly from accessing the site?

Barakat
09-04-2008, 12:40 PM
works nice .... thanks

Lea Verou
09-04-2008, 02:04 PM
How to block chrome-browser users completly from accessing the site?

You could create a plugin with the code:

if(is_browser('chrome')) print_no_permission();

and play a bit with the hooks (2 possible candidates are global_start and global_complete) as I can't think of the right one atm.

However, imho its an extremely bad idea to do such a thing. If you want to shut a browser out of your site, do it to IE6, you would benefit the web more :P

sarum
09-04-2008, 06:49 PM
just what the doctor ordered thx
i love the new browser...

MrZeropage
09-04-2008, 07:21 PM
How to block chrome-browser users completly from accessing the site?
https://vborg.vbsupport.ru/showthread.php?t=190037

;)

FiMeTi
09-07-2008, 11:10 AM
thx man installed. :)

S@NL - BlackBik
09-09-2008, 07:53 PM
Thanks!
Was allready searching for this :)

VeeDubZ
09-09-2008, 10:32 PM
top mod

TimberFloorAu
09-11-2008, 05:59 AM
Installed: But have not noticed any difference with Opacity ( perhaps Chrome just doesnt linke Reflections )

Lea Verou
09-11-2008, 06:22 AM
Installed: But have not noticed any difference with Opacity ( perhaps Chrome just doesnt linke Reflections )
What do you mean?
This mod just lets you detect Chrome, its not a fix for any particular issue with it, but rather something you'll definately need when making such a fix.

TimberFloorAu
09-11-2008, 07:33 PM
What do you mean?
This mod just lets you detect Chrome, its not a fix for any particular issue with it, but rather something you'll definately need when making such a fix.

Your Initial Post:


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).

Lea Verou
09-11-2008, 07:43 PM
Exactly. It doesn't provide the exact code to insert, just the ability to do so.

TimberFloorAu
09-11-2008, 10:44 PM
Exactly. It doesn't provide the exact code to insert, just the ability to do so.

You have lost me.

We use opacity on various mods within our sites, with the google chrome fix, you have created, it doesnt in any way make any difference to image opacity.
All image reflections, have opacity set as reflective properties.

Or perhaps I have missed the ghist of your initial statement...

Lea Verou
09-11-2008, 11:19 PM
Have you actually read the is_browser() documentation that I provided a link to at the first post? Perhaps that will help you understand what this mod does.