473,225 Members | 1,229 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Mozilla vs Netscape and getenv("HTTP_USER_AGENT")

Hi,

if i use...

// php
$info = getenv("HTTP_USER_AGENT");
// I noticed that Mozzila and Netscape <6(?) both use the same Agent.
// so i was thinking of

if (preg_match("/Mozilla/i", $info)) {
if (preg_match("/rv:/i", $info)) { $web = "Mozilla"; }
else
if (preg_match("/Mozilla\/3/i", $info)) { $web = "Netscape 3.x"; }
else
if (preg_match("/Mozilla\/4.5/i", $info)) { $web = "Netscape 4.5"; }
else
if (preg_match("/Mozilla\/4.6/i", $info)) { $web = "Netscape 4.6"; }
else
if (preg_match("/Mozilla\/4.7/i", $info)) { $web = "Netscape 4.7"; }
else
if (preg_match("/Mozilla\/4/i", $info)) { $web = "Netscape 4.x"; }
else
{ $web = "Mozilla"; }
}

Is the code above correct or is there a better way of doing it?
Regards

Sims
Jul 17 '05 #1
1 5006
> Hi,

if i use...

// php
$info = getenv("HTTP_USER_AGENT");
// I noticed that Mozzila and Netscape <6(?) both use the same Agent.
// so i was thinking of


Ok, after playing around i think i have refined it to

// php
$info = getenv("HTTP_USER_AGENT");

if (preg_match("/Mozilla/i", $info))
{
if (preg_match("/Mozilla\/3/i", $info)) { $web = "Netscape 3.x"; }
else if (preg_match("/Mozilla\/4.5/i", $info)) { $web = "Netscape
4.5"; }
else if (preg_match("/Mozilla\/4.6/i", $info)) { $web = "Netscape
4.6"; }
else if (preg_match("/Mozilla\/4.7/i", $info)) { $web = "Netscape
4.7"; }
else if (preg_match("/Mozilla\/4/i", $info)) { $web = "Netscape
4.x"; }
else if (preg_match("/Netscape\/6/i", $info)) { $web = "Netscape
6"; }
else if (preg_match("/Netscape\/7/i", $info)) { $web = "Netscape
7"; }
else { $web = "Mozilla"; }
}

Regards

Sims
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kornelius Finkenbein | last post by:
Hello folks! I've got a strange problem with my download-script in conjunction with M$ internet explorer, if the filename I want to link to includes more than one points. In Netscape the problem...
2
by: Sharon | last post by:
Can I use request.servervariables("HTTP_USER_AGENT") to determine if the user has Firefox or Internet Explorer? Is the return string differentiated enough? Thanks for any input.
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.