My site looks quite wierd in IE 6. And I don't want to spend my time on adjusting these problems. (png's with no tranparency, several div's are misplaced causing the entire site to look wierd).

I figured that I can create at block that tell's IE 6 users to update their browser and make life easier for lazy webdesigners, like me.

The problem is that I can't find a php-snippet that would do this. I do know that it has to do with the function "get-browser" (
http://us3.php.net/manual/en/function.get-browser.php). And here http://drupal.org/node/65903 there is a snippet to detect which browser is used. But I can't figure out how to get both the browser and the version.

What i need is actually some sort of filter that filters out any browser that is older than IE6.

Comments

gpk’s picture

Don't forget that a large proportion of your web traffic will be using IE6 for a long time still.

Anyway this page http://www.theregister.co.uk/2008/06/26/avg_disguises_fake_traffic_as_ie6/ suggests the user agent string for IE6 is Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1). Maybe easiest just to check for MSIE 6.0 in $_SERVER['HTTP_USER_AGENT'].

gpk
----
www.alexoria.co.uk

whitingx’s picture

The IE Destroyer Module may be worth looking at.

Script autodetects IE
Displays switch splash screen to IE users

Hope this helps.

Metusela’s picture

Because IE 7 shows most of my css theming correctly I want to treat it as any browser.

But in IE6 and older there are several quite serious problems when it comes to theming. So unless IE Destroyer has a capability to select witch versions of IE to "Destroy" I would rather make a block that shows up only in IE 6 and older.

For now I solved the issue with my theme. But I still wish I could have this functionality to tell visitors to upgrade before they complain bout broken design.

yuriy.babenko’s picture

Been there done that...

	$browser = $_SERVER['HTTP_USER_AGENT'];

	//running internet explorer
	if($msie = strpos($browser, "MSIE"))
	{
		//version number
		$ver = substr($browser, $msie + 5, 3);

		if($ver < 7.0)
		{
			echo	'
						Welcome!
						<br /><br />
						It appears you\'re using Microsoft Internet Explorer '.$ver.'.
						<br />
						Since Microsoft does not wish to fix this ancient and bug-ridden browser, the developer of this site has refused to support it.
						<br /><br />
						Before you can proceed to this site you will need to upgrade to a modern browser, such as FireFox or Internet Explorer 7.						
					';
			exit();
		}
	}

---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials

---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com

Metusela’s picture

Thanks! I'll try that.

As I understand you put this in your page.tpl.php, right?

And as far as I understand the site won't show anything but the message.

There is a snippet to show which browser is used, here: http://drupal.org/node/65903
But this shows the browser in the block. Not the version. Because i have problems with older versions of IE this is not the approach I am looking for.

I have an idea for a slightly different approach. I want to create a block were I have a similar message:

It appears you\'re using an old version of Microsoft Internet Explorer.

Because many bugs in older versions of Microsoft Internet Explorer it is strongly recommended to upgrade your browser to the latest version.

If you don not upgrade there is a great risk that you will encounter some bugs on caused by your browser.

Then i would use a similar code in the visibility settings:

<?php
    $browser = $_SERVER['HTTP_USER_AGENT'];

    //running internet explorer
    if($msie = strpos($browser, "MSIE"))
    {
        //version number
        $ver = substr($browser, $msie + 5, 3);

        if($ver < 7.0)
        {
            return TRUE;
        } else {
        return FALSE;
    } else {
    return FALSE;
?>

This would show the block only if the browser version is older then 7.0.

Using a block, and visibility, makes it much easier to place the message in a more appropriate way. It doesn't "kill" the site for those using older versions, but works more like warning.