vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=228)
-   -   Administrative and Maintenance Tools - Add Google Chrome to the is_browser() function (https://vborg.vbsupport.ru/showthread.php?t=189991)

Lea Verou 09-03-2008 10:00 PM

Add Google Chrome to the is_browser() function
 
About the is_browser() function

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


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

Quote:

Originally Posted by nerofix (Post 1614369)
How to block chrome-browser users completly from accessing the site?

You could create a plugin with the code:
PHP 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

Quote:

Originally Posted by nerofix (Post 1614369)
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. :)


All times are GMT. The time now is 04:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01070 seconds
  • Memory Usage 1,755KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete