Solved

Urgent - OS detection

Posted on 2004-09-30
7
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Http 404 error while consuming RESTful service in .Net passing data in JSON format 5 85
Problem to file 3 98
Grunt script for Build Process 1 90
How to build a web site 17 98
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

737 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