Posted By

sorehead on 10/09/06


Tagged

get os


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Memphys
vali29
willcodeforfood
Nix


get os


 / Published in: PHP
 

getos For using: print getos($SERVER['HTTPUSER_AGENT']) */

  1. <?php
  2. /* get_os_
  3. For using:
  4. print get_os_($_SERVER['HTTP_USER_AGENT']) */
  5.  
  6. function get_os_($user_agent)
  7. {
  8. $oses = array (
  9. 'Windows 3.11' => 'Win16',
  10. 'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
  11. 'Windows 98' => '(Windows 98)|(Win98)',
  12. 'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
  13. 'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
  14. 'Windows 2003' => '(Windows NT 5.2)',
  15. 'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
  16. 'Windows ME' => 'Windows ME',
  17. 'Open BSD'=>'OpenBSD',
  18. 'Sun OS'=>'SunOS',
  19. 'Linux'=>'(Linux)|(X11)',
  20. 'Macintosh'=>'(Mac_PowerPC)|(Macintosh)',
  21. 'QNX'=>'QNX',
  22. 'BeOS'=>'BeOS',
  23. 'OS/2'=>'OS/2',
  24. 'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)'
  25. );
  26.  
  27. foreach($oses as $os=>$pattern)
  28. {
  29. if (eregi($pattern, $user_agent))
  30. return $os;
  31. }
  32. return 'Unknown';
  33. }
  34. ?>

Report this snippet  

You need to login to post a comment.