Page 1 of 1
Detecting Browsers with registered globals set to off
Posted: Tue Apr 17, 2007 7:54 am
by SteveMellor
I'm wondering if anyone can help me with this problem I have.
I'm working on a script and I need to be able to detect the browser that is being used in PHP. I can't use 'HTTP_USER_AGENT' because for some reason it's not available on the server we have. Now, the odd thing is that we are on a dedicated server and register globals is set to on, but that's a different matter.
I was wondering if anybody had found a solution to this for servers where register globals is set to off (or similar). All help would be greatly appreciated as it's becoming a little urgent now.
Posted: Tue Apr 17, 2007 7:56 am
by stereofrog
Posted: Tue Apr 17, 2007 8:30 am
by SteveMellor
Interestingly is says the following, which wasn't working before.
Code: Select all
Array ( [HTTP_HOST] => XXXXX [HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
I've removed the rest (and added Xs) as I don't want some of the info publicly available.
Posted: Tue Apr 17, 2007 8:34 am
by onion2k
You need to use $_SERVER['HTTP_USER_AGENT'] if register_globals is off. In fact, I'll go further than that, you need to use $_SERVER['HTTP_USER_AGENT'] even if register_globals is on. Because register_globals is stupid and should be switched off.
Posted: Tue Apr 17, 2007 8:36 am
by feyd
Why not simply use
get_browser() or variants thereof?
Posted: Tue Apr 17, 2007 9:23 am
by SteveMellor
You need to use $_SERVER['HTTP_USER_AGENT'] if register_globals is off. In fact, I'll go further than that, you need to use $_SERVER['HTTP_USER_AGENT'] even if register_globals is on. Because register_globals is stupid and should be switched off.
Actually I was using that, and it wasn't working. It was returning nothing when I tried to call it. It appears to be working now though.
Why not simply use get_browser() or variants thereof?
As far as I am aware, get_browser uses the HTTP_USER_AGENT header as well, which I was unable to access.
Posted: Tue Apr 17, 2007 11:02 am
by RobertGonzalez
I wrote a class (currently in Coding Critique) that will do what you need as well.
get_browser() is a nice little function however.
Posted: Tue Apr 17, 2007 12:10 pm
by volka
SteveMellor wrote:Why not simply use get_browser() or variants thereof?
As far as I am aware, get_browser uses the HTTP_USER_AGENT header as well, which I was unable to access.
It does, but it knows how to access it
