![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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 <?php delimiter. the next line is blank, and the few lines after that are comments. after that, it goes:
sniffer.php
and i'm calling it like this:
header.php
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?
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. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
break;
case "iemac":
$sniffedcss1 = "absolute";
$sniffedcss2 = "top";
$GLOBALS['brwsrmssg'] = "Safer, faster, better. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
break;
case "ie5mac":
$sniffedcss1 = "absolute";
$sniffedcss2 = "top";
$GLOBALS['brwsrmssg'] = "Safer, faster, better. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
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. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
break;
case "nswin":
$sniffedcss1 = "fixed";
$sniffedcss2 = "bottom";
$GLOBALS['brwsrmssg'] = "Safer, faster, better. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
break;
case "nsunix":
$sniffedcss1 = "absolute";
$sniffedcss2 = "top";
$GLOBALS['brwsrmssg'] = "Safer, faster, better. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
break;
case "nsmac":
$sniffedcss1 = "absolute";
$sniffedcss2 = "top";
$GLOBALS['brwsrmssg'] = "Safer, faster, better. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
break;
case "mozilla":
$sniffedcss1 = "fixed";
$sniffedcss2 = "bottom";
$GLOBALS['brwsrmssg'] = "Safer, faster, better. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!</a>";
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. <a href=\"http://www.spreadfirefox.com/?q=affiliates&id=7148&t=1\">Get Firefox!!</a>";
break;
}
and i'm calling it like this:
header.php
<?
require_once ("sniffer.php");
?>
/* snip */
<img src="<? echo $_GLOBALS["direkt"]; ?>wp-content/themes/Ice/images/image.gif" style="position: <? echo $sniffedcss1; ?>; <? echo $sniffedcss2; ?>: 0px; right: 0px;" alt="description" />
footer.php
<? echo $GLOBALS['brwsrmssg']; ?>
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?
no subject
Date: 2006-02-06 07:24 pm (UTC)ps nagging people to change browsers is lame
no subject
Date: 2006-02-07 02:15 am (UTC)