Solved

Urgent - OS detection

Posted on 2004-09-30
7
237 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
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 about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

791 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