Browser detection?



  • I found this in some affiliate code I was asked to integrate into a site:

    $browser = strtolower($_SERVER['HTTP_USER_AGENT']); // what browser they use.
    if(ereg("firefox", $browser)) {
    	$browser = 'FF';
    } else {
    	$browser = 'IE';
    }

    ...because we all know that if you're not using Firefox, you must be using IE!



  • $browser = strtolower($_SERVER['HTTP_USER_AGENT']); // what browser they use.
    if(ereg("firefox", $browser)) {
    $browser = 'FF';
    } else if (ereg("msie", $browser)) {
    $browser = 'IE';
    } else {
            $browser = 'POS'; 
    }

    FTFY.

     

    TRWTF is using regular expressions to check for static substrings.



  • @jchannell said:

    ...because we all know that if you're not using Firefox, you must be using IE!

    Of course, there's also Mozilla, they should add a check for eregi('mozilla', $browser)



  • No, TRWTF is using a deprecated function that has a clear notice about being crap.



  • No, TRWTF is having browser detection.

    ...Unless you're doing some sort of stats, in which case it's only fishy.



  • And browser identification can't be faked....
    for example with a user agent switcher



  • @Neuromancer said:

    And browser identification can't be faked....

    Yes.  For example, whenever I use telnet as a browser, I find myself compelled to include a user agent string that not only identifies the fact I'm using telnet, but also specifies which version I'm using.

    Oh wait, I never do that.  Sorry, I got confused for a moment there.



  • Is it possible that you were somehow unable to detect the thick layer of sarcasm on Neuromancer's post?



  •  Really, "IE" and "not IE" are usuallly the only checks you need  to care about.  This guy did it backwards



  • Same script sigh

    //	DD MMM YYYY to YYYY-MM-DD
    function rewriteDate01 ($date,$seperator='/') {
    	$date_d	= substr($date, 0,2);
    	$date_m	= substr($date, 3,3);
    	$date_y	= substr($date, 7,4);
    	if ($date_m == 'Jan') {
    		$date_m = '01';
    	} else if ($date_m == 'Feb') {
    		$date_m = '02';
    	} else if ($date_m == 'Mar') {
    		$date_m = '03';
    	} else if ($date_m == 'Apr') {
    		$date_m = '04';
    	} else if ($date_m == 'May') {
    		$date_m = '05';
    	} else if ($date_m == 'Jun') {
    		$date_m = '06';
    	} else if ($date_m == 'Jul') {
    		$date_m = '07';
    	} else if ($date_m == 'Aug') {
    		$date_m = '08';
    	} else if ($date_m == 'Sep') {
    		$date_m = '09';
    	} else if ($date_m == 'Oct') {
    		$date_m = '10';
    	} else if ($date_m == 'Nov') {
    		$date_m = '11';
    	} else if ($date_m == 'Dec') {
    		$date_m = '12';
    	}
    	return $date_y.$seperator.$date_m.$seperator.$date_d;
    }
    
    //	YYYY-MM-DD to DD-MM-YYYY
    function rewriteDate02 ($date,$seperator='/') {
    	$date_y	= substr($date, 0,4);
    	$date_m	= substr($date, 5,2);
    	$date_d	= substr($date, 8,2);
    
    	return $date_d.$seperator.$date_m.$seperator.$date_y;
    }

    Oh, the agony...



  • @Neuromancer said:

    And browser identification can't be faked....
    for example with a user agent switcher

    Who cares?  If someone changes their UA string and it breaks things for them, that's their fucking problem.  They're also free to use NoScript to disable Javascript and free to put a sledgehammer through their monitor.  Now, trusting the UA for security would be a WTF.



  • @vt_mruhlin said:

     Really, "IE" and "not IE" are usuallly the only checks you need  to care about.  This guy did it backwards

    Well, supposedly IE8 is now super standards-compliant, so maybe he's just forward-thinking.  The only check you need is "IE" and "non-standards-compliant rubbish".



  • @morbiuswilters said:


     Well, supposedly IE8 is now super standards-compliant, so maybe he's just forward-thinking.

     Lol at IE8 standards-compliance. We still have to deal with all of our CSS styling working perfectly in Firefox, Chrome, Opera, and even the Visual Studio Web designer, but not working well at all in IE7 or IE8.



  • @mott555 said:

    @morbiuswilters said:


     Well, supposedly IE8 is now super standards-compliant, so maybe he's just forward-thinking.

     Lol at IE8 standards-compliance. We still have to deal with all of our CSS styling working perfectly in Firefox, Chrome, Opera, and even the Visual Studio Web designer, but not working well at all in IE7 or IE8.

    You're missing the more likely explanation of you sucking at CSS.



  • @morbiuswilters said:

    @mott555 said:

    @morbiuswilters said:


     Well, supposedly IE8 is now super standards-compliant, so maybe he's just forward-thinking.

     Lol at IE8 standards-compliance. We still have to deal with all of our CSS styling working perfectly in Firefox, Chrome, Opera, and even the Visual Studio Web designer, but not working well at all in IE7 or IE8.

    You're missing the more likely explanation of you sucking at CSS.

    IE8 still has its quirks. Not as bad as it predecessors...



  • @jchannell said:

    IE8 still has its quirks. Not as bad as it predecessors...

    All browsers have quirks.  I'm illustrating they hypocrisy of standards Nazis who, at the end of the day, don't really care much about standards-compliance.



  • @morbiuswilters said:

    @jchannell said:

    IE8 still has its quirks. Not as bad as it predecessors...

    All browsers have quirks.  I'm illustrating they hypocrisy of standards Nazis who, at the end of the day, don't really care much about standards-compliance.

    True. <!-- >Firefox, much?<!-- -->



  • @jchannell said:

    @morbiuswilters said:

    @jchannell said:

    IE8 still has its quirks. Not as bad as it predecessors...

    All browsers have quirks.  I'm illustrating they hypocrisy of standards Nazis who, at the end of the day, don't really care much about standards-compliance.

    True. Firefox, much?

    I love Firefox.  It's been my primary browser since Phoenix 0.4 or so.  And before that my primary browser was Mozilla for a couple of years.  Still, I know it's got problems.



  • @morbiuswilters said:

    @jchannell said:

    @morbiuswilters said:

    @jchannell said:

    IE8 still has its quirks. Not as bad as it predecessors...

    All browsers have quirks.  I'm illustrating they hypocrisy of standards Nazis who, at the end of the day, don't really care much about standards-compliance.

    True. Firefox, much?

    I love Firefox.  It's been my primary browser since Phoenix 0.4 or so.  And before that my primary browser was Mozilla for a couple of years.  Still, I know it's got problems.

    I </3 FF. After it decided that my home directory was its profile directory and shat all over it (It wasnt really FF's fault, it was really the fault of its maintainer on Debian) I've been using Chromium. Except on <300MB-Ram machines, where I use a very very slimmed down version FF.

     [Mod note: Fixed your angle brackets.  -bs]



  • @Indrora said:

    After it decided that my home directory was its profile directory and shat all over it...

    What damage would that even do?  It should just create subdirectories.  It's not like it's going to delete everything for the hell of it.



  • Also:

    @Indrora said:

    It wasnt really FF's fault, it was really the fault of its maintainer on Debian

     

    Seriously?  Debian?  I didn't know they had any browsers newer than Mosaic...



  • @morbiuswilters said:

    Also:

    @Indrora said:

    It wasnt really FF's fault, it was really the fault of its maintainer on Debian

     

    Seriously?  Debian?  I didn't know they had any browsers newer than Mosaic...

    How dare you ignore Iceweasel!



  • @bstorer said:

    @morbiuswilters said:

    Also:

    @Indrora said:

    It wasnt really FF's fault, it was really the fault of its maintainer on Debian

     

    Seriously?  Debian?  I didn't know they had any browsers newer than Mosaic...

    How dare you ignore Iceweasel lynx!

    FTFY



  • @bstorer said:

    @morbiuswilters said:

    Also:

    @Indrora said:

    It wasnt really FF's fault, it was really the fault of its maintainer on Debian

     

    Seriously?  Debian?  I didn't know they had any browsers newer than Mosaic...

    How dare you ignore Iceweasel!

    Yeah, wait a minute..  Does Debian even have FF?  I thought they only had Iceweasel...



  • @morbiuswilters said:

    @bstorer said:

    @morbiuswilters said:

    Also:

    @Indrora said:

    It wasnt really FF's fault, it was really the fault of its maintainer on Debian

     

    Seriously?  Debian?  I didn't know they had any browsers newer than Mosaic...

    How dare you ignore Iceweasel!

    Yeah, wait a minute..  Does Debian even have FF?  I thought they only had Iceweasel...

    Debian has had Firefox in the past. Iceweasel is firefox with a diff to upstream to change a few lines. Trust me, any "iceweasel" extention will work with firefox and vice versa.

    As for FF deleting things, it decided my home directory was its cache because of a variable getting set wrong. I clear cache, I baleet my home dir. Thankfully, tripwire and backups are amazing things.



  • @Indrora said:

    Debian has had Firefox in the past. Iceweasel is firefox with a diff to upstream to change a few lines. Trust me, any "iceweasel" extention will work with firefox and vice versa.

    I fucking know what Iceweasel is; it's unbranded FF to get around Debian's "free software only" rule.  I wasn't aware that FF had been in Debian at one point (since it would violate their rules) but if you say so..  It just made your story questionable to me.

     

    @Indrora said:

    As for FF deleting things, it decided my home directory was its cache because of a variable getting set wrong. I clear cache, I baleet my home dir. Thankfully, tripwire and backups are amazing things.

    That's a pretty fantastic fuck-up. Yet another reason to avoid Debian like it was the Mexican Herpes.



  • Wait, WTF? Iceweasel is "unbranded" Firefox, to get around Debian's FOSS-nazi rules? So, how does renaming it magically make it free software? And how is it not free enough already? Did the Mozilla Foundation close up the source code somehow???



  • @ekolis said:

    Wait, WTF? Iceweasel is "unbranded" Firefox, to get around Debian's FOSS-nazi rules? So, how does renaming it magically make it free software? And how is it not free enough already? Did the Mozilla Foundation close up the source code somehow???

    Trademark rules, fool. Mozilla requires you obtain their permission to use the trademark "Firefox", and Debian refuses to do that because they can't pass on that permission to the downstream. So they remove all the Firefox trademarks and replace them with "Iceweasel".



  • @tgape said:

    @Neuromancer said:
    And browser identification can't be faked....

    Yes.  For example, whenever I use telnet as a browser, I find myself compelled to include a user agent string that not only identifies the fact I'm using telnet, but also specifies which version I'm using.

    Oh wait, I never do that.  Sorry, I got confused for a moment there.

    I've done that once.  A mate was teaching himself PHP.  I taught him something about sanitising your data even if it comes from what you think of as an automated, trusted, predictable source, like an HTTP request header... ;-)



  • This seems pertinent: [url]http://en.wikipedia.org/wiki/Iceweasel#User_Agent_problem[/url]

    Some web sites do not recognise the browsers' User-Agent strings and refuse to work properly.

    This issue was corrected in Iceweasel 3.5.5 with the addition of a "like Firefox x.x.x" string to the User-Agent.



  • @morbiuswilters said:

     

    I fucking know what Iceweasel is; it's unbranded FF to get around Debian's "free software only" rule.  I wasn't aware that FF had been in Debian at one point (since it would violate their rules) but if you say so..  It just made your story questionable to me.

    At one point, Mozilla had given Debian permission to use the Firefox trademark, but they rescinded it years ago.



  • @Kyanar said:

    @ekolis said:

    Wait, WTF? Iceweasel is "unbranded" Firefox, to get around Debian's FOSS-nazi rules? So, how does renaming it magically make it free software? And how is it not free enough already? Did the Mozilla Foundation close up the source code somehow???

    Trademark rules, fool. Mozilla requires you obtain their permission to use the trademark "Firefox", and Debian refuses to do that because they can't pass on that permission to the downstream. So they remove all the Firefox trademarks and replace them with "Iceweasel".

    Right.  If you compile FF from source (as I do) then the default isn't to use the branding unless you enable it.  It's always annoying to finish a 20 minute compile just to launch the browser and get that "bon echo" crap.

     

    Related question: Linux is also a registered TM.  How do the anal-retentive jackasses at Debian deal with that one?



  • @morbiuswilters said:

     

    Related question: Linux is also a registered TM.  How do the anal-retentive jackasses at Debian deal with that one?

    From my (admittedly limited) recollection, mostly via fair use mixed with assertions that the trademarks don't apply to them.



  • @morbiuswilters said:

    Related question: Linux is also a registered TM.  How do the anal-retentive jackasses at Debian deal with that one?

     

    They like the penguin too much to admit it goes against their principles?



  • @bob171123 said:

     

    They like the penguin too much to admit it goes against their principles?

    Tux is owned by Larry Ewing, who permits use and modification.  The issue is with "Linux,"  which is trademarked by LMI.



  • @morbiuswilters said:

    Related question: Linux is also a registered TM.  How do the anal-retentive jackasses at Debian deal with that one?
    IIRC, the actual problem between Debian and Mozilla is because Debian applied it's own patches to Firefox (while staying with an old version), and Mozilla then didn't want such patched version to be using their trademarks.



  • @ender said:

    @morbiuswilters said:
    Related question: Linux is also a registered TM.  How do the anal-retentive jackasses at Debian deal with that one?
    IIRC, the actual problem between Debian and Mozilla is because Debian applied it's own patches to Firefox (while staying with an old version), and Mozilla then didn't want such patched version to be using their trademarks.
    Yes.  Mozilla would only grant trademark permission on a case-by-case basis upon approval of the patches, which Debian was not willing to accept.



  • @bob171123 said:

    @morbiuswilters said:

    Related question: Linux is also a registered TM.  How do the anal-retentive jackasses at Debian deal with that one?

     

    They like the massive ego boo too much to admit it goes against their principles?

    FTFY, and its a "Registered Trademark" of Torvalds, who apparently has said "I dont give a flying fuck so long as its got the kernel at the middle." (or something along those lines.) As for the firefox thing, the biggest problem was that the graphics were not perfectly Free/OpenSource. Thats their damn gripe. First: Who the hell cares? I mean seriously do they get off on the fact they have open source graphics? I can understand maybe not liking the logo (as it is technically a trademark) but the fact that they cant handle trademarks in their packages is going to become harder and harder as Novell owns the technical trademark to Mono under the guise of a .NET Compatible environment, but they still have that in the main repo.



  • @Indrora said:

    As for the firefox thing, the biggest problem was that the graphics were not perfectly Free/OpenSource. Thats their damn gripe. First: Who the hell cares? I mean seriously do they get off on the fact they have open source graphics?

    Hence why Debian is retarded (in addition to being decades behind in software releases and having a shitty track record on security).  Hence why we are mocking Debian.



  • @ekolis said:

    So, how does renaming it magically make it free software
    All the code is FOSS.  The logos and name Firefox is not.  Removing the logos and name reduces it to its FOSS core.

    This is how I understand it.  Someone correct me if I'm wrong.

    I feel like I'm repeating something, but I can't find it put exactly this way earlier in the thread.



  • @belgariontheking said:

    @ekolis said:

    So, how does renaming it magically make it free software
    All the code is FOSS.  The logos and name Firefox is not.  Removing the logos and name reduces it to its FOSS core.

    This is how I understand it.  Someone correct me if I'm wrong.

    Don't forget the part where you give it your own logos with a smart-ass name like "Iceweasel" when you could have been finding and fixing the horrible SSL bugs in your core libraries.



  • @morbiuswilters said:

    smart-ass name like "Iceweasel"
    Are you trying to tell me that Iceweasel was chosen because Ice is the opposite of fire and a weasel is somewhat similar to a fox?  They didn't just want to invoke that "DAWW" reaction?  BAH, I tell you, BAH!



  • @belgariontheking said:

    @morbiuswilters said:

    smart-ass name like "Iceweasel"
    Are you trying to tell me that Iceweasel was chosen because Ice is the opposite of fire and a weasel is somewhat similar to a fox?  They didn't just want to invoke that "DAWW" reaction?  BAH, I tell you, BAH!

    Other, less-successful product names from the same range included Waterflea, Plasmaplatypus, and Turdmonkey.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.