Solved

Urgent - OS detection

Posted on 2004-09-30
7
233 Views
Last Modified: 2010-04-06
Hi experts,

do the asp, php or javascript can detect which OS lang. the user are using ?
ASAP !!!

Thanks for your advice !
0
Comment
Question by:kankan
  • 4
  • 2
7 Comments
 

Author Comment

by:kankan
ID: 12188324
the script checking MUST compatible with Palm OS!!!!
0
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12188784
0
 

Author Comment

by:kankan
ID: 12191375
ok, let me try for next week ! coz i'm day off on coming weekend!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Accepted Solution

by:
harveykane earned 250 total points
ID: 12198883
This is a PHP function I have used to detect MAcOS - you should be able to modify it to detect Palm OS.

<?php
//Function
function ismac($useragent) {
//True / False if $useragent is a Mac
  $useragent = strtolower($useragent);
  if (strpos($useragent,"mac") !== false) {
    $mac = true;
  } else if (strpos($useragent,"ppc") !== false) {
    $mac = true;
  } else if (strpos($useragent,"powerpc") !== false) {
    $mac = true;
  } else if (strpos($useragent,"safari") !== false) {
    $mac = true;
  } else {
    $mac = false;
  }
  return $mac;
}


//Function called by....
if (ismac($_SERVER["HTTP_USER_AGENT"] ) === true) {
  echo "Mac Detected";
}
?>

The key here is the variable $HTTP_USER_AGENT variable. This is sent by the browser to your website with every request. Each browser has it's own different $HTTP_USER_AGENT type so I don't know of any way to cover them all without listing each one.

Here are some $HTTP_USER_AGENT types I found for mobile devices. Not a complete list of course, but it should get you started in the right direction. The above function is looking for "mac", "ppc", of "safari" within the $HTTP_USER_AGENT string - substrings only found in Mac Browsers (to my knowledge). You will want to modify these to include your palm browsers rather than Mac browsers.

You will find many more $HTTP_USER_AGENT types by doing a google search. The list is long, major browsers seem to change types every time a new brwowser version is released.

"Windows CE" //Windows CE and Pocket PC
"NetFront" //PalmSource WebBrowser 2.0
"Palm OS" //Eudora Web Browser for Palm
"Blazer" //Handspring Blazer Browser
"Elaine" //RIM Devices
"^WAP.*$" //WAP Browsers
"Plucker" //Plucker Offline download client
"AvantGo" //AvantGo Service


0
 

Author Comment

by:kankan
ID: 12202125
but can detect chinese or english OS ?
0
 
LVL 2

Expert Comment

by:harveykane
ID: 12208202
I'm not sure if browsers in different languages have different user agent strings - I assume they would. I know the above method doesn't seem ideal, having to build every browser into your function, but I dont think there is any other way, short of prompting the visitor to enter their browser / language.
0
 

Author Comment

by:kankan
ID: 12216628
ok thx, i also can do the same way ! thx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now