Solved

Urgent - OS detection

Posted on 2004-09-30
7
232 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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 learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

760 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

18 Experts available now in Live!

Get 1:1 Help Now