why does my browser sniffer script break all of a sudden?

    Date: 02/06/06 (PHP Community)    Keywords: browser

    UPDATE: fixed, thanks to '[info]'onah.

    my old browser sniffer that's worked so well for me for years, cobbled together from various sources, doesn't work when i upload it. funny thing is, no matter what i change, it always says the error is on line 1, which is of course the
    sniffer.php
    function inAgent($agent) {
    if (eregi($agent,$_SERVER['HTTP_USER_AGENT'])){
    $br = true;
    } else {
    $br = false;
    }
    return $br;
    }
    if (!isset($browser)) {
    $browser = "";
    }
    switch (inAgent("MSIE")) {
    case true:
    if (inAgent("Mac")) {$browser = inAgent("MSIE 5") ? "ie5mac" : "ie4mac";}
    elseif (inAgent("Win")) {$browser = "iewin";}
    break;

    case false:
    if (inAgent("Firefox")) {$browser = "firefox";}
    elseif (inAgent("iCab")) {$browser = "icab";}
    elseif (inAgent("Mozilla/5")) {$browser = "mozilla";}
    elseif (inAgent("Mozilla/4"))
    {
    if ( inAgent('Mac')) {$browser = "nsmac";}
    else {$browser = (inAgent("Win")) ? "nswin" : "nsunix";}
    }
    elseif (inAgent("Opera")) {$browser = "opera";}
    elseif (inAgent("Safari")) {$browser = "safari";}
    else {$browser = "unknown";}
    break;
    }

    switch ($browser) {
    case "iewin":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top:";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "iemac":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "ie5mac":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "firefox":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "thank you for using Firefox!";
    break;

    case "icab":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "nswin":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "nsunix":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "nsmac":
    $sniffedcss1 = "absolute";
    $sniffedcss2 = "top";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "mozilla":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!";
    break;

    case "opera":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "thank you for using Opera!";
    break;

    case "safari":
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "thank you for using Safari!";
    break;

    default:
    $sniffedcss1 = "fixed";
    $sniffedcss2 = "bottom";
    $GLOBALS['brwsrmssg'] = "Safer, faster, better. http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!!";
    break;
    }

    and i'm calling it like this:
    header.php

    require_once ("sniffer.php");
    ?>

    /* snip */

    wp-content/themes/Ice/images/image.gif" style="position: ; : 0px; right: 0px;" alt="description" />



    footer.php


    it works perfectly locally, as it should. i'm on Apache 2.2.0 and PHP 4.4.1 (Win), whereas my host is using PHP 4.4.1 on Apache 1.3.34 (Unix).

    the error i'm getting is either
    Parse error: parse error, unexpected T_STRING in /real/path/to/html/sniffer.php on line 1
    or ...unexpected T_FUNCTION..., depending on what i've tried to do to fix it.

    i just don't get it. any ideas? TIA...

    Source: http://community.livejournal.com/php/408599.html

« Dead function || Help with buttons? »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home