LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 390 users online 221633 members 1751 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
serenarawr
Movies: I'm a huge movie person, i go to the m...
Mood: Lonely
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
4 online / 23 MPM
Fresh Topics
  LiveWire / Technical Forums / Web Design & Search Engine Optimization / Viewing Topic

PHP issue
Trying to gather browser and OS along with version in PHP
Replies: 10Last Post Jan. 21 11:19pm by Macropiper
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( pleaseremove )


meh

Patron
Tech Support Leader
Reply
OK, usual reminder, only reply if you have something useful to add, people saying "Wat?" etc will have their posts removed.

I am working in PHP on putting in better logging into my error handling system. As part of this i want to get out the users browser name and version and their OS.

So we after something like Firefox 3 and Windows Vista in my case.

Now I know we can get the user agent which technically does contain this information, although it requires some processing first. Details are often stored in different places depending on OS and browser.

Obviously I would be using get_browser() but this is not supported in the installation of PHP I have and I don't have the relative permissions to change this.

Any ideas on how best to do this?

Note, I want to do this in PHP, not Javascript.

Cheers guys.

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


1:29 pm on Dec. 30, 2008 | Joined: Feb. 2005 | Days Active: 1,299
Join to learn more about pleaseremove England, United Kingdom | Straight Male | Posts: 5,945 | Points: 37,468
LiveWire Humor
Post from this position was omitted due to content violations
Mediocre


Dairy Product Addict
Reply
PEAR has a popular package that does this: http://pear.php.net/package/Net_UserAgent_Detect/

Ugly code, but meh.

-------
Incest and bestiality are neat.


1:34 pm on Dec. 30, 2008 | Joined: Nov. 2007 | Days Active: 209
Join to learn more about Mediocre Czech Republic | Male | Posts: 1,642 | Points: 3,195
( pleaseremove )


meh

Patron
Tech Support Leader
Reply
Quote: from Mediocre at 9:34 pm on Dec. 30, 2008

PEAR has a popular package that does this: http://pear.php.net/package/Net_UserAgent_Detect/

Ugly code, but meh.


That looks like exactly what I'm looking for. I don't suppose you have any experience in implementing this? As per usual Pear's documentation is very poor and I am having a hard time chasing docs after docs and not got it working as yet.

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


1:56 pm on Dec. 30, 2008 | Joined: Feb. 2005 | Days Active: 1,299
Join to learn more about pleaseremove England, United Kingdom | Straight Male | Posts: 5,945 | Points: 37,468
Mediocre


Dairy Product Addict
Reply
Basically:

Code:
require_once('Detect.php');

echo 'OS: '.Net_UserAgent_Detect::getOSString().'<br />Browser: '.Net_UserAgent_Detect::getBrowserString();

Post edited at 2:06 pm on Dec. 30, 2008 by Mediocre

-------
Incest and bestiality are neat.


2:06 pm on Dec. 30, 2008 | Joined: Nov. 2007 | Days Active: 209
Join to learn more about Mediocre Czech Republic | Male | Posts: 1,642 | Points: 3,195
( pleaseremove )


meh

Patron
Tech Support Leader
Reply
It was looking good, but unfortunately it isn't quite what I am after. It doesn't do much more than reg ex the user agent. At current, when asking for browser and OS i am getting the following:

Browser: Mozilla/Netscape 6.x
OS: Microsoft Windows NT

I am looking for something that actually figures out I have Vista and Firefox 3.

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


2:18 pm on Dec. 30, 2008 | Joined: Feb. 2005 | Days Active: 1,299
Join to learn more about pleaseremove England, United Kingdom | Straight Male | Posts: 5,945 | Points: 37,468
Mediocre


Dairy Product Addict
Reply
I don't see how it's possible to determine browser/OS except through the user agent string.

Post edited at 2:34 pm on Dec. 30, 2008 by Mediocre

-------
Incest and bestiality are neat.


2:34 pm on Dec. 30, 2008 | Joined: Nov. 2007 | Days Active: 209
Join to learn more about Mediocre Czech Republic | Male | Posts: 1,642 | Points: 3,195
( pleaseremove )


meh

Patron
Tech Support Leader
Reply
Quote: from Mediocre at 10:34 pm on Dec. 30, 2008

I don't see how it's possible to determine browser/OS except through the user agent string.

Oh, i know this has to be done through the user agent, it is more than i need something human readable. I dont want it to spit back that i have Windows NT 6.0 or something, I want it to work out Vista. I guess im more looking for smart conversion tables than anything else. The feature is in PHP and there are even ways to get updates for such tables, but it is turned off in my install.

-------
Anyone who isn't confused really doesn't understand the situation
http://craigk.org/pictures/
Can you work out the code?


3:24 pm on Dec. 30, 2008 | Joined: Feb. 2005 | Days Active: 1,299
Join to learn more about pleaseremove England, United Kingdom | Straight Male | Posts: 5,945 | Points: 37,468
jkjslkjind


Personal Assistant
Reply
$_SERVER['HTTP_USER_AGENT']

try that :)


11:37 pm on Dec. 30, 2008 | Joined: June 2008 | Days Active: 9
Join to learn more about jkjslkjind United States | Posts: 77 | Points: 169
jkjslkjind


Personal Assistant
Reply
and if you wanna find browser

if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== false)
  echo 'Internet explorer';

remember, you must compare strpos to false. NOT to true.
you can use ===false or !==false


11:39 pm on Dec. 30, 2008 | Joined: June 2008 | Days Active: 9
Join to learn more about jkjslkjind United States | Posts: 77 | Points: 169
Macropiper


Like a Ninja!

Patron
Tech Support Leader
Reply
I would use regular expressions to extract the information out of the user agent, best place to start is by obtaining a nice long diverse list of user agents and keep working at the code till it processes them all perfectly.

11:19 pm on Jan. 21, 2009 | Joined: Oct. 2002 | Days Active: 2,390
Join to learn more about Macropiper New Zealand | Straight Male | Posts: 8,995 | Points: 43,076
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Web Design & Search Engine Optimization / Viewing Topic