Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons

Reply
 
Thread Tools
Add Google Chrome to the is_browser() function Details »»
Add Google Chrome to the is_browser() function
Version: 1.00, by Lea Verou Lea Verou is offline
Developer Last Online: Jul 2012 Show Printable Version Email this Page

Category: Administrative and Maintenance Tools - Version: 3.7.2 Rating:
Released: 09-03-2008 Last Update: Never Installs: 24
Re-useable Code Code Changes Translations  
No support by the author.

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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 09-04-2008, 03:09 AM
Floris Floris is offline
 
Join Date: Jan 2002
Posts: 1,898
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 09-04-2008, 03:12 AM
Merjawy's Avatar
Merjawy Merjawy is offline
 
Join Date: Sep 2002
Location: USA
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks.. my site looked wierd.. things at the top were listed at the buttom
Reply With Quote
  #4  
Old 09-04-2008, 05:00 AM
Michael Biddle Michael Biddle is offline
 
Join Date: Apr 2004
Location: Anaheim, CA
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tagged for later. Thank you!
Reply With Quote
  #5  
Old 09-04-2008, 12:33 PM
nerofix nerofix is offline
 
Join Date: Mar 2006
Location: Saarland
Posts: 219
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How to block chrome-browser users completly from accessing the site?
Reply With Quote
  #6  
Old 09-04-2008, 12:40 PM
Barakat's Avatar
Barakat Barakat is offline
 
Join Date: Nov 2004
Location: Jerusalem
Posts: 571
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works nice .... thanks
Reply With Quote
  #7  
Old 09-04-2008, 02:04 PM
Lea Verou Lea Verou is offline
 
Join Date: Jul 2005
Location: Greece
Posts: 1,856
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerofix View Post
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
Reply With Quote
  #8  
Old 09-04-2008, 06:49 PM
sarum sarum is offline
 
Join Date: Aug 2005
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just what the doctor ordered thx
i love the new browser...
Reply With Quote
  #9  
Old 09-04-2008, 07:21 PM
MrZeropage's Avatar
MrZeropage MrZeropage is offline
 
Join Date: Nov 2003
Location: Munich, Germany
Posts: 3,012
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerofix View Post
How to block chrome-browser users completly from accessing the site?
https://vborg.vbsupport.ru/showthread.php?t=190037

Reply With Quote
  #10  
Old 09-07-2008, 11:10 AM
FiMeTi FiMeTi is offline
 
Join Date: May 2008
Location: Germany
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thx man installed.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:33 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.04441 seconds
  • Memory Usage 2,311KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete