Browsers!!!

<<< Previous Entry: Cherrytastic! | This Month's entries | Next Entry: I Am Kloot/Turin Brakes & Budapest/Tom Mcrae >>

Ladies and gentlemen, check out what I just did


<?php
/**first we've got to identfy the browser */
$toFind = "(";
$browser = str_replace( strchr($HTTP_USER_AGENT, $toFind), "", $HTTP_USER_AGENT);
/**the code above takes the first part out of the http user request, this will say the basics of the browser */
/**internet explorer work round */
/**due to msie identifying ie5.0 to ie6.0 as mozilla/4.0 we've got to work round that. So if the browser identifies as mozilla/4.0 we've then got to see if it's ie 6.0 or lower */
/**first we find out if the browser contains MSIE in it*/
$msiecheck = strpos($HTTP_USER_AGENT, "MSIE");
if ($msiecheck === false) {$msie = 'nay';} /**sets $msie as nay if it's not msie browser*/
else {$msie = 'yay';} /**sets $msie yay if it is msie browser*/
/**then we find out if the browser contains 6.0 in it*/
$msieversioncheck = strpos($HTTP_USER_AGENT, "6.0");
if ($msieversioncheck === false) {$msie6 = "nope";} /**sets $msie6 as nope if it's not version 6.0*/
else {$msie6 = "yay";} /**sets $msie6 as yay if it is 6.0 browser*/
/**that's the msie stuff set for use later. I may optimize this at somepoint so it'll only run if it's mozilla/4.0 but I'm not sure how to do that yet. So with that out of the way we can carry on*/
/** now we set the good browsers, that like css */
$goodbrowsers = ( 'Opera/7.01 Mozilla/5.0 Mozilla/6.0 Opera/7 Opera/6' );
/** I may add more to this list later, I've got to check which browsers I like and which I don't */
/**this is the part that checks to see if I have a browser from the list*/
$goodbrowsercheck = strpos($goodbrowsers, "$browser");
if ($goodbrowsercheck === false) {$goodorbad = 'bad';}
else {$goodorbad = 'good';}
/** now i've set everything I can start to use it all, this sets the $skin and newskin as what they should be.*/
if (!isset($newskin)) {
if ($msie == $msie6) $newskin=1;
elseif ($goodorbad == 'good') $newskin=1;
else $newskin=2;
}
elseif (isset($newskin)) {
$newskin=(int)$newskin;
if ($newskin<1) $newskin=1;
if ($newskin>2) $newskin=1;
} elseif (isset($skin)) {
$newskin=(int)$skin;
if ($skin<1) $newskin=1;
if ($skin>2) $newskin=1;
}
$skin=$newskin;
setcookie ('skin', "", time() - 3600);
setcookie('skin',$newskin,time()+(86400*365),'/');
setcookie('skin',$newskin,time()+(86400*365),'/','.iamsparticus.co.uk');
$skin=$newskin;
?>
<?php
print "$skin";
print "$HTTP_USER_AGENT";
?>

I know you don't know what it does, but I wrote it all myself, aren't you impressed?

Right Now

(8)Heleno
(t)Heleno


Your Comments

sandi

always glad to help, don't hesitate to ask me any more technical questions you come up with.

Benjamin

What does C++ stand for??


About, Navigation, And Other Details

This is a website by Mark Walley. If you want to find out more or get in touch, that'd be nice.

Getting around this website can be a tad confusing. If you're looking to explore the better stuff of what I've written then this navigation should help you. If you're after a specific post then searching or looking through the archives chronologically may help.

Things I Found Interesting

People I Generally Find Interesting

Last Words

This site tries its best to be accessible for everyone. Atom, and RSS feeds are available. All content licensed through a creative commons licence. I may have stolen ideas off you when you weren't looking, but it was almost certainly an accident. As with all claims of originality and ownership Psalm 24 v1 applies.