PDA

View Full Version : Forum Display Enhancements - Script to reject browsers


Kzyl-orda
06-30-2008, 10:00 PM
Hello Everyone,
I had like to reject some browsers to enter my site, so first i installed ZH-Restrict A Browser (https://vborg.vbsupport.ru/showthread.php?t=165624), but blocking javascript on the browser was letting you easly passing through it, then i started to write a more crude, but php, version of the addon, that is different, but with the same target, not enabling some browser to view your page.

To do so i simply entered that string on the global.php in the root directory of the vbulletin installation (global.php, so it will work from every page of your vbulletin installation):
$browsername = $_SERVER['HTTP_USER_AGENT'];
$kz_b1 = '-yourrejectingbrowsername1-';
$kz_b2 = '-yourrejectingbrowsername1-';
$kz_f1 = strpos($browsername, $kz_b1);
$kz_f2 = strpos($browsername, $kz_b2);
if ($kz_f1 === false) {
if ($kz_f2 === false) {
} else {
header("Location: http://www.where-you-want-to-send-people-to-do-it-externally-of-your-vbulletininstallation-or-it-will-give-you-a-loop-bug-for-example-to-download-an-other-browser-like-firefox.com");
}
} else {
header("Location: http://www.where-you-want-to-send-people-to-do-it-externally-of-your-vbulletininstallation-or-it-will-give-you-a-loop-bug-for-example-to-download-an-other-browser-like-firefox.com");
}
I installed it after the following string, and it's working perfectly:
// ################################################## ###########################
// set the referrer cookie if URI contains a referrerid
if ($vbulletin->GPC['referrerid'] AND !$vbulletin->GPC[COOKIE_PREFIX . 'referrerid'] AND !$vbulletin->userinfo['userid'] AND $vbulletin->options['usereferrer'])
{
if ($referrerid = verify_id('user', $vbulletin->GPC['referrerid'], 0))
{
vbsetcookie('referrerid', $referrerid);
}
}

OFC instead of "-yourrejectingbrowsername1-" you must place the name of the browser you want to reject, for example "MSIE" (Internet explorer), "Safari" (Safari), "Firefox" (Firefox), "Opera" (Opera) i know the name of just those 4, more is Konqueror, gecho...

Instead of two you may want to reject just one browser, than:
$browsername = $_SERVER['HTTP_USER_AGENT'];
$kz_b1 = '-yourrejectingbrowsername1-';
$kz_f1 = strpos($browsername, $kz_b1);
if ($kz_f1 === false) {
} else {
header("Location: http://www.where-you-want-to-send-people-to-do-it-externally-of-your-vbulletininstallation-or-it-will-give-you-a-loop-bug-for-example-to-download-an-other-browser-like-firefox.com");
}

Here is a working example, this one reject safari and IE, and send you to firefox download page:
$browsername = $_SERVER['HTTP_USER_AGENT'];
$kz_b1 = 'MSIE';
$kz_b2 = 'Safari';
$kz_f1 = strpos($browsername, $kz_b1);
$kz_f2 = strpos($browsername, $kz_b2);
if ($kz_f1 === false) {
if ($kz_f2 === false) {
} else {
header("Location: http://www.spreadfirefox.com/en-US/worldrecord/");
}
} else {
header("Location: http://www.spreadfirefox.com/en-US/worldrecord/");
}

I'm using Php 4.4, if you'r with a different version and it doesn't work try to change the string:
header("Location: http://www.url.com");
With the command http_redirect, if you'll google you'll find more information about, actually i can't help without a different php version to test it. :confused:

Enjoy.

dannykilla
07-01-2008, 02:27 PM
Sounds Awesome, but do you have a screenshot?
Also can you reject certain browser versions for example IE6 ?

Brandon Sheley
07-01-2008, 03:24 PM
a demo link would be nice, so we could try different browsers

indie2industry
07-01-2008, 05:08 PM
why would anyone want to do this??? Wouldn't it just restrict users from your forum???

Nice mod, but I definatly can not use this one....

I may be slow, lol, but what are the up-side to restricting a browser from your site?

TonySkullz
07-01-2008, 11:58 PM
I agree with the above, what's the purpose of completely restricting a browser to use your site? Restricting browsers access to specific sections for incompatibility reasons is more understandable, and is already easily done with conditionals. So, how does anyone benefit from this?

To clarify, I'm not meaning that in a rude way if it seems so, I'm just curious. :)

Q-v-n-s-Q
07-02-2008, 12:26 AM
thank you for the release

Josh1
07-02-2008, 12:46 AM
And why the heck would you want to do this?

Kzyl-orda
07-02-2008, 07:39 AM
I'm back!

@Loco.M
You can see a working demo at my own website if you'll like www.perditionpoetry.com (http://www.perditionpoetry.com).
But the site itself will not be completed untill september, just in time for Left 4 Dead, great new game from Valve and Turtle Rock, with zombie and much more :D.
Then don't troll it too much :rolleyes: .

@dannykilla
To restrict specific browser like IE 6, you can download the browser first (or IE Net Render (https://addons.mozilla.org/it/firefox/addon/6455) if you'r using firefox 3.0), than create a clean *.php page, upload it in your website tests directory.
In the file (within <body></body> of the basic HTML code)write:
<?php
$browser = $_SERVER['HTTP_USER_AGENT'];
echo "$browser";
?>
Than you'll see the possible specific keyword fo the browser you'r using.
IE 6 is "MSIE 6.0", anyway if you'll like to reject more than 2 browser (more than two IE version for example, and sending people to download the last version) modifing the script is really simple, just ask and I'll help you.

@Diffidents :D
The above one is an example of a possible utility for the addon, how to use it's all about you. :)

On my side,
I thought this addong while creating a restricted gaming community for my friends, I'm a nerd gamer.
There is no incompatibility issues to avoid, i know how to solve them if i need to, if you are a commercial developer you should use it with real care, as others said kicking people from the site is not usually a commercial benefit, in my side I'm not interested in making money, but in choosing who I'm going to play with, so i can kick people from my site, and be selective.

In specific, the reason i want to reject other browser is also to force people using firefox, or browser different from IE or safari, and this is a my personal battle. I'm not going to explain the reason here because it's not the right place to, it's a my personal choise, and my personal ideals.
Second, as i said not allowing IE i make too young or non nerd users harder to join my community, and that is my target. (I'm not saying that IE is a browser for child or casual users at all. don't misunderstand!)

I'm not surprised if you'll find it silly or useless, it's was invented mainly just for some zealots of hardcore gaming and firefox supported, and even if just 2 people installed it, and maybe there will not be many more, this already make me happy, since this is also my first release. After 2 weeks i bought vb.

I hope to have answered all your question ;) .